V3.2.1 Clocks, Power-Good and Reset from the Board

MediumImplement25 minIcarus · browser samples / server checksReview the topic

Write the board side of a chip bench: two unrelated clocks, a power-good, a reset pad and a boot strap. The reset waits a counted number of edges, and no pad moves on a clock edge.

Hardware context: The board's clock, supply, reset pad and boot strap around ap_soc v1.5. Writing a board generator for clocks, power-good and the reset pad.

A chip bench owns only the pads. So it must make what the board makes: the clocks, the supply, the reset pad and the straps. soc_tb puts every clock edge at an odd time and moves every pad at an even time. Icarus and Verilator then agree on every run.

ap_soc makes its own always-on clock inside the chip. Many chips instead take a slow clock from a crystal on the board, and this board is for such a chip. So it makes a second clock, RTC, unrelated to CLK.

Write board_gen. CLK and RTC are free-running and unrelated. power_good rises at PG_NS. The reset pad rst_n is held low from time 0. It is released 3 ns after the HOLD-th rising edge of CLK after power_good rose. The boot strap carries BOOT from time 0 and never changes.

Signals in the Timeline

SignalWidthRole
scenario4input of each check
Full specification
OutputRule
clk0 at time 0. Rising edges at REF_NS / 4 + k × REF_NS, falling edges half a period later.
rtc0 at time 0. Rising edges at RTC_NS / 2 + k × RTC_NS, falling edges half a period later.
power_good0 until PG_NS, then 1.
rst_n0 from time 0. Rises once: 3 ns after the HOLD-th rising edge of clk after power_good rose.
bootBOOT from time 0. Never changes.

power_good, rst_n and boot may change only at even times; every clock edge is at an odd time. The parameters always allow that: REF_NS / 4 and RTC_NS / 2 are odd, and PG_NS is even.

With REF_NS = 20 the first CLK edges are at 5, 25 and 45 ns, as on the soc_tb board. With RTC_NS = 14 the second clock rises at 7, 21 and 35 ns, the same times as ap_soc's own always-on clock.

Examples

Example 1

The soc_tb Board, Power-Good at 100 Ns
Input
REF_NS = 20, RTC_NS = 14, PG_NS = 100, HOLD = 4, BOOT = 0
Output
clk_first = 5, clk_period = 20, clk_high = 10, rtc_first = 7, rtc_period = 14, rtc_high = 7, reset_released_at = 168, power_good_at = 100, reset_rises = 1, reset_held_at_start = yes, strap_steady = yes, pads_at_even_times = yes

CLK rises at 5, 25, 45 ns. power_good rises at 100. The first four edges after it are 105, 125, 145 and 165, so rst_n rises at 168.

Example 2

Power-Good at Once, One Edge of Hold, BOOT = 1
Input
REF_NS = 20, RTC_NS = 14, PG_NS = 2, HOLD = 1, BOOT = 1
Output
clk_first = 5, clk_period = 20, clk_high = 10, rtc_first = 7, rtc_period = 14, rtc_high = 7, reset_released_at = 8, power_good_at = 2, reset_rises = 1, reset_held_at_start = yes, strap_steady = yes, pads_at_even_times = yes

The first CLK edge after 2 ns is at 5. One edge of hold, then 3 ns: the release is at 8 ns.

Example 3

A Faster CLK and a Slow Second Clock
Input
REF_NS = 12, RTC_NS = 30, PG_NS = 50, HOLD = 3, BOOT = 1
Output
clk_first = 3, clk_period = 12, clk_high = 6, rtc_first = 15, rtc_period = 30, rtc_high = 15, reset_released_at = 78, power_good_at = 50, reset_rises = 1, reset_held_at_start = yes, strap_steady = yes, pads_at_even_times = yes

With a 12 ns CLK the edges are at 3, 15, 27, 39, 51 ns. After 50 ns: 51, 63, 75; the release is at 78.

Constraints and Contract

  • Keep the module name, its parameters and its ports.
  • Each case builds its own instance and measures it for 1,000 ns. The parameters always meet the rules of the comments.

Hints

Hint 1

Count edges, not nanoseconds: the release must follow CLK wherever power-good lands.

Hint 2

An event control on the clock edge, then a small delay, puts the release between two edges.

Hint 3

Two initial blocks for the two clocks keep them independent.

What the grader checks: Eight instances with different parameters, each measured for 1,000 ns. The bench reads the first edges and periods of both clocks, and when power-good and the reset pad rose. It also checks how often the reset rose, the strap, and whether every pad moved at an even time. It does not check what your module does after 1,000 ns.

8 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 2 problems on this path

Report a problem with this page

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

The soc_tb Board, Power-Good at 100 Ns

Input
REF_NS = 20, RTC_NS = 14, PG_NS = 100, HOLD = 4, BOOT = 0
Expected output
clk_first = 5, clk_period = 20, clk_high = 10, rtc_first = 7, rtc_period = 14, rtc_high = 7, reset_released_at = 168, power_good_at = 100, reset_rises = 1, reset_held_at_start = yes, strap_steady = yes, pads_at_even_times = yes

CLK rises at 5, 25, 45 ns. power_good rises at 100. The first four edges after it are 105, 125, 145 and 165, so rst_n rises at 168.

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

Icarus · browser samples / server checks