I'm still relatively new to Verilog and FPGA programming, so I've been struggling quite a bit with this one. The goal of the project here is to play a super basic game of 'blackjack' and I can't quite seem to get the system to work. As a note: The game goal is to get to 21, but a number reasonably high and close to 21 could still win the game based on what the Dealer has.
The first few if - else if statements are there to interpret the card input from switches on the basys3, and then decide how much to add to the count based on the 'card' input. The latter if - else statement is there to output either an 'H' or an 'S' to the 7-segment display in order to output whether the player should 'hit' and recieve another card, or if that person should 'stay' and just hold onto the cards they have. For some reason, the board only displays the 'H' value on the 7 segment display, and I have no way to find out if the count is actually incrementing in the program since I can't figure out how to test this outside of the board. Any assistance would be greatly appreciated. As a note: I have checked the constraints file, and everything looks correct.
blackjack.v verilog file:
module BlackJack(input clk, ace, four, five, six, eight, jack, reset, output clk_slow, reg A, B, C, D, E, F, G, H, wire segEn, segEnd);
//slow clock code
parameter clkbit = 27;
reg [clkbit:0] clk2 = 0;
always@(posedge clk)
begin
clk2 <= clk2+1;
end
assign clk_slow = clk2[clkbit];
reg count = 0;
assign segEn = 0; // enable for the 7-segment display
assign segEnd = 1;
always @(posedge clk_slow)
begin
if (count <= 10) //states from start to 10 - card decisions made here
begin
if (ace)
count <= count + 11; //adds 11
else if (four)
count <= count + 4;
else if (five)
count <= count + 5;
else if (six)
count <= count + 6;
else if (eight)
count <= count + 8;
else if (jack)
count <= count + 10;
else
count <= count;
end
else if (count <= 11) // states from 11 to 17
begin
if (ace)
count <= count + 1; //adds 1
else if (four)
count <= count + 4;
else if (five)
count <= count + 5;
else if (six)
count <= count + 6;
else if (eight)
count <= count + 8;
else if (jack)
count <= count + 10;
else
count <= count;
end
else if (reset)
begin
count <= 0;
end
else
begin
count <= count;
end
if (count < 17)
begin
F <= 1'b0;
B <= 1'b0;
G <= 1'b0;
E <= 1'b0;
C <= 1'b0;
A <= 1'b1;
D <= 1'b1;
end
else
begin
A <= 1'b0;
F <= 1'b0;
G <= 1'b0;
C <= 1'b0;
D <= 1'b0;
B <= 1'b1;
E <= 1'b1;
end
end
Question
theConfusedOne
I'm still relatively new to Verilog and FPGA programming, so I've been struggling quite a bit with this one. The goal of the project here is to play a super basic game of 'blackjack' and I can't quite seem to get the system to work. As a note: The game goal is to get to 21, but a number reasonably high and close to 21 could still win the game based on what the Dealer has.
The first few if - else if statements are there to interpret the card input from switches on the basys3, and then decide how much to add to the count based on the 'card' input. The latter if - else statement is there to output either an 'H' or an 'S' to the 7-segment display in order to output whether the player should 'hit' and recieve another card, or if that person should 'stay' and just hold onto the cards they have. For some reason, the board only displays the 'H' value on the 7 segment display, and I have no way to find out if the count is actually incrementing in the program since I can't figure out how to test this outside of the board. Any assistance would be greatly appreciated. As a note: I have checked the constraints file, and everything looks correct.
blackjack.v verilog file:
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.