Interview Question - Analog Devices
Company: Analog Devices
Question
Analyze the following Verilog code and determine the waveform for signals clk and a.
module stratified_event;
reg a, clk;
always
#10 clk = ~clk;
always @(posedge clk) begin
$display($time);
a <= #15 clk;
end
initial begin
clk = 1'b1;
a = 1'b0;
#200 $finish;
end
endmodule
Analysis
Clock Behavior
clkstarts at1(initial block)- Toggles every 10 time units
- Period = 20 time units
Signal 'a' Behavior
astarts at0- On each
posedge clk, samplesclkvalue (always 1) - Assigns to
aafter 15 time unit delay (intra-assignment delay) - Since
clk=1at every posedge,abecomes1at t=25 and stays1
Timing Diagram
| Time | Event | clk | a |
|---|---|---|---|
| 0 | Initial | 1 | 0 |
| 10 | posedge clk, schedule a<=1 at t=25 | 0 | 0 |
| 20 | clk toggles | 1 | 0 |
| 25 | a updated | 1 | 1 |
| 30 | posedge clk | 0 | 1 |
Key Concept: The
#15is an intra-assignment delay - it samplesclkimmediately but delays the assignment toaby 15 time units.
Comments (0)
Leave a Comment