|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
我在做一个计数器,功能是计算每秒接收到的脉冲个数,通过八段数码管显示,使用的时钟是100MHz,接收的脉冲其频率远低于100MHz,代码如下:
- //在高频信号中读取低频脉冲;
- module pulse_counter(pulse,clk,rst_n,out1,out2,out3,out4,out5,di);
- output reg [7:0] out1,out2,out3,out4,out5;
- output wire [9:0] di;
- input pulse;
- input clk;
- input rst_n;
- reg now=0;
- reg past;
- parameter num_0=8'b11100111;
- parameter num_1=8'b00100001;
- parameter num_2=8'b11001011;
- parameter num_3=8'b01101011;
- parameter num_4=8'b00101101;
- parameter num_5=8'b01101110;
- parameter num_6=8'b11101110;
- parameter num_7=8'b00100011;
- parameter num_8=8'b11101111;
- parameter num_9=8'b00101111;
- reg [7:0] num1,num2,num3,num4,num5;
- //reg [7:0]out_1,out_2,out_3,out_4,out_5;
- reg [26:0]counter1; //每秒显示一次数字;
- reg [16:0] counter2;//显示的数字;
- reg rst;
- //reg [26:0] reference=27'd0;//通过reference来判断是否在1s之内;
- assign di=10'd0;
- parameter range=27'd100000000;
- always @(posedge clk)
- rst=rst_n;
- always @(posedge clk or negedge rst)
- if(!rst)
- begin
- counter1=0;
- out1=num_0;
- out2=num_0;
- out3=num_0;
- out4=num_0;
- out5=num_0;
- end
- else if(counter1<range-1)
- counter1=counter1+1;
- else
- begin
- num5=30000/10000;
- num4=(30000-num5*10000)/1000;
- num3=(30000-num5*10000-num4*1000)/100;
- num2=(30000-num5*10000-num4*1000-num3*100)/10;
- num1=30000-num5*10000-num4*1000-num3*100-num2*10;
-
- case(num5)
- 0: out5=num_0;
- 1: out5=num_1;
- 2: out5=num_2;
- 3: out5=num_3;
- 4: out5=num_4;
- 5: out5=num_5;
- 6: out5=num_6;
- 7: out5=num_7;
- 8: out5=num_8;
- 9: out5=num_9;
- endcase
- case(num4)
- 0: out4=num_0;
- 1: out4=num_1;
- 2: out4=num_2;
- 3: out4=num_3;
- 4: out4=num_4;
- 5: out4=num_5;
- 6: out4=num_6;
- 7: out4=num_7;
- 8: out4=num_8;
- 9: out4=num_9;
- endcase
- case(num3)
- 0: out3=num_0;
- 1: out3=num_1;
- 2: out3=num_2;
- 3: out3=num_3;
- 4: out3=num_4;
- 5: out3=num_5;
- 6: out3=num_6;
- 7: out3=num_7;
- 8: out3=num_8;
- 9: out3=num_9;
- endcase
- case(num2)
- 0: out2=num_0;
- 1: out2=num_1;
- 2: out2=num_2;
- 3: out2=num_3;
- 4: out2=num_4;
- 5: out2=num_5;
- 6: out2=num_6;
- 7: out2=num_7;
- 8: out2=num_8;
- 9: out2=num_9;
- endcase
- case(num1)
- 0: out1=num_0;
- 1: out1=num_1;
- 2: out1=num_2;
- 3: out1=num_3;
- 4: out1=num_4;
- 5: out1=num_5;
- 6: out1=num_6;
- 7: out1=num_7;
- 8: out1=num_8;
- 9: out1=num_9;
- endcase
- counter1=0;
- end
- always @(posedge clk or negedge rst)
- if(!rst)
- begin
- past=0;
- now=0;
- end
- else
- begin
-
- // if(!rst)
- // counter2=0;
- // else if(past==0&&now==1)
- // counter2=counter2+1;
- // else
- // counter2=counter2;
- past=now;
- now=pulse;
- end
-
- always @(now)
- if(!rst)
- counter2=0;
- else if(now==1&&past==0)
- counter2=counter2+1;
- else
- counter2=counter2;
-
- endmodule
复制代码
但是警告如下:
WARNING - ngdbuild: logical net 'pulse' has no load
WARNING - map: IO buffer missing for top level port pulse...logic will be discarded.
从而使得在speedsheet view中缺少pulse这一项;
通过仿真,观察得到RTL图中根本就没有关于counter2的电路部分。
求指教!为什么会出现WARNING - ngdbuild: logical net 'pulse' has no load? |
|