微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 时钟切换电路的Verilog实现

时钟切换电路的Verilog实现

时间:10-02 整理:3721RD 点击:
图1是参照图2写的Verilog综合后的RTL级,但是写了个TB,仿真结果不对,输出的时钟一直保持为0;

  1. module clk_switch(input  CLK_A,
  2.                   input  CLK_B,
  3.                                                 input  SEL,
  4.                                                 output CLK
  5.                  );
  6. wire c1,c2,c3,c4;
  7. reg r_a;
  8. reg r_b;

  9. and and1(c1,SEL,r_b);
  10. not not1(c2,SEL);
  11. and and2(c3,c2,r_a);

  12. always@(posedge CLK_A)
  13.      r_a <= c1;

  14. always@(posedge CLK_B)
  15.      r_b <= c3;
  16. wire c5,c6;
  17. and   and3(c5,r_a,CLK_A);
  18. and   and4(c6,r_b,CLK_B);
  19. or    or1(CLK,c5,c6);
  20. initial
  21. //$monitor ("CLK=%b,c5=%b,c6=%b",CLK,c5,c6);
  22. //$monitor ("r_a=%b,r_b=%b",r_a,r_b);
  23. $monitor ("r_a=%b,r_b=%b,c1=%b,c3=%b",r_a,r_b,c1,c3);
  24. endmodule

复制代码

代码这样写可以吗?


谢谢指导

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top