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

  • clk starts at 1 (initial block)
  • Toggles every 10 time units
  • Period = 20 time units

Signal 'a' Behavior

  • a starts at 0
  • On each posedge clk, samples clk value (always 1)
  • Assigns to a after 15 time unit delay (intra-assignment delay)
  • Since clk=1 at every posedge, a becomes 1 at t=25 and stays 1

Timing Diagram

TimeEventclka
0Initial10
10posedge clk, schedule a<=1 at t=2500
20clk toggles10
25a updated11
30posedge clk01

Key Concept: The #15 is an intra-assignment delay - it samples clk immediately but delays the assignment to a by 15 time units.

Author
Mayur Kubavat
VLSI Design and Verification Engineer sharing knowledge about SystemVerilog, UVM, and hardware verification methodologies.

Comments (0)

Leave a Comment