我是verilog的新手,我正在尝试使用数组编写此图表。
2x4图
到目前为止,我有这个,但我没有得到我正在寻找的输出。
module DecoderMod(s, o); // module definition
input [0:1] s;
output [0:1] o;
wire [0:1] snot;
not(snot[1], s1);
not(snot[0], s0);
and(o[0], snot[1], snot[0]);
and(o[1], snot[1], s[0]);
and(o[2], s[1] , snot[0]);
and(o[3], s[1] , s[0]);
endmodule
module TestMod;
reg [0:1] s;
wire [0:3] o;
DecoderMod my_decoder(s, o); // create instance
initial begin
$monitor("%0d\t%b\t%b", $time, s, o);
$display("Time s o");
$display("--------------");
end
initial begin
s[1] = 0; s[0] = 0;#1;
s[1] = 0; s[0] = 1;#1;
s[1] = 1; s[0] = 0;#1;
s[1] = 1; s[0] = 1;
end
endmodule
我明白了:
Time s o
--------------------
0 00 x000
1 01 xx00
2 10 x0x0
3 11 xxx1
但我想要这个:
Time s o
--------------------
0 00 1000
1 01 0100
2 10 0010
3 11 0001
我做错了什么?
答案 0 :(得分:0)
您在s0
个实例中使用s1
和not
,它们应该是:
not(snot[1], s[1]);
not(snot[0], s[0]);