打印

altera 重构pll失锁问题

[复制链接]
3003|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ysdx|  楼主 | 2011-11-1 16:35 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
应用中想得到灵活的时钟,就想到altpll_reconfig。但是今天实际操作,发现配置后不能锁定。以下是配置代码。(先输出18MHZ时钟一会,然后修改成9MHZ)
module setpll(
clk,
rst_n,
busy,
reconfig,
read_param,
write_param,
data_out,
counter_type,
counter_param,
pll_areset_out,
reset
);
input   clk;
input   rst_n;
input   busy;
output   reconfig;
output   read_param;
output   write_param;
output [8:0] data_out;
output [3:0] counter_type;
output [2:0] counter_param;
output   pll_areset_out;
output          reset;
reg    reconfig;
reg    read_param;
reg    write_param;
reg  [8:0] data_out;
reg  [3:0] counter_type;
reg  [2:0] counter_param;
reg    pll_areset_out;
reg             reset;

reg     [31:0] count;
reg     [3:0]  state;
parameter idle =4'b0000,
    s0   =4'b0001,
    s1   =4'b0010,
    s2   =4'b0011,
    s3   =4'b0100,
    s4   =4'b0101,
    s5   =4'b0110,
    s6   =4'b0111,
    s7   =4'b1000,   
    s8   =4'b1001,
    s9   =4'b1010,
    s10   =4'b1011,
    s11   =4'b1100;
always @(posedge clk or negedge rst_n) begin
if(!rst_n) begin
  reconfig  <=0;
  read_param <=0;
  write_param <=0;
  data_out    <=9'd0;
  counter_type<=4'b0000;
  counter_param<=3'b000;
  pll_areset_out<=1;
  reset <=1;
  
  count <=32'd0;
  state <= idle;
  
end
else begin
   case(state)
    idle: begin
     reconfig  <=0;
     read_param <=0;
     write_param <=0;
     data_out    <=9'd0;
     counter_type<=4'b0000;
     counter_param<=3'b000;
     pll_areset_out<=1;
     reset <=1;
         
     count <= count +32'd1;
     if(count==32'h10000000)
      state <= s9;
    end
    s9:begin
     pll_areset_out<=0;
     reset <=0;
     count <= count +32'd1;
     if(count==32'h20000000)
      state <= s0;   
    end
    s0: begin
     data_out    <=9'd36;
     counter_type<=4'b0100;
     counter_param<=3'b000;
     state <= s1;
    end
    s1: begin
     count <= count +32'd1;
     if(count==32'h21000000) begin
      if(!busy) begin
       write_param <=1;
       state <= s2;
      end
     end
    end
    s2: begin
     write_param <=0;
     state <= s3;
    end
    s3: begin
     if(!busy)
      state <= s4;      
    end
    s4: begin
     data_out    <=9'd36;
     counter_type<=4'b0100;
     counter_param<=3'b001;
     state <= s5;
    end
    s5: begin
     if(!busy) begin
      write_param <=1;
      state <= s6;
     end
    end
    s6: begin
     write_param <=0;
     state <= s7;
    end
    s7: begin
     if(!busy) begin
      reconfig <=1;
      state <= s8;
     end      
    end
    s8: begin
     reconfig <=0;
     if(!busy)
      state <= s10;     
    end
    s10: begin
    // pll_areset_out<=1;
     state <= s11;
    end
    s11: begin
    // pll_areset_out<=0;
     state <= s11;
    end
     
    default:
     state <= idle;
   endcase
end
end
endmodule

altpll.JPG (230.71 KB )

实际捕获的波形

实际捕获的波形

top.JPG (260.66 KB )

top.JPG

相关帖子

沙发
hanbin08041813| | 2012-6-10 15:00 | 只看该作者
我也在搞这个

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:新手死于追涨,老手死于抄底,高手死于杠杆,价值投资死于满仓死杠!

337

主题

1054

帖子

21

粉丝