今天在modelsim里进行程序
仿真, 但是无论用手动激励还是激励文件,点击RUN以后modelsim就没有反应了,点stop也没有反应,不能停止仿真,而且左下角始终显示运行了0ps,不知道是不是编写的程序有问题?请各位大神帮帮忙看看!万分感谢
代码如下:
- module count96( add_clk,d_in,en,adder,lp,red,d_out,sel,i,cl );
- input add_clk,sel,en; //地址计数时钟,8分频
- output adder,d_out,lp,red,i,cl; //地址输出,lp为锁存移位信号
- input[7:0] d_in;
- reg[15:0] adder,adder1;
- reg lp,red,i,a;
- reg[15:0] count1;
- reg[7:0] count2,d_out;
- reg count3;
- wire clk,cl;
- parameter dely = 10;
- parameter zero = 8'h00;
- //
- //初始化内部计数数据
- //
- initial begin
- count1 <= 0;
- count2 <= 0;
- count3 <= 0;
- i <= 0;
- a <= 0;
- red <= 0;
- end
- //
- //输出逻辑组合
- //
- assign clk = a & add_clk; //使能控制时钟输出
- assign cl = clk; //移位脉冲
- always if(en) a <= 1; //将出发信号转换成使能信号
- else if(count1 == 0)
- @(negedge add_clk) #(7*dely) a <= 0;
- always if(a) begin d_out <= (sel)? d_in:zero ; //使能控制数据输出.通过sel判断输出数据
- adder <= adder1;
- end
- else begin d_out <= 8'hzz;
- adder <= 16'd0;
- end
- //
- //地址信号产生模块
- //
- always @(posedge add_clk)
- if(count1 == 38399) begin //计数MAX`h9600
- adder1 = count1;
- i = ~i;
- count1 = 0;
- end
- else if( en |(count1 != 0)) begin
- adder1 = count1;
- count1 = count1 + 16'd1;
- end
- //
- //LP信号计数模块
- //每120个时钟产生一个1时钟宽的高电平out信号
- always @(posedge add_clk)
- if(count2 == 119) begin
- count3 = 1;
- count2 = 0;
- end
- else if ( a | (count2 != 0)) begin
- count3 = 0;
- count2 = count2 + 8'd1;
- end
- //
- //LP信号产生模块
- //当out为高时,生成一个80ns脉宽的lp信号
- always @(negedge clk )
- if( count3 & a ) begin
- lp <= 1;
- #( 8*dely ) lp <= ~lp ; //使lp产生80ns脉宽的出发信号
- end
- else lp<=0;
- //
- //读信号red产生模块
- //脉宽130ns
- always @(posedge add_clk )if (a) begin
- #(3*dely) red <= 0;
- #(13*dely) red <= ~red; //脉宽100ns
- end
- endmodule
复制代码
一周热门 更多>