Skip to question
SystemVerilogDesignVerificationFirmwareArchitectureASIC Interview Questions→
/Interview questions/Look up time-indexed register history

Q021·Free·SystemVerilog

Look up time-indexed register history

Difficulty
Medium
Topic
Memory Systems
Language
SV
Interview prompt

Question

Store timestamped values for four register keys and answer queries with the value whose stored timestamp is the greatest one less than or equal to the requested time. A query miss returns rsp_hit=0, rsp_timestamp=0, and rsp_value=0. Accepted queries and writes use cmd_valid && cmd_ready.

Append-only timestamp slots, inclusive query results, and the decision taken after each registered history read.
Later writes append to a new slot. Search newest to oldest for the greatest stored timestamp at most the query time, then hold the hit or miss response until accepted.
Candidate starting point

Implementation scaffold

module register_history_lookup (
  input  logic        clk,
  input  logic        rst_n,
  input  logic        cmd_valid,
  input  logic        cmd_query,
  input  logic [1:0]  cmd_key,
  input  logic [15:0] cmd_timestamp,
  input  logic [31:0] cmd_value,
  input  logic        rsp_ready,
  output logic        cmd_ready,
  output logic        rsp_valid,
  output logic        rsp_hit,
  output logic [15:0] rsp_timestamp,
  output logic [31:0] rsp_value
);
  typedef enum logic [2:0] {S_IDLE, S_READ, S_CHECK, S_RSP} state_t;
  state_t state_q;

  logic [15:0] timestamp_q [0:3][0:7];
  logic [31:0] value_q [0:3][0:7];
  logic [3:0] count_q [0:3];

  logic [1:0] query_key_q;
  logic [15:0] query_timestamp_q;
  logic [2:0] scan_q;
  logic [15:0] read_timestamp_q;
  logic [31:0] read_value_q;
  logic hit_q;
  logic [15:0] response_timestamp_q;
  logic [31:0] response_value_q;

  assign cmd_ready     = (state_q == S_IDLE);
  assign rsp_valid     = (state_q == S_RSP);
  assign rsp_hit       = hit_q;
  assign rsp_timestamp = response_timestamp_q;
  assign rsp_value     = response_value_q;

  always_ff @(posedge clk) begin : append_scan_and_respond
    // TODO: Implement append_scan_and_respond using the supplied state and interface.
  end
endmodule
Reviewed example

Trace one case

Input
write key=2 (t=10,A), then (t=20,B); query key=2 at t=5,10,17,20
Expected output
MISS, A, A, B

The backward search returns the newest timestamp less than or equal to the query and treats an exact timestamp as a hit.

What to cover

Requirements

  1. Support four keys and at most eight writes per key, with strictly increasing timestamps within each key.
  2. Serialize accepted commands and make every accepted write visible to every later accepted query.
  3. Return a miss before the first stored timestamp and use inclusive less-than-or-equal behavior for exact matches.
  4. Model a one-cycle local-memory read rather than comparing an entire history combinationally.
  5. A query response must remain stable until accepted; writes do not generate responses.
Exact question handoffPractice Q021

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessEach time you open this Solution, one Practice Credit is used; it is not permanently unlocked. Premium Solution content also uses one credit per opening.
Continue learning

RTL Synthesis and Proof

Review widths, parameterization, memory inference, pipelining, implementation pressure, and proof evidence.

  • Memory Systems
  • Timestamp
  • Upper bound
  • Local memory
RTL Synthesis and Proof →
Continue practicing

Related questions

Q159 · ArraysFind lower and upper boundsMedium→Q649 · Verification UtilitiesTimestamp exactly 100 rising edgesEasyP→Q846 · Post-Silicon & ReliabilitySubtract two PTP timestampsMediumP→
ASIC.FYI · Learn silicon end to end.info@asic.fyi