我有以下任务,但是当我使用该任务时,它没有给我正确的数字输出,我尝试不使用该任务,但它给了我正确的输出。任何人都可以看看我有什么问题吗?
例如当 display(17,hex3) 时,都显示全部关闭,而不是全部关闭和数字 '1'。
我对 4 位使用 7 段,十六进制 [6:0],1 关闭。
output reg [6:0] hex3, hex2, hex1, hex0
task display;
input [5:0] num;
output hex;
reg hex;
begin
case(num) // 6543210
if(hex==hex3) begin
0:hex3 =7'b1000000; //0
1:hex3 =7'b1111001; //1
2:hex3 =7'b0100100; //2
3:hex3 =7'b0110000; //3
4:hex3 =7'b0011001; //4
5:hex3 =7'b0010010; //5
6:hex3 =7'b0000010; //6
7:hex3 =7'b1111000; //7
8:hex3 =7'b0000000; //8
9:hex3 =7'b0011000; //9
10:hex3 =7'b0001000; //A
11:hex3 =7'b0000011; //b
12:hex3 =7'b1000110; //C
13:hex3 =7'b0100001; //d
14:hex3 =7'b0000110; //E
15:hex3 =7'b0000111; //F
16:hex3 =7'b0010000; //g
17:hex3 =7'b1111111; //Off
18:hex3 =7'b0001001; //H
endcase
end
else if(hex==hex2) begin
case(num)
0:hex3 =7'b1000000; //0
1:hex2 =7'b1111001; //1
2:hex2 =7'b0100100; //2
3:hex2 =7'b0110000; //3
4:hex2 =7'b0011001; //4
5:hex2 =7'b0010010; //5
6:hex2 =7'b0000010; //6
7:hex2 =7'b1111000; //7
8:hex2 =7'b0000000; //8
9:hex2 =7'b0011000; //9
10:hex2 =7'b0001000; //A
11:hex2 =7'b0000011; //b
12:hex2 =7'b1000110; //C
13:hex2 =7'b0100001; //d
14:hex2 =7'b0000110; //E
15:hex2 =7'b0000111; //F
16:hex2 =7'b0010000; //g
17:hex2 =7'b1111111; //Off
18:hex2 =7'b0001001; //H
endcase
end
endtask
//final
always @(*) begin
if(init) begin
display(17,hex3);
display(1,hex2);
end
end