当前位置:   article > 正文

16.分频器设计—奇分频

16.分频器设计—奇分频

(1)Visio视图:

(2)Verilog代码:

  1. module divider_five(clk,reset_n,clk_out);
  2. input clk;
  3. input reset_n;
  4. output clk_out;
  5. reg [2:0]cnt;
  6. reg clk_1;
  7. reg clk_2;
  8. //计数器模块设计
  9. always@(posedge clk or negedge reset_n)
  10. if(!reset_n)
  11. cnt <= 3'd0;
  12. else if(cnt == 3'd4)
  13. cnt <= 3'd0;
  14. else
  15. cnt <= cnt + 3'd1;
  16. //clk_1信号设计
  17. always@(posedge clk or negedge reset_n)
  18. if(!reset_n)
  19. clk_1 <= 1'd0;
  20. else if(cnt == 3'd2)
  21. clk_1 <= 1'd1;
  22. else if(cnt == 3'd4)
  23. clk_1 <= 1'd0;
  24. else
  25. clk_1 <= clk_1;
  26. //clk_2信号设计
  27. always@(negedge clk or negedge reset_n)
  28. if(!reset_n)
  29. clk_2 <= 1'd0;
  30. else if(cnt == 3'd2)
  31. clk_2 <= 1'd1;
  32. else if(cnt == 3'd4)
  33. clk_2 <= 1'd0;
  34. else
  35. clk_2 <= clk_2;
  36. assign clk_out = (clk_1 | clk_2);
  37. endmodule

(3)RTL视图:

(4)仿真文件代码:

  1. `timescale 1ns / 1ps
  2. module divider_five_tb;
  3. reg clk;
  4. reg reset_n;
  5. wire clk_out;
  6. divider_five divider_five_inst(
  7. .clk(clk),
  8. .reset_n(reset_n),
  9. .clk_out(clk_out)
  10. );
  11. initial clk = 1'd1;
  12. always #10 clk = ~clk;
  13. initial begin
  14. reset_n = 1'd0;
  15. #20;
  16. reset_n = 1'd1;
  17. #2000
  18. $stop;
  19. end
  20. endmodule

(5)仿真波形:

(6)引脚绑定:

  1. set_property IOSTANDARD LVCMOS33 [get_ports clk_out]
  2. set_property IOSTANDARD LVCMOS33 [get_ports reset_n]
  3. set_property IOSTANDARD LVCMOS33 [get_ports clk]
  4. set_property PACKAGE_PIN M13 [get_ports clk_out]
  5. set_property PACKAGE_PIN N15 [get_ports reset_n]
  6. set_property PACKAGE_PIN W19 [get_ports clk]

(7)实验现象:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/808128
推荐阅读
相关标签
  

闽ICP备14008679号