当前位置:网站首页>Door level modeling - after class exercises
Door level modeling - after class exercises
2022-07-01 23:33:00 【Jiangnan small workshop】
exercises
Using dual input nand door , use Verilog Write your own and or not gate , And verify the function of these doors with the excitation module .
And gate ,verilog Realization , Use three NAND gates
module my_add( output out, input a, input b ); wire w1,w2; nand na1(w1,a,b); nand na2(w2,a,b); nand na3(out,w1,w2); endmoduleRTL View

Simulation Implementation

The simulation results meet the and gate logic .

And gate ( The second way ),Verilog Realization , Two NAND gates
module my_and( output out, input a, input b ); wire w1; nand na1(w1,a,b); nand na2(out,w1,w1); endmoduleRTL View

Simulation results

Or gate ,verilog Realization
// Build or gate module my_or( output out, input a, input b ); // Input short circuit wire w1,w2; nand (w1,a,a); nand (w2,b,b); nand (out,w1,w2); endmoduleSimulation verification

Not gate , It's very simple , Just short-circuit the NAND gate , We don't have to verify them one by one . I didn't want to write my_not Of , As a result, the second question needs , Stick its code .

Use the definition in the above question my_and,my_or,my_not, To build an XOR gate (xor), Function calculation z = x ˉ y + x y ˉ z=\bar{x}y+x\bar{y} z=xˉy+xyˉ, Write simulation signal to test it .
verilog Realization
// comprehensive my_and,my_or,my_not module my_xor( output out, input a, input b ); // Declare intranet wire w1,w2,w3,w4; my_not my_not_1(w1,a); my_not my_not_2(w2,b); my_and my_and_1(w3,w1,b); my_and my_and_2(w4,w2,a); my_or my_or_1(out,w3,w4); endmoduleRTL View

Simulation design
// Simulation definition module my_xor_tb(); reg x,y; wire z; my_xor my_xor_inst(z,x,y); initial begin x=1'b0; y=1'b1; #10 x=1'b0; y=1'b0; #1 $display("x=%b,y=%b,z=%b\n",x,y,z); #10 x=1'b0; y=1'b1; #1 $display("x=%b,y=%b,z=%b\n",x,y,z); #10 x=1'b1; y=1'b0; #1 $display("x=%b,y=%b,z=%b\n",x,y,z); #10 x=1'b1; y=1'b1; #1 $display("x=%b,y=%b,z=%b\n",x,y,z); end endmoduleSimulation results , Satisfy XOR gate logic

Too lazy to type , The title is as follows

Verilog Realization
module my_fulladder( output sum, output c_out, input a, input b, input c_in ); wire a_1, b_1, c_in_1; wire s1, s2, s3, s4; wire c1, c2, c3; // First realize the not gate in the equation , And connect with the network defined above not (a_1, a); not (b_1, b); not (c_in_1, c_in); // Realize sum and (s1,a,b,c_in); and (s2,a_1,b,c_in_1); and (s3,a_1,b_1,c_in); and (s4,a,b_1,c_in_1); or (sum,s1,s2,s3,s4); // Realize c_out and (c1,a,b); and (c2,b,c_in); and (c3,a,c_in); or (c_out,c1,c2,c3); endmoduleRTL View

Simulation Implementation
module my_fulladder_tb(); reg A,B,C_IN; wire C_OUT,SUM; my_fulladder my_fulladder_inst(SUM, C_OUT, A, B, C_IN); initial begin A = 1'b0; B = 1'b0; C_IN = 1'b0; #10 A = 1'b0; B = 1'b0; C_IN = 1'b1; #1 $display("A=%b,B=%b,C_IN=%b,SUM=%b,C_OUT=%b\n", A, B, C_IN, SUM, C_OUT); #10 A = 1'b0; B = 1'b1; C_IN = 1'b0; #1 $display("A=%b,B=%b,C_IN=%b,SUM=%b,C_OUT=%b\n", A, B, C_IN, SUM, C_OUT); #10 A = 1'b0; B = 1'b1; C_IN = 1'b1; #1 $display("A=%b,B=%b,C_IN=%b,SUM=%b,C_OUT=%b\n", A, B, C_IN, SUM, C_OUT); #10 A = 1'b1; B = 1'b0; C_IN = 1'b0; #1 $display("A=%b,B=%b,C_IN=%b,SUM=%b,C_OUT=%b\n", A, B, C_IN, SUM, C_OUT); #10 A = 1'b1; B = 1'b0; C_IN = 1'b1; #1 $display("A=%b,B=%b,C_IN=%b,SUM=%b,C_OUT=%b\n", A, B, C_IN, SUM, C_OUT); #10 A = 1'b1; B = 1'b1; C_IN = 1'b0; #1 $display("A=%b,B=%b,C_IN=%b,SUM=%b,C_OUT=%b\n", A, B, C_IN, SUM, C_OUT); #10 A = 1'b1; B = 1'b1; C_IN = 1'b1; #1 $display("A=%b,B=%b,C_IN=%b,SUM=%b,C_OUT=%b\n", A, B, C_IN, SUM, C_OUT); #10 A = 1'b0; B = 1'b0; C_IN = 1'b0; #1 $display("A=%b,B=%b,C_IN=%b,SUM=%b,C_OUT=%b\n", A, B, C_IN, SUM, C_OUT); end endmoduleSimulation results , Meet the design requirements

