当前位置:网站首页>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
边栏推荐
- mt管理器测试滑雪大冒险
- 2022 examination questions and online simulation examination for safety management personnel of hazardous chemical business units
- What is mosaic?
- Postgresql源码(58)元组拼接heap_form_tuple剖析
- SWT/ANR问题--SWT 导致 kernel fuse deadlock
- 常见的积分商城游戏类型有哪些?
- PostgreSQL notes (10) dynamically execute syntax parsing process
- Redis数据类型和应用场景
- 共享电商的背后: 共创、共生、共享、共富,共赢的共富精神
- Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
猜你喜欢

Notes on problems - /usr/bin/perl is needed by mysql-server-5.1.73-1 glibc23.x86_ sixty-four

2022年起重机司机(限桥式起重机)考试试题及模拟考试
![[micro service sentinel] sentinel integrates openfeign](/img/8b/46156255fd980eb422c7e05d5af7ee.png)
[micro service sentinel] sentinel integrates openfeign

MySQL binlog cleanup

2022 safety officer-c certificate examination question simulation examination question bank and simulation examination

Redis RDB快照

2021 RoboCom 世界机器人开发者大赛-本科组初赛

What is the relationship between modeling and later film and television?

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

PostgreSQL source code (57) why is the performance gap so large in hot update?
随机推荐
【C#】依赖注入及Autofac
Redis data types and application scenarios
Distance measurement - Hamming distance
Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
Anomaly-Transformer (ICLR 2022 Spotlight)复现过程及问题
[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing
Reproduction process and problems of analog transformer (ICLR 2022 Spotlight)
ShanDong Multi-University Training #3
ARP报文头部格式和请求流程
sql 优化
Redis 主从同步
云信小课堂 | IM及音视频中常见的认知误区
Li Kou today's question -241 Design priorities for operational expressions
问题随记 —— file /usr/share/mysql/charsets/README from install of MySQL-server-5.1.73-1.glibc23.x86_64 c
dat. GUI
2022-07-01:某公司年会上,大家要玩一食发奖金游戏,一共有n个员工, 每个员工都有建设积分和捣乱积分, 他们需要排成一队,在队伍最前面的一定是老板
What are the common types of points mall games?
2022年起重机司机(限桥式起重机)考试试题及模拟考试
MySQL binlog cleanup
【微服务|Sentinel】sentinel整合openfeign