Declaring wires¶
Why should we declare wires?¶
The circuits so far have been simple enough that the outputs are simple functions of the inputs. As circuits become more complex, you will need wires to connect internal components together. When you need to use a wire, you should declare it in the body of the module, somewhere before it is first used.
Example¶
- Note that it doesn't matter which of the NOT gates you create first: You still end up with the same circuit.
Problem statement¶
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.
Verilog | |
---|---|