Simstates and Supply Defaults

The core counter reads X. Follow its supply, its clock and its last write to find out when it lost the count.

You Will Be Able To

  • Predict the first powered sample from an edition and a switch position.
  • Distinguish a supply value, a supply-set state and its simstate.
  • Find the first corrupt event by comparing a register with a combinational output.
  • Choose an instance behavior and describe a library handoff.
Lesson
W4.13
Time
35 min
Runs on
Your browser
Check
6 questions
Follow Power from the Pad to the CountOne regulator stays on through sleep. The switch can still cut off its core.
  • Power
Follow Power From the Pad to the CountOne regulator stays on through sleep. The switch can still cut off its core. component VDD_LO regulator pad component SW_CORE controlled by pwr_en component PD_CORE acc and beats component PD_TOP PMU on VDD VDDL_Npwr_enVDD_CORE
  1. component VDD_LOregulator pad
    • VDDL_N → SW_CORE
  2. component SW_COREcontrolled by pwr_en
    • VDD_CORE → PD_CORE
  3. component PD_TOPPMU on VDD
    • pwr_en → SW_CORE
  4. component PD_COREacc and beats
  1. Read the pad

    The bench controls VDD_LO. Changing the edition changes its starting condition.

  2. Follow the switch

    In RUN, the PMU closes SW_CORE. The core now depends on both the pad and the control.

  3. Park the core

    The PMU opens SW_CORE while VDD_LO stays on. Read the register beyond the switch.

Read the diagram as text
  • VDD_LO: regulator pad
  • SW_CORE: controlled by pwr_en
  • PD_CORE: acc and beats
  • PD_TOP: PMU on VDD
  • VDD_LO → SW_CORE: VDDL_N
  • PD_TOP → SW_CORE: pwr_en
  • SW_CORE → PD_CORE: VDD_CORE

Drawn supply path for pmu_soc. The samples below come from the power-aware copy.

Recorded PMU sequence.
working pad=1 switch=1 top=0 core=0 acc=16 beats=1
parked pad=1 switch=0 top=0 core=5 acc=xx beats=x

When pmu_soc parks, both registers lose their values even though the input of SW_CORE stays powered.

Here 0 means NORMAL and 5 means CORRUPT. The last two columns show what happened to the accumulator and counter.

Start with the Undriven Pads

Before you drive VDD, can the PMU already close SW_CORE? Compare the headers at one picosecond.

Before

upf_version 1.0

OpenPA selects its legacy pad defaults.

After

upf_version 2.1

OpenPA starts these pads off.

Recorded sampleOpenPA with 1.0 intentOpenPA with 2.1 intent
initialpad=1 host_pad=1pad=0 host_pad=0
undrivenpad=1 switch=1 top=0 core=0 acc=xx beats=xpad=0 switch=0 top=5 core=5 acc=xx beats=x

In initial, pad reads 1 with the 1.0 file and 0 with the 2.1 file.

The legacy pad starts connected to its external supply (UPF 1.0, 5.1.3). IEEE 1801-2024 starts supply ports and nets OFF (9.2.1).

OpenPA 0.3.0 uses the header to select these defaults. Clause 6.61 leaves interpretation of older headers to the tool.

After the reset edge, the legacy core already reads mode 0. SW_CORE closed after that edge, too late for the core to capture reset.

Now drive the pads and reset both domains.

Drive the Supply and Follow the Switch

To recover a known count, power both sides of pmu_soc before pulsing reset again.

Bench calls before the explicit reset.
void'(supply_on("VDD"));
void'(supply_on("VDD_LO",0.8));
void'(supply_on("VSS",0.0));

supply_on takes a supply name. Its voltage defaults to 1.0 V (11.2.3.3, 11.2.4).

Ground needs a connected supply at zero volts. Turning that supply off would describe a different circuit.

Recorded core sequence.
working pad=1 switch=1 top=0 core=0 acc=16 beats=1
parked pad=1 switch=0 top=0 core=5 acc=xx beats=x
restarted pad=1 switch=1 top=0 core=0 acc=00 beats=0
removed pad=0 switch=0 top=0 core=5 acc=xx beats=x

In parked, pad stays 1 while switch falls to 0 and acc becomes xx.

The top stays NORMAL because opening SW_CORE leaves VDD alone. The core takes its primary power from the switched output.

At restarted, acc reads 00 because the wake sequence reset it. Removing VDD_LO then cuts the core even with the switch closed.

Compare the Completed pmu_soc File
Recorded eventRails and switch aloneWith the completed power intent
workingacc=16 beats=1acc=16 beats=1
parkedacc=xx beats=xacc=xx beats=x
restartedacc=00 beats=0acc=16 beats=0

At restarted, retention restores acc to 16. The unretained counter still returns to zero.

Recorded with the switch alone. D9 identifies the exposed receiver.
OPENPA-CHECK D9 @ 19000: u_core/acc of PD_CORE (off) is read by pmu_soc output total in PD_TOP (on) with no active isolation

D11 reports the voltage difference. The completed PMU adds shifters and isolation.

Next, keep the voltage and change the supply state.

Separate Partial Power from Voltage

VDD_LO can report 0.8 V while the regulator still cannot promise a working core.

Two distinct supply events in the runnable bench.
void'(supply_partial_on("VDD_LO",0.8));
// Sample after the network settles.
void'(supply_off("VDD_LO"));

supply_partial_on sets the state and voltage. supply_off sets OFF and leaves the voltage field unchanged (11.2.3.3). Neither call writes a reset value into acc.

Recorded sampleOpenPA with 1.0 intentOpenPA with 2.1 intent
partialpad=1 switch=1 top=0 core=0 acc=00 beats=0pad=0 switch=0 top=0 core=5 acc=xx beats=x
weak_railstate=3 millivolts=800state=2 millivolts=800
removedpad=0 switch=0 top=0 core=5 acc=xx beats=xpad=0 switch=0 top=0 core=5 acc=xx beats=x

The 2.1 weak_rail row reports 800 millivolts even though partial shows core=5.

pad in this bench is get_supply_on_state. To distinguish partial power from an open pad, inspect get_supply_state as well.

OpenPA reports legacy state bits under 1.0 and an enumeration in its later package. Compare the decoded state across editions.

ReadingQuestion answeredWhere to look
get_supply_valueWhat value reaches this named supply?Pass its result to the query functions.
get_supply_voltageWhat voltage accompanies that value?Read weak_rail in millivolts.
get_supply_stateWhich supply state does the regulator report?Use the edition’s representation.
get_supply_on_stateDoes this query treat the value as on?The two partial rows differ.
Package detailOpenPA reading of the 1.0 fileLater-edition bench
get_supply_value resultOpenPA uses upfSupplyTypeT internally.upfSupplyTypeT holds the state and voltage.
get_supply_state resultThe high bit marks partial power. The low bit marks on.upfSupplyStateE identifies the supply state.
Decoding weak_rail3 is binary 11. Both partial and on bits are set.2 denotes PARTIAL_ON in this package.
Meaning of modeThe top and core fields come from OpenPA instrumentation.These codes describe logic behavior, separately from the rail enum.

Here the default ON test needs FULL_ON power and ground (4.7.4). Clause 6.50 allows an explicit partial-state translation for state evaluation.

Now try a buffer whose power intent names the behavior at each voltage.

Attach a Simstate to a Supply State

The sample buffer u_slot has written hexadecimal 39. Its regulator can now lower VUNIT while the clock keeps running.

At 0.65 V, should a new write succeed or destroy the stored byte? Compare two runs at the same voltage.

Recorded Icarus samples with NORMAL on Coast.
entry mode=0 wr=0 valid=0 stored=39
new_word mode=0 wr=1 valid=1 stored=c6
Recorded Icarus samples with CORRUPT on Coast.
entry mode=5 wr=0 valid=x stored=xx
new_word mode=5 wr=1 valid=x stored=xx

At entry, NORMAL keeps stored=39 while CORRUPT immediately shows stored=xx.

A simstate tells the simulator how the logic behaves while its supply state is active (6.5, 9.5).

Before

create_supply_set UNIT -function {power UNIT_N} -function {ground GND_N}

UNIT already has its full-voltage state, Write. Use -update to add Coast at 0.65 V (5.10).

After

add_power_state UNIT -supply -update -state {Coast -supply_expr {power == {FULL_ON 0.65}} -simstate CORRUPT_ON_CHANGE}

Coast now covers 0.65 V.

Coast belongs to UNIT. The association to PD_UNIT.primary brings those semantics to the sample buffer.

The buffer has one clocked byte and one combinational output.
always_ff @(posedge clk) if (wr) stored <= data;
assign valid = wr;
Event on u_slotWhat changes at that instantWhat to inspect
entryOnly VUNIT changesDid 39 survive entry?
idle_edgeclk rises with wr lowCan clock activity alone destroy 39?
data_edgewr rises between edgesCan valid change independently?
same_wordA write presents the old byteDoes a write require a different value?
new_wordThe next edge writes the complementWhich object loses its known value first?

The NORMAL run later writes c6, the complement of 39. CORRUPT loses both the stored byte and the driven valid output.

Between those endpoints the first damaging event matters. Keep the same waveform and change only the simstate.

Find the First Damaging Event

When u_slot coasts, an idle clock, a changing input and a changing stored bit give three different tests.

Read each recorded row from left to right.

Simstate (recorded)After an idle clock edgeAfter wr rises
NORMALvalid=0 stored=39valid=1 stored=39
CORRUPT_STATE_ON_CHANGEvalid=0 stored=39valid=1 stored=39
CORRUPT_STATE_ON_ACTIVITYvalid=0 stored=xxvalid=1 stored=xx
CORRUPT_ON_CHANGEvalid=0 stored=39valid=x stored=39
CORRUPT_ON_ACTIVITYvalid=x stored=xxvalid=x stored=xx
NOT_NORMALvalid=x stored=xxvalid=x stored=xx
CORRUPTvalid=x stored=xxvalid=x stored=xx
Read One Rung Without Looking at the Mode Code
Suppose the first difference is hereWhich observation resolves it?Candidate on this buffer
Before any input movesLook for both outputs already unknown at entry.CORRUPT or its NOT_NORMAL placeholder
At the first idle clock edgeBoth valid and stored become unknown together.CORRUPT_ON_ACTIVITY
At the first idle clock edgeThe byte is lost but valid still follows wr.CORRUPT_STATE_ON_ACTIVITY
When wr rises between clock edgesOnly the changing output valid becomes unknown.CORRUPT_ON_CHANGE
When a write changes the stored bitsA repeated write kept 39 and valid kept following wr.CORRUPT_STATE_ON_CHANGE
After every probe still passesThe changing write produced the complement and valid followed wr.NORMAL in this sweep

At idle_edge, CORRUPT_STATE_ON_ACTIVITY loses 39 while CORRUPT_STATE_ON_CHANGE keeps it.

Clause 9.5.7 ties corruption to activity inside the state element. OpenPA 0.3.0 uses its active clock edge even when wr is low.

In CORRUPT_STATE_ON_CHANGE, repeating 39 preserves the byte. Only a write that changes stored corrupts it (9.5.6).

Recorded Icarus samples with CORRUPT_STATE_ON_CHANGE on Coast.
data_edge mode=1 wr=1 valid=1 stored=39
same_word mode=1 wr=1 valid=1 stored=39
new_word mode=1 wr=1 valid=1 stored=xx

Now watch valid when wr rises. CORRUPT_ON_CHANGE corrupts a changing element output (9.5.5).

Recorded Icarus samples with CORRUPT_ON_CHANGE on Coast.
idle_edge mode=3 wr=0 valid=0 stored=39
data_edge mode=3 wr=1 valid=x stored=39
new_word mode=3 wr=1 valid=x stored=xx
back mode=0 wr=1 valid=1 stored=xx
rewritten mode=0 wr=1 valid=1 stored=c6

At data_edge, valid becomes x while stored stays 39. At new_word, stored also changes and becomes xx.

In 9.5.4, an input event corrupts the affected element’s state and driven nets. OpenPA watches the domain root’s inputs.

Recorded Icarus samples with CORRUPT_ON_ACTIVITY on Coast.
entry mode=4 wr=0 valid=0 stored=39
idle_edge mode=4 wr=0 valid=x stored=xx

OpenPA watches registers and boundary outputs for CORRUPT_ON_CHANGE. Here those are stored and valid.

If the library team has yet to choose a rung, you can still describe the mode conservatively.

Reserve a Nonoperational State

The library team knows u_slot cannot operate normally at one setting. It has yet to characterize which switching events are safe.

Watch what happens to the saved byte when the regulator enters that setting.

Recorded Icarus samples with NOT_NORMAL on Coast.
entry mode=5 wr=0 valid=x stored=xx
idle_edge mode=5 wr=0 valid=x stored=xx
back mode=0 wr=1 valid=1 stored=xx
rewritten mode=0 wr=1 valid=1 stored=c6

At entry, stored is already xx because NOT_NORMAL uses CORRUPT by default (9.5.8).

In back, mode returns to 0 but stored remains xx until rewritten supplies c6.

Before

add_power_state UNIT -supply -update -state {Coast -supply_expr {power == {FULL_ON 0.65}} -simstate NOT_NORMAL}

Initial characterization.

After

add_power_state UNIT -supply -update -state {Coast -simstate CORRUPT_STATE_ON_CHANGE}

Refinement of Coast in the second run.

Recorded comparisonUpon entering CoastWriting the same byteWriting its complement
Before refinementxxxxxx
After refinement3939xx

After refinement, same_word keeps 39 and new_word loses it. The changing write now marks the first unsafe event.

Clause 6.5.6 allows a more specific nonnormal simstate here. Changing a declared NOT_NORMAL to NORMAL would contradict the earlier commitment.

What if the model already implements its own response to weak power? Then choose how the simulator treats that instance.

Choose Behavior for One Instance

Suppose u_slot models corruption internally. Adding ordinary simulator corruption could hide the behavior you intended to inspect.

Recorded Icarus samples with CORRUPT on Coast.
new_word mode=5 wr=1 valid=x stored=xx

At new_word, ordinary corruption leaves stored=xx. Disable it on u_slot to see what the RTL itself writes (6.56).

Before

# Default simulation behavior for this ordinary RTL instance.

Coast can corrupt the slot and its output.

After

set_simstate_behavior DISABLE -elements {u_slot}

The instance keeps evaluating its own RTL.

Recorded with DISABLE on u_slot.
entry mode=5 wr=0 valid=0 stored=39
idle_edge mode=5 wr=0 valid=0 stored=39
new_word mode=5 wr=1 valid=1 stored=c6

With DISABLE, new_word shows mode=5 and stored=c6 because u_slot still executes its write.

BehaviorSimstate semanticsHard-macro port corruption
ENABLEEnabledEnabled where applicable
SIMSTATE_ONLYEnabledDisabled
PORT_CORR_ONLYDisabledEnabled; requires a hard macro
DISABLEDisabledDisabled

OpenPA runs the instance form here. Sharing the same policy across library models needs a different command.

Hand the Policy to a Library

A second chip calls its tile u_cache. The path u_slot from buffer_soc no longer picks that instance.

Put the tile policy in slot_behavior.upf so both chips can use it. Apply it to buffer_cells with load_simstate_behavior (6.34).

Before

set_simstate_behavior SIMSTATE_ONLY -models {tile}

Drawn contents of slot_behavior.upf.

After

load_simstate_behavior buffer_cells -file {slot_behavior.upf}

Drawn library handoff. The surrounding file names the library.

Recorded OpenPA refusal for a library load.
contract.upf:1: load_simstate_behavior is not supported (IEEE 1801-2024 6.34): it sets simstate behaviour for library models, and OpenPA reads no library

The refusal names load_simstate_behavior because OpenPA has no model library to load.

Only set_simstate_behavior belongs in slot_behavior.upf. Omit -lib there because the load supplies buffer_cells. That library must contain tile.

In Choose the Simstate, run the instance policy and draw the handoff for a library delivery.

Try It

Run the 2.1 file. Locate the first sample where the top and core disagree.

Change the addend and rerun. Which fields depend on the arithmetic, and which depend only on the supplies?

In the quiz, run the 1.0 copy with the same bench. Then run the voltage sweep to try every rung.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: OPENPA-INFO corruption=x seed=1 initial pad=0 host_pad=0 undriven pad=0 switch=0 top=5 core=5 acc=xx beats=x OPENPA-CHECK D10 @ 3000: power switch SW_CORE is undetermined: a control is X, or no state (or more than one) holds (pmu_soc.upf:24) OPENPA-CHECK D11 @ 6000: PD_CORE (800000 uV) drives PD_TOP (1000000 uV) on 6 port(s) with no level shifter for this direction OPENPA-CHECK D11 @ 6000: PD_TOP (1000000 uV) drives PD_CORE (800000 uV) on 6 port(s) with no level shifter for this direction working pad=1 switch=1 top=0 core=0 acc=16 beats=1 OPENPA-CHECK D9 @ 19000: u_core/acc of PD_CORE (off) is read by logic in pmu_soc in PD_TOP (on) with no active isolation OPENPA-CHECK D9 @ 19000: u_core/acc of PD_CORE (off) is read by pmu_soc output total in PD_TOP (on) with no active isolation OPENPA-CHECK D9 @ 19000: u_core/beats of PD_CORE (off) is read by pmu_soc output beats in PD_TOP (on) with no active isolation OPENPA-CHECK D9 @ 19000: u_core/busy of PD_CORE (off) is read by logic in pmu_soc in PD_TOP (on) with no active isolation OPENPA-CHECK D9 @ 19000: u_core/busy of PD_CORE (off) is read by pmu_soc output led in PD_TOP (on) with no active isolation OPENPA-CHECK D9 @ 19000: u_core/rf_rd of PD_CORE (off) is read by pmu_soc output rd in PD_TOP (on) with no active isolation parked pad=1 switch=0 top=0 core=5 acc=xx beats=x OPENPA-CHECK D11 @ 22000: PD_CORE (800000 uV) drives PD_TOP (1000000 uV) on 6 port(s) with no level shifter for this direction OPENPA-CHECK D11 @ 22000: PD_TOP (1000000 uV) drives PD_CORE (800000 uV) on 6 port(s) with no level shifter for this direction restarted pad=1 switch=1 top=0 core=0 acc=00 beats=0 OPENPA-CHECK D9 @ 36000: u_core/acc of PD_CORE (off) is read by logic in pmu_soc in PD_TOP (on) with no active isolation OPENPA-CHECK D9 @ 36000: u_core/acc of PD_CORE (off) is read by pmu_soc output total in PD_TOP (on) with no active isolation OPENPA-CHECK D9 @ 36000: u_core/beats of PD_CORE (off) is read by pmu_soc output beats in PD_TOP (on) with no active isolation OPENPA-CHECK D9 @ 36000: u_core/busy of PD_CORE (off) is read by logic in pmu_soc in PD_TOP (on) with no active isolation OPENPA-CHECK D9 @ 36000: u_core/busy of PD_CORE (off) is read by pmu_soc output led in PD_TOP (on) with no active isolation OPENPA-CHECK D9 @ 36000: u_core/rf_rd of PD_CORE (off) is read by pmu_soc output rd in PD_TOP (on) with no active isolation partial pad=0 switch=0 top=0 core=5 acc=xx beats=x weak_rail state=2 millivolts=800 removed pad=0 switch=0 top=0 core=5 acc=xx beats=x OPENPA-SUMMARY D1=0 D2=0 D3=0 D4=0 D5=0 D6=0 D7=0 D8=0 D9=12 D10=1 D11=4 D12=0 D13=0 D14=0 OPENPA-COVER-SUMMARY states=0/0 declared_transitions=0/0 sequences=0/0
Read the power intent: pmu_soc.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

Read the power-unaware RTL: 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
Read the power-unaware RTL: 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
Read the power-unaware RTL: 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
What UPF added: 39 objects

3 supply port, 4 supply net, 10 output corruption, 1 power switch, 2 supply set, 4 register corruption, 1 memory corruption, 14 dynamic check.

ObjectWhereDetailRuleUPF line
Supply portVDDpmu_soc.upf:9
Supply portVDD_LOpmu_soc.upf:10
Supply portVSSpmu_soc.upf:11
Supply netVDD_Npmu_soc.upf:9
Supply netVDDL_Npmu_soc.upf:10
Supply netVSS_Npmu_soc.upf:11
Supply netVDD_COREpmu_soc.upf:24
Output corruptionu_core/accC2pmu_soc.upf:6
Output corruptionu_core/beatsC2pmu_soc.upf:6
Output corruptionu_core/busyC2pmu_soc.upf:6
Output corruptionu_core/rf_rdC2pmu_soc.upf:6
Output corruptionu_core/clkC2pmu_soc.upf:5
Output corruptionu_core/dC2pmu_soc.upf:5
Output corruptionu_core/enC2pmu_soc.upf:5
Output corruptionu_core/rf_addrC2pmu_soc.upf:5
Output corruptionu_core/rf_weC2pmu_soc.upf:5
Output corruptionu_core/rst_nC2pmu_soc.upf:5
Power switchSW_CORES3 (IEEE 1801-2024 6.23)pmu_soc.upf:24
Supply setPD_TOP.primarypmu_soc.upf:5
Supply setPD_CORE.primarypmu_soc.upf:6
Register corruptionstatusC1pmu_soc.upf:5
Register corruptionu_pmu.stC1pmu_soc.upf:5
Register corruptionu_core.accC1pmu_soc.upf:6
Register corruptionu_core.beatsC1pmu_soc.upf:6
Memory corruptionu_core.rfC1pmu_soc.upf:6
Dynamic checkD9 crossing 1D9pmu_soc.upf:6
Dynamic checkD9 crossing 2D9pmu_soc.upf:6
Dynamic checkD9 crossing 3D9pmu_soc.upf:6
Dynamic checkD9 crossing 4D9pmu_soc.upf:6
Dynamic checkD9 crossing 5D9pmu_soc.upf:6
Dynamic checkD9 crossing 6D9pmu_soc.upf:6
Dynamic checkD9 crossing 7D9pmu_soc.upf:5
Dynamic checkD9 crossing 8D9pmu_soc.upf:5
Dynamic checkD9 crossing 9D9pmu_soc.upf:5
Dynamic checkD9 crossing 10D9pmu_soc.upf:5
Dynamic checkD9 crossing 11D9pmu_soc.upf:5
Dynamic checkD9 crossing 12D9pmu_soc.upf:5
Dynamic checkD11 PD_CORE->PD_TOPD11pmu_soc.upf:6
Dynamic checkD11 PD_TOP->PD_CORED11pmu_soc.upf:5

OpenPA warnings:

  • pmu_soc.upf:6 no isolation on u_core/acc -> logic in pmu_soc: domain PD_CORE can be switched off and PD_TOP receives its output (check D9 watches this at run time)
  • pmu_soc.upf:6 no isolation on u_core/acc -> pmu_soc output total: domain PD_CORE can be switched off and PD_TOP receives its output (check D9 watches this at run time)
  • pmu_soc.upf:6 no isolation on u_core/beats -> pmu_soc output beats: domain PD_CORE can be switched off and PD_TOP receives its output (check D9 watches this at run time)
  • pmu_soc.upf:6 no isolation on u_core/busy -> logic in pmu_soc: domain PD_CORE can be switched off and PD_TOP receives its output (check D9 watches this at run time)
  • pmu_soc.upf:6 no isolation on u_core/busy -> pmu_soc output led: domain PD_CORE can be switched off and PD_TOP receives its output (check D9 watches this at run time)
  • pmu_soc.upf:6 no isolation on u_core/rf_rd -> pmu_soc output rd: domain PD_CORE can be switched off and PD_TOP receives its output (check D9 watches this at run time)
Read the power-aware copy that runs (generated by OpenPA 0.3.0): pa_pmu_soc.sv
// pa_pmu_soc.sv: power-aware copy of pmu_soc, generated by OpenPA from pmu_soc.upf.
// Do not edit: regenerate. Simulators: Icarus 12 (4-state, X corruption) or Verilator 5 with --timing (2-state).
// Build with -Wno-fatal on Verilator: forced registers raise MULTIDRIVEN warnings.
`timescale 1ns/1ps
// ---------------------------------------------------------------------------
// package UPF: generated by OpenPA. Supply types, supply_on/supply_off and the power
// state of the design. Names starting with openpa_ are internal.
// ---------------------------------------------------------------------------
package UPF;
  typedef string upfStringT; typedef int upfIntegerT; typedef bit upfBooleanT; typedef logic upfLogicT; typedef real upfRealT; typedef int upfHandleT;
  typedef enum { OFF, FULL_ON, PARTIAL_ON, UNDETERMINED } upfSupplyStateE;
  typedef struct packed { upfSupplyStateE state; int voltage; } upfSupplyTypeT;  // voltage in microvolts
  typedef upfSupplyTypeT supply_net_type;
  bit openpa_armed;        // set by the first call that drives a supply
  bit openpa_kick;         // pulsed once at time 0 to evaluate everything
  bit openpa_xmode;        // 1: corrupt to X; 0: seeded 2-state values
  int unsigned openpa_seed = 1;
  int openpa_cmode;        // 2-state corruption: 0 random, 1 all zero, 2 all one
  supply_net_type openpa_port_VDD;   // supply port VDD (pmu_soc.upf:9)
  supply_net_type openpa_port_VDD_LO;   // supply port VDD_LO (pmu_soc.upf:10)
  supply_net_type openpa_port_VSS;   // supply port VSS (pmu_soc.upf:11)
  supply_net_type openpa_net_VDD_N;   // supply net VDD_N
  supply_net_type openpa_net_VDDL_N;   // supply net VDDL_N
  supply_net_type openpa_net_VSS_N;   // supply net VSS_N
  supply_net_type openpa_net_VDD_CORE;   // supply net VDD_CORE
  int openpa_sw_SW_CORE_st = -1;   // switch SW_CORE: -1 undetermined, 0 off, k on-state k (pmu_soc.upf:24)
  bit openpa_ss_PD_TOP_primary_ok; int unsigned openpa_ss_PD_TOP_primary_ep; int openpa_ss_PD_TOP_primary_st = -1; bit openpa_ss_PD_TOP_primary_multi; int openpa_ss_PD_TOP_primary_sim = 5;   // supply set PD_TOP.primary
  bit openpa_ss_PD_CORE_primary_ok; int unsigned openpa_ss_PD_CORE_primary_ep; int openpa_ss_PD_CORE_primary_st = -1; bit openpa_ss_PD_CORE_primary_multi; int openpa_ss_PD_CORE_primary_sim = 5;   // supply set PD_CORE.primary
  bit openpa_dom_PD_TOP_ok; int unsigned openpa_dom_PD_TOP_ep; int openpa_dom_PD_TOP_sim = 5;   // power domain PD_TOP: ok = powered (simstate not CORRUPT); sim = simstate code (pmu_soc.upf:5)
  bit openpa_dom_PD_CORE_ok; int unsigned openpa_dom_PD_CORE_ep; int openpa_dom_PD_CORE_sim = 5;   // power domain PD_CORE: ok = powered (simstate not CORRUPT); sim = simstate code (pmu_soc.upf:6)
  // simstate codes, by IEEE 1801-2024 4.8 precedence: 0 NORMAL, 1 CORRUPT_STATE_ON_CHANGE, 2 CORRUPT_STATE_ON_ACTIVITY,
  // 3 CORRUPT_ON_CHANGE, 4 CORRUPT_ON_ACTIVITY, 5 CORRUPT (and NOT_NORMAL, 9.5.8); README "Simstates"
  logic openpa_ctl_0_u_pmu_pwr_en;   // copy of u_pmu.pwr_en (switch SW_CORE)
  function automatic logic [63:0] openpa_mix(int unsigned id, int unsigned ep, int unsigned lane);
    logic [63:0] z;
    if (openpa_cmode == 1) return 64'd0;
    if (openpa_cmode == 2) return ~64'd0;
    z = {32'd0, openpa_seed} * 64'h9E3779B97F4A7C15 + {32'd0, id} * 64'hC2B2AE3D27D4EB4F + {32'd0, ep} * 64'h165667B19E3779F9 + {32'd0, lane} * 64'hD6E8FEB86659FD93;
    z = (z ^ (z >> 30)) * 64'hBF58476D1CE4E5B9;
    z = (z ^ (z >> 27)) * 64'h94D049BB133111EB;
    return z ^ (z >> 31);
  endfunction
  function automatic bit openpa_bit(int unsigned id, int unsigned ep); logic [63:0] z; z = openpa_mix(id, ep, 0); return z[0]; endfunction
  function automatic int openpa_uv(real v); return $rtoi(v * 1.0e6 + (v < 0.0 ? -0.5 : 0.5)); endfunction
  // supply_on: FULL_ON at the given voltage (11.2.4; default 1.0 V)
  function automatic upfBooleanT supply_on(string pad_name, real value = 1.0);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = FULL_ON; openpa_port_VDD.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = FULL_ON; openpa_port_VDD_LO.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = FULL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_on(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // supply_off: OFF, voltage unchanged (9.3.1); a second argument is accepted and ignored
  function automatic upfBooleanT supply_off(string pad_name, real value = 0.0);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = OFF; return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = OFF; return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = OFF; return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_off(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // supply_partial_on: PARTIAL_ON at the given voltage (11.2.4)
  function automatic upfBooleanT supply_partial_on(string pad_name, real value = 1.0);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = PARTIAL_ON; openpa_port_VDD.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = PARTIAL_ON; openpa_port_VDD_LO.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = PARTIAL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_partial_on(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // set_supply_state: the state only, voltage unchanged (9.3.1)
  function automatic upfBooleanT set_supply_state(string pad_name, upfSupplyStateE supply_state);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = supply_state; return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = supply_state; return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = supply_state; return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR set_supply_state(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // set_power_state (9.3.1) is not supported: OpenPA has no deferred power states. A call is reported, never ignored.
  function automatic upfBooleanT set_power_state(string object_name, string power_state);
    $display("OPENPA-ERROR set_power_state(\"%s\", \"%s\"): not supported by OpenPA; drive the supplies with supply_on, supply_off or set_supply_state", object_name, power_state);
    return 0;
  endfunction
  // Supply queries (11.2.4). Names: supply ports, supply nets and supply set functions as the UPF wrote them.
  function automatic upfSupplyTypeT get_supply_value(string name);
    if (name == "VDD" || name == "VDD_N" || name == "PD_TOP.primary.power") return openpa_net_VDD_N;
    if (name == "VDD_LO" || name == "VDDL_N") return openpa_net_VDDL_N;
    if (name == "VSS" || name == "VSS_N" || name == "PD_TOP.primary.ground" || name == "PD_CORE.primary.ground") return openpa_net_VSS_N;
    if (name == "VDD_CORE" || name == "PD_CORE.primary.power") return openpa_net_VDD_CORE;
    $display("OPENPA-ERROR get_supply_value(\"%s\"): no supply net, port or supply set function of that name", name);
    return 0;
  endfunction
  function automatic upfRealT get_supply_voltage(upfSupplyTypeT arg); return arg.voltage / 1.0e6; endfunction
  // 11.2.4: 1 for FULL_ON; 0 otherwise.
  function automatic upfBooleanT get_supply_on_state(upfSupplyTypeT arg); return arg.state == FULL_ON; endfunction
  function automatic upfSupplyStateE get_supply_state(upfSupplyTypeT arg); return arg.state; endfunction
endpackage
// ---------------------------------------------------------------------------
// OpenPA cells (generated; do not edit)
// ---------------------------------------------------------------------------
// openpa_corrupt: rule C2. Passes d while the driving domain is NORMAL; otherwise drives X (4-state)
// or a seeded value (2-state). The value is computed ahead for the episode the next power-down starts
// (ep + 1 while ok), so at power-down the output goes straight from d to the new value: no delta glitch
// through the previous episode's value (Icarus would turn one into a clock edge).
module openpa_corrupt #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           ok,
  input  int unsigned  ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  always @(ep or ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
  assign q = ok ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

// openpa_corrupt_sim: rule C2 for a domain that has intermediate simstates (IEEE 1801-2024 9.5). As
// openpa_corrupt, and also corrupt while lhit is set (CORRUPT_ON_ACTIVITY after input activity), or after d
// changed while coc is set (CORRUPT_ON_CHANGE); leaving CORRUPT_ON_CHANGE clears that.
module openpa_corrupt_sim #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           ok,
  input  int unsigned  ep,
  input  bit           lhit,
  input  bit           coc
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  bit chg;
  always @(ep or ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
  // verilator lint_off MULTIDRIVEN
  for (genvar i = 0; i < W; i++) begin : g_chg
    always @(posedge d[i] or negedge d[i]) if (coc && ok) chg = 1'b1;
  end
  always @(negedge coc) chg = 1'b0;
  // verilator lint_on MULTIDRIVEN
  assign q = (ok && !lhit && !chg) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

// openpa_iso: rules I1-I4 (IEEE 1801-2024 9.8). CLAMP 0, 1, 2 (latch: the value the input had while the enable
// was inactive) or 3 (Z: high impedance on 4-state; 0 on 2-state backends, which cannot represent Z).
// sup_ok is 1 while the isolation supply is NORMAL (always, for a strategy with no supply); otherwise the output,
// and a latched value, are corrupt. An enable at X or Z corrupts the output and the latched value.
module openpa_iso #(parameter int W = 1, parameter int CLAMP = 0, parameter bit SENSE = 1'b1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  logic         en,
  input  bit           sup_ok,
  input  int unsigned  sup_ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  logic [W-1:0] held;
  always @(sup_ep or sup_ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h4000_0000, sup_ok ? sup_ep + 1 : sup_ep, i);
  wire active   = (en === SENSE);
  wire inactive = (en === !SENSE);
  wire [W-1:0] bad    = UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0];
  if (CLAMP == 2) begin : g_latch
    always @(d or en or sup_ok or bad) if (!sup_ok || !(active || inactive)) held = bad; else if (inactive) held = d;
  end
  wire [W-1:0] clampv = (CLAMP == 3) ? (UPF::openpa_xmode ? {W{1'bz}} : {W{1'b0}}) : (CLAMP == 2) ? held : (CLAMP == 1) ? {W{1'b1}} : {W{1'b0}};
  assign q = !sup_ok ? bad : active ? clampv : inactive ? d : bad;
endmodule

// openpa_ls: rule L1 (IEEE 1801-2024 9.9). Passes d while every supply set of the cell is NORMAL; otherwise corrupt.
module openpa_ls #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           src_ok,
  input  bit           dst_ok,
  input  int unsigned  ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  always @(ep or src_ok or dst_ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h8000_0000, (src_ok && dst_ok) ? ep + 1 : ep, i);
  assign q = (src_ok && dst_ok) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

`line 1 "pmu_soc.sv" 0
// 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)
  );

  wire [7:0] openpa_u_core_acc_raw; wire [3:0] openpa_u_core_beats_raw; wire [0:0] openpa_u_core_busy_raw; wire [7:0] openpa_u_core_rf_rd_raw; wire [0:0] openpa_u_core_clk_s1; wire [7:0] openpa_u_core_d_s1; wire [0:0] openpa_u_core_en_s1; wire [1:0] openpa_u_core_rf_addr_s1; wire [0:0] openpa_u_core_rf_we_s1; wire [0:0] openpa_u_core_rst_n_s1; core u_core (
    .clk     (openpa_u_core_clk_s1),
    .rst_n   (openpa_u_core_rst_n_s1),
    .en      (openpa_u_core_en_s1),
    .d       (openpa_u_core_d_s1),
    .rf_addr (openpa_u_core_rf_addr_s1),
    .rf_we   (openpa_u_core_rf_we_s1),
    .acc     (openpa_u_core_acc_raw),
    .rf_rd   (openpa_u_core_rf_rd_raw),
    .busy    (openpa_u_core_busy_raw),
    .beats   (openpa_u_core_beats_raw)
  ); openpa_corrupt #(.W(8), .ID(268435456)) openpa_u_core_acc_cor (.d(openpa_u_core_acc_raw), .q(acc), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_corrupt #(.W(4), .ID(268435464)) openpa_u_core_beats_cor (.d(openpa_u_core_beats_raw), .q(core_beats), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_corrupt #(.W(1), .ID(268435472)) openpa_u_core_busy_cor (.d(openpa_u_core_busy_raw), .q(busy), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_corrupt #(.W(8), .ID(268435480)) openpa_u_core_rf_rd_cor (.d(openpa_u_core_rf_rd_raw), .q(rf_rd), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_corrupt #(.W(1), .ID(268435488)) openpa_u_core_clk_cor (.d(clk), .q(openpa_u_core_clk_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(8), .ID(268435496)) openpa_u_core_d_cor (.d(d), .q(openpa_u_core_d_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435504)) openpa_u_core_en_cor (.d(en), .q(openpa_u_core_en_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(2), .ID(268435512)) openpa_u_core_rf_addr_cor (.d(rf_addr), .q(openpa_u_core_rf_addr_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435520)) openpa_u_core_rf_we_cor (.d(rf_we), .q(openpa_u_core_rf_we_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435528)) openpa_u_core_rst_n_cor (.d(core_rst_n), .q(openpa_u_core_rst_n_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep));

  // 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;

