我一直在玩 Verilog,但才刚刚开始。我已经从 NAND 实现了几个逻辑门,它们正在工作,但现在当我尝试对几个位执行 OR 时,我遇到了死胡同。
Verilog 中的模块输出错误值(0 或 X),目标是对所有位执行“或”运算;但是,即使仅评估第一位,代码也不起作用。
Inputs: in_a = 1
Output: out = x
Inputs: in_a = 0
Output: out = 0
Inputs: in_a = 25
Output: out = x
Inputs: in_a = 32
Output: out = 0
Inputs: in_a = 4180
Output: out = 0
Inputs: in_a = 0
Output: out = 0
module Or8Way( input [7:0] in_a, output out);
reg tmp_in = 0;
or(out, in_a[0], tmp_in);
// etc,
endmodule
module OR8;
reg [7:0] in_a;
wire out = 0;
Or8Way or8_gate(in_a,out);
initial begin
$display("Inputs: in_a = 1");
in_a = 1;
#20 $display("Output: out = %b", out);
$display("Inputs: in_a = 0");
in_a = 0;
#20 $display("Output: out = %b", out);
$display("Inputs: in_a = 25");
in_a = 25;
#20 $display("Output: out = %b", out);
$display("Inputs: in_a = 32");
in_a = 32;
#20 $display("Output: out = %b", out);
$display("Inputs: in_a = 4180");
in_a = 4180;
#20 $display("Output: out = %b", out);
$display("Inputs: in_a = 0");
in_a = 0;
#20 $display("Output: out = %b", out);
end
endmodule