大家好,我用的是modelsim6.1,遇到了只有输入只有振荡波形,输出为0,请大侠帮帮忙!!!!
头文件:
module fz;
// Inputs
reg clk_36M;
reg rst;
// Outputs
wire dateout1;
wire dateout2;
wire dateout3;
// Instantiate the Unit Under Test (UUT)
NO2 uut (
.clk_36M(clk_36M),
.dateout1(dateout1),
.dateout2(dateout2),
.dateout3(dateout3),
.rst(rst)
);
initial
begin
// Initialize Inputs
clk_36M = 0;
#100 rst = 0;
#130 rst = 1;
//forever
//#100 clk_36M=~clk_36M;
end
forever
#100 clk_36M=~clk_36M;
endmodule
程序内容:
module NO2(
clk_36M,
dateout1,
dateout2,
dateout3,
rst,
);
input clk_36M;
input rst;
output dateout1;
output dateout2;
output dateout3;
reg dateout1;
reg dateout2;
reg dateout3; //死区报警指示
reg clk_div1;
reg clk_div2;
reg[24:0]count;
reg[24:0]count1;
always @ (posedge clk_36M)
begin
/*模拟信号的产生*/
if(count==25000000) //用户定义波形周期,25M/36M
count<=0;
else
begin
count<=count+1;
begin
if(count>15900000 && count<20000000) //clk_div1为1时的输出时间
clk_div1<=1;
else
clk_div1<=0;
if(count>10000000 && count<16000000) //clk_div2为1时的输出时间
clk_div2<=1;
else
clk_div2<=0;
end
end
end
/*输入信号重叠是,死区告警*/
always @(posedge clk_36M or negedge rst )
if(!rst) //复位电路
begin
dateout3<=0;
dateout2<=0;
dateout1<=0;
end
else
begin
if( ((clk_div1&&clk_div2)!=1) && ((dateout2&&dateout1)!=1) ) //当输入信号和输出信号不同是为1时
begin
dateout3<=0;
dateout2<=clk_div2;
dateout1<=clk_div1;
end
else
begin
if(count1==6000000) //当输入信号或者输入信号同时为1,计数器count1=6000000时。
count1<=0;
if( ((clk_div1&&clk_div2)!=1) && ((dateout2&&dateout1)!=1))
begin
dateout3<=0;
dateout2<=clk_div2;
dateout1<=clk_div1;
end
else //当输入信号或者输入信号同时为1,计数器不为6000000的情况下。
begin
dateout3<=1;
dateout2<=0;
dateout1<=0;
count1<=count1+1;
end
end
end
endmodule |