W4.13.1 Predict the Simstate

EasyDebugOpenPA + Icarus · serverReview the topic

A counter loses its count on one rail cut. Use the PMU sequence to reconstruct its state in six prediction rows.

Hardware context: A switched accumulator and a low-voltage sample buffer. Locate the event that first destroys stored data.

A counter loses its count on one rail cut. Use the PMU sequence to reconstruct its state in six prediction rows.

Record each named row with predict phase host tile acc count or its equivalent project attribute. Host means PD_TOP and tile means PD_CORE. Write NORMAL or CORRUPT for each domain. Write two hex digits for acc and one for beats. Use x for unknown digits.

Full specification
DecisionRequirement
before10After one reset edge with undriven pads in the 1.0 file, the uninitialized PMU has just selected RUN. Neither core register has captured reset yet.
before21Sample the same edge and the same registers in the 2.1 file. Use 2.1 for all remaining rows.
countedDrive VDD, VDD_LO and ground. Reset both domains. Add hexadecimal 0b to the accumulator on each of three enabled edges.
disconnectedKeep all pads driven. Sample after the PMU enters OFF and opens SW_CORE.
reset_againWake the PMU. Its core reset runs before the return to RUN. Keep writes disabled.
board_cutRemove both positive supplies after wake. Ground stays connected.

What the Grader Checks

OpenPA reads your file. A refusal ends the check with OpenPA's message and line. Otherwise every row below must pass.

RowRule
Board sequencepublic scenario: Run shows it
Board trial 1hidden scenario
Intent equals the referencethe domain of every instance; supply ports, nets and their connections; the primary supply of every domain; isolation cells (clamp, enable, sense, supply); where each isolation cell is placed; supply sets and switches; power states; level shifters; retained registers and their controls; switch names, acknowledge wires, supplies and delays

The Design

The power-unaware RTL your UPF describes (top pmu_soc). Open a file to read it.

pmu_soc.sv
// pmu_soc: two power domains. The top and the controller are always on; u_core can be switched off.
// The RTL is power-unaware: no isolation cell, no supply, no retention register is written here.
module pmu_soc (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       sleep_req,
  input  logic       wake_req,
  input  logic       en,
  input  logic [7:0] d,
  input  logic [1:0] rf_addr,
  input  logic       rf_we,
  output logic [7:0] total,
  output logic       led,
  output logic [7:0] rd,
  output logic [3:0] beats,
  output logic [7:0] status,
  output logic [2:0] pmu_state
);
  logic iso_en, save, restore, pwr_en, core_rst_n;
  logic [7:0] acc, rf_rd;
  logic busy;
  logic [3:0] core_beats;

  pmu u_pmu (
    .clk        (clk),
    .rst_n      (rst_n),
    .sleep_req  (sleep_req),
    .wake_req   (wake_req),
    .iso_en     (iso_en),
    .save       (save),
    .restore    (restore),
    .pwr_en     (pwr_en),
    .core_rst_n (core_rst_n),
    .state_o    (pmu_state)
  );

  core u_core (
    .clk     (clk),
    .rst_n   (core_rst_n),
    .en      (en),
    .d       (d),
    .rf_addr (rf_addr),
    .rf_we   (rf_we),
    .acc     (acc),
    .rf_rd   (rf_rd),
    .busy    (busy),
    .beats   (core_beats)
  );

  // Always-on consumers of the core's outputs.
  assign total = acc;
  assign led   = busy;
  assign rd    = rf_rd;
  assign beats = core_beats;
  // A status register: keeps the last accumulator value seen while the core was busy.
  always_ff @(posedge clk or negedge rst_n)
    if (!rst_n) status <= '0;
    else if (busy) status <= acc;
