P1.2.1 The Reset Synchronizer

MediumImplementIcarus · browser samples / server checksReview the topic

Build the circuit behind "asserted asynchronously, released synchronously". Reset must act at once, even with the clock stopped, and let go only on a clock edge.

Hardware context: The reset synchronizer at the edge of a clock domain. Implement a two-flop reset synchronizer with asynchronous assert and synchronous release.

Lesson P1.2 gave the rule every bus follows. Reset is asserted without waiting for a clock and released at a clock edge. Somebody has to build the circuit that turns a raw reset into that.

Write module rst_sync. When rst_in_n falls, rst_out_n must fall in the same instant, with or without a clock. When rst_in_n rises, rst_out_n stays low through the next rising edge of clk and rises at the second one.

The fixture runs a timeline in 1 ns steps and samples rst_out_n every 2 ns. It releases reset at different points of the cycle and sends a short pulse between two edges. It also stops the clock while reset comes and goes.

Signals in the Timeline

SignalWidthRole
pulses3input of each check
Full specification
The module you write (keep these ports)
module rst_sync (
  input  logic clk,
  input  logic rst_in_n,    // from a pin or a reset controller: active low, may change at any time
  output logic rst_out_n    // to the block: active low
);
  // your synchronizer
endmodule
Eventrst_out_n
rst_in_n fallsFalls at once, in the same time step, even when clk is not toggling.
rst_in_n is lowStays low.
rst_in_n risesStays low. The first rising edge of clk with rst_in_n high changes nothing visible.
The second rising edge with rst_in_n highRises at that edge.
rst_in_n falls again before thatFalls, or stays low, and the count of edges starts again.

The clock has a 10 ns period with rising edges at 5, 15, 25 ns, unless a case stops it. rst_in_n is low from time 0 and never changes on a clock edge.

The result is 64 samples of rst_out_n, bit i at t = 2i + 1 ns. A 1 means the block runs.

Examples

Example 1

Power-Up
Input
rst_in_n falls at 0 ns; rises at 22 ns
The clock runs throughout: rising edges at 5, 15, 25, ... ns
Output
samples = 0xfffffffffffe0000

rst_in_n rises at 22 ns. The edge at 25 ns is the first one that sees it high; the edge at 35 ns releases rst_out_n. Samples from t = 35 ns read 1.

Example 2

Released Just Before an Edge
Input
rst_in_n falls at 0 ns; rises at 14 ns
The clock runs throughout: rising edges at 5, 15, 25, ... ns
Output
samples = 0xfffffffffffff000

rst_in_n rises at 14 ns, one nanosecond before the edge at 15 ns. That edge counts as the first, and rst_out_n rises at 25 ns.

Example 3

A Reset in the Middle of a Cycle
Input
rst_in_n falls at 0 ns, 61 ns; rises at 37 ns, 68 ns
The clock runs throughout: rising edges at 5, 15, 25, ... ns
Output
samples = 0xfffffc0038000000

rst_in_n falls at 61 ns and rst_out_n falls with it. After the release at 68 ns, rst_out_n returns at the edge at 85 ns.

Constraints and Contract

  • Keep the module name and the ports. Use clk and rst_in_n only.
  • Your output must be 0 or 1 at every sample. Do not reach outside your ports.

Hints

Hint 1

Two flip-flops in a chain, both with an asynchronous clear from rst_in_n. The first takes a constant 1, the second takes the first.

Hint 2

Put rst_in_n in the sensitivity list with its edge: always @(posedge clk or negedge rst_in_n).

Hint 3

A flop that is not cleared by the reset can carry a stale 1 out of the pulse. Clear both.

What the grader checks: Your synchronizer runs seven timelines of 130 ns, sampled every 2 ns, with the clock stopped in two of them. Passing shows the assert and release timing on these timelines. It says nothing about metastability, which no RTL simulation can show.

7 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Power-Up

Input
rst_in_n falls at 0 ns; rises at 22 ns
The clock runs throughout: rising edges at 5, 15, 25, ... ns
Expected output
samples = 0xfffffffffffe0000

rst_in_n rises at 22 ns. The edge at 25 ns is the first one that sees it high; the edge at 35 ns releases rst_out_n. Samples from t = 35 ns read 1.

Run samples executes all 3 public checks. Check all tests runs 7 checks on the server.

Icarus · browser samples / server checks