FPGA学习-1,ModelSim 仿真
作者:互联网
参考
https://blog.csdn.net/xy_z_H/article/details/124825179
补充
1、用到的两个文件(手敲一遍)
BCD.v
module BCD(A,B , Sum, Cout);
input [3:0]A , B;
output [3:0]Sum;
output Cout;
wire [4:0]Temp;
assign Temp =A + B;
assign {Cout , Sum} = (Temp > 9)?Temp +6 : Temp;
endmodule
BCD_TB1
`timescale 1ns/1ns
module BCD_tb;
reg [3:0]addend1,addend2;
wire [3:0]sum;
wire C;
parameter DELAY = 100;
integer i,j;
BCD U1( .A(addend1),
.B(addend2),
.Cout(C),
.Sum( sum)
); //BCD UI (addend1 , addend2 , sum, C);该调用方法注意顺序不能颠倒
//调用测试对象
initial //激励波形设定(初始化)
begin
addend1 = 0;
addend2 = 0;
for(i = 0;i < 10;i = i + 1)
for(j = 0;j < 10;j = j + 1)
begin
#DELAY addend1 = i;
addend2 = j;
end
end
initial
$monitor ($time,,,"%d + %d = %d,carry=%d ",addend1,addend2,sum,C);
//输出格式定义
// s$monitor("格式空制符,输出变量名列表);
/*==>每次信号的值发生变化,都会激活该语句,并显示当前仿真时间可看作一个持续监控器,可在transcript下查看wave的仿真结果。*/
endmodule
2、开始仿真时注意勾掉这个,不然出不了波形
3、仿真结果
4、局部大图
5、监控输出
标签:仿真,Temp,FPGA,BCD,Sum,ModelSim,addend2,addend1,sum 来源: https://www.cnblogs.com/zhaogaojian/p/16484498.html