endmodule
pmu.sv
// pmu_soc: the always-on power controller. Power-unaware RTL: it only drives control signals.
// Sleep: isolate, save, switch off. Wake: switch on, reset, restore, release isolation.
module pmu (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       sleep_req,
  input  logic       wake_req,
  output logic       iso_en,
  output logic       save,
  output logic       restore,
  output logic       pwr_en,
  output logic       core_rst_n,
  output logic [2:0] state_o
);
  typedef enum logic [2:0] { RUN, ISOLATE, SAVE, OFF, PWRUP, RESET, RESTORE, RELEASE } st_e;
  st_e st;
  always_ff @(posedge clk or negedge rst_n)
    if (!rst_n) st <= RUN;
    else case (st)
      RUN:     if (sleep_req) st <= ISOLATE;
      ISOLATE: st <= SAVE;
      SAVE:    st <= OFF;
      OFF:     if (wake_req) st <= PWRUP;
      PWRUP:   st <= RESET;
      RESET:   st <= RESTORE;
      RESTORE: st <= RELEASE;
      RELEASE: st <= RUN;
      default: st <= RUN;
    endcase
  assign iso_en     = (st != RUN);
  assign save       = (st == SAVE);
  assign restore    = (st == RESTORE);
  assign pwr_en     = !(st == OFF);
  assign core_rst_n = rst_n && (st != RESET);
  assign state_o    = st;
endmodule
core.sv
// pmu_soc: the switchable core. An accumulator, a beat counter and a 4-word register file.
// Power-unaware RTL: nothing here knows about supplies.
module core (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       en,
  input  logic [7:0] d,
  input  logic [1:0] rf_addr,
  input  logic       rf_we,
  output logic [7:0] acc,
  output logic [7:0] rf_rd,
  output logic       busy,
  output logic [3:0] beats
);
  logic [7:0] rf [0:3];
  always_ff @(posedge clk or negedge rst_n)
    if (!rst_n) begin
      acc   <= '0;
      beats <= '0;
    end else if (en) begin
      acc   <= acc + d;
      beats <= beats + 4'd1;
    end
  always_ff @(posedge clk)
    if (rf_we) rf[rf_addr] <= acc;
  assign rf_rd = rf[rf_addr];
  assign busy  = en;
endmodule

Given UPF Files

Your file may load these with load_upf. The grader uses the same text.

board.upf
upf_version 2.1
# pmu_soc power intent, UPF 1.0 style (Accellera UPF tutorial, slides 33-45).
# The always-on top runs at 1.0 V. The core runs at 0.8 V from VDD_LO through a power switch.

create_power_domain PD_TOP -include_scope
create_power_domain PD_CORE -elements {u_core}

# Supply ports, driven by the bench with supply_on()/supply_off()
create_supply_port VDD    -direction in
create_supply_port VDD_LO -direction in
create_supply_port VSS    -direction in

create_supply_net VDD_N  -domain PD_TOP
create_supply_net VDDL_N -domain PD_TOP
create_supply_net VSS_N  -domain PD_TOP
connect_supply_net VDD_N  -ports {VDD}
connect_supply_net VDDL_N -ports {VDD_LO}
connect_supply_net VSS_N  -ports {VSS}
set_domain_supply_net PD_TOP -primary_power_net VDD_N -primary_ground_net VSS_N

# The core's switched supply
create_supply_net VSS_N -reuse -domain PD_CORE
create_supply_net VDD_CORE -domain PD_CORE
create_power_switch SW_CORE \
    -domain PD_CORE \
    -input_supply_port  {vin VDDL_N} \
    -output_supply_port {vout VDD_CORE} \
    -control_port       {ctrl u_pmu/pwr_en} \
    -on_state           {on vin {ctrl}} \
    -off_state          {off {!ctrl}}
set_domain_supply_net PD_CORE -primary_power_net VDD_CORE -primary_ground_net VSS_N

proc predict {phase host tile acc count} {
  set_design_attributes -elements {u_core} -attribute [list $phase [list $host $tile $acc $count]]
}

The Public Scenario

Board sequence. Run checks its output and shows the expected lines and any failure.

