Producing a clock glitch in a Verilog design

倖福魔咒の 提交于 2020-05-15 05:36:09

问题


I am designing a chip using Verilog. I have a 3-bit counter. I want that when the counter is in its 8th loop, there should be a clock glitch, and thereafter work normally. What could be the possible ways of producing a clock glitch in a Verilog design?


回答1:


One way to inject glitches on a clock signal is to use force and release from your testbench:

module tb;

reg clk;
reg [2:0] cnt;
reg reset;

always begin
    #5 clk <= 0;
    #5 clk <= 1;
end

always @(posedge clk or posedge reset) begin
    if (reset) begin
        cnt <= 0;
    end else begin
        cnt <= cnt + 1;
    end
end

always begin: inject_clk_glitch
    wait(cnt == 7);
    #1 force clk = 1;
    #1 force clk = 0;
    #1 release clk;
end

initial begin
    reset = 1;
    #20 reset = 0;
    #500 $finish;
end

endmodule



回答2:


So you essentially want an extra clock edge? I can't think of a way to do this in RTL. You may be able to do an ugly hack utilising gate delays, but this would need to be characterised over temperature and process variations.

I'd recommend that you think of another solution to your problem. Why do you need this extra clock edge?



来源:https://stackoverflow.com/questions/2251465/producing-a-clock-glitch-in-a-verilog-design

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!