Declaring wires
Implement the following circuit. Create two intermediate wires (named anything you want) to connect the AND and OR gates together. Note that the wire that feeds the NOT gate is really wire out
, so you do not necessarily need to declare a third wire here. Notice how wires are driven by exactly one source (output of a gate), but can feed multiple inputs.
If you're following the circuit structure in the diagram, you should end up with four assign statements, as there are four signals that need a value assigned.
(Yes, it is possible to create a circuit with the same functionality without the intermediate wires.)
实现以下电路。创建两条中间线(命名您想要的任何名称)以将 AND 和 OR 门连接在一起。请注意,馈送给 NOT 门的 wire 实际上是 wire out,因此您不一定需要在此处声明第三根 wire 。请注意 wires 是如何由一个 source (gate 的 output) 驱动的,但可以馈送多个 inputs。
如果您遵循图中的电路结构,则最终应该有四个 assign 语句,因为有四个信号需要赋值。
(是的,可以创建具有相同功能的电路,而无需中间导线。)
`default_nettype none
module top_module(input a,input b,input c,input d,output out,output out_n ); wire and_1;//直接wire w1,w2;更简便wire and_2;wire or_1;//这个线可以不用assign and_1=a&b;assign and_2=c&d;assign or_1=and_1|and_2;assign out=or_1;//直接out=w1|w2;更简便assign out_n=~or_1;//直接out_n=~out;更简便endmodule