tb.sv (public scenario)
`timescale 1ns/1ps
module tb;
 import UPF::*;
 logic clk=0,rst_n=0,sleep_req=0,wake_req=0,en=0,rf_we=0;
 logic [7:0] d=0; logic [1:0] rf_addr=0;
 wire [7:0] total,rd,status; wire led; wire [3:0] beats; wire [2:0] pmu_state;
 pmu_soc dut(.*);
 task tick; #1 clk=1; #1 clk=0; #1; endtask
 task sample(input string phase);
   $display("%s pad=%0d switch=%0d top=%0d core=%0d acc=%h beats=%h",phase,
     get_supply_on_state(get_supply_value("VDD_LO")),get_supply_on_state(get_supply_value("VDD_CORE")),
     openpa_dom_PD_TOP_sim,openpa_dom_PD_CORE_sim,dut.u_core.acc,dut.u_core.beats);
 endtask
 initial begin
   #1ps; $display("initial pad=%0d host_pad=%0d",get_supply_on_state(get_supply_value("VDD_LO")),get_supply_on_state(get_supply_value("VDD")));
   tick; sample("observation");
   void'(supply_on("VDD")); void'(supply_on("VDD_LO",0.8)); void'(supply_on("VSS",0.0));
   #2; rst_n=1; #1; rst_n=0; tick; rst_n=1; en=1; d=8'h03; repeat(3) tick; en=0; sample("observation");
   sleep_req=1; tick; sleep_req=0; tick; tick; sample("observation");
   wake_req=1; tick; wake_req=0; repeat(4) tick; sample("observation");
   
   void'(supply_off("VDD")); void'(supply_off("VDD_LO")); #2; sample("observation"); $finish;
 end
endmodule

Examples

Example 1

Connected Supply Nets (Recorded)
Input
Load the supplied board file.
OpenPA reports (recorded)
Supply network
  VDD_N: port VDD  {port:VDD net:VDD_N fn:PD_TOP.primary.power}
  VDDL_N: port VDD_LO  {port:VDD_LO net:VDDL_N sw:SW_CORE/vin}
  VDD_CORE: switch SW_CORE  {net:VDD_CORE sw:SW_CORE/vout fn:PD_CORE.primary.power}

Follow each supply port to the net it drives.

Example 2

Domain Ownership (Recorded)
Input
Load the supplied board file.
OpenPA reports (recorded)
Power domains
  PD_TOP (board.upf:5): pmu_soc, u_pmu
    primary supply PD_TOP.primary: power VDD_N, ground VSS_N
  PD_CORE (board.upf:6): u_core
    primary supply PD_CORE.primary: power VDD_CORE, ground VSS_N  [switchable]

The two domains separate the peripheral from its powered host.

Example 3

Board Sequence (Recorded)
Input
Apply the public bench stimulus.
The bench prints (recorded)
initial pad=0 host_pad=0
observation pad=0 switch=0 top=5 core=5 acc=xx beats=x
observation pad=1 switch=1 top=0 core=0 acc=09 beats=3
observation pad=1 switch=0 top=0 core=5 acc=xx beats=x
observation pad=1 switch=1 top=0 core=0 acc=00 beats=0
observation pad=0 switch=0 top=5 core=5 acc=xx beats=x

The calibration uses a different increment. Look for the first loss at the switched rail.

Constraints and Contract

  • Load board.upf and keep its domains and wiring intact.
  • Record each named row with predict phase host tile acc count or its equivalent project attribute. Host means PD_TOP and tile means PD_CORE. Write NORMAL or CORRUPT for each domain. Write two hex digits for acc and one for beats. Use x for unknown digits.

Hints

Hint 1

Start with the supplied wiring and the public stimulus.

Hint 2

After one reset edge with undriven pads in the 1.0 file, the uninitialized PMU has just selected RUN. Neither core register has captured reset yet.

Hint 3

Compare the first changed output with the timing of its supply and control.

What the grader checks: OpenPA models digital supply and register behavior. Icarus represents corruption with X.

Run checks the public scenario only and never accepts. Submit runs every row. OpenPA is our open power-aware tool: it reads the UPF, writes a power-aware copy of the RTL, and Icarus runs that copy.

See all 2 problems on this path
Your UPF file UPFSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs
Not run yet

Run checks the public scenario. Submit checks every row in the description.

OpenPA + Icarus · server