`line 1 "openpa_overlay.sv" 0
  // ===================================================================================
  // OpenPA overlay for pmu_soc: generated from pmu_soc.upf. Do not edit.
  // ===================================================================================
  // verilator lint_off MULTIDRIVEN
  // verilator lint_off ENUMVALUE
  // verilator lint_off WIDTHTRUNC
  // verilator lint_off WIDTHEXPAND
  // verilator lint_off BLKSEQ
  // verilator lint_off IGNOREDRETURN
  import UPF::openpa_cmode;
  import UPF::openpa_ctl_0_u_pmu_pwr_en;
  import UPF::openpa_dom_PD_CORE_ep;
  import UPF::openpa_dom_PD_CORE_ok;
  import UPF::openpa_dom_PD_CORE_sim;
  import UPF::openpa_dom_PD_TOP_ep;
  import UPF::openpa_dom_PD_TOP_ok;
  import UPF::openpa_dom_PD_TOP_sim;
  import UPF::openpa_kick;
  import UPF::openpa_net_VDDL_N;
  import UPF::openpa_net_VDD_CORE;
  import UPF::openpa_net_VDD_N;
  import UPF::openpa_net_VSS_N;
  import UPF::openpa_seed;
  import UPF::openpa_ss_PD_CORE_primary_ep;
  import UPF::openpa_ss_PD_CORE_primary_multi;
  import UPF::openpa_ss_PD_CORE_primary_ok;
  import UPF::openpa_ss_PD_CORE_primary_sim;
  import UPF::openpa_ss_PD_CORE_primary_st;
  import UPF::openpa_ss_PD_TOP_primary_ep;
  import UPF::openpa_ss_PD_TOP_primary_multi;
  import UPF::openpa_ss_PD_TOP_primary_ok;
  import UPF::openpa_ss_PD_TOP_primary_sim;
  import UPF::openpa_ss_PD_TOP_primary_st;
  import UPF::openpa_sw_SW_CORE_st;
  import UPF::openpa_xmode;
  // ---- mode, seed, trace
  bit openpa_tr, openpa_obs;
  int openpa_n [1:14];
  int openpa_seq [1:1];   // good-form sequence bins (coverage)
  bit openpa_sreq; bit openpa_sp [1:16];   // deferred checks: request and pending flags
  string openpa_mode_arg;
  initial begin
  `ifdef VERILATOR
    openpa_xmode = 1'b0;
  `else
    openpa_xmode = 1'b1;
  `endif
    openpa_cmode = 0;
    if ($value$plusargs("openpa_corrupt=%s", openpa_mode_arg)) begin
      if (openpa_mode_arg == "x") openpa_xmode = 1'b1;
      else if (openpa_mode_arg == "random") openpa_xmode = 1'b0;
      else if (openpa_mode_arg == "zero") begin openpa_xmode = 1'b0; openpa_cmode = 1; end
      else if (openpa_mode_arg == "one") begin openpa_xmode = 1'b0; openpa_cmode = 2; end
      else $display("OPENPA-ERROR +openpa_corrupt=%s: use x, random, zero or one", openpa_mode_arg);
    end
    if (!$value$plusargs("openpa_seed=%d", openpa_seed)) openpa_seed = 1;
    openpa_tr = $test$plusargs("openpa_trace");
    openpa_obs = $test$plusargs("openpa_obs");
    $display("OPENPA-INFO corruption=%0s seed=%0d", openpa_xmode ? "x" : (openpa_cmode == 1 ? "zero" : openpa_cmode == 2 ? "one" : "random"), openpa_seed);
    #0 openpa_kick = 1'b1;
  end
  task automatic openpa_check(input int id, input string msg);
    openpa_n[id] = openpa_n[id] + 1;
    $display("OPENPA-CHECK D%0d @ %0t: %s", id, $time, msg);
  endtask
  task automatic openpa_t(input string msg);
    if (openpa_tr) $display("OPENPA-TRACE @ %0t: %s", $time, msg);
  endtask

  // ---- copies of the design signals the UPF names (4-state, so X is visible)
  always @(u_pmu.pwr_en or openpa_kick) openpa_ctl_0_u_pmu_pwr_en = u_pmu.pwr_en;

  // ---- supply network, switches, supply sets, simstates, power states (one block, evaluated in order)
  bit openpa_tg_sw_SW_CORE_st; int openpa_pv_sw_SW_CORE_st = -2;
  UPF::supply_net_type openpa_swv_SW_CORE_f, openpa_swv_SW_CORE_p; bit openpa_swv_SW_CORE_u, openpa_swv_SW_CORE_hf, openpa_swv_SW_CORE_hp, openpa_swv_SW_CORE_vd, openpa_swv_SW_CORE_on, openpa_swv_SW_CORE_pt; int openpa_swv_SW_CORE_k;   // switch SW_CORE
  always @(openpa_kick or UPF::openpa_port_VDD or UPF::openpa_port_VDD_LO or UPF::openpa_port_VSS or UPF::openpa_ctl_0_u_pmu_pwr_en) begin : openpa_network
    openpa_net_VDD_N = UPF::openpa_port_VDD;   // VDD_N <- port VDD
    openpa_net_VDDL_N = UPF::openpa_port_VDD_LO;   // VDDL_N <- port VDD_LO
    openpa_net_VSS_N = UPF::openpa_port_VSS;   // VSS_N <- port VSS
    // switch SW_CORE (pmu_soc.upf:24): IEEE 1801-2024 6.23
    openpa_swv_SW_CORE_u = 1'b0; openpa_swv_SW_CORE_hf = 1'b0; openpa_swv_SW_CORE_hp = 1'b0; openpa_swv_SW_CORE_vd = 1'b0; openpa_swv_SW_CORE_on = 1'b0; openpa_swv_SW_CORE_pt = 1'b0; openpa_swv_SW_CORE_k = 0;
    if (($isunknown(openpa_ctl_0_u_pmu_pwr_en)) && UPF::openpa_net_VDDL_N.state != UPF::OFF) openpa_swv_SW_CORE_u = 1'b1;   // on state on: a control is X or Z
    else if ((openpa_ctl_0_u_pmu_pwr_en === 1'b1)) begin
      if (!openpa_swv_SW_CORE_on) openpa_swv_SW_CORE_k = 1;
      openpa_swv_SW_CORE_on = 1'b1;
      if (UPF::openpa_net_VDDL_N.state == UPF::UNDETERMINED) openpa_swv_SW_CORE_u = 1'b1;
      else if (UPF::openpa_net_VDDL_N.state == UPF::FULL_ON) begin
        if ((openpa_swv_SW_CORE_hf && openpa_swv_SW_CORE_f.voltage != UPF::openpa_net_VDDL_N.voltage) || (openpa_swv_SW_CORE_hp && openpa_swv_SW_CORE_p.voltage != UPF::openpa_net_VDDL_N.voltage)) openpa_swv_SW_CORE_vd = 1'b1;
        openpa_swv_SW_CORE_f = UPF::openpa_net_VDDL_N; openpa_swv_SW_CORE_hf = 1'b1;
      end
      else if (UPF::openpa_net_VDDL_N.state == UPF::PARTIAL_ON) begin
        if ((openpa_swv_SW_CORE_hf && openpa_swv_SW_CORE_f.voltage != UPF::openpa_net_VDDL_N.voltage) || (openpa_swv_SW_CORE_hp && openpa_swv_SW_CORE_p.voltage != UPF::openpa_net_VDDL_N.voltage)) openpa_swv_SW_CORE_vd = 1'b1;
        openpa_swv_SW_CORE_p = UPF::openpa_net_VDDL_N; openpa_swv_SW_CORE_hp = 1'b1;
      end
    end
    if ((1'b0) || (((!((openpa_ctl_0_u_pmu_pwr_en === 1'b1)))) && (openpa_swv_SW_CORE_on || openpa_swv_SW_CORE_pt)) || openpa_swv_SW_CORE_u || openpa_swv_SW_CORE_vd || (!($isunknown(openpa_ctl_0_u_pmu_pwr_en)) && !openpa_swv_SW_CORE_on && !openpa_swv_SW_CORE_pt && !((!((openpa_ctl_0_u_pmu_pwr_en === 1'b1)))) && !(1'b0))) begin openpa_sw_SW_CORE_st = -1; openpa_net_VDD_CORE.state = UPF::UNDETERMINED; openpa_net_VDD_CORE.voltage = 0; end
    else begin openpa_sw_SW_CORE_st = openpa_swv_SW_CORE_k; if (openpa_swv_SW_CORE_hf) openpa_net_VDD_CORE = openpa_swv_SW_CORE_f; else if (openpa_swv_SW_CORE_hp) openpa_net_VDD_CORE = openpa_swv_SW_CORE_p; else begin openpa_net_VDD_CORE.state = UPF::OFF; openpa_net_VDD_CORE.voltage = 0; end end
    // supply set PD_TOP.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_PD_TOP_primary
      bit nx; int sm;
      sm = (UPF::openpa_net_VDD_N.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_PD_TOP_primary_sim = sm;
      nx = sm < 5;
      if (openpa_ss_PD_TOP_primary_ok && !nx) openpa_ss_PD_TOP_primary_ep = openpa_ss_PD_TOP_primary_ep + 1;
      openpa_ss_PD_TOP_primary_ok = nx;
    end
    // supply set PD_CORE.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_PD_CORE_primary
      bit nx; int sm;
      sm = (UPF::openpa_net_VDD_CORE.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_PD_CORE_primary_sim = sm;
      nx = sm < 5;
      if (openpa_ss_PD_CORE_primary_ok && !nx) openpa_ss_PD_CORE_primary_ep = openpa_ss_PD_CORE_primary_ep + 1;
      openpa_ss_PD_CORE_primary_ok = nx;
    end
    // domain PD_TOP: simstate of its primary supply set PD_TOP.primary
    if (openpa_dom_PD_TOP_ok && !UPF::openpa_ss_PD_TOP_primary_ok) openpa_dom_PD_TOP_ep = openpa_dom_PD_TOP_ep + 1;
    openpa_dom_PD_TOP_ok = UPF::openpa_ss_PD_TOP_primary_ok;
    openpa_dom_PD_TOP_sim = openpa_ss_PD_TOP_primary_sim;
    // domain PD_CORE: simstate of its primary supply set PD_CORE.primary
    if (openpa_dom_PD_CORE_ok && !UPF::openpa_ss_PD_CORE_primary_ok) openpa_dom_PD_CORE_ep = openpa_dom_PD_CORE_ep + 1;
    openpa_dom_PD_CORE_ok = UPF::openpa_ss_PD_CORE_primary_ok;
    openpa_dom_PD_CORE_sim = openpa_ss_PD_CORE_primary_sim;
    if (openpa_sw_SW_CORE_st != openpa_pv_sw_SW_CORE_st) begin openpa_tg_sw_SW_CORE_st = ~openpa_tg_sw_SW_CORE_st; openpa_pv_sw_SW_CORE_st = openpa_sw_SW_CORE_st; end
  end

  // ---- corruption: registers forced, memories overwritten (rules C1, C3)
  // domain PD_TOP (pmu_soc.upf:5): 2 register(s), 0 memory(ies)
  bit openpa_PD_TOP_applied, openpa_PD_TOP_valid;
  logic [7:0] openpa_cv1;   // corruption value for status
  logic [2:0] openpa_cv2;   // corruption value for u_pmu.st
  // The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
  // supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
  always @(UPF::openpa_dom_PD_TOP_ok or openpa_kick) if (!openpa_PD_TOP_valid || openpa_PD_TOP_applied != UPF::openpa_dom_PD_TOP_ok) begin
    openpa_t({"PD_TOP ", UPF::openpa_dom_PD_TOP_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_PD_TOP_ok || !openpa_PD_TOP_valid) begin
      if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_PD_TOP_ep, 0);
      force status = openpa_cv1;
      if (openpa_xmode) openpa_cv2 = 'x; else openpa_cv2 = UPF::openpa_mix(2, UPF::openpa_dom_PD_TOP_ep, 0);
      force u_pmu.st = openpa_cv2;
    end
    if (UPF::openpa_dom_PD_TOP_ok) begin
      release status;
      release u_pmu.st;
    end
    openpa_PD_TOP_valid = 1'b1; openpa_PD_TOP_applied = UPF::openpa_dom_PD_TOP_ok;
  end
  // domain PD_CORE (pmu_soc.upf:6): 2 register(s), 1 memory(ies)
  bit openpa_PD_CORE_applied, openpa_PD_CORE_valid;
  logic [7:0] openpa_cv3;   // corruption value for u_core.acc
  logic [3:0] openpa_cv4;   // corruption value for u_core.beats
  // The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
  // supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
  always @(UPF::openpa_dom_PD_CORE_ok or openpa_kick) if (!openpa_PD_CORE_valid || openpa_PD_CORE_applied != UPF::openpa_dom_PD_CORE_ok) begin
    openpa_t({"PD_CORE ", UPF::openpa_dom_PD_CORE_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_PD_CORE_ok || !openpa_PD_CORE_valid) begin
      if (openpa_xmode) openpa_cv3 = 'x; else openpa_cv3 = UPF::openpa_mix(3, UPF::openpa_dom_PD_CORE_ep, 0);
      force u_core.acc = openpa_cv3;
      if (openpa_xmode) openpa_cv4 = 'x; else openpa_cv4 = UPF::openpa_mix(4, UPF::openpa_dom_PD_CORE_ep, 0);
      force u_core.beats = openpa_cv4;
      for (int i = 0; i < 4; i++) u_core.rf[0 + i] = openpa_xmode ? 8'bx : UPF::openpa_mix(100000, UPF::openpa_dom_PD_CORE_ep, (i) * 1 + 0);
    end
    if (UPF::openpa_dom_PD_CORE_ok) begin
      for (int i = 0; i < 4; i++) u_core.rf[0 + i] = openpa_xmode ? 8'bx : UPF::openpa_mix(100000, UPF::openpa_dom_PD_CORE_ep, (i) * 1 + 0);
      release u_core.acc;
      release u_core.beats;
    end
    openpa_PD_CORE_valid = 1'b1; openpa_PD_CORE_applied = UPF::openpa_dom_PD_CORE_ok;
  end
  // crossing 1: u_core/acc (PD_CORE) -> logic in pmu_soc (PD_TOP), not isolated
  bit openpa_x1_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x1_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x1_t)
    begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 2: u_core/acc (PD_CORE) -> pmu_soc output total (PD_TOP), not isolated
  bit openpa_x2_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x2_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x2_t)
    begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 3: u_core/beats (PD_CORE) -> pmu_soc output beats (PD_TOP), not isolated
  bit openpa_x3_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x3_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x3_t)
    begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 4: u_core/busy (PD_CORE) -> logic in pmu_soc (PD_TOP), not isolated
  bit openpa_x4_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x4_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x4_t)
    begin openpa_sp[4] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 5: u_core/busy (PD_CORE) -> pmu_soc output led (PD_TOP), not isolated
  bit openpa_x5_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x5_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x5_t)
    begin openpa_sp[5] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 6: u_core/rf_rd (PD_CORE) -> pmu_soc output rd (PD_TOP), not isolated
  bit openpa_x6_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x6_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x6_t)
    begin openpa_sp[6] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 7: pmu_soc input clk (PD_TOP) -> u_core/clk (PD_CORE), not isolated
  bit openpa_x7_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x7_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x7_t)
    begin openpa_sp[7] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 8: pmu_soc input d (PD_TOP) -> u_core/d (PD_CORE), not isolated
  bit openpa_x8_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x8_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x8_t)
    begin openpa_sp[8] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 9: pmu_soc input en (PD_TOP) -> u_core/en (PD_CORE), not isolated
  bit openpa_x9_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x9_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x9_t)
    begin openpa_sp[9] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 10: pmu_soc input rf_addr (PD_TOP) -> u_core/rf_addr (PD_CORE), not isolated
  bit openpa_x10_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x10_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x10_t)
    begin openpa_sp[10] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 11: pmu_soc input rf_we (PD_TOP) -> u_core/rf_we (PD_CORE), not isolated
  bit openpa_x11_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x11_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x11_t)
    begin openpa_sp[11] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 12: u_pmu/core_rst_n (PD_TOP) -> u_core/rst_n (PD_CORE), not isolated
  bit openpa_x12_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x12_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x12_t)
    begin openpa_sp[12] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 1: PD_CORE -> PD_TOP (no level shifter strategy, threshold 0)
  bit openpa_l1_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VDD_N) openpa_l1_t = UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_CORE.voltage - UPF::openpa_net_VDD_N.voltage > 0 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_CORE.voltage > 0) && !1'b0;
  always @(posedge openpa_l1_t)
    begin openpa_sp[13] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 2: PD_TOP -> PD_CORE (no level shifter strategy, threshold 0)
  bit openpa_l2_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_CORE) openpa_l2_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_CORE.voltage > 0 || UPF::openpa_net_VDD_CORE.voltage - UPF::openpa_net_VDD_N.voltage > 0) && !1'b0;
  always @(posedge openpa_l2_t)
    begin openpa_sp[14] = 1'b1; openpa_sreq = 1'b1; end
  bit openpa_SW_CORE_def;
  always @(posedge openpa_tg_sw_SW_CORE_st or negedge openpa_tg_sw_SW_CORE_st)
    begin openpa_sp[15] = 1'b1; openpa_sreq = 1'b1; end
  always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
    begin openpa_sp[16] = 1'b1; openpa_sreq = 1'b1; end

  // ---- observation for differential corruption (+openpa_obs): design-top outputs while the top domain is on
  `ifdef OPENPA_OBS
  longint openpa_obs_after;
  initial if (!$value$plusargs("openpa_obs_after=%d", openpa_obs_after)) openpa_obs_after = 0;
  always @(total) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: total=%h", $time, total);
  always @(led) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: led=%h", $time, led);
  always @(rd) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: rd=%h", $time, rd);
  always @(beats) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: beats=%h", $time, beats);
  always @(status) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: status=%h", $time, status);
  always @(pmu_state) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: pmu_state=%h", $time, pmu_state);
  `else
  initial if ($test$plusargs("openpa_obs")) $display("OPENPA-ERROR +openpa_obs needs the copy compiled with OPENPA_OBS defined (-DOPENPA_OBS or +define+OPENPA_OBS)");
  `endif

  // Icarus 12 runs no named block inside a final block, so the report is a function.
  function automatic void openpa_cover_report();
      int hs, ht, hq;
      hs = 0; ht = 0; hq = 0;
      $display("OPENPA-COVER-SUMMARY states=%0d/0 declared_transitions=%0d/0 sequences=%0d/0", hs, ht, hq);
  endfunction

  // ---- settle process: 16 deferred check(s), run after one #0 in a fixed order
  initial forever begin
    wait (openpa_sreq && openpa_kick);
    #0;
    openpa_sreq = 1'b0;
    if (openpa_sp[1]) begin
      openpa_sp[1] = 1'b0;
      if (openpa_x1_t) openpa_check(9, "u_core/acc of PD_CORE (off) is read by logic in pmu_soc in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[2]) begin
      openpa_sp[2] = 1'b0;
      if (openpa_x2_t) openpa_check(9, "u_core/acc of PD_CORE (off) is read by pmu_soc output total in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[3]) begin
      openpa_sp[3] = 1'b0;
      if (openpa_x3_t) openpa_check(9, "u_core/beats of PD_CORE (off) is read by pmu_soc output beats in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[4]) begin
      openpa_sp[4] = 1'b0;
      if (openpa_x4_t) openpa_check(9, "u_core/busy of PD_CORE (off) is read by logic in pmu_soc in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[5]) begin
      openpa_sp[5] = 1'b0;
      if (openpa_x5_t) openpa_check(9, "u_core/busy of PD_CORE (off) is read by pmu_soc output led in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[6]) begin
      openpa_sp[6] = 1'b0;
      if (openpa_x6_t) openpa_check(9, "u_core/rf_rd of PD_CORE (off) is read by pmu_soc output rd in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[7]) begin
      openpa_sp[7] = 1'b0;
      if (openpa_x7_t) openpa_check(9, "pmu_soc input clk of PD_TOP (off) is read by u_core/clk in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[8]) begin
      openpa_sp[8] = 1'b0;
      if (openpa_x8_t) openpa_check(9, "pmu_soc input d of PD_TOP (off) is read by u_core/d in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[9]) begin
      openpa_sp[9] = 1'b0;
      if (openpa_x9_t) openpa_check(9, "pmu_soc input en of PD_TOP (off) is read by u_core/en in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[10]) begin
      openpa_sp[10] = 1'b0;
      if (openpa_x10_t) openpa_check(9, "pmu_soc input rf_addr of PD_TOP (off) is read by u_core/rf_addr in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[11]) begin
      openpa_sp[11] = 1'b0;
      if (openpa_x11_t) openpa_check(9, "pmu_soc input rf_we of PD_TOP (off) is read by u_core/rf_we in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[12]) begin
      openpa_sp[12] = 1'b0;
      if (openpa_x12_t) openpa_check(9, "u_pmu/core_rst_n of PD_TOP (off) is read by u_core/rst_n in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[13]) begin
      openpa_sp[13] = 1'b0;
      if (openpa_l1_t) openpa_check(11, $sformatf("PD_CORE (%0d uV) drives PD_TOP (%0d uV) on 6 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_CORE.voltage, UPF::openpa_net_VDD_N.voltage));
    end
    if (openpa_sp[14]) begin
      openpa_sp[14] = 1'b0;
      if (openpa_l2_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_CORE (%0d uV) on 6 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_CORE.voltage));
    end
    if (openpa_sp[15]) begin
      openpa_sp[15] = 1'b0;
      if (UPF::openpa_sw_SW_CORE_st != -1) openpa_SW_CORE_def = 1'b1; else if (openpa_SW_CORE_def) openpa_check(10, "power switch SW_CORE is undetermined: a control is X, or no state (or more than one) holds (pmu_soc.upf:24)");
    end
    if (openpa_sp[16]) begin
      openpa_sp[16] = 1'b0;
      if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_CORE_ok)) openpa_check(12, "u_pmu.pwr_en (switch SW_CORE) comes from PD_TOP, which is off while other domains are on");
    end
  end
  final begin
    $display("OPENPA-SUMMARY D1=%0d D2=%0d D3=%0d D4=%0d D5=%0d D6=%0d D7=%0d D8=%0d D9=%0d D10=%0d D11=%0d D12=%0d D13=%0d D14=%0d", openpa_n[1], openpa_n[2], openpa_n[3], openpa_n[4], openpa_n[5], openpa_n[6], openpa_n[7], openpa_n[8], openpa_n[9], openpa_n[10], openpa_n[11], openpa_n[12], openpa_n[13], openpa_n[14]);
    openpa_cover_report();
    if (!UPF::openpa_armed) $display("OPENPA-WARNING no supply was driven (supply_on/supply_off never called): every domain stayed CORRUPT");
    if (!openpa_SW_CORE_def) $display("OPENPA-WARNING power switch SW_CORE never reached a defined state");
  end
  // verilator lint_on MULTIDRIVEN
`line 59 "pmu_soc.sv" 0
endmodule

`line 1 "pmu.sv" 0
// 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

`line 1 "core.sv" 0
// 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

Check Yourself

