配置环境
https://soc.ustc.edu.cn/Digital/lab1/verilog_coding/
iverilog 编译器工具使用
https://zhuanlan.zhihu.com/p/95081329
要求:
- 代码实现功能
- 仿真波形
- testbeach
7.1 full adder
Implement the full adder of two 1-bit binary numbers in Verilog.
- Use the dataflow level description to implement the logic functions of both the sum and the carry for the higher-bit.
- Use the gate level description to implement the logic functions of both the sum and the carry for the higher-bit
第一问
adder.v
adder_tb.v
编译命令:
iverilog -o wave adder.v adder_tb.v
vvp -n wave -lxt2
gtkwave wave.vcd
程序输出:
第二问
对 adder.v
修改:
编译命令不变,程序输出:
7.2 voting circuit
Implement the voting circuit of 7 people in Verilog.
- If more than 3 people agree, the decision is approved. Otherwise, the decision is rejected.
- Use the behavior level description to implement the logic function of the voting circuit.
voting_circuit.v
voting_circuit_tb.v
编译命令:
iverilog -o wave voting_circuit.v voting_circuit_tb.v
vvp -n wave -lxt2
gtkwave wave.vcd
运行结果: