Subject: [sv-ac] Reply to Adam on gated clocks
From: Stephen Meier (Stephen.Meier@synopsys.com)
Date: Fri Mar 21 2003 - 18:16:03 PST
Hi Steve, all;
We also talked briefly about support for enabled (gated) clocks.
The thought was that (clk & enable) would produce the desired effects and is supported
by the current methods.
However I do not believe that this is correct.
The question is are these two fragments equivalent.
always @(posedge (clk & enable)) q <= d;
vs.
always @(posedge clk) if (enable) q <= d; // q1 below
Running a small program to test this theory, here are the results from Vcs 6.0
I stripped out the negedge clk changes...
Compiler version 6.0; Runtime version 6.0; Mar 21 09:57 2003
q uses clk & enable.
q1 uses clk iff enable.
time clk d e q q1
10 1 1 1 0 x early
30 1 2 0 1 1 later
50 1 3 0 1 1
70 1 4 1 3 1 early
90 1 5 0 4 4 later
110 1 6 0 4 4
130 1 7 1 6 4 early
150 1 8 0 7 7 later
...
Notice that q and q1 are not the same. Q (clk & enable) changes when the enable is asserted. Q1 (clk iff enable) changes 1 clock later. For Q, this is because when the clock is asserted, the enable becomes the clocking event. However for Q1 the clocking
event is only based on clk and then Q1 is updated only if enable is asserted.
Thus I would recommend that the clocking proposal be updated to allow
@@(posedge clk iff enable)
as legal syntax. This syntax is already part of SystemVerilog.
Without this you will have a hole in multiple clock support. Clock gating/enable is becoming a more and more common technique especially in power sensitive designs. Proper
support will be necessary to for ease of use with properties.
Adam Krolnik
Verification Mgr.
LSI Logic Corp.
Plano TX. 75074
module enableclk;
reg clk;
reg enable;
reg [3:0] d, q, q1;
initial begin
clk = 0;
forever clk = #10 ~clk;
end
initial
begin
$display(" q uses clk & enable.");
$display("q1 uses clk iff enable.");
$display(" time clk d e q q1");
$monitor($stime,,, clk,, d,,, enable,, q,, q1);
end
always @(posedge clk) if (enable) q1 <= d;
always @(posedge (clk & enable)) q <= d;
initial begin
d = 0;
repeat (20) @(posedge clk) d <= d + 1'b1;
$finish;
end
initial begin
enable = 0;
repeat (10)
begin
@(posedge clk);
enable = 1'b1;
@(posedge clk);
enable = 1'b0;
@(posedge clk);
end
end
endmodule
This archive was generated by hypermail 2b28 : Fri Mar 21 2003 - 18:20:02 PST