Predict the outputUnder the legacy header, what does the initial pad sample print?
`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("undriven");
   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'h16; tick; en=0; sample("working");
   sleep_req=1; tick; sleep_req=0; tick; tick; sample("parked");
   wake_req=1; tick; wake_req=0; repeat(4) tick; sample("restarted");
   void'(supply_partial_on("VDD_LO",0.8)); #2; sample("partial");
   $display("weak_rail state=%0d millivolts=%0d",get_supply_state(get_supply_value("VDD_LO")),
     $rtoi(1000*get_supply_voltage(get_supply_value("VDD_LO"))));
   void'(supply_off("VDD_LO")); #2; sample("removed"); $finish;
 end
endmodule
Read included file: pa_pmu_soc.sv
// pa_pmu_soc.sv: power-aware copy of pmu_soc, generated by OpenPA from pmu_soc.upf.
// Do not edit: regenerate. Simulators: Icarus 12 (4-state, X corruption) or Verilator 5 with --timing (2-state).
// Build with -Wno-fatal on Verilator: forced registers raise MULTIDRIVEN warnings.
`timescale 1ns/1ps
// ---------------------------------------------------------------------------
// package UPF: generated by OpenPA. Supply types, supply_on/supply_off and the power
// state of the design. Names starting with openpa_ are internal.
// ---------------------------------------------------------------------------
package UPF;
  typedef string upfStringT; typedef int upfIntegerT; typedef bit upfBooleanT; typedef logic upfLogicT; typedef real upfRealT; typedef int upfHandleT;
  typedef enum { OFF, FULL_ON, PARTIAL_ON, UNDETERMINED } upfSupplyStateE;
  typedef struct packed { upfSupplyStateE state; int voltage; } upfSupplyTypeT;  // voltage in microvolts
  typedef upfSupplyTypeT supply_net_type;
  bit openpa_armed = 1'b1;        // set by the first call that drives a supply (UPF 1.0: pads start on)
  bit openpa_kick;         // pulsed once at time 0 to evaluate everything
  bit openpa_xmode;        // 1: corrupt to X; 0: seeded 2-state values
  int unsigned openpa_seed = 1;
  int openpa_cmode;        // 2-state corruption: 0 random, 1 all zero, 2 all one
  supply_net_type openpa_port_VDD = {FULL_ON, 32'sd0};   // supply port VDD (pmu_soc.upf:9)
  supply_net_type openpa_port_VDD_LO = {FULL_ON, 32'sd0};   // supply port VDD_LO (pmu_soc.upf:10)
  supply_net_type openpa_port_VSS = {FULL_ON, 32'sd0};   // supply port VSS (pmu_soc.upf:11)
  supply_net_type openpa_net_VDD_N;   // supply net VDD_N
  supply_net_type openpa_net_VDDL_N;   // supply net VDDL_N
  supply_net_type openpa_net_VSS_N;   // supply net VSS_N
  supply_net_type openpa_net_VDD_CORE;   // supply net VDD_CORE
  int openpa_sw_SW_CORE_st = -1;   // switch SW_CORE: -1 undetermined, 0 off, k on-state k (pmu_soc.upf:24)
  bit openpa_ss_PD_TOP_primary_ok; int unsigned openpa_ss_PD_TOP_primary_ep; int openpa_ss_PD_TOP_primary_st = -1; bit openpa_ss_PD_TOP_primary_multi; int openpa_ss_PD_TOP_primary_sim = 5;   // supply set PD_TOP.primary
  bit openpa_ss_PD_CORE_primary_ok; int unsigned openpa_ss_PD_CORE_primary_ep; int openpa_ss_PD_CORE_primary_st = -1; bit openpa_ss_PD_CORE_primary_multi; int openpa_ss_PD_CORE_primary_sim = 5;   // supply set PD_CORE.primary
  bit openpa_dom_PD_TOP_ok; int unsigned openpa_dom_PD_TOP_ep; int openpa_dom_PD_TOP_sim = 5;   // power domain PD_TOP: ok = powered (simstate not CORRUPT); sim = simstate code (pmu_soc.upf:5)
  bit openpa_dom_PD_CORE_ok; int unsigned openpa_dom_PD_CORE_ep; int openpa_dom_PD_CORE_sim = 5;   // power domain PD_CORE: ok = powered (simstate not CORRUPT); sim = simstate code (pmu_soc.upf:6)
  // simstate codes, by IEEE 1801-2024 4.8 precedence: 0 NORMAL, 1 CORRUPT_STATE_ON_CHANGE, 2 CORRUPT_STATE_ON_ACTIVITY,
  // 3 CORRUPT_ON_CHANGE, 4 CORRUPT_ON_ACTIVITY, 5 CORRUPT (and NOT_NORMAL, 9.5.8); README "Simstates"
  logic openpa_ctl_0_u_pmu_pwr_en;   // copy of u_pmu.pwr_en (switch SW_CORE)
  function automatic logic [63:0] openpa_mix(int unsigned id, int unsigned ep, int unsigned lane);
    logic [63:0] z;
    if (openpa_cmode == 1) return 64'd0;
    if (openpa_cmode == 2) return ~64'd0;
    z = {32'd0, openpa_seed} * 64'h9E3779B97F4A7C15 + {32'd0, id} * 64'hC2B2AE3D27D4EB4F + {32'd0, ep} * 64'h165667B19E3779F9 + {32'd0, lane} * 64'hD6E8FEB86659FD93;
    z = (z ^ (z >> 30)) * 64'hBF58476D1CE4E5B9;
    z = (z ^ (z >> 27)) * 64'h94D049BB133111EB;
    return z ^ (z >> 31);
  endfunction
  function automatic bit openpa_bit(int unsigned id, int unsigned ep); logic [63:0] z; z = openpa_mix(id, ep, 0); return z[0]; endfunction
  function automatic int openpa_uv(real v); return $rtoi(v * 1.0e6 + (v < 0.0 ? -0.5 : 0.5)); endfunction
  // supply_on: FULL_ON at the given voltage (11.2.4; default 1.0 V)
  function automatic upfBooleanT supply_on(string pad_name, real value = 1.0);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = FULL_ON; openpa_port_VDD.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = FULL_ON; openpa_port_VDD_LO.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = FULL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_on(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // supply_off: OFF, voltage unchanged (9.3.1); a second argument is accepted and ignored
  function automatic upfBooleanT supply_off(string pad_name, real value = 0.0);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = OFF; return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = OFF; return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = OFF; return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_off(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // supply_partial_on: PARTIAL_ON at the given voltage (11.2.4)
  function automatic upfBooleanT supply_partial_on(string pad_name, real value = 1.0);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = PARTIAL_ON; openpa_port_VDD.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = PARTIAL_ON; openpa_port_VDD_LO.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = PARTIAL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_partial_on(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // set_supply_state: the state only, voltage unchanged (9.3.1)
  function automatic upfBooleanT set_supply_state(string pad_name, upfSupplyStateE supply_state);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = supply_state; return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = supply_state; return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = supply_state; return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR set_supply_state(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // set_power_state (9.3.1) is not supported: OpenPA has no deferred power states. A call is reported, never ignored.
  function automatic upfBooleanT set_power_state(string object_name, string power_state);
    $display("OPENPA-ERROR set_power_state(\"%s\", \"%s\"): not supported by OpenPA; drive the supplies with supply_on, supply_off or set_supply_state", object_name, power_state);
    return 0;
  endfunction
  // Supply queries (11.2.4). Names: supply ports, supply nets and supply set functions as the UPF wrote them.
  function automatic upfSupplyTypeT get_supply_value(string name);
    if (name == "VDD" || name == "VDD_N" || name == "PD_TOP.primary.power") return openpa_net_VDD_N;
    if (name == "VDD_LO" || name == "VDDL_N") return openpa_net_VDDL_N;
    if (name == "VSS" || name == "VSS_N" || name == "PD_TOP.primary.ground" || name == "PD_CORE.primary.ground") return openpa_net_VSS_N;
    if (name == "VDD_CORE" || name == "PD_CORE.primary.power") return openpa_net_VDD_CORE;
    $display("OPENPA-ERROR get_supply_value(\"%s\"): no supply net, port or supply set function of that name", name);
    return 0;
  endfunction
  function automatic upfRealT get_supply_voltage(upfSupplyTypeT arg); return arg.voltage / 1.0e6; endfunction
  // UPF 1.0 5.1.4 (this file declares upf_version 1.0): on/off bit; {full/partial, on/off} bits (2'b01 fully on, 2'b11 partially on, 2'b00 off).
  function automatic upfBooleanT get_supply_on_state(upfSupplyTypeT arg); return arg.state == FULL_ON || arg.state == PARTIAL_ON; endfunction
  function automatic bit [1:0] get_supply_state(upfSupplyTypeT arg); return {arg.state == PARTIAL_ON, arg.state == FULL_ON || arg.state == PARTIAL_ON}; endfunction
endpackage
// ---------------------------------------------------------------------------
// OpenPA cells (generated; do not edit)
// ---------------------------------------------------------------------------
// openpa_corrupt: rule C2. Passes d while the driving domain is NORMAL; otherwise drives X (4-state)
// or a seeded value (2-state). The value is computed ahead for the episode the next power-down starts
// (ep + 1 while ok), so at power-down the output goes straight from d to the new value: no delta glitch
// through the previous episode's value (Icarus would turn one into a clock edge).
module openpa_corrupt #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           ok,
  input  int unsigned  ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  always @(ep or ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
  assign q = ok ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

// openpa_corrupt_sim: rule C2 for a domain that has intermediate simstates (IEEE 1801-2024 9.5). As
// openpa_corrupt, and also corrupt while lhit is set (CORRUPT_ON_ACTIVITY after input activity), or after d
// changed while coc is set (CORRUPT_ON_CHANGE); leaving CORRUPT_ON_CHANGE clears that.
module openpa_corrupt_sim #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           ok,
  input  int unsigned  ep,
  input  bit           lhit,
  input  bit           coc
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  bit chg;
  always @(ep or ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
  // verilator lint_off MULTIDRIVEN
  for (genvar i = 0; i < W; i++) begin : g_chg
    always @(posedge d[i] or negedge d[i]) if (coc && ok) chg = 1'b1;
  end
  always @(negedge coc) chg = 1'b0;
  // verilator lint_on MULTIDRIVEN
  assign q = (ok && !lhit && !chg) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

// openpa_iso: rules I1-I4 (IEEE 1801-2024 9.8). CLAMP 0, 1, 2 (latch: the value the input had while the enable
// was inactive) or 3 (Z: high impedance on 4-state; 0 on 2-state backends, which cannot represent Z).
// sup_ok is 1 while the isolation supply is NORMAL (always, for a strategy with no supply); otherwise the output,
// and a latched value, are corrupt. An enable at X or Z corrupts the output and the latched value.
module openpa_iso #(parameter int W = 1, parameter int CLAMP = 0, parameter bit SENSE = 1'b1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  logic         en,
  input  bit           sup_ok,
  input  int unsigned  sup_ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  logic [W-1:0] held;
  always @(sup_ep or sup_ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h4000_0000, sup_ok ? sup_ep + 1 : sup_ep, i);
  wire active   = (en === SENSE);
  wire inactive = (en === !SENSE);
  wire [W-1:0] bad    = UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0];
  if (CLAMP == 2) begin : g_latch
    always @(d or en or sup_ok or bad) if (!sup_ok || !(active || inactive)) held = bad; else if (inactive) held = d;
  end
  wire [W-1:0] clampv = (CLAMP == 3) ? (UPF::openpa_xmode ? {W{1'bz}} : {W{1'b0}}) : (CLAMP == 2) ? held : (CLAMP == 1) ? {W{1'b1}} : {W{1'b0}};
  assign q = !sup_ok ? bad : active ? clampv : inactive ? d : bad;
endmodule

// openpa_ls: rule L1 (IEEE 1801-2024 9.9). Passes d while every supply set of the cell is NORMAL; otherwise corrupt.
module openpa_ls #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           src_ok,
  input  bit           dst_ok,
  input  int unsigned  ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  always @(ep or src_ok or dst_ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h8000_0000, (src_ok && dst_ok) ? ep + 1 : ep, i);
  assign q = (src_ok && dst_ok) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

`line 1 "pmu_soc.sv" 0
// 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)
  );

  wire [7:0] openpa_u_core_acc_raw; wire [3:0] openpa_u_core_beats_raw; wire [0:0] openpa_u_core_busy_raw; wire [7:0] openpa_u_core_rf_rd_raw; wire [0:0] openpa_u_core_clk_s1; wire [7:0] openpa_u_core_d_s1; wire [0:0] openpa_u_core_en_s1; wire [1:0] openpa_u_core_rf_addr_s1; wire [0:0] openpa_u_core_rf_we_s1; wire [0:0] openpa_u_core_rst_n_s1; core u_core (
    .clk     (openpa_u_core_clk_s1),
    .rst_n   (openpa_u_core_rst_n_s1),
    .en      (openpa_u_core_en_s1),
    .d       (openpa_u_core_d_s1),
    .rf_addr (openpa_u_core_rf_addr_s1),
    .rf_we   (openpa_u_core_rf_we_s1),
    .acc     (openpa_u_core_acc_raw),
    .rf_rd   (openpa_u_core_rf_rd_raw),
    .busy    (openpa_u_core_busy_raw),
    .beats   (openpa_u_core_beats_raw)
  ); openpa_corrupt #(.W(8), .ID(268435456)) openpa_u_core_acc_cor (.d(openpa_u_core_acc_raw), .q(acc), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_corrupt #(.W(4), .ID(268435464)) openpa_u_core_beats_cor (.d(openpa_u_core_beats_raw), .q(core_beats), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_corrupt #(.W(1), .ID(268435472)) openpa_u_core_busy_cor (.d(openpa_u_core_busy_raw), .q(busy), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_corrupt #(.W(8), .ID(268435480)) openpa_u_core_rf_rd_cor (.d(openpa_u_core_rf_rd_raw), .q(rf_rd), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_corrupt #(.W(1), .ID(268435488)) openpa_u_core_clk_cor (.d(clk), .q(openpa_u_core_clk_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(8), .ID(268435496)) openpa_u_core_d_cor (.d(d), .q(openpa_u_core_d_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435504)) openpa_u_core_en_cor (.d(en), .q(openpa_u_core_en_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(2), .ID(268435512)) openpa_u_core_rf_addr_cor (.d(rf_addr), .q(openpa_u_core_rf_addr_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435520)) openpa_u_core_rf_we_cor (.d(rf_we), .q(openpa_u_core_rf_we_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435528)) openpa_u_core_rst_n_cor (.d(core_rst_n), .q(openpa_u_core_rst_n_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep));

  // 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;

`line 1 "openpa_overlay.sv" 0
  // ===================================================================================
  // OpenPA overlay for pmu_soc: generated from pmu_soc.upf. Do not edit.
  // ===================================================================================
  // verilator lint_off MULTIDRIVEN
  // verilator lint_off ENUMVALUE
  // verilator lint_off WIDTHTRUNC
  // verilator lint_off WIDTHEXPAND
  // verilator lint_off BLKSEQ
  // verilator lint_off IGNOREDRETURN
  import UPF::openpa_cmode;
  import UPF::openpa_ctl_0_u_pmu_pwr_en;
  import UPF::openpa_dom_PD_CORE_ep;
  import UPF::openpa_dom_PD_CORE_ok;
  import UPF::openpa_dom_PD_CORE_sim;
  import UPF::openpa_dom_PD_TOP_ep;
  import UPF::openpa_dom_PD_TOP_ok;
  import UPF::openpa_dom_PD_TOP_sim;
  import UPF::openpa_kick;
  import UPF::openpa_net_VDDL_N;
  import UPF::openpa_net_VDD_CORE;
  import UPF::openpa_net_VDD_N;
  import UPF::openpa_net_VSS_N;
  import UPF::openpa_seed;
  import UPF::openpa_ss_PD_CORE_primary_ep;
  import UPF::openpa_ss_PD_CORE_primary_multi;
  import UPF::openpa_ss_PD_CORE_primary_ok;
  import UPF::openpa_ss_PD_CORE_primary_sim;
  import UPF::openpa_ss_PD_CORE_primary_st;
  import UPF::openpa_ss_PD_TOP_primary_ep;
  import UPF::openpa_ss_PD_TOP_primary_multi;
  import UPF::openpa_ss_PD_TOP_primary_ok;
  import UPF::openpa_ss_PD_TOP_primary_sim;
  import UPF::openpa_ss_PD_TOP_primary_st;
  import UPF::openpa_sw_SW_CORE_st;
  import UPF::openpa_xmode;
  // ---- mode, seed, trace
  bit openpa_tr, openpa_obs;
  int openpa_n [1:14];
  int openpa_seq [1:1];   // good-form sequence bins (coverage)
  bit openpa_sreq; bit openpa_sp [1:16];   // deferred checks: request and pending flags
  string openpa_mode_arg;
  initial begin
  `ifdef VERILATOR
    openpa_xmode = 1'b0;
  `else
    openpa_xmode = 1'b1;
  `endif
    openpa_cmode = 0;
    if ($value$plusargs("openpa_corrupt=%s", openpa_mode_arg)) begin
      if (openpa_mode_arg == "x") openpa_xmode = 1'b1;
      else if (openpa_mode_arg == "random") openpa_xmode = 1'b0;
      else if (openpa_mode_arg == "zero") begin openpa_xmode = 1'b0; openpa_cmode = 1; end
      else if (openpa_mode_arg == "one") begin openpa_xmode = 1'b0; openpa_cmode = 2; end
      else $display("OPENPA-ERROR +openpa_corrupt=%s: use x, random, zero or one", openpa_mode_arg);
    end
    if (!$value$plusargs("openpa_seed=%d", openpa_seed)) openpa_seed = 1;
    openpa_tr = $test$plusargs("openpa_trace");
    openpa_obs = $test$plusargs("openpa_obs");
    $display("OPENPA-INFO corruption=%0s seed=%0d", openpa_xmode ? "x" : (openpa_cmode == 1 ? "zero" : openpa_cmode == 2 ? "one" : "random"), openpa_seed);
    #0 openpa_kick = 1'b1;
  end
  task automatic openpa_check(input int id, input string msg);
    openpa_n[id] = openpa_n[id] + 1;
    $display("OPENPA-CHECK D%0d @ %0t: %s", id, $time, msg);
  endtask
  task automatic openpa_t(input string msg);
    if (openpa_tr) $display("OPENPA-TRACE @ %0t: %s", $time, msg);
  endtask

  // ---- copies of the design signals the UPF names (4-state, so X is visible)
  always @(u_pmu.pwr_en or openpa_kick) openpa_ctl_0_u_pmu_pwr_en = u_pmu.pwr_en;

  // ---- supply network, switches, supply sets, simstates, power states (one block, evaluated in order)
  bit openpa_tg_sw_SW_CORE_st; int openpa_pv_sw_SW_CORE_st = -2;
  UPF::supply_net_type openpa_swv_SW_CORE_f, openpa_swv_SW_CORE_p; bit openpa_swv_SW_CORE_u, openpa_swv_SW_CORE_hf, openpa_swv_SW_CORE_hp, openpa_swv_SW_CORE_vd, openpa_swv_SW_CORE_on, openpa_swv_SW_CORE_pt; int openpa_swv_SW_CORE_k;   // switch SW_CORE
  always @(openpa_kick or UPF::openpa_port_VDD or UPF::openpa_port_VDD_LO or UPF::openpa_port_VSS or UPF::openpa_ctl_0_u_pmu_pwr_en) begin : openpa_network
    openpa_net_VDD_N = UPF::openpa_port_VDD;   // VDD_N <- port VDD
    openpa_net_VDDL_N = UPF::openpa_port_VDD_LO;   // VDDL_N <- port VDD_LO
    openpa_net_VSS_N = UPF::openpa_port_VSS;   // VSS_N <- port VSS
    // switch SW_CORE (pmu_soc.upf:24): IEEE 1801-2024 6.23
    openpa_swv_SW_CORE_u = 1'b0; openpa_swv_SW_CORE_hf = 1'b0; openpa_swv_SW_CORE_hp = 1'b0; openpa_swv_SW_CORE_vd = 1'b0; openpa_swv_SW_CORE_on = 1'b0; openpa_swv_SW_CORE_pt = 1'b0; openpa_swv_SW_CORE_k = 0;
    if (($isunknown(openpa_ctl_0_u_pmu_pwr_en)) && UPF::openpa_net_VDDL_N.state != UPF::OFF) openpa_swv_SW_CORE_u = 1'b1;   // on state on: a control is X or Z
    else if ((openpa_ctl_0_u_pmu_pwr_en === 1'b1)) begin
      if (!openpa_swv_SW_CORE_on) openpa_swv_SW_CORE_k = 1;
      openpa_swv_SW_CORE_on = 1'b1;
      if (UPF::openpa_net_VDDL_N.state == UPF::UNDETERMINED) openpa_swv_SW_CORE_u = 1'b1;
      else if (UPF::openpa_net_VDDL_N.state == UPF::FULL_ON) begin
        if ((openpa_swv_SW_CORE_hf && openpa_swv_SW_CORE_f.voltage != UPF::openpa_net_VDDL_N.voltage) || (openpa_swv_SW_CORE_hp && openpa_swv_SW_CORE_p.voltage != UPF::openpa_net_VDDL_N.voltage)) openpa_swv_SW_CORE_vd = 1'b1;
        openpa_swv_SW_CORE_f = UPF::openpa_net_VDDL_N; openpa_swv_SW_CORE_hf = 1'b1;
      end
      else if (UPF::openpa_net_VDDL_N.state == UPF::PARTIAL_ON) begin
        if ((openpa_swv_SW_CORE_hf && openpa_swv_SW_CORE_f.voltage != UPF::openpa_net_VDDL_N.voltage) || (openpa_swv_SW_CORE_hp && openpa_swv_SW_CORE_p.voltage != UPF::openpa_net_VDDL_N.voltage)) openpa_swv_SW_CORE_vd = 1'b1;
        openpa_swv_SW_CORE_p = UPF::openpa_net_VDDL_N; openpa_swv_SW_CORE_hp = 1'b1;
      end
    end
    if ((1'b0) || (((!((openpa_ctl_0_u_pmu_pwr_en === 1'b1)))) && (openpa_swv_SW_CORE_on || openpa_swv_SW_CORE_pt)) || openpa_swv_SW_CORE_u || openpa_swv_SW_CORE_vd || (!($isunknown(openpa_ctl_0_u_pmu_pwr_en)) && !openpa_swv_SW_CORE_on && !openpa_swv_SW_CORE_pt && !((!((openpa_ctl_0_u_pmu_pwr_en === 1'b1)))) && !(1'b0))) begin openpa_sw_SW_CORE_st = -1; openpa_net_VDD_CORE.state = UPF::UNDETERMINED; openpa_net_VDD_CORE.voltage = 0; end
    else begin openpa_sw_SW_CORE_st = openpa_swv_SW_CORE_k; if (openpa_swv_SW_CORE_hf) openpa_net_VDD_CORE = openpa_swv_SW_CORE_f; else if (openpa_swv_SW_CORE_hp) openpa_net_VDD_CORE = openpa_swv_SW_CORE_p; else begin openpa_net_VDD_CORE.state = UPF::OFF; openpa_net_VDD_CORE.voltage = 0; end end
    // supply set PD_TOP.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_PD_TOP_primary
      bit nx; int sm;
      sm = ((UPF::openpa_net_VDD_N.state == UPF::FULL_ON || UPF::openpa_net_VDD_N.state == UPF::PARTIAL_ON) && (UPF::openpa_net_VSS_N.state == UPF::FULL_ON || UPF::openpa_net_VSS_N.state == UPF::PARTIAL_ON)) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_PD_TOP_primary_sim = sm;
      nx = sm < 5;
      if (openpa_ss_PD_TOP_primary_ok && !nx) openpa_ss_PD_TOP_primary_ep = openpa_ss_PD_TOP_primary_ep + 1;
      openpa_ss_PD_TOP_primary_ok = nx;
    end
    // supply set PD_CORE.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_PD_CORE_primary
      bit nx; int sm;
      sm = ((UPF::openpa_net_VDD_CORE.state == UPF::FULL_ON || UPF::openpa_net_VDD_CORE.state == UPF::PARTIAL_ON) && (UPF::openpa_net_VSS_N.state == UPF::FULL_ON || UPF::openpa_net_VSS_N.state == UPF::PARTIAL_ON)) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_PD_CORE_primary_sim = sm;
      nx = sm < 5;
      if (openpa_ss_PD_CORE_primary_ok && !nx) openpa_ss_PD_CORE_primary_ep = openpa_ss_PD_CORE_primary_ep + 1;
      openpa_ss_PD_CORE_primary_ok = nx;
    end
    // domain PD_TOP: simstate of its primary supply set PD_TOP.primary
    if (openpa_dom_PD_TOP_ok && !UPF::openpa_ss_PD_TOP_primary_ok) openpa_dom_PD_TOP_ep = openpa_dom_PD_TOP_ep + 1;
    openpa_dom_PD_TOP_ok = UPF::openpa_ss_PD_TOP_primary_ok;
    openpa_dom_PD_TOP_sim = openpa_ss_PD_TOP_primary_sim;
    // domain PD_CORE: simstate of its primary supply set PD_CORE.primary
    if (openpa_dom_PD_CORE_ok && !UPF::openpa_ss_PD_CORE_primary_ok) openpa_dom_PD_CORE_ep = openpa_dom_PD_CORE_ep + 1;
    openpa_dom_PD_CORE_ok = UPF::openpa_ss_PD_CORE_primary_ok;
    openpa_dom_PD_CORE_sim = openpa_ss_PD_CORE_primary_sim;
    if (openpa_sw_SW_CORE_st != openpa_pv_sw_SW_CORE_st) begin openpa_tg_sw_SW_CORE_st = ~openpa_tg_sw_SW_CORE_st; openpa_pv_sw_SW_CORE_st = openpa_sw_SW_CORE_st; end
  end

  // ---- corruption: registers forced, memories overwritten (rules C1, C3)
  // domain PD_TOP (pmu_soc.upf:5): 2 register(s), 0 memory(ies)
  bit openpa_PD_TOP_applied, openpa_PD_TOP_valid;
  logic [7:0] openpa_cv1;   // corruption value for status
  logic [2:0] openpa_cv2;   // corruption value for u_pmu.st
  // The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
  // supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
  always @(UPF::openpa_dom_PD_TOP_ok or openpa_kick) if (!openpa_PD_TOP_valid || openpa_PD_TOP_applied != UPF::openpa_dom_PD_TOP_ok) begin
    openpa_t({"PD_TOP ", UPF::openpa_dom_PD_TOP_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_PD_TOP_ok || !openpa_PD_TOP_valid) begin
      if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_PD_TOP_ep, 0);
      force status = openpa_cv1;
      if (openpa_xmode) openpa_cv2 = 'x; else openpa_cv2 = UPF::openpa_mix(2, UPF::openpa_dom_PD_TOP_ep, 0);
      force u_pmu.st = openpa_cv2;
    end
    if (UPF::openpa_dom_PD_TOP_ok) begin
      release status;
      release u_pmu.st;
    end
    openpa_PD_TOP_valid = 1'b1; openpa_PD_TOP_applied = UPF::openpa_dom_PD_TOP_ok;
  end
  // domain PD_CORE (pmu_soc.upf:6): 2 register(s), 1 memory(ies)
  bit openpa_PD_CORE_applied, openpa_PD_CORE_valid;
  logic [7:0] openpa_cv3;   // corruption value for u_core.acc
  logic [3:0] openpa_cv4;   // corruption value for u_core.beats
  // The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
  // supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
  always @(UPF::openpa_dom_PD_CORE_ok or openpa_kick) if (!openpa_PD_CORE_valid || openpa_PD_CORE_applied != UPF::openpa_dom_PD_CORE_ok) begin
    openpa_t({"PD_CORE ", UPF::openpa_dom_PD_CORE_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_PD_CORE_ok || !openpa_PD_CORE_valid) begin
      if (openpa_xmode) openpa_cv3 = 'x; else openpa_cv3 = UPF::openpa_mix(3, UPF::openpa_dom_PD_CORE_ep, 0);
      force u_core.acc = openpa_cv3;
      if (openpa_xmode) openpa_cv4 = 'x; else openpa_cv4 = UPF::openpa_mix(4, UPF::openpa_dom_PD_CORE_ep, 0);
      force u_core.beats = openpa_cv4;
      for (int i = 0; i < 4; i++) u_core.rf[0 + i] = openpa_xmode ? 8'bx : UPF::openpa_mix(100000, UPF::openpa_dom_PD_CORE_ep, (i) * 1 + 0);
    end
    if (UPF::openpa_dom_PD_CORE_ok) begin
      for (int i = 0; i < 4; i++) u_core.rf[0 + i] = openpa_xmode ? 8'bx : UPF::openpa_mix(100000, UPF::openpa_dom_PD_CORE_ep, (i) * 1 + 0);
      release u_core.acc;
      release u_core.beats;
    end
    openpa_PD_CORE_valid = 1'b1; openpa_PD_CORE_applied = UPF::openpa_dom_PD_CORE_ok;
  end
  // crossing 1: u_core/acc (PD_CORE) -> logic in pmu_soc (PD_TOP), not isolated
  bit openpa_x1_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x1_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x1_t)
    begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 2: u_core/acc (PD_CORE) -> pmu_soc output total (PD_TOP), not isolated
  bit openpa_x2_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x2_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x2_t)
    begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 3: u_core/beats (PD_CORE) -> pmu_soc output beats (PD_TOP), not isolated
  bit openpa_x3_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x3_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x3_t)
    begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 4: u_core/busy (PD_CORE) -> logic in pmu_soc (PD_TOP), not isolated
  bit openpa_x4_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x4_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x4_t)
    begin openpa_sp[4] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 5: u_core/busy (PD_CORE) -> pmu_soc output led (PD_TOP), not isolated
  bit openpa_x5_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x5_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x5_t)
    begin openpa_sp[5] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 6: u_core/rf_rd (PD_CORE) -> pmu_soc output rd (PD_TOP), not isolated
  bit openpa_x6_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x6_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x6_t)
    begin openpa_sp[6] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 7: pmu_soc input clk (PD_TOP) -> u_core/clk (PD_CORE), not isolated
  bit openpa_x7_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x7_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x7_t)
    begin openpa_sp[7] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 8: pmu_soc input d (PD_TOP) -> u_core/d (PD_CORE), not isolated
  bit openpa_x8_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x8_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x8_t)
    begin openpa_sp[8] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 9: pmu_soc input en (PD_TOP) -> u_core/en (PD_CORE), not isolated
  bit openpa_x9_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x9_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x9_t)
    begin openpa_sp[9] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 10: pmu_soc input rf_addr (PD_TOP) -> u_core/rf_addr (PD_CORE), not isolated
  bit openpa_x10_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x10_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x10_t)
    begin openpa_sp[10] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 11: pmu_soc input rf_we (PD_TOP) -> u_core/rf_we (PD_CORE), not isolated
  bit openpa_x11_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x11_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x11_t)
    begin openpa_sp[11] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 12: u_pmu/core_rst_n (PD_TOP) -> u_core/rst_n (PD_CORE), not isolated
  bit openpa_x12_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x12_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x12_t)
    begin openpa_sp[12] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 1: PD_CORE -> PD_TOP (no level shifter strategy, threshold 0)
  bit openpa_l1_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VDD_N) openpa_l1_t = UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_CORE.voltage - UPF::openpa_net_VDD_N.voltage > 0 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_CORE.voltage > 0) && !1'b0;
  always @(posedge openpa_l1_t)
    begin openpa_sp[13] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 2: PD_TOP -> PD_CORE (no level shifter strategy, threshold 0)
  bit openpa_l2_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_CORE) openpa_l2_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_CORE.voltage > 0 || UPF::openpa_net_VDD_CORE.voltage - UPF::openpa_net_VDD_N.voltage > 0) && !1'b0;
  always @(posedge openpa_l2_t)
    begin openpa_sp[14] = 1'b1; openpa_sreq = 1'b1; end
  bit openpa_SW_CORE_def;
  always @(posedge openpa_tg_sw_SW_CORE_st or negedge openpa_tg_sw_SW_CORE_st)
    begin openpa_sp[15] = 1'b1; openpa_sreq = 1'b1; end
  always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
    begin openpa_sp[16] = 1'b1; openpa_sreq = 1'b1; end

  // ---- observation for differential corruption (+openpa_obs): design-top outputs while the top domain is on
  `ifdef OPENPA_OBS
  longint openpa_obs_after;
  initial if (!$value$plusargs("openpa_obs_after=%d", openpa_obs_after)) openpa_obs_after = 0;
  always @(total) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: total=%h", $time, total);
  always @(led) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: led=%h", $time, led);
  always @(rd) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: rd=%h", $time, rd);
  always @(beats) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: beats=%h", $time, beats);
  always @(status) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: status=%h", $time, status);
  always @(pmu_state) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: pmu_state=%h", $time, pmu_state);
  `else
  initial if ($test$plusargs("openpa_obs")) $display("OPENPA-ERROR +openpa_obs needs the copy compiled with OPENPA_OBS defined (-DOPENPA_OBS or +define+OPENPA_OBS)");
  `endif

  // Icarus 12 runs no named block inside a final block, so the report is a function.
  function automatic void openpa_cover_report();
      int hs, ht, hq;
      hs = 0; ht = 0; hq = 0;
      $display("OPENPA-COVER-SUMMARY states=%0d/0 declared_transitions=%0d/0 sequences=%0d/0", hs, ht, hq);
  endfunction

  // ---- settle process: 16 deferred check(s), run after one #0 in a fixed order
  initial forever begin
    wait (openpa_sreq && openpa_kick);
    #0;
    openpa_sreq = 1'b0;
    if (openpa_sp[1]) begin
      openpa_sp[1] = 1'b0;
      if (openpa_x1_t) openpa_check(9, "u_core/acc of PD_CORE (off) is read by logic in pmu_soc in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[2]) begin
      openpa_sp[2] = 1'b0;
      if (openpa_x2_t) openpa_check(9, "u_core/acc of PD_CORE (off) is read by pmu_soc output total in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[3]) begin
      openpa_sp[3] = 1'b0;
      if (openpa_x3_t) openpa_check(9, "u_core/beats of PD_CORE (off) is read by pmu_soc output beats in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[4]) begin
      openpa_sp[4] = 1'b0;
      if (openpa_x4_t) openpa_check(9, "u_core/busy of PD_CORE (off) is read by logic in pmu_soc in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[5]) begin
      openpa_sp[5] = 1'b0;
      if (openpa_x5_t) openpa_check(9, "u_core/busy of PD_CORE (off) is read by pmu_soc output led in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[6]) begin
      openpa_sp[6] = 1'b0;
      if (openpa_x6_t) openpa_check(9, "u_core/rf_rd of PD_CORE (off) is read by pmu_soc output rd in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[7]) begin
      openpa_sp[7] = 1'b0;
      if (openpa_x7_t) openpa_check(9, "pmu_soc input clk of PD_TOP (off) is read by u_core/clk in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[8]) begin
      openpa_sp[8] = 1'b0;
      if (openpa_x8_t) openpa_check(9, "pmu_soc input d of PD_TOP (off) is read by u_core/d in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[9]) begin
      openpa_sp[9] = 1'b0;
      if (openpa_x9_t) openpa_check(9, "pmu_soc input en of PD_TOP (off) is read by u_core/en in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[10]) begin
      openpa_sp[10] = 1'b0;
      if (openpa_x10_t) openpa_check(9, "pmu_soc input rf_addr of PD_TOP (off) is read by u_core/rf_addr in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[11]) begin
      openpa_sp[11] = 1'b0;
      if (openpa_x11_t) openpa_check(9, "pmu_soc input rf_we of PD_TOP (off) is read by u_core/rf_we in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[12]) begin
      openpa_sp[12] = 1'b0;
      if (openpa_x12_t) openpa_check(9, "u_pmu/core_rst_n of PD_TOP (off) is read by u_core/rst_n in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[13]) begin
      openpa_sp[13] = 1'b0;
      if (openpa_l1_t) openpa_check(11, $sformatf("PD_CORE (%0d uV) drives PD_TOP (%0d uV) on 6 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_CORE.voltage, UPF::openpa_net_VDD_N.voltage));
    end
    if (openpa_sp[14]) begin
      openpa_sp[14] = 1'b0;
      if (openpa_l2_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_CORE (%0d uV) on 6 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_CORE.voltage));
    end
    if (openpa_sp[15]) begin
      openpa_sp[15] = 1'b0;
      if (UPF::openpa_sw_SW_CORE_st != -1) openpa_SW_CORE_def = 1'b1; else if (openpa_SW_CORE_def) openpa_check(10, "power switch SW_CORE is undetermined: a control is X, or no state (or more than one) holds (pmu_soc.upf:24)");
    end
    if (openpa_sp[16]) begin
      openpa_sp[16] = 1'b0;
      if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_CORE_ok)) openpa_check(12, "u_pmu.pwr_en (switch SW_CORE) comes from PD_TOP, which is off while other domains are on");
    end
  end
  final begin
    $display("OPENPA-SUMMARY D1=%0d D2=%0d D3=%0d D4=%0d D5=%0d D6=%0d D7=%0d D8=%0d D9=%0d D10=%0d D11=%0d D12=%0d D13=%0d D14=%0d", openpa_n[1], openpa_n[2], openpa_n[3], openpa_n[4], openpa_n[5], openpa_n[6], openpa_n[7], openpa_n[8], openpa_n[9], openpa_n[10], openpa_n[11], openpa_n[12], openpa_n[13], openpa_n[14]);
    openpa_cover_report();
    if (!UPF::openpa_armed) $display("OPENPA-WARNING no supply was driven (supply_on/supply_off never called): every domain stayed CORRUPT");
    if (!openpa_SW_CORE_def) $display("OPENPA-WARNING power switch SW_CORE never reached a defined state");
  end
  // verilator lint_on MULTIDRIVEN
`line 59 "pmu_soc.sv" 0
endmodule

`line 1 "pmu.sv" 0
// 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

`line 1 "core.sv" 0
// 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

Predict the outputRun the voltage sweep. In the first NORMAL trial, what does new_word print?
`timescale 1ns/1ps
module tb;
 import UPF::*;
 logic clk=0,wr=0; logic [7:0] data=0;
 wire [7:0] stored; wire valid;
 buffer_soc dut(.*);
 task tick; #1 clk=1; #1 clk=0; #1; endtask
 task sample(input string phase);
   $display("%s mode=%0d wr=%b valid=%b stored=%h",phase,openpa_dom_PD_UNIT_sim,wr,valid,stored);
 endtask
 task experiment(input real volts);
   void'(supply_on("VHOST")); void'(supply_on("VSS",0.0)); void'(supply_on("VUNIT"));
   #2; wr=1; data=8'h39; tick; wr=0; #1; sample("loaded");
   void'(supply_on("VUNIT",volts)); #2; sample("entry");
   tick; sample("idle_edge");
   wr=1; #1; sample("data_edge");
   tick; sample("same_word");
   data=~data; tick; sample("new_word");
   void'(supply_on("VUNIT")); #2; sample("back");
   tick; sample("rewritten");
 endtask
 initial begin
   $display("Band0 NORMAL"); experiment(1.0);
   $display("Band1 CORRUPT_STATE_ON_CHANGE"); experiment(0.95);
   $display("Band2 CORRUPT_STATE_ON_ACTIVITY"); experiment(0.90);
   $display("Band3 CORRUPT_ON_CHANGE"); experiment(0.85);
   $display("Band4 CORRUPT_ON_ACTIVITY"); experiment(0.80);
   $display("Band5 NOT_NORMAL"); experiment(0.75);
   $display("Band6 CORRUPT"); experiment(0.70);
   $finish;
 end
endmodule
Read included file: pa_buffer_soc.sv
// pa_buffer_soc.sv: power-aware copy of buffer_soc, generated by OpenPA from buffer_soc.upf.
// Do not edit: regenerate. Simulators: Icarus 12 (4-state, X corruption) or Verilator 5 with --timing (2-state).
// Build with -Wno-fatal on Verilator: forced registers raise MULTIDRIVEN warnings.
`timescale 1ns/1ps
// ---------------------------------------------------------------------------
// package UPF: generated by OpenPA. Supply types, supply_on/supply_off and the power
// state of the design. Names starting with openpa_ are internal.
// ---------------------------------------------------------------------------
package UPF;
  typedef string upfStringT; typedef int upfIntegerT; typedef bit upfBooleanT; typedef logic upfLogicT; typedef real upfRealT; typedef int upfHandleT;
  typedef enum { OFF, FULL_ON, PARTIAL_ON, UNDETERMINED } upfSupplyStateE;
  typedef struct packed { upfSupplyStateE state; int voltage; } upfSupplyTypeT;  // voltage in microvolts
  typedef upfSupplyTypeT supply_net_type;
  bit openpa_armed;        // set by the first call that drives a supply
  bit openpa_kick;         // pulsed once at time 0 to evaluate everything
  bit openpa_xmode;        // 1: corrupt to X; 0: seeded 2-state values
  int unsigned openpa_seed = 1;
  int openpa_cmode;        // 2-state corruption: 0 random, 1 all zero, 2 all one
  supply_net_type openpa_port_VHOST;   // supply port VHOST (buffer_soc.upf:5)
  supply_net_type openpa_port_VUNIT;   // supply port VUNIT (buffer_soc.upf:8)
  supply_net_type openpa_port_VKEEP;   // supply port VKEEP (buffer_soc.upf:11)
  supply_net_type openpa_port_VSS;   // supply port VSS (buffer_soc.upf:14)
  supply_net_type openpa_net_HOST_N;   // supply net HOST_N
  supply_net_type openpa_net_UNIT_N;   // supply net UNIT_N
  supply_net_type openpa_net_KEEP_N;   // supply net KEEP_N
  supply_net_type openpa_net_GND_N;   // supply net GND_N
  bit openpa_ss_UNIT_ok; int unsigned openpa_ss_UNIT_ep; int openpa_ss_UNIT_st = -1; bit openpa_ss_UNIT_multi; int openpa_ss_UNIT_sim = 5; bit [6:0] openpa_ss_UNIT_a;   // supply set UNIT
  bit openpa_ss_HOST_ok; int unsigned openpa_ss_HOST_ep; int openpa_ss_HOST_st = -1; bit openpa_ss_HOST_multi; int openpa_ss_HOST_sim = 5;   // supply set HOST
  bit openpa_dom_PD_TOP_ok; int unsigned openpa_dom_PD_TOP_ep; int openpa_dom_PD_TOP_sim = 5;   // power domain PD_TOP: ok = powered (simstate not CORRUPT); sim = simstate code (buffer_soc.upf:3)
  bit openpa_dom_PD_UNIT_ok; int unsigned openpa_dom_PD_UNIT_ep; int openpa_dom_PD_UNIT_sim = 5; bit openpa_dom_PD_UNIT_lhit;   // power domain PD_UNIT: ok = powered (simstate not CORRUPT); sim = simstate code (buffer_soc.upf:4)
  // simstate codes, by IEEE 1801-2024 4.8 precedence: 0 NORMAL, 1 CORRUPT_STATE_ON_CHANGE, 2 CORRUPT_STATE_ON_ACTIVITY,
  // 3 CORRUPT_ON_CHANGE, 4 CORRUPT_ON_ACTIVITY, 5 CORRUPT (and NOT_NORMAL, 9.5.8); README "Simstates"
  function automatic logic [63:0] openpa_mix(int unsigned id, int unsigned ep, int unsigned lane);
    logic [63:0] z;
    if (openpa_cmode == 1) return 64'd0;
    if (openpa_cmode == 2) return ~64'd0;
    z = {32'd0, openpa_seed} * 64'h9E3779B97F4A7C15 + {32'd0, id} * 64'hC2B2AE3D27D4EB4F + {32'd0, ep} * 64'h165667B19E3779F9 + {32'd0, lane} * 64'hD6E8FEB86659FD93;
    z = (z ^ (z >> 30)) * 64'hBF58476D1CE4E5B9;
    z = (z ^ (z >> 27)) * 64'h94D049BB133111EB;
    return z ^ (z >> 31);
  endfunction
  function automatic bit openpa_bit(int unsigned id, int unsigned ep); logic [63:0] z; z = openpa_mix(id, ep, 0); return z[0]; endfunction
  function automatic int openpa_uv(real v); return $rtoi(v * 1.0e6 + (v < 0.0 ? -0.5 : 0.5)); endfunction
  // supply_on: FULL_ON at the given voltage (11.2.4; default 1.0 V)
  function automatic upfBooleanT supply_on(string pad_name, real value = 1.0);
    openpa_armed = 1;
    if (pad_name == "VHOST") begin openpa_port_VHOST.state = FULL_ON; openpa_port_VHOST.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VUNIT") begin openpa_port_VUNIT.state = FULL_ON; openpa_port_VUNIT.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VKEEP") begin openpa_port_VKEEP.state = FULL_ON; openpa_port_VKEEP.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = FULL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
    if (pad_name == "HOST_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST_N already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): UNIT_N already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): UNIT.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_UNIT.primary.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): KEEP_N already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): KEEP.power already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "GND_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): GND_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): UNIT.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): KEEP.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_UNIT.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_on(\"%s\"): no supply port or root supply net of that name (writable: VHOST VUNIT VKEEP VSS)", pad_name);
    return 0;
  endfunction
  // supply_off: OFF, voltage unchanged (9.3.1); a second argument is accepted and ignored
  function automatic upfBooleanT supply_off(string pad_name, real value = 0.0);
    openpa_armed = 1;
    if (pad_name == "VHOST") begin openpa_port_VHOST.state = OFF; return 1; end
    if (pad_name == "VUNIT") begin openpa_port_VUNIT.state = OFF; return 1; end
    if (pad_name == "VKEEP") begin openpa_port_VKEEP.state = OFF; return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = OFF; return 1; end
    if (pad_name == "HOST_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST_N already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): UNIT_N already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): UNIT.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_UNIT.primary.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): KEEP_N already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): KEEP.power already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "GND_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): GND_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): UNIT.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): KEEP.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_UNIT.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_off(\"%s\"): no supply port or root supply net of that name (writable: VHOST VUNIT VKEEP VSS)", pad_name);
    return 0;
  endfunction
  // supply_partial_on: PARTIAL_ON at the given voltage (11.2.4)
  function automatic upfBooleanT supply_partial_on(string pad_name, real value = 1.0);
    openpa_armed = 1;
    if (pad_name == "VHOST") begin openpa_port_VHOST.state = PARTIAL_ON; openpa_port_VHOST.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VUNIT") begin openpa_port_VUNIT.state = PARTIAL_ON; openpa_port_VUNIT.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VKEEP") begin openpa_port_VKEEP.state = PARTIAL_ON; openpa_port_VKEEP.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = PARTIAL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
    if (pad_name == "HOST_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST_N already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): UNIT_N already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): UNIT.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_UNIT.primary.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): KEEP_N already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): KEEP.power already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "GND_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): GND_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): UNIT.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): KEEP.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_UNIT.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_partial_on(\"%s\"): no supply port or root supply net of that name (writable: VHOST VUNIT VKEEP VSS)", pad_name);
    return 0;
  endfunction
  // set_supply_state: the state only, voltage unchanged (9.3.1)
  function automatic upfBooleanT set_supply_state(string pad_name, upfSupplyStateE supply_state);
    openpa_armed = 1;
    if (pad_name == "VHOST") begin openpa_port_VHOST.state = supply_state; return 1; end
    if (pad_name == "VUNIT") begin openpa_port_VUNIT.state = supply_state; return 1; end
    if (pad_name == "VKEEP") begin openpa_port_VKEEP.state = supply_state; return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = supply_state; return 1; end
    if (pad_name == "HOST_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST_N already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): UNIT_N already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): UNIT.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_UNIT.primary.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): KEEP_N already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): KEEP.power already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "GND_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): GND_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): UNIT.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): KEEP.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_UNIT.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR set_supply_state(\"%s\"): no supply port or root supply net of that name (writable: VHOST VUNIT VKEEP VSS)", pad_name);
    return 0;
  endfunction
  // set_power_state (9.3.1) is not supported: OpenPA has no deferred power states. A call is reported, never ignored.
  function automatic upfBooleanT set_power_state(string object_name, string power_state);
    $display("OPENPA-ERROR set_power_state(\"%s\", \"%s\"): not supported by OpenPA; drive the supplies with supply_on, supply_off or set_supply_state", object_name, power_state);
    return 0;
  endfunction
  // Supply queries (11.2.4). Names: supply ports, supply nets and supply set functions as the UPF wrote them.
  function automatic upfSupplyTypeT get_supply_value(string name);
    if (name == "VHOST" || name == "HOST_N" || name == "HOST.power" || name == "PD_TOP.primary.power") return openpa_net_HOST_N;
    if (name == "VUNIT" || name == "UNIT_N" || name == "UNIT.power" || name == "PD_UNIT.primary.power") return openpa_net_UNIT_N;
    if (name == "VKEEP" || name == "KEEP_N" || name == "KEEP.power") return openpa_net_KEEP_N;
    if (name == "VSS" || name == "GND_N" || name == "HOST.ground" || name == "UNIT.ground" || name == "KEEP.ground" || name == "PD_TOP.primary.ground" || name == "PD_UNIT.primary.ground") return openpa_net_GND_N;
    $display("OPENPA-ERROR get_supply_value(\"%s\"): no supply net, port or supply set function of that name", name);
    return 0;
  endfunction
  function automatic upfRealT get_supply_voltage(upfSupplyTypeT arg); return arg.voltage / 1.0e6; endfunction
  // 11.2.4: 1 for FULL_ON; 0 otherwise.
  function automatic upfBooleanT get_supply_on_state(upfSupplyTypeT arg); return arg.state == FULL_ON; endfunction
  function automatic upfSupplyStateE get_supply_state(upfSupplyTypeT arg); return arg.state; endfunction
endpackage
// ---------------------------------------------------------------------------
// OpenPA cells (generated; do not edit)
// ---------------------------------------------------------------------------
// openpa_corrupt: rule C2. Passes d while the driving domain is NORMAL; otherwise drives X (4-state)
// or a seeded value (2-state). The value is computed ahead for the episode the next power-down starts
// (ep + 1 while ok), so at power-down the output goes straight from d to the new value: no delta glitch
// through the previous episode's value (Icarus would turn one into a clock edge).
module openpa_corrupt #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           ok,
  input  int unsigned  ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  always @(ep or ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
  assign q = ok ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

// openpa_corrupt_sim: rule C2 for a domain that has intermediate simstates (IEEE 1801-2024 9.5). As
// openpa_corrupt, and also corrupt while lhit is set (CORRUPT_ON_ACTIVITY after input activity), or after d
// changed while coc is set (CORRUPT_ON_CHANGE); leaving CORRUPT_ON_CHANGE clears that.
module openpa_corrupt_sim #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           ok,
  input  int unsigned  ep,
  input  bit           lhit,
  input  bit           coc
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  bit chg;
  always @(ep or ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
  // verilator lint_off MULTIDRIVEN
  for (genvar i = 0; i < W; i++) begin : g_chg
    always @(posedge d[i] or negedge d[i]) if (coc && ok) chg = 1'b1;
  end
  always @(negedge coc) chg = 1'b0;
  // verilator lint_on MULTIDRIVEN
  assign q = (ok && !lhit && !chg) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

// openpa_iso: rules I1-I4 (IEEE 1801-2024 9.8). CLAMP 0, 1, 2 (latch: the value the input had while the enable
// was inactive) or 3 (Z: high impedance on 4-state; 0 on 2-state backends, which cannot represent Z).
// sup_ok is 1 while the isolation supply is NORMAL (always, for a strategy with no supply); otherwise the output,
// and a latched value, are corrupt. An enable at X or Z corrupts the output and the latched value.
module openpa_iso #(parameter int W = 1, parameter int CLAMP = 0, parameter bit SENSE = 1'b1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  logic         en,
  input  bit           sup_ok,
  input  int unsigned  sup_ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  logic [W-1:0] held;
  always @(sup_ep or sup_ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h4000_0000, sup_ok ? sup_ep + 1 : sup_ep, i);
  wire active   = (en === SENSE);
  wire inactive = (en === !SENSE);
  wire [W-1:0] bad    = UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0];
  if (CLAMP == 2) begin : g_latch
    always @(d or en or sup_ok or bad) if (!sup_ok || !(active || inactive)) held = bad; else if (inactive) held = d;
  end
  wire [W-1:0] clampv = (CLAMP == 3) ? (UPF::openpa_xmode ? {W{1'bz}} : {W{1'b0}}) : (CLAMP == 2) ? held : (CLAMP == 1) ? {W{1'b1}} : {W{1'b0}};
  assign q = !sup_ok ? bad : active ? clampv : inactive ? d : bad;
endmodule

// openpa_ls: rule L1 (IEEE 1801-2024 9.9). Passes d while every supply set of the cell is NORMAL; otherwise corrupt.
module openpa_ls #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           src_ok,
  input  bit           dst_ok,
  input  int unsigned  ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  always @(ep or src_ok or dst_ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h8000_0000, (src_ok && dst_ok) ? ep + 1 : ep, i);
  assign q = (src_ok && dst_ok) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

`line 1 "tile.sv" 0
module tile(input logic clk, wr, input logic [7:0] data,
  output logic [7:0] stored, output wire valid);
  always_ff @(posedge clk) if (wr) stored <= data;
  assign valid = wr;
endmodule
module buffer_soc(input logic clk,wr,input logic [7:0] data,output wire [7:0] stored,output wire valid);
  wire [7:0] openpa_u_slot_stored_raw; wire [0:0] openpa_u_slot_valid_raw; wire [0:0] openpa_u_slot_clk_s1; wire [7:0] openpa_u_slot_data_s1; wire [0:0] openpa_u_slot_wr_s1; tile u_slot(.clk(openpa_u_slot_clk_s1),.wr(openpa_u_slot_wr_s1),.data(openpa_u_slot_data_s1),.stored(openpa_u_slot_stored_raw),.valid(openpa_u_slot_valid_raw)); openpa_corrupt_sim #(.W(8), .ID(268435456)) openpa_u_slot_stored_cor (.d(openpa_u_slot_stored_raw), .q(stored), .ok(UPF::openpa_dom_PD_UNIT_ok), .ep(UPF::openpa_dom_PD_UNIT_ep), .lhit(UPF::openpa_dom_PD_UNIT_lhit), .coc(UPF::openpa_dom_PD_UNIT_sim == 3)); openpa_corrupt_sim #(.W(1), .ID(268435464)) openpa_u_slot_valid_cor (.d(openpa_u_slot_valid_raw), .q(valid), .ok(UPF::openpa_dom_PD_UNIT_ok), .ep(UPF::openpa_dom_PD_UNIT_ep), .lhit(UPF::openpa_dom_PD_UNIT_lhit), .coc(UPF::openpa_dom_PD_UNIT_sim == 3)); openpa_corrupt #(.W(1), .ID(268435472)) openpa_u_slot_clk_cor (.d(clk), .q(openpa_u_slot_clk_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(8), .ID(268435480)) openpa_u_slot_data_cor (.d(data), .q(openpa_u_slot_data_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435488)) openpa_u_slot_wr_cor (.d(wr), .q(openpa_u_slot_wr_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep));

`line 1 "openpa_overlay.sv" 0
  // ===================================================================================
  // OpenPA overlay for buffer_soc: generated from buffer_soc.upf. Do not edit.
  // ===================================================================================
  // verilator lint_off MULTIDRIVEN
  // verilator lint_off ENUMVALUE
  // verilator lint_off WIDTHTRUNC
  // verilator lint_off WIDTHEXPAND
  // verilator lint_off BLKSEQ
  // verilator lint_off IGNOREDRETURN
  import UPF::openpa_cmode;
  import UPF::openpa_dom_PD_TOP_ep;
  import UPF::openpa_dom_PD_TOP_ok;
  import UPF::openpa_dom_PD_TOP_sim;
  import UPF::openpa_dom_PD_UNIT_ep;
  import UPF::openpa_dom_PD_UNIT_lhit;
  import UPF::openpa_dom_PD_UNIT_ok;
  import UPF::openpa_dom_PD_UNIT_sim;
  import UPF::openpa_kick;
  import UPF::openpa_net_GND_N;
  import UPF::openpa_net_HOST_N;
  import UPF::openpa_net_KEEP_N;
  import UPF::openpa_net_UNIT_N;
  import UPF::openpa_seed;
  import UPF::openpa_ss_HOST_ep;
  import UPF::openpa_ss_HOST_multi;
  import UPF::openpa_ss_HOST_ok;
  import UPF::openpa_ss_HOST_sim;
  import UPF::openpa_ss_HOST_st;
  import UPF::openpa_ss_UNIT_a;
  import UPF::openpa_ss_UNIT_ep;
  import UPF::openpa_ss_UNIT_multi;
  import UPF::openpa_ss_UNIT_ok;
  import UPF::openpa_ss_UNIT_sim;
  import UPF::openpa_ss_UNIT_st;
  import UPF::openpa_xmode;
  // ---- mode, seed, trace
  bit openpa_tr, openpa_obs;
  int openpa_n [1:14];
  int openpa_seq [1:1];   // good-form sequence bins (coverage)
  bit openpa_sreq; bit openpa_sp [1:9];   // deferred checks: request and pending flags
  string openpa_mode_arg;
  initial begin
  `ifdef VERILATOR
    openpa_xmode = 1'b0;
  `else
    openpa_xmode = 1'b1;
  `endif
    openpa_cmode = 0;
    if ($value$plusargs("openpa_corrupt=%s", openpa_mode_arg)) begin
      if (openpa_mode_arg == "x") openpa_xmode = 1'b1;
      else if (openpa_mode_arg == "random") openpa_xmode = 1'b0;
      else if (openpa_mode_arg == "zero") begin openpa_xmode = 1'b0; openpa_cmode = 1; end
      else if (openpa_mode_arg == "one") begin openpa_xmode = 1'b0; openpa_cmode = 2; end
      else $display("OPENPA-ERROR +openpa_corrupt=%s: use x, random, zero or one", openpa_mode_arg);
    end
    if (!$value$plusargs("openpa_seed=%d", openpa_seed)) openpa_seed = 1;
    openpa_tr = $test$plusargs("openpa_trace");
    openpa_obs = $test$plusargs("openpa_obs");
    $display("OPENPA-INFO corruption=%0s seed=%0d", openpa_xmode ? "x" : (openpa_cmode == 1 ? "zero" : openpa_cmode == 2 ? "one" : "random"), openpa_seed);
    #0 openpa_kick = 1'b1;
  end
  task automatic openpa_check(input int id, input string msg);
    openpa_n[id] = openpa_n[id] + 1;
    $display("OPENPA-CHECK D%0d @ %0t: %s", id, $time, msg);
  endtask
  task automatic openpa_t(input string msg);
    if (openpa_tr) $display("OPENPA-TRACE @ %0t: %s", $time, msg);
  endtask

  // ---- copies of the design signals the UPF names (4-state, so X is visible)

  // ---- supply network, switches, supply sets, simstates, power states (one block, evaluated in order)
  bit openpa_tg_ss_UNIT_st; int openpa_pv_ss_UNIT_st = -2;
  bit openpa_tg_ss_UNIT_multi; int openpa_pv_ss_UNIT_multi = -2;
  bit openpa_tg_dom_PD_UNIT_sim; int openpa_pv_dom_PD_UNIT_sim = -2;
  always @(openpa_kick or UPF::openpa_port_VHOST or UPF::openpa_port_VUNIT or UPF::openpa_port_VKEEP or UPF::openpa_port_VSS) begin : openpa_network
    openpa_net_HOST_N = UPF::openpa_port_VHOST;   // HOST_N <- port VHOST
    openpa_net_UNIT_N = UPF::openpa_port_VUNIT;   // UNIT_N <- port VUNIT
    openpa_net_KEEP_N = UPF::openpa_port_VKEEP;   // KEEP_N <- port VKEEP
    openpa_net_GND_N = UPF::openpa_port_VSS;   // GND_N <- port VSS
    // supply set HOST (also PD_TOP.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_HOST
      bit nx; int sm;
      sm = (UPF::openpa_net_HOST_N.state == UPF::FULL_ON && UPF::openpa_net_GND_N.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_HOST_sim = sm;
      nx = sm < 5;
      if (openpa_ss_HOST_ok && !nx) openpa_ss_HOST_ep = openpa_ss_HOST_ep + 1;
      openpa_ss_HOST_ok = nx;
    end
    // supply set UNIT (also PD_UNIT.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_UNIT
      bit nx; int sm;
      openpa_ss_UNIT_a = '0; openpa_ss_UNIT_st = -1;
      begin int dm; dm = -1;
        openpa_ss_UNIT_a[0] = ((UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_UNIT_N.voltage == 1000000));   // Band0
        if (openpa_ss_UNIT_a[0] && 0 > dm) begin dm = 0; openpa_ss_UNIT_st = 0; end
        openpa_ss_UNIT_a[1] = ((UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_UNIT_N.voltage == 950000));   // Band1
        if (openpa_ss_UNIT_a[1] && 0 > dm) begin dm = 0; openpa_ss_UNIT_st = 1; end
        openpa_ss_UNIT_a[2] = ((UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_UNIT_N.voltage == 900000));   // Band2
        if (openpa_ss_UNIT_a[2] && 0 > dm) begin dm = 0; openpa_ss_UNIT_st = 2; end
        openpa_ss_UNIT_a[3] = ((UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_UNIT_N.voltage == 850000));   // Band3
        if (openpa_ss_UNIT_a[3] && 0 > dm) begin dm = 0; openpa_ss_UNIT_st = 3; end
        openpa_ss_UNIT_a[4] = ((UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_UNIT_N.voltage == 800000));   // Band4
        if (openpa_ss_UNIT_a[4] && 0 > dm) begin dm = 0; openpa_ss_UNIT_st = 4; end
        openpa_ss_UNIT_a[5] = ((UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_UNIT_N.voltage == 750000));   // Band5
        if (openpa_ss_UNIT_a[5] && 0 > dm) begin dm = 0; openpa_ss_UNIT_st = 5; end
        openpa_ss_UNIT_a[6] = ((UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_UNIT_N.voltage == 700000));   // Band6
        if (openpa_ss_UNIT_a[6] && 0 > dm) begin dm = 0; openpa_ss_UNIT_st = 6; end
      end
      openpa_ss_UNIT_multi = (openpa_ss_UNIT_a[0] + openpa_ss_UNIT_a[1] + openpa_ss_UNIT_a[2] + openpa_ss_UNIT_a[3] + openpa_ss_UNIT_a[4] + openpa_ss_UNIT_a[5] + openpa_ss_UNIT_a[6]) > 1;
      sm = (UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_GND_N.state == UPF::FULL_ON) ? 0 : -1;
      if (openpa_ss_UNIT_a[0] && 0 > sm) sm = 0;   // Band0 NORMAL
      if (openpa_ss_UNIT_a[1] && 1 > sm) sm = 1;   // Band1 CORRUPT_STATE_ON_CHANGE
      if (openpa_ss_UNIT_a[2] && 2 > sm) sm = 2;   // Band2 CORRUPT_STATE_ON_ACTIVITY
      if (openpa_ss_UNIT_a[3] && 3 > sm) sm = 3;   // Band3 CORRUPT_ON_CHANGE
      if (openpa_ss_UNIT_a[4] && 4 > sm) sm = 4;   // Band4 CORRUPT_ON_ACTIVITY
      if (openpa_ss_UNIT_a[5] && 5 > sm) sm = 5;   // Band5 NOT_NORMAL
      if (openpa_ss_UNIT_a[6] && 5 > sm) sm = 5;   // Band6 CORRUPT
      if (sm < 0) sm = 5;
      openpa_ss_UNIT_sim = sm;
      nx = sm < 5;
      if (openpa_ss_UNIT_ok && !nx) openpa_ss_UNIT_ep = openpa_ss_UNIT_ep + 1;
      openpa_ss_UNIT_ok = nx;
    end
    // domain PD_TOP: simstate of its primary supply set HOST
    if (openpa_dom_PD_TOP_ok && !UPF::openpa_ss_HOST_ok) openpa_dom_PD_TOP_ep = openpa_dom_PD_TOP_ep + 1;
    openpa_dom_PD_TOP_ok = UPF::openpa_ss_HOST_ok;
    openpa_dom_PD_TOP_sim = openpa_ss_HOST_sim;
    // domain PD_UNIT: simstate of its primary supply set UNIT
    if (openpa_dom_PD_UNIT_ok && !UPF::openpa_ss_UNIT_ok) openpa_dom_PD_UNIT_ep = openpa_dom_PD_UNIT_ep + 1;
    openpa_dom_PD_UNIT_ok = UPF::openpa_ss_UNIT_ok;
    openpa_dom_PD_UNIT_sim = openpa_ss_UNIT_sim;
    if (openpa_ss_UNIT_st != openpa_pv_ss_UNIT_st) begin openpa_tg_ss_UNIT_st = ~openpa_tg_ss_UNIT_st; openpa_pv_ss_UNIT_st = openpa_ss_UNIT_st; end
    if (openpa_ss_UNIT_multi != openpa_pv_ss_UNIT_multi) begin openpa_tg_ss_UNIT_multi = ~openpa_tg_ss_UNIT_multi; openpa_pv_ss_UNIT_multi = openpa_ss_UNIT_multi; end
    if (openpa_dom_PD_UNIT_sim != openpa_pv_dom_PD_UNIT_sim) begin openpa_tg_dom_PD_UNIT_sim = ~openpa_tg_dom_PD_UNIT_sim; openpa_pv_dom_PD_UNIT_sim = openpa_dom_PD_UNIT_sim; end
  end

  // ---- corruption: registers forced, memories overwritten (rules C1, C3)
  // domain PD_TOP (buffer_soc.upf:3): 0 register(s), 0 memory(ies)
  bit openpa_PD_TOP_applied, openpa_PD_TOP_valid;
  // The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
  // supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
  always @(UPF::openpa_dom_PD_TOP_ok or openpa_kick) if (!openpa_PD_TOP_valid || openpa_PD_TOP_applied != UPF::openpa_dom_PD_TOP_ok) begin
    openpa_t({"PD_TOP ", UPF::openpa_dom_PD_TOP_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_PD_TOP_ok || !openpa_PD_TOP_valid) begin
    end
    if (UPF::openpa_dom_PD_TOP_ok) begin
    end
    openpa_PD_TOP_valid = 1'b1; openpa_PD_TOP_applied = UPF::openpa_dom_PD_TOP_ok;
  end
  // domain PD_UNIT (buffer_soc.upf:4): 1 register(s), 0 memory(ies)
  bit openpa_PD_UNIT_applied, openpa_PD_UNIT_valid;
  logic [7:0] openpa_cv1;   // corruption value for u_slot.stored
  // The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
  // supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
  always @(UPF::openpa_dom_PD_UNIT_ok or openpa_kick) if (!openpa_PD_UNIT_valid || openpa_PD_UNIT_applied != UPF::openpa_dom_PD_UNIT_ok) begin
    openpa_t({"PD_UNIT ", UPF::openpa_dom_PD_UNIT_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_PD_UNIT_ok || !openpa_PD_UNIT_valid) begin
      if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_PD_UNIT_ep, 0);
      force u_slot.stored = openpa_cv1;
    end
    if (UPF::openpa_dom_PD_UNIT_ok) begin
      release u_slot.stored;
    end
    openpa_PD_UNIT_valid = 1'b1; openpa_PD_UNIT_applied = UPF::openpa_dom_PD_UNIT_ok;
  end
  // simstates of PD_UNIT: CORRUPT_STATE_ON_CHANGE, CORRUPT_STATE_ON_ACTIVITY, CORRUPT_ON_CHANGE, CORRUPT_ON_ACTIVITY
  bit openpa_PD_UNIT_shit;   // state corrupted by activity in CORRUPT_STATE_ON_ACTIVITY or CORRUPT_ON_ACTIVITY
  bit openpa_PD_UNIT_rh0; wire [7:0] openpa_PD_UNIT_rw0 = u_slot.stored;
  wire [0:0] openpa_PD_UNIT_in0 = u_slot.clk;
  wire [0:0] openpa_PD_UNIT_in1 = u_slot.wr;
  wire [7:0] openpa_PD_UNIT_in2 = u_slot.data;
  always @(posedge openpa_tg_dom_PD_UNIT_sim or negedge openpa_tg_dom_PD_UNIT_sim) if (UPF::openpa_dom_PD_UNIT_sim == 0 || UPF::openpa_dom_PD_UNIT_sim >= 5) begin
    if (UPF::openpa_dom_PD_UNIT_sim == 0) begin
      if (openpa_PD_UNIT_shit || openpa_PD_UNIT_rh0) release u_slot.stored;
    end
    openpa_PD_UNIT_shit = 1'b0; openpa_dom_PD_UNIT_lhit = 1'b0; openpa_PD_UNIT_rh0 = 1'b0;
  end
  always @(posedge openpa_PD_UNIT_in0 or negedge openpa_PD_UNIT_in0 or posedge openpa_PD_UNIT_in1 or negedge openpa_PD_UNIT_in1 or posedge openpa_PD_UNIT_in2[0] or negedge openpa_PD_UNIT_in2[0] or posedge openpa_PD_UNIT_in2[1] or negedge openpa_PD_UNIT_in2[1] or posedge openpa_PD_UNIT_in2[2] or negedge openpa_PD_UNIT_in2[2] or posedge openpa_PD_UNIT_in2[3] or negedge openpa_PD_UNIT_in2[3] or posedge openpa_PD_UNIT_in2[4] or negedge openpa_PD_UNIT_in2[4] or posedge openpa_PD_UNIT_in2[5] or negedge openpa_PD_UNIT_in2[5] or posedge openpa_PD_UNIT_in2[6] or negedge openpa_PD_UNIT_in2[6] or posedge openpa_PD_UNIT_in2[7] or negedge openpa_PD_UNIT_in2[7])
    if (UPF::openpa_dom_PD_UNIT_ok && (UPF::openpa_dom_PD_UNIT_sim == 2 || UPF::openpa_dom_PD_UNIT_sim == 4) && !openpa_PD_UNIT_shit) begin
      openpa_PD_UNIT_shit = 1'b1; if (UPF::openpa_dom_PD_UNIT_sim == 4) openpa_dom_PD_UNIT_lhit = 1'b1;
      openpa_t({"PD_UNIT input activity in ", UPF::openpa_dom_PD_UNIT_sim == 4 ? "CORRUPT_ON_ACTIVITY" : "CORRUPT_STATE_ON_ACTIVITY", ": state corrupted"});
      if (UPF::openpa_dom_PD_UNIT_sim == 4) begin
        if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_PD_UNIT_ep, 0);
        force u_slot.stored = openpa_cv1;
        openpa_PD_UNIT_rh0 = 1'b1;
      end
    end
  always @(posedge u_slot.clk)
    if (UPF::openpa_dom_PD_UNIT_ok && UPF::openpa_dom_PD_UNIT_sim == 2 && !openpa_PD_UNIT_rh0) begin
      openpa_PD_UNIT_rh0 = 1'b1; openpa_t("PD_UNIT u_slot.stored: clock activity in CORRUPT_STATE_ON_ACTIVITY: corrupted");
      if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_PD_UNIT_ep, 0);
      force u_slot.stored = openpa_cv1;
    end
  always @(posedge openpa_PD_UNIT_rw0[0] or negedge openpa_PD_UNIT_rw0[0] or posedge openpa_PD_UNIT_rw0[1] or negedge openpa_PD_UNIT_rw0[1] or posedge openpa_PD_UNIT_rw0[2] or negedge openpa_PD_UNIT_rw0[2] or posedge openpa_PD_UNIT_rw0[3] or negedge openpa_PD_UNIT_rw0[3] or posedge openpa_PD_UNIT_rw0[4] or negedge openpa_PD_UNIT_rw0[4] or posedge openpa_PD_UNIT_rw0[5] or negedge openpa_PD_UNIT_rw0[5] or posedge openpa_PD_UNIT_rw0[6] or negedge openpa_PD_UNIT_rw0[6] or posedge openpa_PD_UNIT_rw0[7] or negedge openpa_PD_UNIT_rw0[7])
    if (UPF::openpa_dom_PD_UNIT_ok && (UPF::openpa_dom_PD_UNIT_sim == 1 || UPF::openpa_dom_PD_UNIT_sim == 3) && !openpa_PD_UNIT_rh0 && !openpa_PD_UNIT_shit) begin
      openpa_PD_UNIT_rh0 = 1'b1; openpa_t("PD_UNIT u_slot.stored changed in a CORRUPT_*_ON_CHANGE simstate: corrupted");
      if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_PD_UNIT_ep, 0);
      force u_slot.stored = openpa_cv1;
    end
  // crossing 1: u_slot/stored (PD_UNIT) -> buffer_soc output stored (PD_TOP), not isolated
  bit openpa_x1_t;
  always @(UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_UNIT_N or UPF::openpa_net_GND_N) openpa_x1_t = !UPF::openpa_dom_PD_UNIT_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_UNIT_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x1_t)
    begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 2: u_slot/valid (PD_UNIT) -> buffer_soc output valid (PD_TOP), not isolated
  bit openpa_x2_t;
  always @(UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_UNIT_N or UPF::openpa_net_GND_N) openpa_x2_t = !UPF::openpa_dom_PD_UNIT_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_UNIT_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x2_t)
    begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 3: buffer_soc input clk (PD_TOP) -> u_slot/clk (PD_UNIT), not isolated
  bit openpa_x3_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_net_HOST_N or UPF::openpa_net_GND_N) openpa_x3_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_UNIT_ok && !(1'b0) && !(UPF::openpa_net_HOST_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x3_t)
    begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 4: buffer_soc input data (PD_TOP) -> u_slot/data (PD_UNIT), not isolated
  bit openpa_x4_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_net_HOST_N or UPF::openpa_net_GND_N) openpa_x4_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_UNIT_ok && !(1'b0) && !(UPF::openpa_net_HOST_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x4_t)
    begin openpa_sp[4] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 5: buffer_soc input wr (PD_TOP) -> u_slot/wr (PD_UNIT), not isolated
  bit openpa_x5_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_net_HOST_N or UPF::openpa_net_GND_N) openpa_x5_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_UNIT_ok && !(1'b0) && !(UPF::openpa_net_HOST_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x5_t)
    begin openpa_sp[5] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 1: PD_UNIT -> PD_TOP (no level shifter strategy, threshold 0)
  bit openpa_l1_t;
  always @(UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_UNIT_N or UPF::openpa_net_HOST_N) openpa_l1_t = UPF::openpa_dom_PD_UNIT_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_UNIT_N.voltage - UPF::openpa_net_HOST_N.voltage > 0 || UPF::openpa_net_HOST_N.voltage - UPF::openpa_net_UNIT_N.voltage > 0) && !1'b0;
  always @(posedge openpa_l1_t)
    begin openpa_sp[6] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 2: PD_TOP -> PD_UNIT (no level shifter strategy, threshold 0)
  bit openpa_l2_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_net_HOST_N or UPF::openpa_net_UNIT_N) openpa_l2_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_UNIT_ok && (UPF::openpa_net_HOST_N.voltage - UPF::openpa_net_UNIT_N.voltage > 0 || UPF::openpa_net_UNIT_N.voltage - UPF::openpa_net_HOST_N.voltage > 0) && !1'b0;
  always @(posedge openpa_l2_t)
    begin openpa_sp[7] = 1'b1; openpa_sreq = 1'b1; end

  // ---- power states (D8): checked once the bench has driven a supply, after the time step settles
  always @(posedge openpa_tg_ss_UNIT_st or negedge openpa_tg_ss_UNIT_st or posedge openpa_tg_ss_UNIT_multi or negedge openpa_tg_ss_UNIT_multi or posedge UPF::openpa_armed) if (UPF::openpa_armed)
    begin openpa_sp[8] = 1'b1; openpa_sreq = 1'b1; end
  always @(posedge openpa_tg_ss_UNIT_st or negedge openpa_tg_ss_UNIT_st) if (openpa_tr) openpa_t($sformatf("UNIT state %0s", (UPF::openpa_ss_UNIT_st == 0) ? "Band0" : (UPF::openpa_ss_UNIT_st == 1) ? "Band1" : (UPF::openpa_ss_UNIT_st == 2) ? "Band2" : (UPF::openpa_ss_UNIT_st == 3) ? "Band3" : (UPF::openpa_ss_UNIT_st == 4) ? "Band4" : (UPF::openpa_ss_UNIT_st == 5) ? "Band5" : (UPF::openpa_ss_UNIT_st == 6) ? "Band6" : "<none>"));
  int openpa_cs1 [0:7]; int openpa_ct1 [0:7][0:7]; int openpa_cp1 = -1, openpa_cc1;   // coverage of supply set UNIT
  function automatic string openpa_cn1(int i); case (i) 0: return "Band0"; 1: return "Band1"; 2: return "Band2"; 3: return "Band3"; 4: return "Band4"; 5: return "Band5"; 6: return "Band6"; default: return "<none>"; endcase endfunction
  always @(posedge openpa_tg_ss_UNIT_st or negedge openpa_tg_ss_UNIT_st or posedge UPF::openpa_armed) if (UPF::openpa_armed)
    begin openpa_sp[9] = 1'b1; openpa_sreq = 1'b1; end

  // ---- observation for differential corruption (+openpa_obs): design-top outputs while the top domain is on
  `ifdef OPENPA_OBS
  longint openpa_obs_after;
  initial if (!$value$plusargs("openpa_obs_after=%d", openpa_obs_after)) openpa_obs_after = 0;
  always @(stored) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: stored=%h", $time, stored);
  always @(valid) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: valid=%h", $time, valid);
  `else
  initial if ($test$plusargs("openpa_obs")) $display("OPENPA-ERROR +openpa_obs needs the copy compiled with OPENPA_OBS defined (-DOPENPA_OBS or +define+OPENPA_OBS)");
  `endif

  // Icarus 12 runs no named block inside a final block, so the report is a function.
  function automatic void openpa_cover_report();
      int hs, ht, hq;
      hs = 0; ht = 0; hq = 0;
      $display("OPENPA-COVER state supply_set UNIT Band0 %0d", openpa_cs1[0]);
      $display("OPENPA-COVER state supply_set UNIT Band1 %0d", openpa_cs1[1]);
      $display("OPENPA-COVER state supply_set UNIT Band2 %0d", openpa_cs1[2]);
      $display("OPENPA-COVER state supply_set UNIT Band3 %0d", openpa_cs1[3]);
      $display("OPENPA-COVER state supply_set UNIT Band4 %0d", openpa_cs1[4]);
      $display("OPENPA-COVER state supply_set UNIT Band5 %0d", openpa_cs1[5]);
      $display("OPENPA-COVER state supply_set UNIT Band6 %0d", openpa_cs1[6]);
      if (openpa_cs1[7]) $display("OPENPA-COVER state supply_set UNIT <none> %0d", openpa_cs1[7]);
      for (int i = 0; i <= 7; i++) for (int j = 0; j <= 7; j++) if (openpa_ct1[i][j]) $display("OPENPA-COVER transition supply_set UNIT %0s -> %0s %0d", openpa_cn1(i), openpa_cn1(j), openpa_ct1[i][j]);
      if (openpa_cs1[0]) hs = hs + 1;
      if (openpa_cs1[1]) hs = hs + 1;
      if (openpa_cs1[2]) hs = hs + 1;
      if (openpa_cs1[3]) hs = hs + 1;
      if (openpa_cs1[4]) hs = hs + 1;
      if (openpa_cs1[5]) hs = hs + 1;
      if (openpa_cs1[6]) hs = hs + 1;
      $display("OPENPA-COVER-SUMMARY states=%0d/7 declared_transitions=%0d/0 sequences=%0d/0", hs, ht, hq);
  endfunction

  // ---- settle process: 9 deferred check(s), run after one #0 in a fixed order
  initial forever begin
    wait (openpa_sreq && openpa_kick);
    #0;
    openpa_sreq = 1'b0;
    if (openpa_sp[1]) begin
      openpa_sp[1] = 1'b0;
      if (openpa_x1_t) openpa_check(9, "u_slot/stored of PD_UNIT (off) is read by buffer_soc output stored in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[2]) begin
      openpa_sp[2] = 1'b0;
      if (openpa_x2_t) openpa_check(9, "u_slot/valid of PD_UNIT (off) is read by buffer_soc output valid in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[3]) begin
      openpa_sp[3] = 1'b0;
      if (openpa_x3_t) openpa_check(9, "buffer_soc input clk of PD_TOP (off) is read by u_slot/clk in PD_UNIT (on) with no active isolation");
    end
    if (openpa_sp[4]) begin
      openpa_sp[4] = 1'b0;
      if (openpa_x4_t) openpa_check(9, "buffer_soc input data of PD_TOP (off) is read by u_slot/data in PD_UNIT (on) with no active isolation");
    end
    if (openpa_sp[5]) begin
      openpa_sp[5] = 1'b0;
      if (openpa_x5_t) openpa_check(9, "buffer_soc input wr of PD_TOP (off) is read by u_slot/wr in PD_UNIT (on) with no active isolation");
    end
    if (openpa_sp[6]) begin
      openpa_sp[6] = 1'b0;
      if (openpa_l1_t) openpa_check(11, $sformatf("PD_UNIT (%0d uV) drives PD_TOP (%0d uV) on 2 port(s) with no level shifter for this direction", UPF::openpa_net_UNIT_N.voltage, UPF::openpa_net_HOST_N.voltage));
    end
    if (openpa_sp[7]) begin
      openpa_sp[7] = 1'b0;
      if (openpa_l2_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_UNIT (%0d uV) on 3 port(s) with no level shifter for this direction", UPF::openpa_net_HOST_N.voltage, UPF::openpa_net_UNIT_N.voltage));
    end
    if (openpa_sp[8]) begin
      openpa_sp[8] = 1'b0;
        if (!1'b0)   // suspended while a power switch is undetermined (D10 reports that)
        begin
          if (UPF::openpa_ss_UNIT_multi) openpa_check(8, "supply set UNIT: more than one power state holds (the ERROR state)");
        end
    end
    if (openpa_sp[9]) begin
      openpa_sp[9] = 1'b0;
        if (!1'b0) begin
          openpa_cc1 = (UPF::openpa_ss_UNIT_st < 0) ? 7 : UPF::openpa_ss_UNIT_st;
          if (openpa_cc1 != openpa_cp1) begin
            openpa_cs1[openpa_cc1] = openpa_cs1[openpa_cc1] + 1;
            if (openpa_cp1 >= 0) openpa_ct1[openpa_cp1][openpa_cc1] = openpa_ct1[openpa_cp1][openpa_cc1] + 1;
            openpa_cp1 = openpa_cc1;
          end
        end
    end
  end
  final begin
    $display("OPENPA-SUMMARY D1=%0d D2=%0d D3=%0d D4=%0d D5=%0d D6=%0d D7=%0d D8=%0d D9=%0d D10=%0d D11=%0d D12=%0d D13=%0d D14=%0d", openpa_n[1], openpa_n[2], openpa_n[3], openpa_n[4], openpa_n[5], openpa_n[6], openpa_n[7], openpa_n[8], openpa_n[9], openpa_n[10], openpa_n[11], openpa_n[12], openpa_n[13], openpa_n[14]);
    openpa_cover_report();
    if (!UPF::openpa_armed) $display("OPENPA-WARNING no supply was driven (supply_on/supply_off never called): every domain stayed CORRUPT");
  end
  // verilator lint_on MULTIDRIVEN
`line 8 "tile.sv" 0
endmodule
Predict the outputWith instance corruption disabled, what does new_word print?
`timescale 1ns/1ps
module tb;
 import UPF::*;
 logic clk=0,wr=0; logic [7:0] data=0;
 wire [7:0] stored; wire valid;
 buffer_soc dut(.*);
 task tick; #1 clk=1; #1 clk=0; #1; endtask
 task sample(input string phase);
   $display("%s mode=%0d wr=%b valid=%b stored=%h",phase,openpa_dom_PD_UNIT_sim,wr,valid,stored);
 endtask
 initial begin
   void'(supply_on("VHOST")); void'(supply_on("VSS",0.0)); void'(supply_on("VUNIT"));
   #2; wr=1; data=8'h39; tick; wr=0; #1; sample("loaded");
   void'(supply_on("VUNIT",0.65)); #2; sample("entry");
   tick; sample("idle_edge");
   wr=1; #1; sample("data_edge");
   tick; sample("same_word");
   data=~data; tick; sample("new_word");
   void'(supply_on("VUNIT")); #2; sample("back");
   tick; sample("rewritten"); $finish;
 end
endmodule
Read included file: pa_buffer_soc.sv
// pa_buffer_soc.sv: power-aware copy of buffer_soc, generated by OpenPA from buffer_soc.upf.
// Do not edit: regenerate. Simulators: Icarus 12 (4-state, X corruption) or Verilator 5 with --timing (2-state).
// Build with -Wno-fatal on Verilator: forced registers raise MULTIDRIVEN warnings.
`timescale 1ns/1ps
// ---------------------------------------------------------------------------
// package UPF: generated by OpenPA. Supply types, supply_on/supply_off and the power
// state of the design. Names starting with openpa_ are internal.
// ---------------------------------------------------------------------------
package UPF;
  typedef string upfStringT; typedef int upfIntegerT; typedef bit upfBooleanT; typedef logic upfLogicT; typedef real upfRealT; typedef int upfHandleT;
  typedef enum { OFF, FULL_ON, PARTIAL_ON, UNDETERMINED } upfSupplyStateE;
  typedef struct packed { upfSupplyStateE state; int voltage; } upfSupplyTypeT;  // voltage in microvolts
  typedef upfSupplyTypeT supply_net_type;
  bit openpa_armed;        // set by the first call that drives a supply
  bit openpa_kick;         // pulsed once at time 0 to evaluate everything
  bit openpa_xmode;        // 1: corrupt to X; 0: seeded 2-state values
  int unsigned openpa_seed = 1;
  int openpa_cmode;        // 2-state corruption: 0 random, 1 all zero, 2 all one
  supply_net_type openpa_port_VHOST;   // supply port VHOST (buffer_soc.upf:5)
  supply_net_type openpa_port_VUNIT;   // supply port VUNIT (buffer_soc.upf:8)
  supply_net_type openpa_port_VKEEP;   // supply port VKEEP (buffer_soc.upf:11)
  supply_net_type openpa_port_VSS;   // supply port VSS (buffer_soc.upf:14)
  supply_net_type openpa_net_HOST_N;   // supply net HOST_N
  supply_net_type openpa_net_UNIT_N;   // supply net UNIT_N
  supply_net_type openpa_net_KEEP_N;   // supply net KEEP_N
  supply_net_type openpa_net_GND_N;   // supply net GND_N
  bit openpa_ss_UNIT_ok; int unsigned openpa_ss_UNIT_ep; int openpa_ss_UNIT_st = -1; bit openpa_ss_UNIT_multi; int openpa_ss_UNIT_sim = 5; bit [1:0] openpa_ss_UNIT_a;   // supply set UNIT
  bit openpa_ss_HOST_ok; int unsigned openpa_ss_HOST_ep; int openpa_ss_HOST_st = -1; bit openpa_ss_HOST_multi; int openpa_ss_HOST_sim = 5;   // supply set HOST
  bit openpa_dom_PD_TOP_ok; int unsigned openpa_dom_PD_TOP_ep; int openpa_dom_PD_TOP_sim = 5;   // power domain PD_TOP: ok = powered (simstate not CORRUPT); sim = simstate code (buffer_soc.upf:3)
  bit openpa_dom_PD_UNIT_ok; int unsigned openpa_dom_PD_UNIT_ep; int openpa_dom_PD_UNIT_sim = 5;   // power domain PD_UNIT: ok = powered (simstate not CORRUPT); sim = simstate code (buffer_soc.upf:4)
  // simstate codes, by IEEE 1801-2024 4.8 precedence: 0 NORMAL, 1 CORRUPT_STATE_ON_CHANGE, 2 CORRUPT_STATE_ON_ACTIVITY,
  // 3 CORRUPT_ON_CHANGE, 4 CORRUPT_ON_ACTIVITY, 5 CORRUPT (and NOT_NORMAL, 9.5.8); README "Simstates"
  function automatic logic [63:0] openpa_mix(int unsigned id, int unsigned ep, int unsigned lane);
    logic [63:0] z;
    if (openpa_cmode == 1) return 64'd0;
    if (openpa_cmode == 2) return ~64'd0;
    z = {32'd0, openpa_seed} * 64'h9E3779B97F4A7C15 + {32'd0, id} * 64'hC2B2AE3D27D4EB4F + {32'd0, ep} * 64'h165667B19E3779F9 + {32'd0, lane} * 64'hD6E8FEB86659FD93;
    z = (z ^ (z >> 30)) * 64'hBF58476D1CE4E5B9;
    z = (z ^ (z >> 27)) * 64'h94D049BB133111EB;
    return z ^ (z >> 31);
  endfunction
  function automatic bit openpa_bit(int unsigned id, int unsigned ep); logic [63:0] z; z = openpa_mix(id, ep, 0); return z[0]; endfunction
  function automatic int openpa_uv(real v); return $rtoi(v * 1.0e6 + (v < 0.0 ? -0.5 : 0.5)); endfunction
  // supply_on: FULL_ON at the given voltage (11.2.4; default 1.0 V)
  function automatic upfBooleanT supply_on(string pad_name, real value = 1.0);
    openpa_armed = 1;
    if (pad_name == "VHOST") begin openpa_port_VHOST.state = FULL_ON; openpa_port_VHOST.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VUNIT") begin openpa_port_VUNIT.state = FULL_ON; openpa_port_VUNIT.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VKEEP") begin openpa_port_VKEEP.state = FULL_ON; openpa_port_VKEEP.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = FULL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
    if (pad_name == "HOST_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST_N already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): UNIT_N already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): UNIT.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_UNIT.primary.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): KEEP_N already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): KEEP.power already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "GND_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): GND_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): UNIT.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): KEEP.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_UNIT.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_on(\"%s\"): no supply port or root supply net of that name (writable: VHOST VUNIT VKEEP VSS)", pad_name);
    return 0;
  endfunction
  // supply_off: OFF, voltage unchanged (9.3.1); a second argument is accepted and ignored
  function automatic upfBooleanT supply_off(string pad_name, real value = 0.0);
    openpa_armed = 1;
    if (pad_name == "VHOST") begin openpa_port_VHOST.state = OFF; return 1; end
    if (pad_name == "VUNIT") begin openpa_port_VUNIT.state = OFF; return 1; end
    if (pad_name == "VKEEP") begin openpa_port_VKEEP.state = OFF; return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = OFF; return 1; end
    if (pad_name == "HOST_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST_N already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): UNIT_N already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): UNIT.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_UNIT.primary.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): KEEP_N already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): KEEP.power already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "GND_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): GND_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): UNIT.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): KEEP.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_UNIT.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_off(\"%s\"): no supply port or root supply net of that name (writable: VHOST VUNIT VKEEP VSS)", pad_name);
    return 0;
  endfunction
  // supply_partial_on: PARTIAL_ON at the given voltage (11.2.4)
  function automatic upfBooleanT supply_partial_on(string pad_name, real value = 1.0);
    openpa_armed = 1;
    if (pad_name == "VHOST") begin openpa_port_VHOST.state = PARTIAL_ON; openpa_port_VHOST.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VUNIT") begin openpa_port_VUNIT.state = PARTIAL_ON; openpa_port_VUNIT.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VKEEP") begin openpa_port_VKEEP.state = PARTIAL_ON; openpa_port_VKEEP.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = PARTIAL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
    if (pad_name == "HOST_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST_N already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): UNIT_N already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): UNIT.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_UNIT.primary.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): KEEP_N already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): KEEP.power already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "GND_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): GND_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): UNIT.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): KEEP.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_UNIT.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_partial_on(\"%s\"): no supply port or root supply net of that name (writable: VHOST VUNIT VKEEP VSS)", pad_name);
    return 0;
  endfunction
  // set_supply_state: the state only, voltage unchanged (9.3.1)
  function automatic upfBooleanT set_supply_state(string pad_name, upfSupplyStateE supply_state);
    openpa_armed = 1;
    if (pad_name == "VHOST") begin openpa_port_VHOST.state = supply_state; return 1; end
    if (pad_name == "VUNIT") begin openpa_port_VUNIT.state = supply_state; return 1; end
    if (pad_name == "VKEEP") begin openpa_port_VKEEP.state = supply_state; return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = supply_state; return 1; end
    if (pad_name == "HOST_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST_N already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): UNIT_N already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): UNIT.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_UNIT.primary.power already has a driver (port VUNIT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): KEEP_N already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): KEEP.power already has a driver (port VKEEP); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "GND_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): GND_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "UNIT.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): UNIT.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "KEEP.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): KEEP.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_UNIT.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_UNIT.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR set_supply_state(\"%s\"): no supply port or root supply net of that name (writable: VHOST VUNIT VKEEP VSS)", pad_name);
    return 0;
  endfunction
  // set_power_state (9.3.1) is not supported: OpenPA has no deferred power states. A call is reported, never ignored.
  function automatic upfBooleanT set_power_state(string object_name, string power_state);
    $display("OPENPA-ERROR set_power_state(\"%s\", \"%s\"): not supported by OpenPA; drive the supplies with supply_on, supply_off or set_supply_state", object_name, power_state);
    return 0;
  endfunction
  // Supply queries (11.2.4). Names: supply ports, supply nets and supply set functions as the UPF wrote them.
  function automatic upfSupplyTypeT get_supply_value(string name);
    if (name == "VHOST" || name == "HOST_N" || name == "HOST.power" || name == "PD_TOP.primary.power") return openpa_net_HOST_N;
    if (name == "VUNIT" || name == "UNIT_N" || name == "UNIT.power" || name == "PD_UNIT.primary.power") return openpa_net_UNIT_N;
    if (name == "VKEEP" || name == "KEEP_N" || name == "KEEP.power") return openpa_net_KEEP_N;
    if (name == "VSS" || name == "GND_N" || name == "HOST.ground" || name == "UNIT.ground" || name == "KEEP.ground" || name == "PD_TOP.primary.ground" || name == "PD_UNIT.primary.ground") return openpa_net_GND_N;
    $display("OPENPA-ERROR get_supply_value(\"%s\"): no supply net, port or supply set function of that name", name);
    return 0;
  endfunction
  function automatic upfRealT get_supply_voltage(upfSupplyTypeT arg); return arg.voltage / 1.0e6; endfunction
  // 11.2.4: 1 for FULL_ON; 0 otherwise.
  function automatic upfBooleanT get_supply_on_state(upfSupplyTypeT arg); return arg.state == FULL_ON; endfunction
  function automatic upfSupplyStateE get_supply_state(upfSupplyTypeT arg); return arg.state; endfunction
endpackage
// ---------------------------------------------------------------------------
// OpenPA cells (generated; do not edit)
// ---------------------------------------------------------------------------
// openpa_corrupt: rule C2. Passes d while the driving domain is NORMAL; otherwise drives X (4-state)
// or a seeded value (2-state). The value is computed ahead for the episode the next power-down starts
// (ep + 1 while ok), so at power-down the output goes straight from d to the new value: no delta glitch
// through the previous episode's value (Icarus would turn one into a clock edge).
module openpa_corrupt #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           ok,
  input  int unsigned  ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  always @(ep or ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
  assign q = ok ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

// openpa_corrupt_sim: rule C2 for a domain that has intermediate simstates (IEEE 1801-2024 9.5). As
// openpa_corrupt, and also corrupt while lhit is set (CORRUPT_ON_ACTIVITY after input activity), or after d
// changed while coc is set (CORRUPT_ON_CHANGE); leaving CORRUPT_ON_CHANGE clears that.
module openpa_corrupt_sim #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           ok,
  input  int unsigned  ep,
  input  bit           lhit,
  input  bit           coc
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  bit chg;
  always @(ep or ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
  // verilator lint_off MULTIDRIVEN
  for (genvar i = 0; i < W; i++) begin : g_chg
    always @(posedge d[i] or negedge d[i]) if (coc && ok) chg = 1'b1;
  end
  always @(negedge coc) chg = 1'b0;
  // verilator lint_on MULTIDRIVEN
  assign q = (ok && !lhit && !chg) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

// openpa_iso: rules I1-I4 (IEEE 1801-2024 9.8). CLAMP 0, 1, 2 (latch: the value the input had while the enable
// was inactive) or 3 (Z: high impedance on 4-state; 0 on 2-state backends, which cannot represent Z).
// sup_ok is 1 while the isolation supply is NORMAL (always, for a strategy with no supply); otherwise the output,
// and a latched value, are corrupt. An enable at X or Z corrupts the output and the latched value.
module openpa_iso #(parameter int W = 1, parameter int CLAMP = 0, parameter bit SENSE = 1'b1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  logic         en,
  input  bit           sup_ok,
  input  int unsigned  sup_ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  logic [W-1:0] held;
  always @(sup_ep or sup_ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h4000_0000, sup_ok ? sup_ep + 1 : sup_ep, i);
  wire active   = (en === SENSE);
  wire inactive = (en === !SENSE);
  wire [W-1:0] bad    = UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0];
  if (CLAMP == 2) begin : g_latch
    always @(d or en or sup_ok or bad) if (!sup_ok || !(active || inactive)) held = bad; else if (inactive) held = d;
  end
  wire [W-1:0] clampv = (CLAMP == 3) ? (UPF::openpa_xmode ? {W{1'bz}} : {W{1'b0}}) : (CLAMP == 2) ? held : (CLAMP == 1) ? {W{1'b1}} : {W{1'b0}};
  assign q = !sup_ok ? bad : active ? clampv : inactive ? d : bad;
endmodule

// openpa_ls: rule L1 (IEEE 1801-2024 9.9). Passes d while every supply set of the cell is NORMAL; otherwise corrupt.
module openpa_ls #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           src_ok,
  input  bit           dst_ok,
  input  int unsigned  ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  always @(ep or src_ok or dst_ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h8000_0000, (src_ok && dst_ok) ? ep + 1 : ep, i);
  assign q = (src_ok && dst_ok) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

`line 1 "tile.sv" 0
module tile(input logic clk, wr, input logic [7:0] data,
  output logic [7:0] stored, output wire valid);
  always_ff @(posedge clk) if (wr) stored <= data;
  assign valid = wr;
endmodule
module buffer_soc(input logic clk,wr,input logic [7:0] data,output wire [7:0] stored,output wire valid);
  wire [7:0] openpa_u_slot_stored_raw; wire [0:0] openpa_u_slot_valid_raw; wire [0:0] openpa_u_slot_clk_s1; wire [7:0] openpa_u_slot_data_s1; wire [0:0] openpa_u_slot_wr_s1; tile u_slot(.clk(openpa_u_slot_clk_s1),.wr(openpa_u_slot_wr_s1),.data(openpa_u_slot_data_s1),.stored(openpa_u_slot_stored_raw),.valid(openpa_u_slot_valid_raw)); assign stored = openpa_u_slot_stored_raw; /* openpa_u_slot_stored_cor: set_simstate_behavior DISABLE */ assign valid = openpa_u_slot_valid_raw; /* openpa_u_slot_valid_cor: set_simstate_behavior DISABLE */ openpa_corrupt #(.W(1), .ID(268435472)) openpa_u_slot_clk_cor (.d(clk), .q(openpa_u_slot_clk_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(8), .ID(268435480)) openpa_u_slot_data_cor (.d(data), .q(openpa_u_slot_data_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435488)) openpa_u_slot_wr_cor (.d(wr), .q(openpa_u_slot_wr_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep));

`line 1 "openpa_overlay.sv" 0
  // ===================================================================================
  // OpenPA overlay for buffer_soc: generated from buffer_soc.upf. Do not edit.
  // ===================================================================================
  // verilator lint_off MULTIDRIVEN
  // verilator lint_off ENUMVALUE
  // verilator lint_off WIDTHTRUNC
  // verilator lint_off WIDTHEXPAND
  // verilator lint_off BLKSEQ
  // verilator lint_off IGNOREDRETURN
  import UPF::openpa_cmode;
  import UPF::openpa_dom_PD_TOP_ep;
  import UPF::openpa_dom_PD_TOP_ok;
  import UPF::openpa_dom_PD_TOP_sim;
  import UPF::openpa_dom_PD_UNIT_ep;
  import UPF::openpa_dom_PD_UNIT_ok;
  import UPF::openpa_dom_PD_UNIT_sim;
  import UPF::openpa_kick;
  import UPF::openpa_net_GND_N;
  import UPF::openpa_net_HOST_N;
  import UPF::openpa_net_KEEP_N;
  import UPF::openpa_net_UNIT_N;
  import UPF::openpa_seed;
  import UPF::openpa_ss_HOST_ep;
  import UPF::openpa_ss_HOST_multi;
  import UPF::openpa_ss_HOST_ok;
  import UPF::openpa_ss_HOST_sim;
  import UPF::openpa_ss_HOST_st;
  import UPF::openpa_ss_UNIT_a;
  import UPF::openpa_ss_UNIT_ep;
  import UPF::openpa_ss_UNIT_multi;
  import UPF::openpa_ss_UNIT_ok;
  import UPF::openpa_ss_UNIT_sim;
  import UPF::openpa_ss_UNIT_st;
  import UPF::openpa_xmode;
  // ---- mode, seed, trace
  bit openpa_tr, openpa_obs;
  int openpa_n [1:14];
  int openpa_seq [1:1];   // good-form sequence bins (coverage)
  bit openpa_sreq; bit openpa_sp [1:9];   // deferred checks: request and pending flags
  string openpa_mode_arg;
  initial begin
  `ifdef VERILATOR
    openpa_xmode = 1'b0;
  `else
    openpa_xmode = 1'b1;
  `endif
    openpa_cmode = 0;
    if ($value$plusargs("openpa_corrupt=%s", openpa_mode_arg)) begin
      if (openpa_mode_arg == "x") openpa_xmode = 1'b1;
      else if (openpa_mode_arg == "random") openpa_xmode = 1'b0;
      else if (openpa_mode_arg == "zero") begin openpa_xmode = 1'b0; openpa_cmode = 1; end
      else if (openpa_mode_arg == "one") begin openpa_xmode = 1'b0; openpa_cmode = 2; end
      else $display("OPENPA-ERROR +openpa_corrupt=%s: use x, random, zero or one", openpa_mode_arg);
    end
    if (!$value$plusargs("openpa_seed=%d", openpa_seed)) openpa_seed = 1;
    openpa_tr = $test$plusargs("openpa_trace");
    openpa_obs = $test$plusargs("openpa_obs");
    $display("OPENPA-INFO corruption=%0s seed=%0d", openpa_xmode ? "x" : (openpa_cmode == 1 ? "zero" : openpa_cmode == 2 ? "one" : "random"), openpa_seed);
    #0 openpa_kick = 1'b1;
  end
  task automatic openpa_check(input int id, input string msg);
    openpa_n[id] = openpa_n[id] + 1;
    $display("OPENPA-CHECK D%0d @ %0t: %s", id, $time, msg);
  endtask
  task automatic openpa_t(input string msg);
    if (openpa_tr) $display("OPENPA-TRACE @ %0t: %s", $time, msg);
  endtask

  // ---- copies of the design signals the UPF names (4-state, so X is visible)

  // ---- supply network, switches, supply sets, simstates, power states (one block, evaluated in order)
  bit openpa_tg_ss_UNIT_st; int openpa_pv_ss_UNIT_st = -2;
  bit openpa_tg_ss_UNIT_multi; int openpa_pv_ss_UNIT_multi = -2;
  always @(openpa_kick or UPF::openpa_port_VHOST or UPF::openpa_port_VUNIT or UPF::openpa_port_VKEEP or UPF::openpa_port_VSS) begin : openpa_network
    openpa_net_HOST_N = UPF::openpa_port_VHOST;   // HOST_N <- port VHOST
    openpa_net_UNIT_N = UPF::openpa_port_VUNIT;   // UNIT_N <- port VUNIT
    openpa_net_KEEP_N = UPF::openpa_port_VKEEP;   // KEEP_N <- port VKEEP
    openpa_net_GND_N = UPF::openpa_port_VSS;   // GND_N <- port VSS
    // supply set HOST (also PD_TOP.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_HOST
      bit nx; int sm;
      sm = (UPF::openpa_net_HOST_N.state == UPF::FULL_ON && UPF::openpa_net_GND_N.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_HOST_sim = sm;
      nx = sm < 5;
      if (openpa_ss_HOST_ok && !nx) openpa_ss_HOST_ep = openpa_ss_HOST_ep + 1;
      openpa_ss_HOST_ok = nx;
    end
    // supply set UNIT (also PD_UNIT.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_UNIT
      bit nx; int sm;
      openpa_ss_UNIT_a = '0; openpa_ss_UNIT_st = -1;
      begin int dm; dm = -1;
        openpa_ss_UNIT_a[0] = ((UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_UNIT_N.voltage == 1000000));   // Write
        if (openpa_ss_UNIT_a[0] && 0 > dm) begin dm = 0; openpa_ss_UNIT_st = 0; end
        openpa_ss_UNIT_a[1] = ((UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_UNIT_N.voltage == 650000));   // Coast
        if (openpa_ss_UNIT_a[1] && 0 > dm) begin dm = 0; openpa_ss_UNIT_st = 1; end
      end
      openpa_ss_UNIT_multi = (openpa_ss_UNIT_a[0] + openpa_ss_UNIT_a[1]) > 1;
      sm = (UPF::openpa_net_UNIT_N.state == UPF::FULL_ON && UPF::openpa_net_GND_N.state == UPF::FULL_ON) ? 0 : -1;
      if (openpa_ss_UNIT_a[0] && 0 > sm) sm = 0;   // Write NORMAL
      if (openpa_ss_UNIT_a[1] && 5 > sm) sm = 5;   // Coast CORRUPT
      if (sm < 0) sm = 5;
      openpa_ss_UNIT_sim = sm;
      nx = sm < 5;
      if (openpa_ss_UNIT_ok && !nx) openpa_ss_UNIT_ep = openpa_ss_UNIT_ep + 1;
      openpa_ss_UNIT_ok = nx;
    end
    // domain PD_TOP: simstate of its primary supply set HOST
    if (openpa_dom_PD_TOP_ok && !UPF::openpa_ss_HOST_ok) openpa_dom_PD_TOP_ep = openpa_dom_PD_TOP_ep + 1;
    openpa_dom_PD_TOP_ok = UPF::openpa_ss_HOST_ok;
    openpa_dom_PD_TOP_sim = openpa_ss_HOST_sim;
    // domain PD_UNIT: simstate of its primary supply set UNIT
    if (openpa_dom_PD_UNIT_ok && !UPF::openpa_ss_UNIT_ok) openpa_dom_PD_UNIT_ep = openpa_dom_PD_UNIT_ep + 1;
    openpa_dom_PD_UNIT_ok = UPF::openpa_ss_UNIT_ok;
    openpa_dom_PD_UNIT_sim = openpa_ss_UNIT_sim;
    if (openpa_ss_UNIT_st != openpa_pv_ss_UNIT_st) begin openpa_tg_ss_UNIT_st = ~openpa_tg_ss_UNIT_st; openpa_pv_ss_UNIT_st = openpa_ss_UNIT_st; end
    if (openpa_ss_UNIT_multi != openpa_pv_ss_UNIT_multi) begin openpa_tg_ss_UNIT_multi = ~openpa_tg_ss_UNIT_multi; openpa_pv_ss_UNIT_multi = openpa_ss_UNIT_multi; end
  end

  // ---- corruption: registers forced, memories overwritten (rules C1, C3)
  // domain PD_TOP (buffer_soc.upf:3): 0 register(s), 0 memory(ies)
  bit openpa_PD_TOP_applied, openpa_PD_TOP_valid;
  // The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
  // supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
  always @(UPF::openpa_dom_PD_TOP_ok or openpa_kick) if (!openpa_PD_TOP_valid || openpa_PD_TOP_applied != UPF::openpa_dom_PD_TOP_ok) begin
    openpa_t({"PD_TOP ", UPF::openpa_dom_PD_TOP_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_PD_TOP_ok || !openpa_PD_TOP_valid) begin
    end
    if (UPF::openpa_dom_PD_TOP_ok) begin
    end
    openpa_PD_TOP_valid = 1'b1; openpa_PD_TOP_applied = UPF::openpa_dom_PD_TOP_ok;
  end
  // domain PD_UNIT (buffer_soc.upf:4): 0 register(s), 0 memory(ies)
  bit openpa_PD_UNIT_applied, openpa_PD_UNIT_valid;
  // The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
  // supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
  always @(UPF::openpa_dom_PD_UNIT_ok or openpa_kick) if (!openpa_PD_UNIT_valid || openpa_PD_UNIT_applied != UPF::openpa_dom_PD_UNIT_ok) begin
    openpa_t({"PD_UNIT ", UPF::openpa_dom_PD_UNIT_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_PD_UNIT_ok || !openpa_PD_UNIT_valid) begin
    end
    if (UPF::openpa_dom_PD_UNIT_ok) begin
    end
    openpa_PD_UNIT_valid = 1'b1; openpa_PD_UNIT_applied = UPF::openpa_dom_PD_UNIT_ok;
  end
  // crossing 1: u_slot/stored (PD_UNIT) -> buffer_soc output stored (PD_TOP), not isolated
  bit openpa_x1_t;
  always @(UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_UNIT_N or UPF::openpa_net_GND_N) openpa_x1_t = !UPF::openpa_dom_PD_UNIT_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_UNIT_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x1_t)
    begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 2: u_slot/valid (PD_UNIT) -> buffer_soc output valid (PD_TOP), not isolated
  bit openpa_x2_t;
  always @(UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_UNIT_N or UPF::openpa_net_GND_N) openpa_x2_t = !UPF::openpa_dom_PD_UNIT_ok && UPF::openpa_dom_PD_TOP_ok && !(1'b0) && !(UPF::openpa_net_UNIT_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x2_t)
    begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 3: buffer_soc input clk (PD_TOP) -> u_slot/clk (PD_UNIT), not isolated
  bit openpa_x3_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_net_HOST_N or UPF::openpa_net_GND_N) openpa_x3_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_UNIT_ok && !(1'b0) && !(UPF::openpa_net_HOST_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x3_t)
    begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 4: buffer_soc input data (PD_TOP) -> u_slot/data (PD_UNIT), not isolated
  bit openpa_x4_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_net_HOST_N or UPF::openpa_net_GND_N) openpa_x4_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_UNIT_ok && !(1'b0) && !(UPF::openpa_net_HOST_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x4_t)
    begin openpa_sp[4] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 5: buffer_soc input wr (PD_TOP) -> u_slot/wr (PD_UNIT), not isolated
  bit openpa_x5_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_net_HOST_N or UPF::openpa_net_GND_N) openpa_x5_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_UNIT_ok && !(1'b0) && !(UPF::openpa_net_HOST_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x5_t)
    begin openpa_sp[5] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 1: PD_UNIT -> PD_TOP (no level shifter strategy, threshold 0)
  bit openpa_l1_t;
  always @(UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_UNIT_N or UPF::openpa_net_HOST_N) openpa_l1_t = UPF::openpa_dom_PD_UNIT_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_UNIT_N.voltage - UPF::openpa_net_HOST_N.voltage > 0 || UPF::openpa_net_HOST_N.voltage - UPF::openpa_net_UNIT_N.voltage > 0) && !1'b0;
  always @(posedge openpa_l1_t)
    begin openpa_sp[6] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 2: PD_TOP -> PD_UNIT (no level shifter strategy, threshold 0)
  bit openpa_l2_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_UNIT_ok or UPF::openpa_net_HOST_N or UPF::openpa_net_UNIT_N) openpa_l2_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_UNIT_ok && (UPF::openpa_net_HOST_N.voltage - UPF::openpa_net_UNIT_N.voltage > 0 || UPF::openpa_net_UNIT_N.voltage - UPF::openpa_net_HOST_N.voltage > 0) && !1'b0;
  always @(posedge openpa_l2_t)
    begin openpa_sp[7] = 1'b1; openpa_sreq = 1'b1; end

  // ---- power states (D8): checked once the bench has driven a supply, after the time step settles
  always @(posedge openpa_tg_ss_UNIT_st or negedge openpa_tg_ss_UNIT_st or posedge openpa_tg_ss_UNIT_multi or negedge openpa_tg_ss_UNIT_multi or posedge UPF::openpa_armed) if (UPF::openpa_armed)
    begin openpa_sp[8] = 1'b1; openpa_sreq = 1'b1; end
  always @(posedge openpa_tg_ss_UNIT_st or negedge openpa_tg_ss_UNIT_st) if (openpa_tr) openpa_t($sformatf("UNIT state %0s", (UPF::openpa_ss_UNIT_st == 0) ? "Write" : (UPF::openpa_ss_UNIT_st == 1) ? "Coast" : "<none>"));
  int openpa_cs1 [0:2]; int openpa_ct1 [0:2][0:2]; int openpa_cp1 = -1, openpa_cc1;   // coverage of supply set UNIT
  function automatic string openpa_cn1(int i); case (i) 0: return "Write"; 1: return "Coast"; default: return "<none>"; endcase endfunction
  always @(posedge openpa_tg_ss_UNIT_st or negedge openpa_tg_ss_UNIT_st or posedge UPF::openpa_armed) if (UPF::openpa_armed)
    begin openpa_sp[9] = 1'b1; openpa_sreq = 1'b1; end

  // ---- observation for differential corruption (+openpa_obs): design-top outputs while the top domain is on
  `ifdef OPENPA_OBS
  longint openpa_obs_after;
  initial if (!$value$plusargs("openpa_obs_after=%d", openpa_obs_after)) openpa_obs_after = 0;
  always @(stored) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: stored=%h", $time, stored);
  always @(valid) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: valid=%h", $time, valid);
  `else
  initial if ($test$plusargs("openpa_obs")) $display("OPENPA-ERROR +openpa_obs needs the copy compiled with OPENPA_OBS defined (-DOPENPA_OBS or +define+OPENPA_OBS)");
  `endif

  // Icarus 12 runs no named block inside a final block, so the report is a function.
  function automatic void openpa_cover_report();
      int hs, ht, hq;
      hs = 0; ht = 0; hq = 0;
      $display("OPENPA-COVER state supply_set UNIT Write %0d", openpa_cs1[0]);
      $display("OPENPA-COVER state supply_set UNIT Coast %0d", openpa_cs1[1]);
      if (openpa_cs1[2]) $display("OPENPA-COVER state supply_set UNIT <none> %0d", openpa_cs1[2]);
      for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2; j++) if (openpa_ct1[i][j]) $display("OPENPA-COVER transition supply_set UNIT %0s -> %0s %0d", openpa_cn1(i), openpa_cn1(j), openpa_ct1[i][j]);
      if (openpa_cs1[0]) hs = hs + 1;
      if (openpa_cs1[1]) hs = hs + 1;
      $display("OPENPA-COVER-SUMMARY states=%0d/2 declared_transitions=%0d/0 sequences=%0d/0", hs, ht, hq);
  endfunction

  // ---- settle process: 9 deferred check(s), run after one #0 in a fixed order
  initial forever begin
    wait (openpa_sreq && openpa_kick);
    #0;
    openpa_sreq = 1'b0;
    if (openpa_sp[1]) begin
      openpa_sp[1] = 1'b0;
      if (openpa_x1_t) openpa_check(9, "u_slot/stored of PD_UNIT (off) is read by buffer_soc output stored in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[2]) begin
      openpa_sp[2] = 1'b0;
      if (openpa_x2_t) openpa_check(9, "u_slot/valid of PD_UNIT (off) is read by buffer_soc output valid in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[3]) begin
      openpa_sp[3] = 1'b0;
      if (openpa_x3_t) openpa_check(9, "buffer_soc input clk of PD_TOP (off) is read by u_slot/clk in PD_UNIT (on) with no active isolation");
    end
    if (openpa_sp[4]) begin
      openpa_sp[4] = 1'b0;
      if (openpa_x4_t) openpa_check(9, "buffer_soc input data of PD_TOP (off) is read by u_slot/data in PD_UNIT (on) with no active isolation");
    end
    if (openpa_sp[5]) begin
      openpa_sp[5] = 1'b0;
      if (openpa_x5_t) openpa_check(9, "buffer_soc input wr of PD_TOP (off) is read by u_slot/wr in PD_UNIT (on) with no active isolation");
    end
    if (openpa_sp[6]) begin
      openpa_sp[6] = 1'b0;
      if (openpa_l1_t) openpa_check(11, $sformatf("PD_UNIT (%0d uV) drives PD_TOP (%0d uV) on 2 port(s) with no level shifter for this direction", UPF::openpa_net_UNIT_N.voltage, UPF::openpa_net_HOST_N.voltage));
    end
    if (openpa_sp[7]) begin
      openpa_sp[7] = 1'b0;
      if (openpa_l2_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_UNIT (%0d uV) on 3 port(s) with no level shifter for this direction", UPF::openpa_net_HOST_N.voltage, UPF::openpa_net_UNIT_N.voltage));
    end
    if (openpa_sp[8]) begin
      openpa_sp[8] = 1'b0;
        if (!1'b0)   // suspended while a power switch is undetermined (D10 reports that)
        begin
          if (UPF::openpa_ss_UNIT_multi) openpa_check(8, "supply set UNIT: more than one power state holds (the ERROR state)");
        end
    end
    if (openpa_sp[9]) begin
      openpa_sp[9] = 1'b0;
        if (!1'b0) begin
          openpa_cc1 = (UPF::openpa_ss_UNIT_st < 0) ? 2 : UPF::openpa_ss_UNIT_st;
          if (openpa_cc1 != openpa_cp1) begin
            openpa_cs1[openpa_cc1] = openpa_cs1[openpa_cc1] + 1;
            if (openpa_cp1 >= 0) openpa_ct1[openpa_cp1][openpa_cc1] = openpa_ct1[openpa_cp1][openpa_cc1] + 1;
            openpa_cp1 = openpa_cc1;
          end
        end
    end
  end
  final begin
    $display("OPENPA-SUMMARY D1=%0d D2=%0d D3=%0d D4=%0d D5=%0d D6=%0d D7=%0d D8=%0d D9=%0d D10=%0d D11=%0d D12=%0d D13=%0d D14=%0d", openpa_n[1], openpa_n[2], openpa_n[3], openpa_n[4], openpa_n[5], openpa_n[6], openpa_n[7], openpa_n[8], openpa_n[9], openpa_n[10], openpa_n[11], openpa_n[12], openpa_n[13], openpa_n[14]);
    openpa_cover_report();
    if (!UPF::openpa_armed) $display("OPENPA-WARNING no supply was driven (supply_on/supply_off never called): every domain stayed CORRUPT");
  end
  // verilator lint_on MULTIDRIVEN
`line 8 "tile.sv" 0
endmodule
ConceptWhich event first loses the byte in CORRUPT_STATE_ON_CHANGE?
ConceptWhat does NOT_NORMAL promise during refinement?
Predict the outputWith the completed PMU intent, what does restarted print?
`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("undriven");
   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'h16; tick; en=0; sample("working");
   sleep_req=1; tick; sleep_req=0; tick; tick; sample("parked");
   wake_req=1; tick; wake_req=0; repeat(4) tick; sample("restarted");
   void'(supply_partial_on("VDD_LO",0.8)); #2; sample("partial");
   $display("weak_rail state=%0d millivolts=%0d",get_supply_state(get_supply_value("VDD_LO")),
     $rtoi(1000*get_supply_voltage(get_supply_value("VDD_LO"))));
   void'(supply_off("VDD_LO")); #2; sample("removed"); $finish;
 end
endmodule
Read included file: pa_pmu_soc.sv
// pa_pmu_soc.sv: power-aware copy of pmu_soc, generated by OpenPA from pmu_soc.upf.
// Do not edit: regenerate. Simulators: Icarus 12 (4-state, X corruption) or Verilator 5 with --timing (2-state).
// Build with -Wno-fatal on Verilator: forced registers raise MULTIDRIVEN warnings.
`timescale 1ns/1ps
// ---------------------------------------------------------------------------
// package UPF: generated by OpenPA. Supply types, supply_on/supply_off and the power
// state of the design. Names starting with openpa_ are internal.
// ---------------------------------------------------------------------------
package UPF;
  typedef string upfStringT; typedef int upfIntegerT; typedef bit upfBooleanT; typedef logic upfLogicT; typedef real upfRealT; typedef int upfHandleT;
  typedef enum { OFF, FULL_ON, PARTIAL_ON, UNDETERMINED } upfSupplyStateE;
  typedef struct packed { upfSupplyStateE state; int voltage; } upfSupplyTypeT;  // voltage in microvolts
  typedef upfSupplyTypeT supply_net_type;
  bit openpa_armed;        // set by the first call that drives a supply
  bit openpa_kick;         // pulsed once at time 0 to evaluate everything
  bit openpa_xmode;        // 1: corrupt to X; 0: seeded 2-state values
  int unsigned openpa_seed = 1;
  int openpa_cmode;        // 2-state corruption: 0 random, 1 all zero, 2 all one
  supply_net_type openpa_port_VDD;   // supply port VDD (pmu_soc.upf:9)
  supply_net_type openpa_port_VDD_LO;   // supply port VDD_LO (pmu_soc.upf:10)
  supply_net_type openpa_port_VSS;   // supply port VSS (pmu_soc.upf:11)
  supply_net_type openpa_net_VDD_N;   // supply net VDD_N
  supply_net_type openpa_net_VDDL_N;   // supply net VDDL_N
  supply_net_type openpa_net_VSS_N;   // supply net VSS_N
  supply_net_type openpa_net_VDD_CORE;   // supply net VDD_CORE
  int openpa_sw_SW_CORE_st = -1;   // switch SW_CORE: -1 undetermined, 0 off, k on-state k (pmu_soc.upf:24)
  bit openpa_ss_PD_TOP_primary_ok; int unsigned openpa_ss_PD_TOP_primary_ep; int openpa_ss_PD_TOP_primary_st = -1; bit openpa_ss_PD_TOP_primary_multi; int openpa_ss_PD_TOP_primary_sim = 5;   // supply set PD_TOP.primary
  bit openpa_ss_PD_CORE_primary_ok; int unsigned openpa_ss_PD_CORE_primary_ep; int openpa_ss_PD_CORE_primary_st = -1; bit openpa_ss_PD_CORE_primary_multi; int openpa_ss_PD_CORE_primary_sim = 5;   // supply set PD_CORE.primary
  bit openpa_ss_AON_ok; int unsigned openpa_ss_AON_ep; int openpa_ss_AON_st = -1; bit openpa_ss_AON_multi; int openpa_ss_AON_sim = 5;   // supply set AON
  bit openpa_ss_anon_VDD_N_VSS_N_ok; int unsigned openpa_ss_anon_VDD_N_VSS_N_ep; int openpa_ss_anon_VDD_N_VSS_N_st = -1; bit openpa_ss_anon_VDD_N_VSS_N_multi; int openpa_ss_anon_VDD_N_VSS_N_sim = 5;   // supply set {VDD_N VSS_N}
  bit openpa_dom_PD_TOP_ok; int unsigned openpa_dom_PD_TOP_ep; int openpa_dom_PD_TOP_sim = 5;   // power domain PD_TOP: ok = powered (simstate not CORRUPT); sim = simstate code (pmu_soc.upf:5)
  bit openpa_dom_PD_CORE_ok; int unsigned openpa_dom_PD_CORE_ep; int openpa_dom_PD_CORE_sim = 5;   // power domain PD_CORE: ok = powered (simstate not CORRUPT); sim = simstate code (pmu_soc.upf:6)
  // simstate codes, by IEEE 1801-2024 4.8 precedence: 0 NORMAL, 1 CORRUPT_STATE_ON_CHANGE, 2 CORRUPT_STATE_ON_ACTIVITY,
  // 3 CORRUPT_ON_CHANGE, 4 CORRUPT_ON_ACTIVITY, 5 CORRUPT (and NOT_NORMAL, 9.5.8); README "Simstates"
  int openpa_pst_PST_SOC_row = -1;   // PST PST_SOC (pmu_soc.upf:58)
  logic openpa_ctl_0_u_pmu_pwr_en;   // copy of u_pmu.pwr_en (switch SW_CORE)
  logic openpa_ctl_1_u_pmu_iso_en;   // copy of u_pmu.iso_en (isolation QUIET; isolation FULL; isolation HOLD; isolation RELEASE)
  logic openpa_ctl_2_u_pmu_save;   // copy of u_pmu.save (retention RET_CORE save)
  logic openpa_ctl_3_u_pmu_restore;   // copy of u_pmu.restore (retention RET_CORE restore)
  function automatic logic [63:0] openpa_mix(int unsigned id, int unsigned ep, int unsigned lane);
    logic [63:0] z;
    if (openpa_cmode == 1) return 64'd0;
    if (openpa_cmode == 2) return ~64'd0;
    z = {32'd0, openpa_seed} * 64'h9E3779B97F4A7C15 + {32'd0, id} * 64'hC2B2AE3D27D4EB4F + {32'd0, ep} * 64'h165667B19E3779F9 + {32'd0, lane} * 64'hD6E8FEB86659FD93;
    z = (z ^ (z >> 30)) * 64'hBF58476D1CE4E5B9;
    z = (z ^ (z >> 27)) * 64'h94D049BB133111EB;
    return z ^ (z >> 31);
  endfunction
  function automatic bit openpa_bit(int unsigned id, int unsigned ep); logic [63:0] z; z = openpa_mix(id, ep, 0); return z[0]; endfunction
  function automatic int openpa_uv(real v); return $rtoi(v * 1.0e6 + (v < 0.0 ? -0.5 : 0.5)); endfunction
  // supply_on: FULL_ON at the given voltage (11.2.4; default 1.0 V)
  function automatic upfBooleanT supply_on(string pad_name, real value = 1.0);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = FULL_ON; openpa_port_VDD.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = FULL_ON; openpa_port_VDD_LO.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = FULL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "AON.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): AON.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "AON.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): AON.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_on(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // supply_off: OFF, voltage unchanged (9.3.1); a second argument is accepted and ignored
  function automatic upfBooleanT supply_off(string pad_name, real value = 0.0);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = OFF; return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = OFF; return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = OFF; return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "AON.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): AON.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "AON.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): AON.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_off(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // supply_partial_on: PARTIAL_ON at the given voltage (11.2.4)
  function automatic upfBooleanT supply_partial_on(string pad_name, real value = 1.0);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = PARTIAL_ON; openpa_port_VDD.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = PARTIAL_ON; openpa_port_VDD_LO.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = PARTIAL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "AON.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): AON.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "AON.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): AON.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR supply_partial_on(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // set_supply_state: the state only, voltage unchanged (9.3.1)
  function automatic upfBooleanT set_supply_state(string pad_name, upfSupplyStateE supply_state);
    openpa_armed = 1;
    if (pad_name == "VDD") begin openpa_port_VDD.state = supply_state; return 1; end
    if (pad_name == "VDD_LO") begin openpa_port_VDD_LO.state = supply_state; return 1; end
    if (pad_name == "VSS") begin openpa_port_VSS.state = supply_state; return 1; end
    if (pad_name == "VDD_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "AON.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): AON.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDDL_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDDL_N already has a driver (port VDD_LO); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VSS_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "AON.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): AON.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
    $display("OPENPA-ERROR set_supply_state(\"%s\"): no supply port or root supply net of that name (writable: VDD VDD_LO VSS)", pad_name);
    return 0;
  endfunction
  // set_power_state (9.3.1) is not supported: OpenPA has no deferred power states. A call is reported, never ignored.
  function automatic upfBooleanT set_power_state(string object_name, string power_state);
    $display("OPENPA-ERROR set_power_state(\"%s\", \"%s\"): not supported by OpenPA; drive the supplies with supply_on, supply_off or set_supply_state", object_name, power_state);
    return 0;
  endfunction
  // Supply queries (11.2.4). Names: supply ports, supply nets and supply set functions as the UPF wrote them.
  function automatic upfSupplyTypeT get_supply_value(string name);
    if (name == "VDD" || name == "VDD_N" || name == "AON.power" || name == "PD_TOP.primary.power") return openpa_net_VDD_N;
    if (name == "VDD_LO" || name == "VDDL_N") return openpa_net_VDDL_N;
    if (name == "VSS" || name == "VSS_N" || name == "AON.ground" || name == "PD_TOP.primary.ground" || name == "PD_CORE.primary.ground") return openpa_net_VSS_N;
    if (name == "VDD_CORE" || name == "PD_CORE.primary.power") return openpa_net_VDD_CORE;
    $display("OPENPA-ERROR get_supply_value(\"%s\"): no supply net, port or supply set function of that name", name);
    return 0;
  endfunction
  function automatic upfRealT get_supply_voltage(upfSupplyTypeT arg); return arg.voltage / 1.0e6; endfunction
  // 11.2.4: 1 for FULL_ON; 0 otherwise.
  function automatic upfBooleanT get_supply_on_state(upfSupplyTypeT arg); return arg.state == FULL_ON; endfunction
  function automatic upfSupplyStateE get_supply_state(upfSupplyTypeT arg); return arg.state; endfunction
endpackage
// ---------------------------------------------------------------------------
// OpenPA cells (generated; do not edit)
// ---------------------------------------------------------------------------
// openpa_corrupt: rule C2. Passes d while the driving domain is NORMAL; otherwise drives X (4-state)
// or a seeded value (2-state). The value is computed ahead for the episode the next power-down starts
// (ep + 1 while ok), so at power-down the output goes straight from d to the new value: no delta glitch
// through the previous episode's value (Icarus would turn one into a clock edge).
module openpa_corrupt #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           ok,
  input  int unsigned  ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  always @(ep or ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
  assign q = ok ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

// openpa_corrupt_sim: rule C2 for a domain that has intermediate simstates (IEEE 1801-2024 9.5). As
// openpa_corrupt, and also corrupt while lhit is set (CORRUPT_ON_ACTIVITY after input activity), or after d
// changed while coc is set (CORRUPT_ON_CHANGE); leaving CORRUPT_ON_CHANGE clears that.
module openpa_corrupt_sim #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           ok,
  input  int unsigned  ep,
  input  bit           lhit,
  input  bit           coc
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  bit chg;
  always @(ep or ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
  // verilator lint_off MULTIDRIVEN
  for (genvar i = 0; i < W; i++) begin : g_chg
    always @(posedge d[i] or negedge d[i]) if (coc && ok) chg = 1'b1;
  end
  always @(negedge coc) chg = 1'b0;
  // verilator lint_on MULTIDRIVEN
  assign q = (ok && !lhit && !chg) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

// openpa_iso: rules I1-I4 (IEEE 1801-2024 9.8). CLAMP 0, 1, 2 (latch: the value the input had while the enable
// was inactive) or 3 (Z: high impedance on 4-state; 0 on 2-state backends, which cannot represent Z).
// sup_ok is 1 while the isolation supply is NORMAL (always, for a strategy with no supply); otherwise the output,
// and a latched value, are corrupt. An enable at X or Z corrupts the output and the latched value.
module openpa_iso #(parameter int W = 1, parameter int CLAMP = 0, parameter bit SENSE = 1'b1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  logic         en,
  input  bit           sup_ok,
  input  int unsigned  sup_ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  logic [W-1:0] held;
  always @(sup_ep or sup_ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h4000_0000, sup_ok ? sup_ep + 1 : sup_ep, i);
  wire active   = (en === SENSE);
  wire inactive = (en === !SENSE);
  wire [W-1:0] bad    = UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0];
  if (CLAMP == 2) begin : g_latch
    always @(d or en or sup_ok or bad) if (!sup_ok || !(active || inactive)) held = bad; else if (inactive) held = d;
  end
  wire [W-1:0] clampv = (CLAMP == 3) ? (UPF::openpa_xmode ? {W{1'bz}} : {W{1'b0}}) : (CLAMP == 2) ? held : (CLAMP == 1) ? {W{1'b1}} : {W{1'b0}};
  assign q = !sup_ok ? bad : active ? clampv : inactive ? d : bad;
endmodule

// openpa_ls: rule L1 (IEEE 1801-2024 9.9). Passes d while every supply set of the cell is NORMAL; otherwise corrupt.
module openpa_ls #(parameter int W = 1, parameter int unsigned ID = 0) (
  input  logic [W-1:0] d,
  output logic [W-1:0] q,
  input  bit           src_ok,
  input  bit           dst_ok,
  input  int unsigned  ep
);
  localparam int L = (W + 63) / 64;
  logic [L*64-1:0] cv;
  always @(ep or src_ok or dst_ok or UPF::openpa_kick)
    for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h8000_0000, (src_ok && dst_ok) ? ep + 1 : ep, i);
  assign q = (src_ok && dst_ok) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule

`line 1 "pmu_soc.sv" 0
// 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)
  );

  wire [7:0] openpa_u_core_acc_raw, openpa_u_core_acc_s1; wire [3:0] openpa_u_core_beats_raw, openpa_u_core_beats_s1; wire [0:0] openpa_u_core_busy_raw, openpa_u_core_busy_s1; wire [7:0] openpa_u_core_rf_rd_raw, openpa_u_core_rf_rd_s1; wire [0:0] openpa_u_core_clk_s1; wire [7:0] openpa_u_core_d_s1; wire [0:0] openpa_u_core_en_s1; wire [1:0] openpa_u_core_rf_addr_s1; wire [0:0] openpa_u_core_rf_we_s1; wire [0:0] openpa_u_core_rst_n_s1; core u_core (
    .clk     (openpa_u_core_clk_s1),
    .rst_n   (openpa_u_core_rst_n_s1),
    .en      (openpa_u_core_en_s1),
    .d       (openpa_u_core_d_s1),
    .rf_addr (openpa_u_core_rf_addr_s1),
    .rf_we   (openpa_u_core_rf_we_s1),
    .acc     (openpa_u_core_acc_raw),
    .rf_rd   (openpa_u_core_rf_rd_raw),
    .busy    (openpa_u_core_busy_raw),
    .beats   (openpa_u_core_beats_raw)
  ); openpa_corrupt #(.W(8), .ID(268435456)) openpa_u_core_acc_cor (.d(openpa_u_core_acc_raw), .q(openpa_u_core_acc_s1), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_iso #(.W(8), .CLAMP(2), .SENSE(1'b1), .ID(268435458)) openpa_u_core_acc_iso (.d(openpa_u_core_acc_s1), .q(acc), .en(UPF::openpa_ctl_1_u_pmu_iso_en), .sup_ok((UPF::openpa_ss_AON_sim == 0)), .sup_ep(UPF::openpa_ss_AON_ep)); openpa_corrupt #(.W(4), .ID(268435464)) openpa_u_core_beats_cor (.d(openpa_u_core_beats_raw), .q(openpa_u_core_beats_s1), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_iso #(.W(4), .CLAMP(1), .SENSE(1'b1), .ID(268435466)) openpa_u_core_beats_iso (.d(openpa_u_core_beats_s1), .q(core_beats), .en(UPF::openpa_ctl_1_u_pmu_iso_en), .sup_ok((UPF::openpa_ss_AON_sim == 0)), .sup_ep(UPF::openpa_ss_AON_ep)); openpa_corrupt #(.W(1), .ID(268435472)) openpa_u_core_busy_cor (.d(openpa_u_core_busy_raw), .q(openpa_u_core_busy_s1), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_iso #(.W(1), .CLAMP(0), .SENSE(1'b1), .ID(268435474)) openpa_u_core_busy_iso (.d(openpa_u_core_busy_s1), .q(busy), .en(UPF::openpa_ctl_1_u_pmu_iso_en), .sup_ok((UPF::openpa_ss_AON_sim == 0)), .sup_ep(UPF::openpa_ss_AON_ep)); openpa_corrupt #(.W(8), .ID(268435480)) openpa_u_core_rf_rd_cor (.d(openpa_u_core_rf_rd_raw), .q(openpa_u_core_rf_rd_s1), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_iso #(.W(8), .CLAMP(3), .SENSE(1'b1), .ID(268435482)) openpa_u_core_rf_rd_iso (.d(openpa_u_core_rf_rd_s1), .q(rf_rd), .en(UPF::openpa_ctl_1_u_pmu_iso_en), .sup_ok((UPF::openpa_ss_AON_sim == 0)), .sup_ep(UPF::openpa_ss_AON_ep)); openpa_corrupt #(.W(1), .ID(268435488)) openpa_u_core_clk_cor (.d(clk), .q(openpa_u_core_clk_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(8), .ID(268435496)) openpa_u_core_d_cor (.d(d), .q(openpa_u_core_d_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435504)) openpa_u_core_en_cor (.d(en), .q(openpa_u_core_en_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(2), .ID(268435512)) openpa_u_core_rf_addr_cor (.d(rf_addr), .q(openpa_u_core_rf_addr_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435520)) openpa_u_core_rf_we_cor (.d(rf_we), .q(openpa_u_core_rf_we_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435528)) openpa_u_core_rst_n_cor (.d(core_rst_n), .q(openpa_u_core_rst_n_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep));

  // 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;

`line 1 "openpa_overlay.sv" 0
  // ===================================================================================
  // OpenPA overlay for pmu_soc: generated from pmu_soc.upf. Do not edit.
  // ===================================================================================
  // verilator lint_off MULTIDRIVEN
  // verilator lint_off ENUMVALUE
  // verilator lint_off WIDTHTRUNC
  // verilator lint_off WIDTHEXPAND
  // verilator lint_off BLKSEQ
  // verilator lint_off IGNOREDRETURN
  import UPF::openpa_cmode;
  import UPF::openpa_ctl_0_u_pmu_pwr_en;
  import UPF::openpa_ctl_1_u_pmu_iso_en;
  import UPF::openpa_ctl_2_u_pmu_save;
  import UPF::openpa_ctl_3_u_pmu_restore;
  import UPF::openpa_dom_PD_CORE_ep;
  import UPF::openpa_dom_PD_CORE_ok;
  import UPF::openpa_dom_PD_CORE_sim;
  import UPF::openpa_dom_PD_TOP_ep;
  import UPF::openpa_dom_PD_TOP_ok;
  import UPF::openpa_dom_PD_TOP_sim;
  import UPF::openpa_kick;
  import UPF::openpa_net_VDDL_N;
  import UPF::openpa_net_VDD_CORE;
  import UPF::openpa_net_VDD_N;
  import UPF::openpa_net_VSS_N;
  import UPF::openpa_pst_PST_SOC_row;
  import UPF::openpa_seed;
  import UPF::openpa_ss_AON_ep;
  import UPF::openpa_ss_AON_multi;
  import UPF::openpa_ss_AON_ok;
  import UPF::openpa_ss_AON_sim;
  import UPF::openpa_ss_AON_st;
  import UPF::openpa_ss_PD_CORE_primary_ep;
  import UPF::openpa_ss_PD_CORE_primary_multi;
  import UPF::openpa_ss_PD_CORE_primary_ok;
  import UPF::openpa_ss_PD_CORE_primary_sim;
  import UPF::openpa_ss_PD_CORE_primary_st;
  import UPF::openpa_ss_PD_TOP_primary_ep;
  import UPF::openpa_ss_PD_TOP_primary_multi;
  import UPF::openpa_ss_PD_TOP_primary_ok;
  import UPF::openpa_ss_PD_TOP_primary_sim;
  import UPF::openpa_ss_PD_TOP_primary_st;
  import UPF::openpa_ss_anon_VDD_N_VSS_N_ep;
  import UPF::openpa_ss_anon_VDD_N_VSS_N_multi;
  import UPF::openpa_ss_anon_VDD_N_VSS_N_ok;
  import UPF::openpa_ss_anon_VDD_N_VSS_N_sim;
  import UPF::openpa_ss_anon_VDD_N_VSS_N_st;
  import UPF::openpa_sw_SW_CORE_st;
  import UPF::openpa_xmode;
  // ---- mode, seed, trace
  bit openpa_tr, openpa_obs;
  int openpa_n [1:14];
  int openpa_seq [1:10];   // good-form sequence bins (coverage)
  bit openpa_sreq; bit openpa_sp [1:35];   // deferred checks: request and pending flags
  string openpa_mode_arg;
  initial begin
  `ifdef VERILATOR
    openpa_xmode = 1'b0;
  `else
    openpa_xmode = 1'b1;
  `endif
    openpa_cmode = 0;
    if ($value$plusargs("openpa_corrupt=%s", openpa_mode_arg)) begin
      if (openpa_mode_arg == "x") openpa_xmode = 1'b1;
      else if (openpa_mode_arg == "random") openpa_xmode = 1'b0;
      else if (openpa_mode_arg == "zero") begin openpa_xmode = 1'b0; openpa_cmode = 1; end
      else if (openpa_mode_arg == "one") begin openpa_xmode = 1'b0; openpa_cmode = 2; end
      else $display("OPENPA-ERROR +openpa_corrupt=%s: use x, random, zero or one", openpa_mode_arg);
    end
    if (!$value$plusargs("openpa_seed=%d", openpa_seed)) openpa_seed = 1;
    openpa_tr = $test$plusargs("openpa_trace");
    openpa_obs = $test$plusargs("openpa_obs");
    $display("OPENPA-INFO corruption=%0s seed=%0d", openpa_xmode ? "x" : (openpa_cmode == 1 ? "zero" : openpa_cmode == 2 ? "one" : "random"), openpa_seed);
    #0 openpa_kick = 1'b1;
  end
  task automatic openpa_check(input int id, input string msg);
    openpa_n[id] = openpa_n[id] + 1;
    $display("OPENPA-CHECK D%0d @ %0t: %s", id, $time, msg);
  endtask
  task automatic openpa_t(input string msg);
    if (openpa_tr) $display("OPENPA-TRACE @ %0t: %s", $time, msg);
  endtask

  // ---- copies of the design signals the UPF names (4-state, so X is visible)
  always @(u_pmu.pwr_en or openpa_kick) openpa_ctl_0_u_pmu_pwr_en = u_pmu.pwr_en;
  always @(u_pmu.iso_en or openpa_kick) openpa_ctl_1_u_pmu_iso_en = u_pmu.iso_en;
  always @(u_pmu.save or openpa_kick) openpa_ctl_2_u_pmu_save = u_pmu.save;
  always @(u_pmu.restore or openpa_kick) openpa_ctl_3_u_pmu_restore = u_pmu.restore;

  // ---- supply network, switches, supply sets, simstates, power states (one block, evaluated in order)
  bit openpa_tg_sw_SW_CORE_st; int openpa_pv_sw_SW_CORE_st = -2;
  bit openpa_tg_pst_PST_SOC_row; int openpa_pv_pst_PST_SOC_row = -2;
  UPF::supply_net_type openpa_swv_SW_CORE_f, openpa_swv_SW_CORE_p; bit openpa_swv_SW_CORE_u, openpa_swv_SW_CORE_hf, openpa_swv_SW_CORE_hp, openpa_swv_SW_CORE_vd, openpa_swv_SW_CORE_on, openpa_swv_SW_CORE_pt; int openpa_swv_SW_CORE_k;   // switch SW_CORE
  always @(openpa_kick or UPF::openpa_port_VDD or UPF::openpa_port_VDD_LO or UPF::openpa_port_VSS or UPF::openpa_ctl_0_u_pmu_pwr_en) begin : openpa_network
    openpa_net_VDD_N = UPF::openpa_port_VDD;   // VDD_N <- port VDD
    openpa_net_VDDL_N = UPF::openpa_port_VDD_LO;   // VDDL_N <- port VDD_LO
    openpa_net_VSS_N = UPF::openpa_port_VSS;   // VSS_N <- port VSS
    // switch SW_CORE (pmu_soc.upf:24): IEEE 1801-2024 6.23
    openpa_swv_SW_CORE_u = 1'b0; openpa_swv_SW_CORE_hf = 1'b0; openpa_swv_SW_CORE_hp = 1'b0; openpa_swv_SW_CORE_vd = 1'b0; openpa_swv_SW_CORE_on = 1'b0; openpa_swv_SW_CORE_pt = 1'b0; openpa_swv_SW_CORE_k = 0;
    if (($isunknown(openpa_ctl_0_u_pmu_pwr_en)) && UPF::openpa_net_VDDL_N.state != UPF::OFF) openpa_swv_SW_CORE_u = 1'b1;   // on state on: a control is X or Z
    else if ((openpa_ctl_0_u_pmu_pwr_en === 1'b1)) begin
      if (!openpa_swv_SW_CORE_on) openpa_swv_SW_CORE_k = 1;
      openpa_swv_SW_CORE_on = 1'b1;
      if (UPF::openpa_net_VDDL_N.state == UPF::UNDETERMINED) openpa_swv_SW_CORE_u = 1'b1;
      else if (UPF::openpa_net_VDDL_N.state == UPF::FULL_ON) begin
        if ((openpa_swv_SW_CORE_hf && openpa_swv_SW_CORE_f.voltage != UPF::openpa_net_VDDL_N.voltage) || (openpa_swv_SW_CORE_hp && openpa_swv_SW_CORE_p.voltage != UPF::openpa_net_VDDL_N.voltage)) openpa_swv_SW_CORE_vd = 1'b1;
        openpa_swv_SW_CORE_f = UPF::openpa_net_VDDL_N; openpa_swv_SW_CORE_hf = 1'b1;
      end
      else if (UPF::openpa_net_VDDL_N.state == UPF::PARTIAL_ON) begin
        if ((openpa_swv_SW_CORE_hf && openpa_swv_SW_CORE_f.voltage != UPF::openpa_net_VDDL_N.voltage) || (openpa_swv_SW_CORE_hp && openpa_swv_SW_CORE_p.voltage != UPF::openpa_net_VDDL_N.voltage)) openpa_swv_SW_CORE_vd = 1'b1;
        openpa_swv_SW_CORE_p = UPF::openpa_net_VDDL_N; openpa_swv_SW_CORE_hp = 1'b1;
      end
    end
    if ((1'b0) || (((!((openpa_ctl_0_u_pmu_pwr_en === 1'b1)))) && (openpa_swv_SW_CORE_on || openpa_swv_SW_CORE_pt)) || openpa_swv_SW_CORE_u || openpa_swv_SW_CORE_vd || (!($isunknown(openpa_ctl_0_u_pmu_pwr_en)) && !openpa_swv_SW_CORE_on && !openpa_swv_SW_CORE_pt && !((!((openpa_ctl_0_u_pmu_pwr_en === 1'b1)))) && !(1'b0))) begin openpa_sw_SW_CORE_st = -1; openpa_net_VDD_CORE.state = UPF::UNDETERMINED; openpa_net_VDD_CORE.voltage = 0; end
    else begin openpa_sw_SW_CORE_st = openpa_swv_SW_CORE_k; if (openpa_swv_SW_CORE_hf) openpa_net_VDD_CORE = openpa_swv_SW_CORE_f; else if (openpa_swv_SW_CORE_hp) openpa_net_VDD_CORE = openpa_swv_SW_CORE_p; else begin openpa_net_VDD_CORE.state = UPF::OFF; openpa_net_VDD_CORE.voltage = 0; end end
    // supply set PD_TOP.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_PD_TOP_primary
      bit nx; int sm;
      sm = (UPF::openpa_net_VDD_N.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_PD_TOP_primary_sim = sm;
      nx = sm < 5;
      if (openpa_ss_PD_TOP_primary_ok && !nx) openpa_ss_PD_TOP_primary_ep = openpa_ss_PD_TOP_primary_ep + 1;
      openpa_ss_PD_TOP_primary_ok = nx;
    end
    // supply set PD_CORE.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_PD_CORE_primary
      bit nx; int sm;
      sm = (UPF::openpa_net_VDD_CORE.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_PD_CORE_primary_sim = sm;
      nx = sm < 5;
      if (openpa_ss_PD_CORE_primary_ok && !nx) openpa_ss_PD_CORE_primary_ep = openpa_ss_PD_CORE_primary_ep + 1;
      openpa_ss_PD_CORE_primary_ok = nx;
    end
    // supply set AON: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_AON
      bit nx; int sm;
      sm = (UPF::openpa_net_VDD_N.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_AON_sim = sm;
      nx = sm < 5;
      if (openpa_ss_AON_ok && !nx) openpa_ss_AON_ep = openpa_ss_AON_ep + 1;
      openpa_ss_AON_ok = nx;
    end
    // supply set {VDD_N VSS_N}: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_anon_VDD_N_VSS_N
      bit nx; int sm;
      sm = (UPF::openpa_net_VDD_N.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_anon_VDD_N_VSS_N_sim = sm;
      nx = sm < 5;
      if (openpa_ss_anon_VDD_N_VSS_N_ok && !nx) openpa_ss_anon_VDD_N_VSS_N_ep = openpa_ss_anon_VDD_N_VSS_N_ep + 1;
      openpa_ss_anon_VDD_N_VSS_N_ok = nx;
    end
    // domain PD_TOP: simstate of its primary supply set PD_TOP.primary
    if (openpa_dom_PD_TOP_ok && !UPF::openpa_ss_PD_TOP_primary_ok) openpa_dom_PD_TOP_ep = openpa_dom_PD_TOP_ep + 1;
    openpa_dom_PD_TOP_ok = UPF::openpa_ss_PD_TOP_primary_ok;
    openpa_dom_PD_TOP_sim = openpa_ss_PD_TOP_primary_sim;
    // domain PD_CORE: simstate of its primary supply set PD_CORE.primary
    if (openpa_dom_PD_CORE_ok && !UPF::openpa_ss_PD_CORE_primary_ok) openpa_dom_PD_CORE_ep = openpa_dom_PD_CORE_ep + 1;
    openpa_dom_PD_CORE_ok = UPF::openpa_ss_PD_CORE_primary_ok;
    openpa_dom_PD_CORE_sim = openpa_ss_PD_CORE_primary_sim;
    // power state table PST_SOC (pmu_soc.upf:58): rule P4
    openpa_pst_PST_SOC_row = -1;
    if (openpa_pst_PST_SOC_row == -1 && (UPF::openpa_net_VDD_N.state == UPF::FULL_ON && UPF::openpa_net_VDD_N.voltage == 1000000) && (UPF::openpa_net_VDDL_N.state == UPF::FULL_ON && UPF::openpa_net_VDDL_N.voltage == 800000) && (UPF::openpa_net_VDD_CORE.state == UPF::FULL_ON && UPF::openpa_net_VDD_CORE.voltage == 800000) && (UPF::openpa_net_VSS_N.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.voltage == 0)) openpa_pst_PST_SOC_row = 0;   // RUN
    if (openpa_pst_PST_SOC_row == -1 && (UPF::openpa_net_VDD_N.state == UPF::FULL_ON && UPF::openpa_net_VDD_N.voltage == 1000000) && (UPF::openpa_net_VDDL_N.state == UPF::FULL_ON && UPF::openpa_net_VDDL_N.voltage == 800000) && (UPF::openpa_net_VDD_CORE.state == UPF::OFF) && (UPF::openpa_net_VSS_N.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.voltage == 0)) openpa_pst_PST_SOC_row = 1;   // SLEEP
    if (openpa_sw_SW_CORE_st != openpa_pv_sw_SW_CORE_st) begin openpa_tg_sw_SW_CORE_st = ~openpa_tg_sw_SW_CORE_st; openpa_pv_sw_SW_CORE_st = openpa_sw_SW_CORE_st; end
    if (openpa_pst_PST_SOC_row != openpa_pv_pst_PST_SOC_row) begin openpa_tg_pst_PST_SOC_row = ~openpa_tg_pst_PST_SOC_row; openpa_pv_pst_PST_SOC_row = openpa_pst_PST_SOC_row; end
  end

  // ---- corruption: registers forced, memories overwritten (rules C1, C3)
  bit openpa_PD_CORE_await;   // PD_CORE powered up with saved state not yet restored (D3)
  // domain PD_TOP (pmu_soc.upf:5): 2 register(s), 0 memory(ies)
  bit openpa_PD_TOP_applied, openpa_PD_TOP_valid;
  logic [7:0] openpa_cv1;   // corruption value for status
  logic [2:0] openpa_cv2;   // corruption value for u_pmu.st
  // The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
  // supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
  always @(UPF::openpa_dom_PD_TOP_ok or openpa_kick) if (!openpa_PD_TOP_valid || openpa_PD_TOP_applied != UPF::openpa_dom_PD_TOP_ok) begin
    openpa_t({"PD_TOP ", UPF::openpa_dom_PD_TOP_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_PD_TOP_ok || !openpa_PD_TOP_valid) begin
      if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_PD_TOP_ep, 0);
      force status = openpa_cv1;
      if (openpa_xmode) openpa_cv2 = 'x; else openpa_cv2 = UPF::openpa_mix(2, UPF::openpa_dom_PD_TOP_ep, 0);
      force u_pmu.st = openpa_cv2;
    end
    if (UPF::openpa_dom_PD_TOP_ok) begin
      release status;
      release u_pmu.st;
    end
    openpa_PD_TOP_valid = 1'b1; openpa_PD_TOP_applied = UPF::openpa_dom_PD_TOP_ok;
  end
  // domain PD_CORE (pmu_soc.upf:6): 2 register(s), 1 memory(ies)
  bit openpa_PD_CORE_applied, openpa_PD_CORE_valid;
  logic [7:0] openpa_cv3;   // corruption value for u_core.acc
  logic [3:0] openpa_cv4;   // corruption value for u_core.beats
  // The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
  // supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
  always @(UPF::openpa_dom_PD_CORE_ok or openpa_kick) if (!openpa_PD_CORE_valid || openpa_PD_CORE_applied != UPF::openpa_dom_PD_CORE_ok) begin
    openpa_t({"PD_CORE ", UPF::openpa_dom_PD_CORE_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_PD_CORE_ok || !openpa_PD_CORE_valid) begin
      if (openpa_xmode) openpa_cv3 = 'x; else openpa_cv3 = UPF::openpa_mix(3, UPF::openpa_dom_PD_CORE_ep, 0);
      force u_core.acc = openpa_cv3;
      if (openpa_xmode) openpa_cv4 = 'x; else openpa_cv4 = UPF::openpa_mix(4, UPF::openpa_dom_PD_CORE_ep, 0);
      force u_core.beats = openpa_cv4;
      for (int i = 0; i < 4; i++) u_core.rf[0 + i] = openpa_xmode ? 8'bx : UPF::openpa_mix(100000, UPF::openpa_dom_PD_CORE_ep, (i) * 1 + 0);
    end
    if (UPF::openpa_dom_PD_CORE_ok) begin
      for (int i = 0; i < 4; i++) u_core.rf[0 + i] = openpa_xmode ? 8'bx : UPF::openpa_mix(100000, UPF::openpa_dom_PD_CORE_ep, (i) * 1 + 0);
      release u_core.acc;
      release u_core.beats;
    end
    openpa_PD_CORE_valid = 1'b1; openpa_PD_CORE_applied = UPF::openpa_dom_PD_CORE_ok;
  end

  // ---- set_retention RET_CORE (pmu_soc.upf:39): u_core.acc (rules R1-R4)
  bit openpa_PD_CORE_RET_CORE_valid; logic openpa_PD_CORE_RET_CORE_sv, openpa_PD_CORE_RET_CORE_rv;
  bit openpa_PD_CORE_RET_CORE_arm7; realtime openpa_PD_CORE_RET_CORE_st7, openpa_PD_CORE_RET_CORE_ck7_0 = -1.0;
  logic [7:0] openpa_PD_CORE_RET_CORE_sh0;   // retained value of u_core.acc, on {VDD_N VSS_N}
  always @(posedge UPF::openpa_ctl_2_u_pmu_save or negedge UPF::openpa_ctl_2_u_pmu_save) begin
    if ($isunknown(openpa_ctl_2_u_pmu_save)) begin   // a save signal at X or Z: the retained value is corrupt (UPF 1.0 5.3)
      openpa_PD_CORE_RET_CORE_sh0 = openpa_xmode ? 'x : UPF::openpa_mix(60003, UPF::openpa_ss_anon_VDD_N_VSS_N_ep, 0);
      if (UPF::openpa_ss_anon_VDD_N_VSS_N_ok) openpa_PD_CORE_RET_CORE_valid = 1'b1;   // the shadow holds a (corrupt) saved value
      openpa_check(4, "set_retention RET_CORE: save signal u_pmu.save is X or Z; the shadow is corrupt (pmu_soc.upf:43)");
    end
    else if (openpa_PD_CORE_RET_CORE_sv === 1'b0 && UPF::openpa_ctl_2_u_pmu_save === 1'b1)
      begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
    openpa_PD_CORE_RET_CORE_sv = UPF::openpa_ctl_2_u_pmu_save;
  end
  always @(posedge UPF::openpa_ctl_3_u_pmu_restore or negedge UPF::openpa_ctl_3_u_pmu_restore) begin
    if ($isunknown(openpa_ctl_3_u_pmu_restore)) begin   // a restore signal at X or Z: the register is corrupt (UPF 1.0 5.3)
      if (openpa_xmode) openpa_cv3 = 'x; else openpa_cv3 = UPF::openpa_mix(3, UPF::openpa_dom_PD_CORE_ep, 0);
      force u_core.acc = openpa_cv3; release u_core.acc;
      openpa_check(5, "set_retention RET_CORE: restore signal u_pmu.restore is X or Z; the registers are corrupt (pmu_soc.upf:44)");
    end
    else if (openpa_PD_CORE_RET_CORE_rv === 1'b0 && UPF::openpa_ctl_3_u_pmu_restore === 1'b1)
      begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
    openpa_PD_CORE_RET_CORE_rv = UPF::openpa_ctl_3_u_pmu_restore;
  end
  always @(negedge UPF::openpa_ss_anon_VDD_N_VSS_N_ok) if (!UPF::openpa_ss_anon_VDD_N_VSS_N_ok) begin
    if (openpa_PD_CORE_RET_CORE_valid) openpa_check(6, "set_retention RET_CORE: retention supply {VDD_N VSS_N} lost while holding saved state");
    openpa_PD_CORE_RET_CORE_valid = 1'b0;
    openpa_PD_CORE_RET_CORE_sh0 = openpa_xmode ? 'x : UPF::openpa_mix(50003, UPF::openpa_ss_anon_VDD_N_VSS_N_ep, 0);
    if (openpa_xmode) openpa_cv3 = 'x; else openpa_cv3 = UPF::openpa_mix(70003, UPF::openpa_ss_anon_VDD_N_VSS_N_ep, 0);
    force u_core.acc = openpa_cv3; release u_core.acc;
  end
  always @(posedge u_core.clk) if (openpa_PD_CORE_RET_CORE_arm7 && UPF::openpa_dom_PD_CORE_ok) openpa_PD_CORE_RET_CORE_ck7_0 = $realtime;
  always @(negedge UPF::openpa_dom_PD_CORE_ok) if (!UPF::openpa_dom_PD_CORE_ok && openpa_PD_CORE_RET_CORE_arm7) begin
    if (openpa_PD_CORE_RET_CORE_ck7_0 > openpa_PD_CORE_RET_CORE_st7 && openpa_PD_CORE_RET_CORE_ck7_0 < $realtime) openpa_check(7, $sformatf("set_retention RET_CORE: u_core.clk had an active edge at %0t, after the save and before PD_CORE went off; the retained state may differ from the saved one (pmu_soc.upf:39)", openpa_PD_CORE_RET_CORE_ck7_0));
    openpa_PD_CORE_RET_CORE_arm7 = 1'b0;
  end
  always @(posedge UPF::openpa_dom_PD_CORE_ok) openpa_PD_CORE_await = openpa_PD_CORE_RET_CORE_valid;

  // ---- checks for set_isolation HOLD (pmu_soc.upf:36): PD_CORE -> PD_TOP on 1 port(s)
  bit openpa_ig1_act, openpa_ig1_cyc;
  always @(negedge UPF::openpa_dom_PD_CORE_ok) if (!UPF::openpa_dom_PD_CORE_ok)
    begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; end
  always @(posedge UPF::openpa_ctl_1_u_pmu_iso_en or negedge UPF::openpa_ctl_1_u_pmu_iso_en or posedge openpa_kick) begin
    if (openpa_ig1_act && !(UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1))
      begin openpa_sp[4] = 1'b1; openpa_sreq = 1'b1; end
    if (openpa_ig1_act != (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_t({"HOLD enable ", (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) ? "active" : "inactive"});
    openpa_ig1_act = (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1);
  end
  always @(negedge UPF::openpa_ss_AON_ok) if (!UPF::openpa_ss_AON_ok)
    begin openpa_sp[5] = 1'b1; openpa_sreq = 1'b1; end

  // ---- checks for set_isolation FULL (pmu_soc.upf:35): PD_CORE -> PD_TOP on 1 port(s)
  bit openpa_ig2_act, openpa_ig2_cyc;
  always @(negedge UPF::openpa_dom_PD_CORE_ok) if (!UPF::openpa_dom_PD_CORE_ok)
    begin openpa_sp[6] = 1'b1; openpa_sreq = 1'b1; end
  always @(posedge UPF::openpa_ctl_1_u_pmu_iso_en or negedge UPF::openpa_ctl_1_u_pmu_iso_en or posedge openpa_kick) begin
    if (openpa_ig2_act && !(UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1))
      begin openpa_sp[7] = 1'b1; openpa_sreq = 1'b1; end
    if (openpa_ig2_act != (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_t({"FULL enable ", (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) ? "active" : "inactive"});
    openpa_ig2_act = (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1);
  end
  always @(negedge UPF::openpa_ss_AON_ok) if (!UPF::openpa_ss_AON_ok)
    begin openpa_sp[8] = 1'b1; openpa_sreq = 1'b1; end

  // ---- checks for set_isolation QUIET (pmu_soc.upf:34): PD_CORE -> PD_TOP on 1 port(s)
  bit openpa_ig3_act, openpa_ig3_cyc;
  always @(negedge UPF::openpa_dom_PD_CORE_ok) if (!UPF::openpa_dom_PD_CORE_ok)
    begin openpa_sp[9] = 1'b1; openpa_sreq = 1'b1; end
  always @(posedge UPF::openpa_ctl_1_u_pmu_iso_en or negedge UPF::openpa_ctl_1_u_pmu_iso_en or posedge openpa_kick) begin
    if (openpa_ig3_act && !(UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1))
      begin openpa_sp[10] = 1'b1; openpa_sreq = 1'b1; end
    if (openpa_ig3_act != (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_t({"QUIET enable ", (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) ? "active" : "inactive"});
    openpa_ig3_act = (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1);
  end
  always @(negedge UPF::openpa_ss_AON_ok) if (!UPF::openpa_ss_AON_ok)
    begin openpa_sp[11] = 1'b1; openpa_sreq = 1'b1; end

  // ---- checks for set_isolation RELEASE (pmu_soc.upf:37): PD_CORE -> PD_TOP on 1 port(s)
  bit openpa_ig4_act, openpa_ig4_cyc;
  always @(negedge UPF::openpa_dom_PD_CORE_ok) if (!UPF::openpa_dom_PD_CORE_ok)
    begin openpa_sp[12] = 1'b1; openpa_sreq = 1'b1; end
  always @(posedge UPF::openpa_ctl_1_u_pmu_iso_en or negedge UPF::openpa_ctl_1_u_pmu_iso_en or posedge openpa_kick) begin
    if (openpa_ig4_act && !(UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1))
      begin openpa_sp[13] = 1'b1; openpa_sreq = 1'b1; end
    if (openpa_ig4_act != (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_t({"RELEASE enable ", (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) ? "active" : "inactive"});
    openpa_ig4_act = (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1);
  end
  always @(negedge UPF::openpa_ss_AON_ok) if (!UPF::openpa_ss_AON_ok)
    begin openpa_sp[14] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 1: u_core/acc (PD_CORE) -> logic in pmu_soc (PD_TOP), isolated by HOLD
  bit openpa_x1_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_1_u_pmu_iso_en or UPF::openpa_ss_AON_sim or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x1_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) && (UPF::openpa_ss_AON_sim == 0))) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x1_t)
    begin openpa_sp[15] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 2: u_core/acc (PD_CORE) -> pmu_soc output total (PD_TOP), isolated by HOLD
  bit openpa_x2_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_1_u_pmu_iso_en or UPF::openpa_ss_AON_sim or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x2_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) && (UPF::openpa_ss_AON_sim == 0))) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x2_t)
    begin openpa_sp[16] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 3: u_core/beats (PD_CORE) -> pmu_soc output beats (PD_TOP), isolated by FULL
  bit openpa_x3_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_1_u_pmu_iso_en or UPF::openpa_ss_AON_sim or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x3_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) && (UPF::openpa_ss_AON_sim == 0))) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x3_t)
    begin openpa_sp[17] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 4: u_core/busy (PD_CORE) -> logic in pmu_soc (PD_TOP), isolated by QUIET
  bit openpa_x4_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_1_u_pmu_iso_en or UPF::openpa_ss_AON_sim or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x4_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) && (UPF::openpa_ss_AON_sim == 0))) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x4_t)
    begin openpa_sp[18] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 5: u_core/busy (PD_CORE) -> pmu_soc output led (PD_TOP), isolated by QUIET
  bit openpa_x5_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_1_u_pmu_iso_en or UPF::openpa_ss_AON_sim or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x5_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) && (UPF::openpa_ss_AON_sim == 0))) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x5_t)
    begin openpa_sp[19] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 6: u_core/rf_rd (PD_CORE) -> pmu_soc output rd (PD_TOP), isolated by RELEASE
  bit openpa_x6_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_1_u_pmu_iso_en or UPF::openpa_ss_AON_sim or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x6_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) && (UPF::openpa_ss_AON_sim == 0))) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x6_t)
    begin openpa_sp[20] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 7: pmu_soc input clk (PD_TOP) -> u_core/clk (PD_CORE), not isolated
  bit openpa_x7_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x7_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x7_t)
    begin openpa_sp[21] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 8: pmu_soc input d (PD_TOP) -> u_core/d (PD_CORE), not isolated
  bit openpa_x8_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x8_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x8_t)
    begin openpa_sp[22] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 9: pmu_soc input en (PD_TOP) -> u_core/en (PD_CORE), not isolated
  bit openpa_x9_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x9_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x9_t)
    begin openpa_sp[23] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 10: pmu_soc input rf_addr (PD_TOP) -> u_core/rf_addr (PD_CORE), not isolated
  bit openpa_x10_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x10_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x10_t)
    begin openpa_sp[24] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 11: pmu_soc input rf_we (PD_TOP) -> u_core/rf_we (PD_CORE), not isolated
  bit openpa_x11_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x11_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x11_t)
    begin openpa_sp[25] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 12: u_pmu/core_rst_n (PD_TOP) -> u_core/rst_n (PD_CORE), not isolated
  bit openpa_x12_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x12_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
  always @(posedge openpa_x12_t)
    begin openpa_sp[26] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 1: PD_CORE -> PD_TOP (set_level_shifter LS_CORE, rule both, threshold 100000 uV)
  bit openpa_l1_t;
  always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VDD_N) openpa_l1_t = UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_CORE.voltage - UPF::openpa_net_VDD_N.voltage > 100000 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_CORE.voltage > 100000) && !1'b1;
  always @(posedge openpa_l1_t)
    begin openpa_sp[27] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 2: PD_TOP -> PD_CORE (set_level_shifter LS_CORE, rule both, threshold 100000 uV)
  bit openpa_l2_t;
  always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_CORE) openpa_l2_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_CORE.voltage > 100000 || UPF::openpa_net_VDD_CORE.voltage - UPF::openpa_net_VDD_N.voltage > 100000) && !1'b1;
  always @(posedge openpa_l2_t)
    begin openpa_sp[28] = 1'b1; openpa_sreq = 1'b1; end

  // ---- power states (D8): checked once the bench has driven a supply, after the time step settles
  always @(posedge openpa_tg_pst_PST_SOC_row or negedge openpa_tg_pst_PST_SOC_row or posedge UPF::openpa_armed or posedge openpa_tg_sw_SW_CORE_st or negedge openpa_tg_sw_SW_CORE_st) if (UPF::openpa_armed)
    begin openpa_sp[29] = 1'b1; openpa_sreq = 1'b1; end
  int openpa_cs1 [0:2]; int openpa_ct1 [0:2][0:2]; int openpa_cp1 = -1, openpa_cc1;   // coverage of pst PST_SOC
  function automatic string openpa_cn1(int i); case (i) 0: return "RUN"; 1: return "SLEEP"; default: return "<none>"; endcase endfunction
  always @(posedge openpa_tg_pst_PST_SOC_row or negedge openpa_tg_pst_PST_SOC_row or posedge UPF::openpa_armed or posedge openpa_tg_sw_SW_CORE_st or negedge openpa_tg_sw_SW_CORE_st) if (UPF::openpa_armed)
    begin openpa_sp[30] = 1'b1; openpa_sreq = 1'b1; end
  bit openpa_SW_CORE_def;
  always @(posedge openpa_tg_sw_SW_CORE_st or negedge openpa_tg_sw_SW_CORE_st)
    begin openpa_sp[31] = 1'b1; openpa_sreq = 1'b1; end
  always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
    begin openpa_sp[32] = 1'b1; openpa_sreq = 1'b1; end
  always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
    begin openpa_sp[33] = 1'b1; openpa_sreq = 1'b1; end
  always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
    begin openpa_sp[34] = 1'b1; openpa_sreq = 1'b1; end
  always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
    begin openpa_sp[35] = 1'b1; openpa_sreq = 1'b1; end

  // ---- observation for differential corruption (+openpa_obs): design-top outputs while the top domain is on
  `ifdef OPENPA_OBS
  longint openpa_obs_after;
  initial if (!$value$plusargs("openpa_obs_after=%d", openpa_obs_after)) openpa_obs_after = 0;
  always @(total) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: total=%h", $time, total);
  always @(led) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: led=%h", $time, led);
  always @(rd) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: rd=%h", $time, rd);
  always @(beats) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: beats=%h", $time, beats);
  always @(status) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: status=%h", $time, status);
  always @(pmu_state) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: pmu_state=%h", $time, pmu_state);
  `else
  initial if ($test$plusargs("openpa_obs")) $display("OPENPA-ERROR +openpa_obs needs the copy compiled with OPENPA_OBS defined (-DOPENPA_OBS or +define+OPENPA_OBS)");
  `endif

  // Icarus 12 runs no named block inside a final block, so the report is a function.
  function automatic void openpa_cover_report();
      int hs, ht, hq;
      hs = 0; ht = 0; hq = 0;
      $display("OPENPA-COVER state pst PST_SOC RUN %0d", openpa_cs1[0]);
      $display("OPENPA-COVER state pst PST_SOC SLEEP %0d", openpa_cs1[1]);
      if (openpa_cs1[2]) $display("OPENPA-COVER state pst PST_SOC <none> %0d", openpa_cs1[2]);
      for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2; j++) if (openpa_ct1[i][j]) $display("OPENPA-COVER transition pst PST_SOC %0s -> %0s %0d", openpa_cn1(i), openpa_cn1(j), openpa_ct1[i][j]);
      $display("OPENPA-COVER sequence D4 RET_CORE: save while PD_CORE is on %0d", openpa_seq[1]);
      $display("OPENPA-COVER sequence D5 RET_CORE: restore of a saved state after power-up %0d", openpa_seq[2]);
      $display("OPENPA-COVER sequence D1 HOLD: PD_CORE isolated before power-down %0d", openpa_seq[3]);
      $display("OPENPA-COVER sequence D2/D3 HOLD: isolation released only after PD_CORE was back and restored %0d", openpa_seq[4]);
      $display("OPENPA-COVER sequence D1 FULL: PD_CORE isolated before power-down %0d", openpa_seq[5]);
      $display("OPENPA-COVER sequence D2/D3 FULL: isolation released only after PD_CORE was back and restored %0d", openpa_seq[6]);
      $display("OPENPA-COVER sequence D1 QUIET: PD_CORE isolated before power-down %0d", openpa_seq[7]);
      $display("OPENPA-COVER sequence D2/D3 QUIET: isolation released only after PD_CORE was back and restored %0d", openpa_seq[8]);
      $display("OPENPA-COVER sequence D1 RELEASE: PD_CORE isolated before power-down %0d", openpa_seq[9]);
      $display("OPENPA-COVER sequence D2/D3 RELEASE: isolation released only after PD_CORE was back and restored %0d", openpa_seq[10]);
      if (openpa_cs1[0]) hs = hs + 1;
      if (openpa_cs1[1]) hs = hs + 1;
      if (openpa_seq[1]) hq = hq + 1;
      if (openpa_seq[2]) hq = hq + 1;
      if (openpa_seq[3]) hq = hq + 1;
      if (openpa_seq[4]) hq = hq + 1;
      if (openpa_seq[5]) hq = hq + 1;
      if (openpa_seq[6]) hq = hq + 1;
      if (openpa_seq[7]) hq = hq + 1;
      if (openpa_seq[8]) hq = hq + 1;
      if (openpa_seq[9]) hq = hq + 1;
      if (openpa_seq[10]) hq = hq + 1;
      $display("OPENPA-COVER-SUMMARY states=%0d/2 declared_transitions=%0d/0 sequences=%0d/10", hs, ht, hq);
  endfunction

  // ---- settle process: 35 deferred check(s), run after one #0 in a fixed order
  initial forever begin
    wait (openpa_sreq && openpa_kick);
    #0;
    openpa_sreq = 1'b0;
    if (openpa_sp[1]) begin
      openpa_sp[1] = 1'b0;
          if (!UPF::openpa_dom_PD_CORE_ok) openpa_check(4, "set_retention RET_CORE: save while PD_CORE is off; the saved value is corrupt (pmu_soc.upf:43)");
          else openpa_seq[1] = openpa_seq[1] + 1;
          if (UPF::openpa_ss_anon_VDD_N_VSS_N_ok) begin
            openpa_PD_CORE_RET_CORE_sh0 = u_core.acc;
            openpa_PD_CORE_RET_CORE_valid = 1'b1; openpa_t("RET_CORE save");
            openpa_PD_CORE_RET_CORE_arm7 = UPF::openpa_dom_PD_CORE_ok;
            openpa_PD_CORE_RET_CORE_st7 = $realtime;
          end
    end
    if (openpa_sp[2]) begin
      openpa_sp[2] = 1'b0;
          if (!UPF::openpa_dom_PD_CORE_ok) begin
            openpa_check(5, "set_retention RET_CORE: restore while PD_CORE is off; the retained value is corrupted (pmu_soc.upf:44)");
            openpa_PD_CORE_RET_CORE_sh0 = openpa_xmode ? 'x : UPF::openpa_mix(90003, UPF::openpa_ss_anon_VDD_N_VSS_N_ep, 0);
          end
          else if (!openpa_PD_CORE_RET_CORE_valid) openpa_check(5, "set_retention RET_CORE: restore with no saved state (pmu_soc.upf:44)");
          else begin
            if (UPF::openpa_dom_PD_CORE_sim == 4) begin
              if (openpa_xmode) openpa_cv3 = 'x; else openpa_cv3 = UPF::openpa_mix(80003, UPF::openpa_dom_PD_CORE_ep, 0);
              force u_core.acc = openpa_cv3; release u_core.acc;
              openpa_t("RET_CORE restore in CORRUPT_ON_ACTIVITY: registers corrupted");
            end else begin
              force u_core.acc = openpa_PD_CORE_RET_CORE_sh0; release u_core.acc;
            end
            openpa_PD_CORE_await = 1'b0; openpa_t("RET_CORE restore"); openpa_seq[2] = openpa_seq[2] + 1;
            openpa_PD_CORE_RET_CORE_arm7 = 1'b0;
          end
    end
    if (openpa_sp[3]) begin
      openpa_sp[3] = 1'b0;
        if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_check(1, "set_isolation HOLD (pmu_soc.upf:36): PD_CORE went off while the isolation enable u_pmu.iso_en was inactive");
        else if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) begin openpa_seq[3] = openpa_seq[3] + 1; openpa_ig1_cyc = 1'b1; end
    end
    if (openpa_sp[4]) begin
      openpa_sp[4] = 1'b0;
          if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation HOLD (pmu_soc.upf:36): isolation released while PD_CORE is still off");
          else if (openpa_PD_CORE_await) openpa_check(3, "set_isolation HOLD (pmu_soc.upf:36): isolation released before PD_CORE was restored");
          else if (openpa_ig1_cyc) openpa_seq[4] = openpa_seq[4] + 1;
          openpa_ig1_cyc = 1'b0;
    end
    if (openpa_sp[5]) begin
      openpa_sp[5] = 1'b0;
      if ((UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) && !UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation HOLD (pmu_soc.upf:36): isolation supply AON lost while clamping");
    end
    if (openpa_sp[6]) begin
      openpa_sp[6] = 1'b0;
        if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_check(1, "set_isolation FULL (pmu_soc.upf:35): PD_CORE went off while the isolation enable u_pmu.iso_en was inactive");
        else if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) begin openpa_seq[5] = openpa_seq[5] + 1; openpa_ig2_cyc = 1'b1; end
    end
    if (openpa_sp[7]) begin
      openpa_sp[7] = 1'b0;
          if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation FULL (pmu_soc.upf:35): isolation released while PD_CORE is still off");
          else if (openpa_PD_CORE_await) openpa_check(3, "set_isolation FULL (pmu_soc.upf:35): isolation released before PD_CORE was restored");
          else if (openpa_ig2_cyc) openpa_seq[6] = openpa_seq[6] + 1;
          openpa_ig2_cyc = 1'b0;
    end
    if (openpa_sp[8]) begin
      openpa_sp[8] = 1'b0;
      if ((UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) && !UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation FULL (pmu_soc.upf:35): isolation supply AON lost while clamping");
    end
    if (openpa_sp[9]) begin
      openpa_sp[9] = 1'b0;
        if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_check(1, "set_isolation QUIET (pmu_soc.upf:34): PD_CORE went off while the isolation enable u_pmu.iso_en was inactive");
        else if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) begin openpa_seq[7] = openpa_seq[7] + 1; openpa_ig3_cyc = 1'b1; end
    end
    if (openpa_sp[10]) begin
      openpa_sp[10] = 1'b0;
          if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation QUIET (pmu_soc.upf:34): isolation released while PD_CORE is still off");
          else if (openpa_PD_CORE_await) openpa_check(3, "set_isolation QUIET (pmu_soc.upf:34): isolation released before PD_CORE was restored");
          else if (openpa_ig3_cyc) openpa_seq[8] = openpa_seq[8] + 1;
          openpa_ig3_cyc = 1'b0;
    end
    if (openpa_sp[11]) begin
      openpa_sp[11] = 1'b0;
      if ((UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) && !UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation QUIET (pmu_soc.upf:34): isolation supply AON lost while clamping");
    end
    if (openpa_sp[12]) begin
      openpa_sp[12] = 1'b0;
        if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_check(1, "set_isolation RELEASE (pmu_soc.upf:37): PD_CORE went off while the isolation enable u_pmu.iso_en was inactive");
        else if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) begin openpa_seq[9] = openpa_seq[9] + 1; openpa_ig4_cyc = 1'b1; end
    end
    if (openpa_sp[13]) begin
      openpa_sp[13] = 1'b0;
          if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation RELEASE (pmu_soc.upf:37): isolation released while PD_CORE is still off");
          else if (openpa_PD_CORE_await) openpa_check(3, "set_isolation RELEASE (pmu_soc.upf:37): isolation released before PD_CORE was restored");
          else if (openpa_ig4_cyc) openpa_seq[10] = openpa_seq[10] + 1;
          openpa_ig4_cyc = 1'b0;
    end
    if (openpa_sp[14]) begin
      openpa_sp[14] = 1'b0;
      if ((UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1) && !UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation RELEASE (pmu_soc.upf:37): isolation supply AON lost while clamping");
    end
    if (openpa_sp[15]) begin
      openpa_sp[15] = 1'b0;
      if (openpa_x1_t) openpa_check(9, "u_core/acc of PD_CORE (off) is read by logic in pmu_soc in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[16]) begin
      openpa_sp[16] = 1'b0;
      if (openpa_x2_t) openpa_check(9, "u_core/acc of PD_CORE (off) is read by pmu_soc output total in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[17]) begin
      openpa_sp[17] = 1'b0;
      if (openpa_x3_t) openpa_check(9, "u_core/beats of PD_CORE (off) is read by pmu_soc output beats in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[18]) begin
      openpa_sp[18] = 1'b0;
      if (openpa_x4_t) openpa_check(9, "u_core/busy of PD_CORE (off) is read by logic in pmu_soc in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[19]) begin
      openpa_sp[19] = 1'b0;
      if (openpa_x5_t) openpa_check(9, "u_core/busy of PD_CORE (off) is read by pmu_soc output led in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[20]) begin
      openpa_sp[20] = 1'b0;
      if (openpa_x6_t) openpa_check(9, "u_core/rf_rd of PD_CORE (off) is read by pmu_soc output rd in PD_TOP (on) with no active isolation");
    end
    if (openpa_sp[21]) begin
      openpa_sp[21] = 1'b0;
      if (openpa_x7_t) openpa_check(9, "pmu_soc input clk of PD_TOP (off) is read by u_core/clk in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[22]) begin
      openpa_sp[22] = 1'b0;
      if (openpa_x8_t) openpa_check(9, "pmu_soc input d of PD_TOP (off) is read by u_core/d in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[23]) begin
      openpa_sp[23] = 1'b0;
      if (openpa_x9_t) openpa_check(9, "pmu_soc input en of PD_TOP (off) is read by u_core/en in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[24]) begin
      openpa_sp[24] = 1'b0;
      if (openpa_x10_t) openpa_check(9, "pmu_soc input rf_addr of PD_TOP (off) is read by u_core/rf_addr in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[25]) begin
      openpa_sp[25] = 1'b0;
      if (openpa_x11_t) openpa_check(9, "pmu_soc input rf_we of PD_TOP (off) is read by u_core/rf_we in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[26]) begin
      openpa_sp[26] = 1'b0;
      if (openpa_x12_t) openpa_check(9, "u_pmu/core_rst_n of PD_TOP (off) is read by u_core/rst_n in PD_CORE (on) with no active isolation");
    end
    if (openpa_sp[27]) begin
      openpa_sp[27] = 1'b0;
      if (openpa_l1_t) openpa_check(11, $sformatf("PD_CORE (%0d uV) drives PD_TOP (%0d uV) on 6 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_CORE.voltage, UPF::openpa_net_VDD_N.voltage));
    end
    if (openpa_sp[28]) begin
      openpa_sp[28] = 1'b0;
      if (openpa_l2_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_CORE (%0d uV) on 6 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_CORE.voltage));
    end
    if (openpa_sp[29]) begin
      openpa_sp[29] = 1'b0;
        if (!(UPF::openpa_sw_SW_CORE_st == -1))   // suspended while a power switch is undetermined (D10 reports that)
        begin
          if (UPF::openpa_pst_PST_SOC_row == -1) openpa_check(8, "supplies VDD VDD_LO SW_CORE/vout VSS match no row of power state table PST_SOC (pmu_soc.upf:58)");
        end
    end
    if (openpa_sp[30]) begin
      openpa_sp[30] = 1'b0;
        if (!(UPF::openpa_sw_SW_CORE_st == -1)) begin
          openpa_cc1 = (UPF::openpa_pst_PST_SOC_row < 0) ? 2 : UPF::openpa_pst_PST_SOC_row;
          if (openpa_cc1 != openpa_cp1) begin
            openpa_cs1[openpa_cc1] = openpa_cs1[openpa_cc1] + 1;
            if (openpa_cp1 >= 0) openpa_ct1[openpa_cp1][openpa_cc1] = openpa_ct1[openpa_cp1][openpa_cc1] + 1;
            openpa_cp1 = openpa_cc1;
          end
        end
    end
    if (openpa_sp[31]) begin
      openpa_sp[31] = 1'b0;
      if (UPF::openpa_sw_SW_CORE_st != -1) openpa_SW_CORE_def = 1'b1; else if (openpa_SW_CORE_def) openpa_check(10, "power switch SW_CORE is undetermined: a control is X, or no state (or more than one) holds (pmu_soc.upf:24)");
    end
    if (openpa_sp[32]) begin
      openpa_sp[32] = 1'b0;
      if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_CORE_ok)) openpa_check(12, "u_pmu.pwr_en (switch SW_CORE) comes from PD_TOP, which is off while other domains are on");
    end
    if (openpa_sp[33]) begin
      openpa_sp[33] = 1'b0;
      if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_CORE_ok)) openpa_check(12, "u_pmu.iso_en (isolation QUIET; isolation FULL; isolation HOLD; isolation RELEASE) comes from PD_TOP, which is off while other domains are on");
    end
    if (openpa_sp[34]) begin
      openpa_sp[34] = 1'b0;
      if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_CORE_ok)) openpa_check(12, "u_pmu.save (retention RET_CORE save) comes from PD_TOP, which is off while other domains are on");
    end
    if (openpa_sp[35]) begin
      openpa_sp[35] = 1'b0;
      if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_CORE_ok)) openpa_check(12, "u_pmu.restore (retention RET_CORE restore) comes from PD_TOP, which is off while other domains are on");
    end
  end
  final begin
    $display("OPENPA-SUMMARY D1=%0d D2=%0d D3=%0d D4=%0d D5=%0d D6=%0d D7=%0d D8=%0d D9=%0d D10=%0d D11=%0d D12=%0d D13=%0d D14=%0d", openpa_n[1], openpa_n[2], openpa_n[3], openpa_n[4], openpa_n[5], openpa_n[6], openpa_n[7], openpa_n[8], openpa_n[9], openpa_n[10], openpa_n[11], openpa_n[12], openpa_n[13], openpa_n[14]);
    openpa_cover_report();
    if (!UPF::openpa_armed) $display("OPENPA-WARNING no supply was driven (supply_on/supply_off never called): every domain stayed CORRUPT");
    if (!openpa_SW_CORE_def) $display("OPENPA-WARNING power switch SW_CORE never reached a defined state");
  end
  // verilator lint_on MULTIDRIVEN
`line 59 "pmu_soc.sv" 0
endmodule

`line 1 "pmu.sv" 0
// 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

`line 1 "core.sv" 0
// 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

Common Mistakes

Wrong Count a live regulator as proof that the core can run.

The core takes its power after SW_CORE. The PMU can open that switch independently.

Fix Read both sides of the switch before interpreting the register.

Wrong Call every unknown value a power failure.

An uninitialized register can read X even in NORMAL.

Fix Compare the supply simstate with the reset and write history.

Wrong Assume an unchanged byte saw no activity.

A clock can rise without changing a single stored bit.

Fix Compare the idle edge, the repeated write and the first changing write.

Wrong Expect the old byte to return with the rail.

Restoring power lets ordinary register behavior resume. This buffer has no retained copy.

Fix Look for a reset, restore or new write before relying on the byte.

Remember

  • Read the input pad and the switched output separately.
  • A supply value carries both a state and a voltage.
  • Use an idle edge, a repeated write and a changing write to distinguish simstates.
  • A model behavior policy and a supply simstate answer different questions.

Practice

Report a problem with this page