【发布时间】:2022-11-10 20:46:43
【问题描述】:
我正在学习verilog,我正在https://hdlbits.01xz.net/wiki上做练习题。 问题之一是:
所以我的回答是:
module top_module(
input a,
input b,
input c,
input d,
output out,
output out_n );
wire and_ab;
wire and_cd;
wire or_out;
and(and_ab,a,b);
and(and_cd, c, d);
or(or_out, and_ab, and_cd);
assign out= or_out;
not(out_n,or_out);
endmodule
毫无疑问这是正确的,但他们的答案是:
module top_module (
input a,
input b,
input c,
input d,
output out,
output out_n );
wire w1, w2; // Declare two wires (named w1 and w2)
assign w1 = a&b; // First AND gate
assign w2 = c&d; // Second AND gate
assign out = w1|w2; // OR gate: Feeds both 'out' and the NOT gate
assign out_n = ~out; // NOT gate
endmodule
我的问题是他们怎么可能将“输出”线用作同一模块中分配的“输入”?它不是 reg 来保存它的值,并不是说我知道你是否可以将 reg 用作“输出”类型。
【问题讨论】:
标签: verilog system-verilog fpga hdl