这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » FPGA » 请教一个很奇怪的问题

共6条 1/1 1 跳转至

请教一个很奇怪的问题

助工
2009-05-25 16:29:03     打赏

我做了一个计数器,在两个信号的控制下启动和停止计数
并且在计数完成后,输出一个脉冲信号,如果clk直接接外部50M晶振的话,输出没有问题,但如果接PLL的话(甚至倍频到80M),计数完成后输出的脉冲就直接输出杂声(高频),请高手指教一二.....,谢谢!

module counter(clk_in,start,stop,rst,count_num,count_over);
input clk_in,start,stop,rst;
output[7:0] count_num;

output count_over;
reg count_over;

reg [7:0] count_num;
reg [32:0] count_over_wide;
reg [32:0] count_out_wide;

parameter pulsewide=80;
reg count_flag;
reg count_over_flag;


always@(negedge start or posedge stop or negedge rst)
 begin
  if(!rst)
   count_flag<=0;
  else if(stop)
   begin
   count_flag<=0;
   end
  else  count_flag<=1;
 end

 

always@(posedge clk_in )
begin
 if(!rst)
  begin

   count_num<=0;

  end
    else if(count_flag==1)
  begin
   count_num<=count_num+1;
   end  
   


end

 always@(posedge clk_in)
  begin
   if(!rst)
    begin
     count_over_flag<=0;
     count_over_wide<=0;
     count_over<=0;
    end
   else if((stop)&(!count_over_flag))
     count_over_flag<=1;

   else if(count_over_flag==1)
    begin
     if(count_over_wide<=pulsewide)
      begin
       count_over<=1;
       count_over_wide<=count_over_wide+1;
      end
     else
      begin
       count_over_flag<=0;
       count_over_wide<=0;
      end
    end
   else
    count_over<=0;
  end


endmodule




关键词: 请教     一个     怪的     问题     count     begin    

助工
2009-05-26 09:47:53     打赏
2楼
fpga是cycloneII的

助工
2009-05-26 09:56:47     打赏
3楼
接PLL有时可以输出脉冲信号,但有时只是输出高频的杂声

刚才接了PLL但是不倍频,效果一样,有时还是输出高频杂声,但是如果有脉冲的话,计数器的读数比较稳定

助工
2009-05-31 15:21:18     打赏
4楼

工程比较复杂,涉及的硬件比较多

仿真没有问题,因为fpga还和arm连接,所以也可能和arm程序有关吧,不过真的很奇怪


助工
2009-06-01 10:17:11     打赏
5楼
对于PLL,是不是只能通过mega来设计,然后再原理图绘制?

助工
2009-06-03 14:00:07     打赏
6楼
内部PLL有自动设置倍频和分频系数,直接设置输出频率即可

共6条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]