纯粹只是自己看了点书完完全全的新手。。。C语言也没有学完。。。老师就要求我们自学verilog并且做四位二进制BCD码实现。。。这段代码下载到板子上完全就乱显示。。。没定义的灯也亮 module BCDjiafaqi(A,B,out,oY,N,AN ); input [3:0] A; input [3:0] B; input [3:0] N; output [3:0] AN; reg [3:0] sum; output reg out; output reg[7:0] oY; assign AN=N; always@(A,B,oY,N,AN) begin if(A>9&&B>9) sum=4'b1111; else sum=A+B; if(sum>9) begin sum=sum+6; out=1; end else out=0; case(sum) 4'b0000:oY=8'hc0; 4'b0001:oY=8'hf9; 4'b0010:oY=8'ha4; 4'b0011:oY=8'hb0; 4'b0100:oY=8'h99; 4'b0101:oY=8'h92; 4'b0110:oY=8'h82; 4'b0111:oY=8'hf8; 4'b1000:oY=8'h80; 4'b1001:oY=8'h90; default:oY=8'hff; endcase end endmodule