没有合适的资源?快使用搜索试试~ 我知道了~
西北工业大学数字逻辑实验一
资源推荐
资源详情
资源评论
实验一 实验环境搭建与数字电路正向设计方法
一、实验目的
1. 学习 Quartus 和 ModelSim 两种 EDA 工具的使用方法;
2.Verilog 硬件描述语言入门;
3.初步了解基本组合逻辑电路的设计方法;
4.学习测试模块(Testbench)的结构和编写方法;
二、实验内容
1.本次实验学习 ModelSim 仿真工具的安装并学习如何使用。
2.使用 ModelSim 工具,使用 Verilog HDL 语言完成课本 Figure2.72,并写出测试模
型,对其进行比较全面的测试。
(1)模块源码和测试模块:
模块源码:
module shared (a, b, c, d, m, s1, s0);
input a, b, c, d, m;
output s1, s0;
wire w1, w2;
mux2to1 U1 (a, c, m, w1);
mux2to1 U2 (b, d, m, w2);
adder U3 (w1, w2, s1, s0);
endmodule
module mux2to1 (x1, x2, s, f);
input x1, x2, s;
output f;
assign f = (~s & x1) | (s & x2);
endmodule
module adder (a, b, s1, s0);
input a, b;
output s1, s0;
assign s1 = a & b;
assign s0 = a ^ b;
endmodule
测试模型:
`timescale 1ns/1ps
module tb_shared;
reg a_test;
reg b_test;
reg c_test;
reg d_test;
reg m_test;
wire s1_test;
wire s0_test;
initial
m_test=0;
always #40 m_test=~m_test;
initial
begin
a_test=0;
b_test=0;
c_test=0;
d_test=0;
#20
a_test=0;
b_test=1;
c_test=0;
d_test=1;
#40
a_test=1;
b_test=1;
c_test=1;
d_test=1;
#80
a_test=1;
b_test=0;
c_test=1;
d_test=0;
end
shared
UUT_shared(.a(a_test),.b(b_test),.c(c_test),.d(d_test),.m(m_test),.s1(s1_t
est),.s0(s0_test));
endmodule
(2)仿真后的波形:
(3)分析波形:
在测试模块中使用了 initial 说明语句,在仿真开始 i 时对各变量进行了初始化,
且延时设置为 20 个时间单位,由波形图知,每个周期的延时时间间隔符合 20 个时间
单位;
由源码可知,输出 S0 = ((~m & a) | (m & c))&((~m & b) | (m & d)); S1 = ((~m & a) | (m
& c))^((~m & b) | (m & d))
分析黄色分割线所在的波形图片段,可知,输入 a = 1,b = 0,c = 1,d = 0,m = 0;输出 S1
= 0,S0 = 1,符合源码中所描述的情况。
3. 使用 ModelSim 工具,使用 Verilog HDL 语言完成课本 Figure2.40、Figure2.42 电
路设计,并编写 testbench 测试,对比分析测试结果。
(1)Figure 2.40 电路设计:
①模块源码和测试模块:
模块源码:
module example3 (x1, x2, s, f);
input x1, x2, s;
output f;
assign f = (~s & x1) | (s & x2);
endmodule
测试模块:
`timescale 1ns/1ps
module tb_example3;
reg x1_test;
reg x2_test;
reg s_test;
wire f_test;
initial
剩余11页未读,继续阅读
资源评论
文文文雅
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功