Design Of Digital Circuits Using Verilog
Steps to Complete the Code
Arrange the Code Blocks:
- Place the code block that defines the Verilog module name, inputs, and outputs first.
- Next, add the code block that defines the module functionality (the assign block).
- Finally, add the code block that ends the module.
Drag and Drop:
- Drag and drop the code blocks to arrange them in the order mentioned above for both the Verilog module and the testbench.
Complete the Code Blocks:
For the Verilog module:
- Enter a name for the module. The name should begin with an alphabet and can include alphanumeric characters and underscores (
_). No spaces or special characters allowed. - Select the inputs as
AandB, and the output asY. - In the assign block, assign
Ythe value of the required logic expression:- For AND logic:
Y = A & B; - For OR logic:
Y = A | B; - For NOR logic:
Y = ~(A | B); - For NAND logic:
Y = ~(A & B);
- For AND logic:
- Use the blocking assignment operator (
=) for combinational logic.
- Enter a name for the module. The name should begin with an alphabet and can include alphanumeric characters and underscores (
For the Verilog testbench:
- Enter a name for the testbench. The name should begin with an alphabet, include only alphanumeric characters and underscores, and must not match the module name.
- Declare
AandBas registers, andYas a wire. - Instantiate the logic gate module by entering its name and selecting the arguments in the same order as in the module definition.
- Define the input
AandBwaveforms in the initial block.
Note:
- While naming modules, testbenches, variables, and instance names, ensure they begin with an alphabet or underscore and only contain alphanumeric characters and underscores.
- Do not use the same name for any two variables in the same module or testbench.
Observations
- After clicking the Validate button (assuming all code blocks are filled correctly), you should see a "Success" message and a truth table under the Observations section.
- Observe the input wave and the corresponding expected and observed output
Y.