关于Verilog的一些提问
大二学生,基于FPGA设计了一个简化的21点游戏。但是综合后出现了两百多个warning,不知道怎么解决,想让大佬指出错误。还有就是数码管的约束文件怎么编写,也想问一下Verilog程序如下:
module black_jack(
input start, //开始游戏按钮
input add, //摸牌按钮
input stop, //停止摸牌按钮
outputreg win, //胜利输出
outputreg lose, //失败输出
outputreg dogfall, //平局输出
outputreg nownumber1, //摸牌十位大小
outputreg nownumber0, //摸牌个位大小
outputreg totalnumber1, //玩家总数十位大小
outputreg totalnumber0, //玩家总数个位大小
outputregbankernumber1, //庄家牌十位大小
outputreg bankernumber0 //庄家牌个位大小
);
reg player;
reg new;
reg total;
reg banker;
reg a1,b1,c1,d1,e1,f1;
always@(negedge start)
begin
player = 0;
player = 0;
banker = 0;
banker = 0;
total = 0;
new = 0;
a1 = 0;
b1 = 0;
c1 = 0;
d1 = 0;
e1 = 0;
f1 = 0;
dogfall = 0;
win = 0;
lose = 0;
nownumber1 = 7'b0000000;
nownumber0 = 7'b0000000;
totalnumber1 = 7'b0000000;
totalnumber0 = 7'b0000000;
bankernumber1 = 7'b0000000;
bankernumber0 = 7'b0000000;
player = 2+{$random}%(11-2+1); //玩家发的第一张手牌
player = 2+{$random}%(11-2+1); //玩家发的第二张手牌
banker = 7+{$random}%(11-7+1); //庄家的第一张手牌
banker = 7+{$random}%(11-7+1); //庄家的第二张手牌
total = player + player;
end //玩家手牌的总和
//将玩家手牌和显示出来的方式
always@(total)
begin
if(total >= 30) //手牌和大于等于30时
begin
a1 = 3;
b1 = total - 30;
end
else if(total<30&&total>=20) //手牌和大于等于20时
begin
a1 = 2;
b1 = total - 20;
end
else if(total<20&&total>=10) //手牌和小于20但大于等于10时
begin
a1 = 1;
b1 = total-10;
end
else //手牌和小于10时
begin
a1 = 0;
b1 = total;
end
end
always@(banker)
begin
if(banker + banker >= 20) //手牌和大于等于20时
begin
e1 = 2;
f1 = banker + banker - 20;
end
else if((banker + banker)<20&&(banker + banker)>=10) //手牌和小于20但大于等于10时
begin
e1 = 1;
f1 = (banker + banker)-10;
end
else //手牌和小于10时
begin
e1 = 0;
f1 = (banker + banker);
end
end
always@(a1) //数码管显示玩家总和手牌十位
begin
case(a1)
'd0:totalnumber1 = 7'b1111110;
'd1:totalnumber1 = 7'b0110000;
'd2:totalnumber1 = 7'b1101101;
'd3:totalnumber1 = 7'b1111001;
default:totalnumber1 = 7'bx;
endcase
end
always@(b1) //数码管显示玩家总和手牌个位
begin
case(b1)
'd0:totalnumber0 = 7'b1111110;
'd1:totalnumber0 = 7'b0110000;
'd2:totalnumber0 = 7'b1101101;
'd3:totalnumber0 = 7'b1111001;
'd4:totalnumber0 = 7'b0110011;
'd5:totalnumber0 = 7'b1011011;
'd6:totalnumber0 = 7'b1011111;
'd7:totalnumber0 = 7'b1110000;
'd8:totalnumber0 = 7'b1111111;
'd9:totalnumber0 = 7'b1111011;
default:totalnumber0 = 7'bx;
endcase
end
always@(negedge add) //添加新牌
begin
new = 2+{$random}%(11-2+1);
total = total + new;
end
always@(new) //分出新牌的个位和十位
begin
if(new>=10)
begin
c1 = 1;
d1 = new - 10;
end
else
begin
c1 = 0;
d1 = new;
end
end
always@(c1) //数码管显示新牌的十位
begin
case(c1)
'd0:nownumber1 = 7'b1111110;
'd1:nownumber1 = 7'b0110000;
default:nownumber1 = 7'bx;
endcase
end
always@(d1) //数码管显示新牌的个位
begin
case(d1)
'd0:nownumber0 = 7'b1111110;
'd1:nownumber0 = 7'b0110000;
'd2:nownumber0 = 7'b1101101;
'd3:nownumber0 = 7'b1111001;
'd4:nownumber0 = 7'b0110011;
'd5:nownumber0 = 7'b1011011;
'd6:nownumber0 = 7'b1011111;
'd7:nownumber0 = 7'b1110000;
'd8:nownumber0 = 7'b1111111;
'd9:nownumber0 = 7'b1111011;
default:nownumber0 = 7'bx;
endcase
end
always@(negedge stop) //玩家停止摸牌
begin
case(e1) //显示出庄家的总和的十位数
'd0:bankernumber1 = 7'b1111110;
'd1:bankernumber1 = 7'b0110000;
'd2:bankernumber1 = 7'b1101101;
default:bankernumber1 = 7'bx;
endcase
case(f1) //显示出庄家总和的个位数
'd0:bankernumber0 = 7'b1111110;
'd1:bankernumber0 = 7'b0110000;
'd2:bankernumber0 = 7'b1101101;
'd3:bankernumber0 = 7'b1111001;
'd4:bankernumber0 = 7'b0110011;
'd5:bankernumber0 = 7'b1011011;
'd6:bankernumber0 = 7'b1011111;
'd7:bankernumber0 = 7'b1110000;
'd8:bankernumber0 = 7'b1111http://www.fpgabbs.cn/data/attachment/common/cf/153124h4ubozb4s0xii164.png111;
'd9:bankernumber0 = 7'b1111011;
default:bankernumber0 = 7'bx;
endcase
begin //比较大小,判断输赢
if((total>21&&(banker + banker)>21)||(total<=21&&(banker+banker<=21)&&(total == (banker+banker))))
dogfall = 1; //两者都大于21或者两者一样大,输出平局
else if(total>banker + banker) //玩家大,输出获胜
win = 1;
else //玩家小,输出失败
lose =1;
end
end
endmodule
页:
[1]