Directly above

verilog Realization
module my_rs_latch( output q, output qbar, input set, input reset ); nor #(1) (q,reset,qbar); nor #(1) (qbar,q,set); endmoduleSimulation
module my_rs_latch_tb(); reg SET,RESET; wire Q,QBAR; my_rs_latch my_rs_latch_inst(Q,QBAR,SET,RESET); initial begin SET=1'b0; RESET = 1'b0; #10 SET=1'b0; RESET = 1'b1; #10 SET=1'b1; RESET = 1'b0; #10 SET=1'b1; RESET = 1'b1; end endmoduleSimulation results , After two time units (2 ps),q Change

Upper figure


This multiplexer , When s by 1 When , Output in1;s by 0 When , Output in2.
verilog Realization
module my_mux2_to_1( output out, input in1,in2, input s ); bufif1 #(1:3:5,2:4:6,3:5:7) buf1(out,in1,s); bufif0 #(1:3:5,2:4:6,3:5:7) buf0(out,in2,s); endmoduleSimulation results
- When s by 0 when , Output in2, When in2 by 1 when , It's delayed 3 In time units ,in2 by 1

- When s by 0 when , Output in2, When in2 by 0 when , It's delayed 4 In time units ,in2 by 0

- When s by 1 when , Empathy .
- When s by 0 when , Output in2, When in2 by 1 when , It's delayed 3 In time units ,in2 by 1
边栏推荐
- Zhao Fuquan: to ensure supply in the short term, we should build a safe, efficient and resilient supply chain in the long term
- Redis 主从同步
- plain framework的实际应用和扩展
- 云信小课堂 | IM及音视频中常见的认知误区
- Daily three questions 6.29
- 内存泄露和内存溢出的区别是什么?
- 【必会】BM41 输出二叉树的右视图【中等+】
- Anomaly-Transformer (ICLR 2022 Spotlight)复现过程及问题
- SQL optimization
- The best smart home open source system in 2022: introduction to Alexa, home assistant and homekit ecosystem
猜你喜欢

Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification

Matplotlib common settings

Huisheng Huiying 2022 intelligent, fast and simple video editing software

2022年R1快开门式压力容器操作考题及答案

【小程序】通过scroll-view组件实现左右【滑动】列表

Know --matplotlib

from pip._internal.cli.main import main ModuleNotFoundError: No module named ‘pip‘

The best smart home open source system in 2022: introduction to Alexa, home assistant and homekit ecosystem

What is the mosaic tailgate?

Stm32f030f4 drives tim1637 nixie tube chip
随机推荐
What is the mosaic tailgate?
【小程序】通过scroll-view组件实现左右【滑动】列表
Leetcode(34)——在排序数组中查找元素的第一个和最后一个位置
Reproduction process and problems of analog transformer (ICLR 2022 Spotlight)
Daily three questions 6.29
内存泄露和内存溢出的区别是什么?
Experience of practical learning of Silicon Valley products
2022-07-01: at the annual meeting of a company, everyone is going to play a game of giving bonuses. There are a total of N employees. Each employee has construction points and trouble points. They nee
typescript枚举
MT manager test skiing Adventure
Create Ca and issue certificate through go language
STM32F030F4驱动TIM1637数码管芯片
常见的积分商城游戏类型有哪些?
What are the common types of points mall games?
2021 RoboCom 世界机器人开发者大赛-本科组初赛
openwrt 开启KV漫游
SWT/ANR问题--SWT 导致 kernel fuse deadlock
Three development trends of enterprise application from the perspective of the third technological revolution
PostgreSQL source code (57) why is the performance gap so large in hot update?
通过Go语言创建CA与签发证书