Hierarchical UPF and Successive Refinement

Integrate an IP block without rewriting its power intent. Follow one guard across three files, then give two copies of an accumulator independent supplies.

You Will Be Able To

  • Assign an IP requirement, a board choice and a technology choice to the appropriate files.
  • Use a scoped load to reuse local names on separate instances.
  • Update the intended strategy without redeclaring it or changing an earlier requirement.
  • Distinguish supply equivalence, reusable UPF libraries and refinable macro boundaries.
Lesson
W4.16
Time
37 min
Runs on
Your browser
Check
6 questions
Three Files Describe One Receiver GuardThe IP owns the required sleep value. The board adds the control and supply. The implementation requests placement.
  • Control
CallValueReturnWaiting
Three Files Describe One Receiver GuardThe IP owns the required sleep value. The board adds the control and supply. The implementation requests placement. component ip.upf locked · safe value component soc.upf enable and supply component technology.upf placement and header component NOTICE one strategy onPD_CORE component led powered receiver select busyadd controladd locationsafe value
  1. component ip.upflocked · safe value
    • select busy → NOTICE
  2. component NOTICEone strategy on PD_CORE
    • safe value → led
  3. component soc.upfenable and supply
    • add control → NOTICE
  4. component ledpowered receiver
  5. component technology.upfplacement and header
    • add location → NOTICE
  1. Read the locked file

    The IP team selects u_core/busy and specifies its safe value. The same file can ship to another board.

  2. Connect the board

    The PMU drives the enable. HOST powers the guard. Both choices refine the existing NOTICE strategy.

  3. Add the implementation

    The new file requests parent placement. NOTICE still selects the same port and still clamps it low.

    Follow the calls, values and waits
    1. data busy: ip.upf → NOTICE
    2. call iso_en: soc.upf → NOTICE
    3. call parent: technology.upf → NOTICE
Read the diagram as text
  • ip.upf: locked · safe value
  • soc.upf: enable and supply
  • technology.upf: placement and header
  • NOTICE: one strategy on PD_CORE
  • led: powered receiver
  • ip.upf → NOTICE: select busy
  • soc.upf → NOTICE: add control
  • technology.upf → NOTICE: add location
  • NOTICE → led: safe value

Drawn file order.

Recorded layerStrategyClampEnableRequested locationUpdates
constraintNOTICE0(unset)(unset)0
configurationNOTICE0u_pmu/iso_en(unset)1
implementationNOTICE0u_pmu/iso_enparent2
Recorded PMU sequence from OpenPA and Icarus.
work switch=1 guard=0 raw=1 led=1
prepare switch=1 guard=1 raw=1 led=0
park switch=0 guard=1 raw=1 led=0

Zero survives every handoff, although the first file knows nothing about the PMU control.

In prepare, raw stays one while led falls to zero. Follow that bit through the three files.

Read the Locked IP Requirements

The host reads busy while the core sleeps. Because every board needs a safe zero, the IP team specifies that requirement.

PMU constraint file.
create_power_domain PD_CORE -elements {u_core}
set_isolation NOTICE -domain PD_CORE -elements {u_core/busy} -clamp_value 0
Recorded layerStrategyClampEnableRequested locationUpdates
constraintNOTICE0(unset)(unset)0
configurationNOTICE0u_pmu/iso_en(unset)1
implementationNOTICE0u_pmu/iso_enparent2

In the constraint row, NOTICE already has clamp 0, but its enable and requested location are both unset.

Before

u_core/busy -> led
Safe value unspecified

Drawn receiving interface before the IP file.

After

PD_CORE owns u_core
NOTICE selects u_core/busy
Safe value = 0

Drawn IP requirement.

The fingerprint below identifies the delivered bytes even if a later edit passes a short sleep test.

Recorded SHA-256 of the exact ip.upf bytes in this assembly.
d1209439b313c8174f1ae8e633cbe42d150d553c2b299ba4967488eb79e5ed54

Who supplies the guard’s enable?

Connect the Board in Configuration UPF

On pmu_soc, u_pmu/iso_en rises before SW_CORE opens.

The guard needs HOST because that supply stays live through the cut.

Board update to NOTICE.
create_supply_set HOST -function {power VDD_N} -function {ground VSS_N}
set_isolation NOTICE -domain PD_CORE -update -isolation_signal u_pmu/iso_en -isolation_supply HOST
Recorded PMU sequence from OpenPA and Icarus.
work switch=1 guard=0 raw=1 led=1
prepare switch=1 guard=1 raw=1 led=0
park switch=0 guard=1 raw=1 led=0

In prepare, switch is still one and raw is still one, yet led has fallen to zero because guard rose.

Layer ownerQuestion this owner can answerChoice in the lab
Core IPWhich value is safe outside the core?Low on the busy path
Board integrationWho asks the guard to assert?u_pmu/iso_en
Board integrationWhat powers the guard during the cut?HOST, derived from VDD_N and VSS_N
ImplementationWhere should the guard be placed?Still open at this checkpoint

Successive refinement adds decisions as the system becomes known (4.9.1).

This runnable board file includes rail setup. A project can deliver rail wiring in its implementation layer.

How does soc.upf add those choices without declaring NOTICE twice?

Update the Same Strategy in the Same Scope

The board author finds NOTICE in ip.upf. Can soc.upf add a controller by repeating the declaration?

Before

set_isolation NOTICE -domain PD_CORE -elements {u_core/busy}
# Second declaration after reading ip.upf.

A declaration collides with NOTICE in this scope.

After

set_isolation NOTICE -domain PD_CORE -update -location parent

An update identifies the existing strategy and adds placement.

Recorded duplicate declaration.
review.upf:2: set_isolation NOTICE: strategy already defined at ip.upf:2; use -update to add options
Recorded misspelled update.
review.upf:2: set_isolation NOTICES: no isolation strategy "NOTICES" on domain PD_CORE to update

The duplicate row points back to ip.upf:2 because NOTICE already exists. The NOTICES row finds no strategy to extend.

Because NOTICE owns the original selection, use -update on the same name and domain in its original scope (5.10, 6.48).

Each command defines which information an update can add.

Now follow the successful update into technology.upf.

Read the Implementation Handoff

NOTICE already guards led. The implementation team still needs to choose placement and a header for SW_CORE.

Implementation file with drawn candidate HEADER_X1.
set_isolation NOTICE -domain PD_CORE -update -location parent
map_power_switch SW_CORE -lib_cells HEADER_X1
Recorded layerStrategyClampEnableRequested locationUpdates
constraintNOTICE0(unset)(unset)0
configurationNOTICE0u_pmu/iso_en(unset)1
implementationNOTICE0u_pmu/iso_enparent2

In the implementation row, parent appears and the update count reaches two. NOTICE still names the same enable and clamp.

OpenPA models parent placement on the host connection.

It records HEADER_X1 while simulating SW_CORE as an abstract switch.

Before

assembly.upf
  read the board layer

Drawn board assembly.

After

assembly.upf
  read the board layer
  read the technology layer

Drawn placement and cell handoff.

Recorded PMU sequence from OpenPA and Icarus.
park switch=0 guard=1 raw=1 led=0
return switch=1 guard=0 raw=1 led=1

At park, switch=0 and led=0. At return, switch=1 and led=1. Both readings came from the abstract switch.

Those samples cannot tell you who chose parent. Use the recorded layer rows to answer that question.

EvidenceQuestion it answersQuestion still open
An unchanged IP fingerprintDid the delivered file change?Did the board choose the correct controller?
Reader origin and update rowsWhich layer made each choice?What did the receiver see during sleep?
An off and wake traceDid the model meet the receiver requirement?Was the requested physical cell placed?

W4.16.1 checks the two layers. Next, make one local file work in two sockets.

Load One Local File at Two Instances

The two accumulators in duo need the same local domain, so tile.upf refers to its instance with a dot.

Complete local IP file in the two-socket run.
create_power_domain LOCAL -elements {.}

Before

load_upf tile.upf
# LOCAL is interpreted at the caller.

At the caller.

After

load_upf tile.upf -scope u_cpu
load_upf tile.upf -scope u_gpu

Inside each socket in turn.

Recorded domainSource fileLine
HOSTpair.upf3
u_cpu/LOCALtile.upf1
u_gpu/LOCALtile.upf1

The u_cpu/LOCAL and u_gpu/LOCAL rows both point to tile.upf line 1 because each load supplies a different scope.

A scoped load executes inside the named instance, then restores the caller’s context (6.35).

Where the reader standsMeaning of the dot hereInstance owned by LOCAL
Inside the CPU callThe CPU socketu_cpu
Inside the GPU callThe GPU socketu_gpu
After both callsThe surrounding design scopeUse the full path to select either LOCAL

An older delivery may use load_upf_protected. OpenPA 0.3.0 refuses it. Current load_upf options cover that handoff (6.35, D.3).

Recorded OpenPA refusal for this feature.
experiment.upf:1: load_upf_protected is not supported (deprecated; IEEE 1801-2024 Annex D names load_upf -hide_globals in its place)

Which regulator powers each socket?

Connect Each Primary and Cut One Rail

Both sockets have a LOCAL domain. To cut just one rail, bind each primary to its own regulator.

Runnable socket assembly.
foreach {socket rail} {u_cpu LEFT_SS u_gpu RIGHT_SS} {
  load_upf tile.upf -scope $socket
  associate_supply_set $rail -handle ${socket}/LOCAL.primary
}

After the CPU load, the dot once again means duo. Use u_cpu/LOCAL.primary to give that socket LEFT_SS (6.10).

Recorded cuts on duo.
both cpu=05 gpu=06
one cpu=xx gpu=0c
other cpu=05 gpu=xx

In one, cpu is xx while gpu advances to 0c because only the left regulator was cut.

After restoring and resetting both sockets, the bench cuts the right rail. Now only gpu is unknown.

Recorded crossing checks from the same run.
OPENPA-CHECK D9 @ 12000: u_cpu/q of LOCAL (off) is read by duo output q_cpu in HOST (on) with no active isolation
OPENPA-CHECK D9 @ 26000: u_gpu/q of LOCAL (off) is read by duo output q_gpu in HOST (on) with no active isolation

D9 names u_cpu/q first and u_gpu/q second. The paths distinguish the two LOCAL domains.

Could these supplies ever be equivalent?

Decide Whether Two Supply Names Mean the Same Thing

At startup, both accumulator rails are live. One voltage sample makes two separate feeds look alike.

Recorded cuts on duo.
both cpu=05 gpu=06
one cpu=xx gpu=0c

In one, gpu still reads 0c while cpu is xx. Independent cuts rule out one electrical supply.

Before

Two names on separate regulator outputs
A matching sample is inconclusive.

Drawn separate feeds.

After

set_equivalent -sets {BOARD_MAIN SERVICE_MAIN}

Drawn names for one connected supply.

Use -sets for supply sets or -nets for supply nets and ports (6.47).

Suppose the board guarantees the same power behavior but requires a particular feed for inserted cells.

Drawn alternative for that board guarantee. The independent accumulator rails do not meet it.
set_equivalent -sets {BOARD_MAIN SERVICE_MAIN} -function_only -interchangeable FALSE

Here -function_only describes the behavior. FALSE prevents one feed from replacing the other for an inserted cell (6.47).

Proposed evidenceWhat you can conclude
Same voltage in one RUN rowOnly that the sampled values match
Separate controls that can shut down either feedOne electrical source cannot explain both independent cuts
Both names trace to the same connected power and groundAn electrical equivalence can describe those two names
A functional relationship specified across operating statesConsider functional equivalence and its interchangeability rules
Recorded OpenPA refusal for this feature.
experiment.upf:1: set_equivalent is not supported (IEEE 1801-2024 6.47): it changes which supplies count as the same in -source, -sink and -diff_supply_only

W4.16.2 checks a drawn equivalence. Next, decide how the sockets can share library objects.

Create, Load and Use a UPF Library

Both duo sockets need the same conversion method. Loading tile.upf again would repeat the domain declaration.

Put the method in io_types so both consumers can refer to it by name.

Before

Socket integration
  tile.upf inside u_cpu
  tile.upf inside u_gpu

Drawn two-instance execution. Each load acts on hardware at its scope.

After

Shared package
  io_catalog.upf defines io_types
  consuming scope uses io_types

Drawn library handoff. Consumers can see shared definitions.

Drawn empty library shell.
create_upf_library io_types -contents {}

This drawn shell creates the io_types namespace (6.29). Its empty braces leave room for a conversion method.

Drawn consuming file. The first name is a file. The second names the UPF library.
load_upf_library io_catalog.upf
use_upf_library io_types

The first line reads io_catalog.upf once through the library loader (6.36).

Once io_types exists, the second line makes its objects visible in this scope (6.63).

StepRecorded OpenPA response
create_upf_libraryexperiment.upf:1: create_upf_library is not supported: UPF libraries (IEEE 1801-2024 6.29)
load_upf_libraryexperiment.upf:1: load_upf_library is not supported: UPF libraries (IEEE 1801-2024 6.36)
use_upf_libraryexperiment.upf:1: use_upf_library is not supported: UPF libraries (IEEE 1801-2024 6.63)

In the load_upf_library row, OpenPA reports unsupported library loading. The earlier socket run used tile.upf directly.

Next, ask what can change inside the delivered macro.

Respect a Refinable Macro Boundary

The accumulator team now wants to preserve its standalone validation when the board adds implementation details.

Before

Plain RTL instance
  board integration can select visible paths

Ordinary duo instance.

After

Refinable macro model
  self-contained IP intent
  separate implementation handoff

Drawn macro with its original intent.

Drawn handoff for a macro view.
set_design_attributes -models acc -is_refinable_macro
load_upf socket_impl.upf -scope u_cpu -implementation

Mark acc as refinable so its instances keep a boundary around their self-contained intent (6.44, 4.9.2.4.3).

A fanout placement search stops at that boundary (4.9.2.3.2). Only implementation commands may appear in socket_impl.upf here (6.35).

Recorded OpenPA refusal for this feature.
experiment.upf:1: set_design_attributes -is_refinable_macro: not supported by OpenPA (IEEE 1801-2024 6.44): macros, power-aware models and switch cell types change simulation
Recorded OpenPA refusal for this feature.
experiment.upf:1: load_upf -implementation: not supported by OpenPA (IEEE 1801-2024 6.35)

The load_upf refusal singles out -implementation. The same reader successfully loaded tile.upf at both ordinary socket scopes.

Return to the running PMU and check the requirement that validation must preserve.

Observe the Handoff with a Verification Checker

The host needs led low on every guarded sample. A single measurement after shutdown could miss an earlier failure.

Before

Inspect led once after the switch opens.

Drawn final sample.

After

At each falling clock edge with guard high:
  require led == 0

Drawn repeated check.

Runnable testbench observer. The case comparison also catches X or Z.
integer checks=0;
 always @(negedge clk) if (rst_n && dut.iso_en===1'b1) begin
   checks++;
   if (led!==1'b0) $fatal(1,"LED escaped during isolation");
 end
Recorded guarded-edge experiment. The quiz reruns this observer.
prepare switch=1 guard=1 raw=1 led=0
park switch=0 guard=1 raw=1 led=0
return switch=1 guard=0 raw=1 led=1
observed guarded_edges=7

The observed row counts seven guarded edges because the monitor stays active through shutdown and the guarded portion of wake.

A verification macro can package this observer. bind_checker attaches a checker module for verification (6.12).

Drawn checker attachment. The bench observes led directly.
bind_checker WAKE_WATCH -module led_monitor -bind_to pmu_soc \
  -ports {{enable iso_en} {observed led} {clock clk}}
Recorded OpenPA refusal for this feature.
experiment.upf:1: bind_checker is not supported (IEEE 1801-2024 6.12); write the checker in the bench
When you review a new integrationEvidence to ask for
A reused IP declarationThe same source file and the scoped object names
A board refinementThe original selection, each update and the resulting intent
An implementation choiceIts owning layer, a compatible technology view and the unchanged functional requirement
A verification observationA named signal, a sampling event and the condition that would fail

In W4.16.1, check which layer made each choice. In W4.16.2, exercise both independent rails.

Try It

Read ip.upf, soc.upf and technology.upf in the source panels. Locate the first declaration of NOTICE and both updates.

Run the sleep sequence with en high. Compare led with raw before the switch opens and after the guard releases.

Try en low. Losing the difference between raw and led makes a bad control connection harder to detect.

D9 reports neighboring unprotected paths. D11 reports voltage crossings. This lab selects only the busy path for isolation.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: OPENPA-INFO corruption=x seed=1 OPENPA-CHECK D11 @ 5000: PD_CORE (800000 uV) drives PD_TOP (1000000 uV) on 6 port(s) with no level shifter for this direction OPENPA-CHECK D11 @ 5000: PD_TOP (1000000 uV) drives PD_CORE (800000 uV) on 6 port(s) with no level shifter for this direction work switch=1 guard=0 raw=1 led=1 prepare switch=1 guard=1 raw=1 led=0 OPENPA-CHECK D9 @ 55000: 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 @ 55000: 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 @ 55000: 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 @ 55000: u_core/rf_rd of PD_CORE (off) is read by pmu_soc output rd in PD_TOP (on) with no active isolation park switch=0 guard=1 raw=1 led=0 OPENPA-CHECK D11 @ 65000: PD_CORE (800000 uV) drives PD_TOP (1000000 uV) on 6 port(s) with no level shifter for this direction OPENPA-CHECK D11 @ 65000: PD_TOP (1000000 uV) drives PD_CORE (800000 uV) on 6 port(s) with no level shifter for this direction return switch=1 guard=0 raw=1 led=1 OPENPA-SUMMARY D1=0 D2=0 D3=0 D4=0 D5=0 D6=0 D7=0 D8=0 D9=4 D10=0 D11=4 D12=0 D13=0 D14=0 OPENPA-COVER sequence D1 NOTICE: PD_CORE isolated before power-down 1 OPENPA-COVER sequence D2/D7 NOTICE: isolation released only after PD_CORE was back and reset 1 OPENPA-COVER-SUMMARY states=0/0 declared_transitions=0/0 sequences=2/2
Read the power intent: assembly.upf
load_upf soc.upf
load_upf technology.upf
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
Read the power-unaware RTL: ip.upf
create_power_domain PD_CORE -elements {u_core}
set_isolation NOTICE -domain PD_CORE -elements {u_core/busy} -clamp_value 0
Read the power-unaware RTL: soc.upf
upf_version 4.0
# 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
load_upf ip.upf

# 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

create_supply_set HOST -function {power VDD_N} -function {ground VSS_N}
set_isolation NOTICE -domain PD_CORE -update -isolation_signal u_pmu/iso_en -isolation_supply HOST
Read the power-unaware RTL: technology.upf
set_isolation NOTICE -domain PD_CORE -update -location parent
map_power_switch SW_CORE -lib_cells HEADER_X1
What UPF added: 42 objects

3 supply port, 4 supply net, 10 output corruption, 1 isolation cell, 1 power switch, 3 supply set, 4 register corruption, 1 memory corruption, 15 dynamic check.

ObjectWhereDetailRuleUPF line
Supply portVDDsoc.upf:9
Supply portVDD_LOsoc.upf:10
Supply portVSSsoc.upf:11
Supply netVDD_Nsoc.upf:9
Supply netVDDL_Nsoc.upf:10
Supply netVSS_Nsoc.upf:11
Supply netVDD_COREsoc.upf:24
Output corruptionu_core/accC2ip.upf:1
Output corruptionu_core/beatsC2ip.upf:1
Output corruptionu_core/busyC2ip.upf:1
Isolation cellu_core/busyNOTICE · clamp 0I1-I5ip.upf:2
Output corruptionu_core/rf_rdC2ip.upf:1
Output corruptionu_core/clkC2soc.upf:5
Output corruptionu_core/dC2soc.upf:5
Output corruptionu_core/enC2soc.upf:5
Output corruptionu_core/rf_addrC2soc.upf:5
Output corruptionu_core/rf_weC2soc.upf:5
Output corruptionu_core/rst_nC2soc.upf:5
Power switchSW_CORES3 (IEEE 1801-2024 6.23)soc.upf:24
Supply setPD_TOP.primarysoc.upf:5
Supply setPD_CORE.primaryip.upf:1
Supply setHOSTsoc.upf:33
Register corruptionstatusC1soc.upf:5
Register corruptionu_pmu.stC1soc.upf:5
Register corruptionu_core.accC1ip.upf:1
Register corruptionu_core.beatsC1ip.upf:1
Memory corruptionu_core.rfC1ip.upf:1
Dynamic checkD1/D2/D7/D6 NOTICED1, D2, D7, D6ip.upf:2
Dynamic checkD9 crossing 1D9ip.upf:1
Dynamic checkD9 crossing 2D9ip.upf:1
Dynamic checkD9 crossing 3D9ip.upf:1
Dynamic checkD9 crossing 4D9ip.upf:1
Dynamic checkD9 crossing 5D9ip.upf:1
Dynamic checkD9 crossing 6D9ip.upf:1
Dynamic checkD9 crossing 7D9soc.upf:5
Dynamic checkD9 crossing 8D9soc.upf:5
Dynamic checkD9 crossing 9D9soc.upf:5
Dynamic checkD9 crossing 10D9soc.upf:5
Dynamic checkD9 crossing 11D9soc.upf:5
Dynamic checkD9 crossing 12D9soc.upf:5
Dynamic checkD11 PD_CORE->PD_TOPD11ip.upf:1
Dynamic checkD11 PD_TOP->PD_CORED11soc.upf:5

OpenPA warnings:

  • ip.upf:1 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)
  • ip.upf:1 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)
  • ip.upf:1 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)
  • ip.upf:1 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 assembly.upf, soc.upf, ip.upf, technology.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 (soc.upf:9)
  supply_net_type openpa_port_VDD_LO;   // supply port VDD_LO (soc.upf:10)
  supply_net_type openpa_port_VSS;   // supply port VSS (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 (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_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 (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 (ip.upf:1)
  // 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)
  logic openpa_ctl_1_u_pmu_iso_en;   // copy of u_pmu.iso_en (isolation NOTICE)
  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 == "HOST.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST.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 == "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 == "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 == "HOST.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST.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 == "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 == "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 == "HOST.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST.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 == "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 == "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 == "HOST.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST.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 == "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 == "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 == "HOST.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 == "HOST.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; wire [3:0] openpa_u_core_beats_raw; wire [0:0] openpa_u_core_busy_raw, openpa_u_core_busy_s1; 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(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(268435473)) 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_HOST_sim == 0)), .sup_ep(UPF::openpa_ss_HOST_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 assembly.upf, soc.upf, ip.upf, technology.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_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_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_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:2];   // good-form sequence bins (coverage)
  bit openpa_sreq; bit openpa_sp [1:20];   // 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;

  // ---- 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 (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 HOST: 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_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_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
    // 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 (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 (ip.upf:1): 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

  // D7 reset check for PD_CORE: resets u_core.rst_n active 0
  bit openpa_PD_CORE_rprev, openpa_PD_CORE_rp0;
  always @(posedge UPF::openpa_dom_PD_CORE_ok or negedge UPF::openpa_dom_PD_CORE_ok or posedge u_core.rst_n or negedge u_core.rst_n) begin
    if (UPF::openpa_dom_PD_CORE_ok && !openpa_PD_CORE_rprev) openpa_PD_CORE_rp0 = 1'b1;
    if (!UPF::openpa_dom_PD_CORE_ok || u_core.rst_n === 1'b0) openpa_PD_CORE_rp0 = 1'b0;
    openpa_PD_CORE_rprev = UPF::openpa_dom_PD_CORE_ok;
  end

  // ---- checks for set_isolation NOTICE (ip.upf:2): 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[1] = 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[2] = 1'b1; openpa_sreq = 1'b1; end
    if (openpa_ig1_act != (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_t({"NOTICE 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_HOST_ok) if (!UPF::openpa_ss_HOST_ok)
    begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; 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[4] = 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[5] = 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[6] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 4: u_core/busy (PD_CORE) -> logic in pmu_soc (PD_TOP), isolated by NOTICE
  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_HOST_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_HOST_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[7] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 5: u_core/busy (PD_CORE) -> pmu_soc output led (PD_TOP), isolated by NOTICE
  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_HOST_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_HOST_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[8] = 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[9] = 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[10] = 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[11] = 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[12] = 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[13] = 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[14] = 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[15] = 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[16] = 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[17] = 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[18] = 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[19] = 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[20] = 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 sequence D1 NOTICE: PD_CORE isolated before power-down %0d", openpa_seq[1]);
      $display("OPENPA-COVER sequence D2/D7 NOTICE: isolation released only after PD_CORE was back and reset %0d", openpa_seq[2]);
      if (openpa_seq[1]) hq = hq + 1;
      if (openpa_seq[2]) hq = hq + 1;
      $display("OPENPA-COVER-SUMMARY states=%0d/0 declared_transitions=%0d/0 sequences=%0d/2", hs, ht, hq);
  endfunction

  // ---- settle process: 20 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 && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_check(1, "set_isolation NOTICE (ip.upf:2): 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[1] = openpa_seq[1] + 1; openpa_ig1_cyc = 1'b1; end
    end
    if (openpa_sp[2]) begin
      openpa_sp[2] = 1'b0;
          if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation NOTICE (ip.upf:2): isolation released while PD_CORE is still off");
          else if (openpa_PD_CORE_rp0) openpa_check(7, "set_isolation NOTICE (ip.upf:2): isolation released after PD_CORE powered up but before its reset u_core.rst_n was asserted");
          else if (openpa_ig1_cyc) openpa_seq[2] = openpa_seq[2] + 1;
          openpa_ig1_cyc = 1'b0;
    end
    if (openpa_sp[3]) begin
      openpa_sp[3] = 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 NOTICE (ip.upf:2): isolation supply HOST lost while clamping");
    end
    if (openpa_sp[4]) begin
      openpa_sp[4] = 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[5]) begin
      openpa_sp[5] = 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[6]) begin
      openpa_sp[6] = 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[7]) begin
      openpa_sp[7] = 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[8]) begin
      openpa_sp[8] = 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[9]) begin
      openpa_sp[9] = 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[10]) begin
      openpa_sp[10] = 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[11]) begin
      openpa_sp[11] = 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[12]) begin
      openpa_sp[12] = 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[13]) begin
      openpa_sp[13] = 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[14]) begin
      openpa_sp[14] = 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[15]) begin
      openpa_sp[15] = 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[16]) begin
      openpa_sp[16] = 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[17]) begin
      openpa_sp[17] = 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[18]) begin
      openpa_sp[18] = 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 (soc.upf:24)");
    end
    if (openpa_sp[19]) begin
      openpa_sp[19] = 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[20]) begin
      openpa_sp[20] = 1'b0;
      if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_CORE_ok)) openpa_check(12, "u_pmu.iso_en (isolation NOTICE) 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 outputThe left socket loses power first. What does the row named one show?
`timescale 1ns/1ps
module tb;
 import UPF::*;
 logic clk=0,rst_n=0,en=1,sleep_cpu_n=1,pwr_gpu=1,iso_cpu=0,iso_gpu=0;
 logic [7:0] d=5; wire [7:0] q_cpu,q_gpu; wire [1:0] acks;
 duo dut(.*);
 task tick; #2 clk=1; #2 clk=0; endtask
 task sample(input string phase); #2; $display("%s cpu=%h gpu=%h",phase,q_cpu,q_gpu); endtask
 initial begin
   void'(supply_on("VG",0.0)); void'(supply_on("VHOST")); void'(supply_on("VLEFT")); void'(supply_on("VRIGHT"));
   #2; tick; rst_n=1; tick; sample("both");
   void'(supply_off("VLEFT")); #2; tick; sample("one");
   void'(supply_on("VLEFT")); rst_n=0; #2; tick; rst_n=1;
   void'(supply_off("VRIGHT")); #2; tick; sample("other"); $finish;
 end
endmodule
Read included file: pa_duo.sv
// pa_duo.sv: power-aware copy of duo, generated by OpenPA from pair.upf, tile.upf, tile.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 (pair.upf:5)
  supply_net_type openpa_port_VLEFT;   // supply port VLEFT (pair.upf:5)
  supply_net_type openpa_port_VRIGHT;   // supply port VRIGHT (pair.upf:5)
  supply_net_type openpa_port_VG;   // supply port VG (pair.upf:5)
  supply_net_type openpa_net_N_VHOST;   // supply net N_VHOST
  supply_net_type openpa_net_N_VLEFT;   // supply net N_VLEFT
  supply_net_type openpa_net_N_VRIGHT;   // supply net N_VRIGHT
  supply_net_type openpa_net_N_VG;   // supply net N_VG
  bit openpa_ss_HOST_SS_ok; int unsigned openpa_ss_HOST_SS_ep; int openpa_ss_HOST_SS_st = -1; bit openpa_ss_HOST_SS_multi; int openpa_ss_HOST_SS_sim = 5;   // supply set HOST_SS
  bit openpa_ss_LEFT_SS_ok; int unsigned openpa_ss_LEFT_SS_ep; int openpa_ss_LEFT_SS_st = -1; bit openpa_ss_LEFT_SS_multi; int openpa_ss_LEFT_SS_sim = 5;   // supply set LEFT_SS
  bit openpa_ss_RIGHT_SS_ok; int unsigned openpa_ss_RIGHT_SS_ep; int openpa_ss_RIGHT_SS_st = -1; bit openpa_ss_RIGHT_SS_multi; int openpa_ss_RIGHT_SS_sim = 5;   // supply set RIGHT_SS
  bit openpa_dom_HOST_ok; int unsigned openpa_dom_HOST_ep; int openpa_dom_HOST_sim = 5;   // power domain HOST: ok = powered (simstate not CORRUPT); sim = simstate code (pair.upf:3)
  bit openpa_dom_u_cpu_LOCAL_ok; int unsigned openpa_dom_u_cpu_LOCAL_ep; int openpa_dom_u_cpu_LOCAL_sim = 5;   // power domain LOCAL: ok = powered (simstate not CORRUPT); sim = simstate code (tile.upf:1)
  bit openpa_dom_u_gpu_LOCAL_ok; int unsigned openpa_dom_u_gpu_LOCAL_ep; int openpa_dom_u_gpu_LOCAL_sim = 5;   // power domain LOCAL: ok = powered (simstate not CORRUPT); sim = simstate code (tile.upf:1)
  // 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 == "VLEFT") begin openpa_port_VLEFT.state = FULL_ON; openpa_port_VLEFT.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VRIGHT") begin openpa_port_VRIGHT.state = FULL_ON; openpa_port_VRIGHT.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VG") begin openpa_port_VG.state = FULL_ON; openpa_port_VG.voltage = openpa_uv(value); return 1; end
    if (pad_name == "N_VHOST") begin $display("OPENPA-ERROR supply_on(\"%s\"): N_VHOST already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_SS.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST_SS.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_ALIAS.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST_ALIAS.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VLEFT") begin $display("OPENPA-ERROR supply_on(\"%s\"): N_VLEFT already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LEFT_SS.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): LEFT_SS.power already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): LOCAL.primary.power already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VRIGHT") begin $display("OPENPA-ERROR supply_on(\"%s\"): N_VRIGHT already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "RIGHT_SS.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): RIGHT_SS.power already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): LOCAL.primary.power already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VG") begin $display("OPENPA-ERROR supply_on(\"%s\"): N_VG already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_SS.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LEFT_SS.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): LEFT_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "RIGHT_SS.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): RIGHT_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_ALIAS.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST_ALIAS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST.primary.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): LOCAL.primary.ground already has a driver (port VG); 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 VLEFT VRIGHT VG)", 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 == "VLEFT") begin openpa_port_VLEFT.state = OFF; return 1; end
    if (pad_name == "VRIGHT") begin openpa_port_VRIGHT.state = OFF; return 1; end
    if (pad_name == "VG") begin openpa_port_VG.state = OFF; return 1; end
    if (pad_name == "N_VHOST") begin $display("OPENPA-ERROR supply_off(\"%s\"): N_VHOST already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_SS.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST_SS.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_ALIAS.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST_ALIAS.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VLEFT") begin $display("OPENPA-ERROR supply_off(\"%s\"): N_VLEFT already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LEFT_SS.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): LEFT_SS.power already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): LOCAL.primary.power already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VRIGHT") begin $display("OPENPA-ERROR supply_off(\"%s\"): N_VRIGHT already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "RIGHT_SS.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): RIGHT_SS.power already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): LOCAL.primary.power already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VG") begin $display("OPENPA-ERROR supply_off(\"%s\"): N_VG already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_SS.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LEFT_SS.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): LEFT_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "RIGHT_SS.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): RIGHT_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_ALIAS.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST_ALIAS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST.primary.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): LOCAL.primary.ground already has a driver (port VG); 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 VLEFT VRIGHT VG)", 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 == "VLEFT") begin openpa_port_VLEFT.state = PARTIAL_ON; openpa_port_VLEFT.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VRIGHT") begin openpa_port_VRIGHT.state = PARTIAL_ON; openpa_port_VRIGHT.voltage = openpa_uv(value); return 1; end
    if (pad_name == "VG") begin openpa_port_VG.state = PARTIAL_ON; openpa_port_VG.voltage = openpa_uv(value); return 1; end
    if (pad_name == "N_VHOST") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): N_VHOST already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_SS.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST_SS.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_ALIAS.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST_ALIAS.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VLEFT") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): N_VLEFT already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LEFT_SS.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): LEFT_SS.power already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): LOCAL.primary.power already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VRIGHT") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): N_VRIGHT already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "RIGHT_SS.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): RIGHT_SS.power already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): LOCAL.primary.power already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VG") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): N_VG already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_SS.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LEFT_SS.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): LEFT_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "RIGHT_SS.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): RIGHT_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_ALIAS.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST_ALIAS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST.primary.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): LOCAL.primary.ground already has a driver (port VG); 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 VLEFT VRIGHT VG)", 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 == "VLEFT") begin openpa_port_VLEFT.state = supply_state; return 1; end
    if (pad_name == "VRIGHT") begin openpa_port_VRIGHT.state = supply_state; return 1; end
    if (pad_name == "VG") begin openpa_port_VG.state = supply_state; return 1; end
    if (pad_name == "N_VHOST") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): N_VHOST already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_SS.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST_SS.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_ALIAS.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST_ALIAS.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST.primary.power already has a driver (port VHOST); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VLEFT") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): N_VLEFT already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LEFT_SS.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): LEFT_SS.power already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): LOCAL.primary.power already has a driver (port VLEFT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VRIGHT") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): N_VRIGHT already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "RIGHT_SS.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): RIGHT_SS.power already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): LOCAL.primary.power already has a driver (port VRIGHT); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "N_VG") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): N_VG already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_SS.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LEFT_SS.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): LEFT_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "RIGHT_SS.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): RIGHT_SS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST_ALIAS.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST_ALIAS.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "HOST.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST.primary.ground already has a driver (port VG); drive its root supply instead", pad_name); return 0; end
    if (pad_name == "LOCAL.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): LOCAL.primary.ground already has a driver (port VG); 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 VLEFT VRIGHT VG)", 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 == "N_VHOST" || name == "HOST_SS.power" || name == "HOST_ALIAS.power" || name == "HOST.primary.power") return openpa_net_N_VHOST;
    if (name == "VLEFT" || name == "N_VLEFT" || name == "LEFT_SS.power" || name == "LOCAL.primary.power") return openpa_net_N_VLEFT;
    if (name == "VRIGHT" || name == "N_VRIGHT" || name == "RIGHT_SS.power" || name == "LOCAL.primary.power") return openpa_net_N_VRIGHT;
    if (name == "VG" || name == "N_VG" || name == "HOST_SS.ground" || name == "LEFT_SS.ground" || name == "RIGHT_SS.ground" || name == "HOST_ALIAS.ground" || name == "HOST.primary.ground" || name == "LOCAL.primary.ground") return openpa_net_N_VG;
    $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 "duo.sv" 0
// duo: an always-on top with a CPU and a GPU. Power-unaware RTL.
module duo (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       en,
  input  logic [7:0] d,
  input  logic       sleep_cpu_n,
  input  logic       pwr_gpu,
  input  logic       iso_cpu,
  input  logic       iso_gpu,
  output logic [7:0] q_cpu,
  output logic [7:0] q_gpu,
  output logic [1:0] acks
);
  wire ack_cpu, ack_gpu;   // no RTL drives these wires: the UPF switches' -ack_port do
  wire [7:0] openpa_u_cpu_q_raw; wire [0:0] openpa_u_cpu_clk_s1; wire [7:0] openpa_u_cpu_d_s1; wire [0:0] openpa_u_cpu_en_s1; wire [0:0] openpa_u_cpu_rst_n_s1; acc u_cpu (.clk(openpa_u_cpu_clk_s1), .rst_n(openpa_u_cpu_rst_n_s1), .en(openpa_u_cpu_en_s1), .d(openpa_u_cpu_d_s1),        .q(openpa_u_cpu_q_raw)); openpa_corrupt #(.W(8), .ID(268435456)) openpa_u_cpu_q_cor (.d(openpa_u_cpu_q_raw), .q(q_cpu), .ok(UPF::openpa_dom_u_cpu_LOCAL_ok), .ep(UPF::openpa_dom_u_cpu_LOCAL_ep)); openpa_corrupt #(.W(1), .ID(268435472)) openpa_u_cpu_clk_cor (.d(clk), .q(openpa_u_cpu_clk_s1), .ok(UPF::openpa_dom_HOST_ok), .ep(UPF::openpa_dom_HOST_ep)); openpa_corrupt #(.W(8), .ID(268435480)) openpa_u_cpu_d_cor (.d(d), .q(openpa_u_cpu_d_s1), .ok(UPF::openpa_dom_HOST_ok), .ep(UPF::openpa_dom_HOST_ep)); openpa_corrupt #(.W(1), .ID(268435488)) openpa_u_cpu_en_cor (.d(en), .q(openpa_u_cpu_en_s1), .ok(UPF::openpa_dom_HOST_ok), .ep(UPF::openpa_dom_HOST_ep)); openpa_corrupt #(.W(1), .ID(268435496)) openpa_u_cpu_rst_n_cor (.d(rst_n), .q(openpa_u_cpu_rst_n_s1), .ok(UPF::openpa_dom_HOST_ok), .ep(UPF::openpa_dom_HOST_ep));
  wire [7:0] openpa_u_gpu_q_raw; wire [0:0] openpa_u_gpu_clk_s1; wire [7:0] openpa_u_gpu_d_s1; wire [0:0] openpa_u_gpu_en_s1; wire [0:0] openpa_u_gpu_rst_n_s1; acc u_gpu (.clk(openpa_u_gpu_clk_s1), .rst_n(openpa_u_gpu_rst_n_s1), .en(openpa_u_gpu_en_s1), .d(openpa_u_gpu_d_s1), .q(openpa_u_gpu_q_raw)); openpa_corrupt #(.W(8), .ID(268435464)) openpa_u_gpu_q_cor (.d(openpa_u_gpu_q_raw), .q(q_gpu), .ok(UPF::openpa_dom_u_gpu_LOCAL_ok), .ep(UPF::openpa_dom_u_gpu_LOCAL_ep)); openpa_corrupt #(.W(1), .ID(268435504)) openpa_u_gpu_clk_cor (.d(clk), .q(openpa_u_gpu_clk_s1), .ok(UPF::openpa_dom_HOST_ok), .ep(UPF::openpa_dom_HOST_ep)); openpa_corrupt #(.W(8), .ID(268435512)) openpa_u_gpu_d_cor (.d(d + 8'd1), .q(openpa_u_gpu_d_s1), .ok(UPF::openpa_dom_HOST_ok), .ep(UPF::openpa_dom_HOST_ep)); openpa_corrupt #(.W(1), .ID(268435520)) openpa_u_gpu_en_cor (.d(en), .q(openpa_u_gpu_en_s1), .ok(UPF::openpa_dom_HOST_ok), .ep(UPF::openpa_dom_HOST_ep)); openpa_corrupt #(.W(1), .ID(268435528)) openpa_u_gpu_rst_n_cor (.d(rst_n), .q(openpa_u_gpu_rst_n_s1), .ok(UPF::openpa_dom_HOST_ok), .ep(UPF::openpa_dom_HOST_ep));
  assign acks = {ack_gpu, ack_cpu};

`line 1 "openpa_overlay.sv" 0
  // ===================================================================================
  // OpenPA overlay for duo: generated from pair.upf, tile.upf, tile.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_HOST_ep;
  import UPF::openpa_dom_HOST_ok;
  import UPF::openpa_dom_HOST_sim;
  import UPF::openpa_dom_u_cpu_LOCAL_ep;
  import UPF::openpa_dom_u_cpu_LOCAL_ok;
  import UPF::openpa_dom_u_cpu_LOCAL_sim;
  import UPF::openpa_dom_u_gpu_LOCAL_ep;
  import UPF::openpa_dom_u_gpu_LOCAL_ok;
  import UPF::openpa_dom_u_gpu_LOCAL_sim;
  import UPF::openpa_kick;
  import UPF::openpa_net_N_VG;
  import UPF::openpa_net_N_VHOST;
  import UPF::openpa_net_N_VLEFT;
  import UPF::openpa_net_N_VRIGHT;
  import UPF::openpa_seed;
  import UPF::openpa_ss_HOST_SS_ep;
  import UPF::openpa_ss_HOST_SS_multi;
  import UPF::openpa_ss_HOST_SS_ok;
  import UPF::openpa_ss_HOST_SS_sim;
  import UPF::openpa_ss_HOST_SS_st;
  import UPF::openpa_ss_LEFT_SS_ep;
  import UPF::openpa_ss_LEFT_SS_multi;
  import UPF::openpa_ss_LEFT_SS_ok;
  import UPF::openpa_ss_LEFT_SS_sim;
  import UPF::openpa_ss_LEFT_SS_st;
  import UPF::openpa_ss_RIGHT_SS_ep;
  import UPF::openpa_ss_RIGHT_SS_multi;
  import UPF::openpa_ss_RIGHT_SS_ok;
  import UPF::openpa_ss_RIGHT_SS_sim;
  import UPF::openpa_ss_RIGHT_SS_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:14];   // 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)
  always @(openpa_kick or UPF::openpa_port_VHOST or UPF::openpa_port_VLEFT or UPF::openpa_port_VRIGHT or UPF::openpa_port_VG) begin : openpa_network
    openpa_net_N_VHOST = UPF::openpa_port_VHOST;   // N_VHOST <- port VHOST
    openpa_net_N_VLEFT = UPF::openpa_port_VLEFT;   // N_VLEFT <- port VLEFT
    openpa_net_N_VRIGHT = UPF::openpa_port_VRIGHT;   // N_VRIGHT <- port VRIGHT
    openpa_net_N_VG = UPF::openpa_port_VG;   // N_VG <- port VG
    // supply set HOST_SS (also HOST.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_HOST_SS
      bit nx; int sm;
      sm = (UPF::openpa_net_N_VHOST.state == UPF::FULL_ON && UPF::openpa_net_N_VG.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_HOST_SS_sim = sm;
      nx = sm < 5;
      if (openpa_ss_HOST_SS_ok && !nx) openpa_ss_HOST_SS_ep = openpa_ss_HOST_SS_ep + 1;
      openpa_ss_HOST_SS_ok = nx;
    end
    // supply set LEFT_SS (also LOCAL.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_LEFT_SS
      bit nx; int sm;
      sm = (UPF::openpa_net_N_VLEFT.state == UPF::FULL_ON && UPF::openpa_net_N_VG.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_LEFT_SS_sim = sm;
      nx = sm < 5;
      if (openpa_ss_LEFT_SS_ok && !nx) openpa_ss_LEFT_SS_ep = openpa_ss_LEFT_SS_ep + 1;
      openpa_ss_LEFT_SS_ok = nx;
    end
    // supply set RIGHT_SS (also LOCAL.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
    begin : openpa_ss_RIGHT_SS
      bit nx; int sm;
      sm = (UPF::openpa_net_N_VRIGHT.state == UPF::FULL_ON && UPF::openpa_net_N_VG.state == UPF::FULL_ON) ? 0 : 5;   // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
      openpa_ss_RIGHT_SS_sim = sm;
      nx = sm < 5;
      if (openpa_ss_RIGHT_SS_ok && !nx) openpa_ss_RIGHT_SS_ep = openpa_ss_RIGHT_SS_ep + 1;
      openpa_ss_RIGHT_SS_ok = nx;
    end
    // domain HOST: simstate of its primary supply set HOST_SS
    if (openpa_dom_HOST_ok && !UPF::openpa_ss_HOST_SS_ok) openpa_dom_HOST_ep = openpa_dom_HOST_ep + 1;
    openpa_dom_HOST_ok = UPF::openpa_ss_HOST_SS_ok;
    openpa_dom_HOST_sim = openpa_ss_HOST_SS_sim;
    // domain LOCAL: simstate of its primary supply set LEFT_SS
    if (openpa_dom_u_cpu_LOCAL_ok && !UPF::openpa_ss_LEFT_SS_ok) openpa_dom_u_cpu_LOCAL_ep = openpa_dom_u_cpu_LOCAL_ep + 1;
    openpa_dom_u_cpu_LOCAL_ok = UPF::openpa_ss_LEFT_SS_ok;
    openpa_dom_u_cpu_LOCAL_sim = openpa_ss_LEFT_SS_sim;
    // domain LOCAL: simstate of its primary supply set RIGHT_SS
    if (openpa_dom_u_gpu_LOCAL_ok && !UPF::openpa_ss_RIGHT_SS_ok) openpa_dom_u_gpu_LOCAL_ep = openpa_dom_u_gpu_LOCAL_ep + 1;
    openpa_dom_u_gpu_LOCAL_ok = UPF::openpa_ss_RIGHT_SS_ok;
    openpa_dom_u_gpu_LOCAL_sim = openpa_ss_RIGHT_SS_sim;
  end

  // ---- corruption: registers forced, memories overwritten (rules C1, C3)
  // domain HOST (pair.upf:3): 0 register(s), 0 memory(ies)
  bit openpa_HOST_applied, openpa_HOST_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_HOST_ok or openpa_kick) if (!openpa_HOST_valid || openpa_HOST_applied != UPF::openpa_dom_HOST_ok) begin
    openpa_t({"HOST ", UPF::openpa_dom_HOST_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_HOST_ok || !openpa_HOST_valid) begin
    end
    if (UPF::openpa_dom_HOST_ok) begin
    end
    openpa_HOST_valid = 1'b1; openpa_HOST_applied = UPF::openpa_dom_HOST_ok;
  end
  // domain LOCAL (tile.upf:1): 1 register(s), 0 memory(ies)
  bit openpa_u_cpu_LOCAL_applied, openpa_u_cpu_LOCAL_valid;
  logic [7:0] openpa_cv1;   // corruption value for u_cpu.q
  // 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_u_cpu_LOCAL_ok or openpa_kick) if (!openpa_u_cpu_LOCAL_valid || openpa_u_cpu_LOCAL_applied != UPF::openpa_dom_u_cpu_LOCAL_ok) begin
    openpa_t({"LOCAL ", UPF::openpa_dom_u_cpu_LOCAL_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_u_cpu_LOCAL_ok || !openpa_u_cpu_LOCAL_valid) begin
      if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_u_cpu_LOCAL_ep, 0);
      force u_cpu.q = openpa_cv1;
    end
    if (UPF::openpa_dom_u_cpu_LOCAL_ok) begin
      release u_cpu.q;
    end
    openpa_u_cpu_LOCAL_valid = 1'b1; openpa_u_cpu_LOCAL_applied = UPF::openpa_dom_u_cpu_LOCAL_ok;
  end
  // domain LOCAL (tile.upf:1): 1 register(s), 0 memory(ies)
  bit openpa_u_gpu_LOCAL_applied, openpa_u_gpu_LOCAL_valid;
  logic [7:0] openpa_cv2;   // corruption value for u_gpu.q
  // 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_u_gpu_LOCAL_ok or openpa_kick) if (!openpa_u_gpu_LOCAL_valid || openpa_u_gpu_LOCAL_applied != UPF::openpa_dom_u_gpu_LOCAL_ok) begin
    openpa_t({"LOCAL ", UPF::openpa_dom_u_gpu_LOCAL_ok ? "NORMAL" : "CORRUPT"});
    if (!UPF::openpa_dom_u_gpu_LOCAL_ok || !openpa_u_gpu_LOCAL_valid) begin
      if (openpa_xmode) openpa_cv2 = 'x; else openpa_cv2 = UPF::openpa_mix(2, UPF::openpa_dom_u_gpu_LOCAL_ep, 0);
      force u_gpu.q = openpa_cv2;
    end
    if (UPF::openpa_dom_u_gpu_LOCAL_ok) begin
      release u_gpu.q;
    end
    openpa_u_gpu_LOCAL_valid = 1'b1; openpa_u_gpu_LOCAL_applied = UPF::openpa_dom_u_gpu_LOCAL_ok;
  end
  // crossing 1: u_cpu/q (LOCAL) -> duo output q_cpu (HOST), not isolated
  bit openpa_x1_t;
  always @(UPF::openpa_dom_u_cpu_LOCAL_ok or UPF::openpa_dom_HOST_ok or UPF::openpa_net_N_VLEFT or UPF::openpa_net_N_VG) openpa_x1_t = !UPF::openpa_dom_u_cpu_LOCAL_ok && UPF::openpa_dom_HOST_ok && !(1'b0) && !(UPF::openpa_net_N_VLEFT.state == UPF::UNDETERMINED || UPF::openpa_net_N_VG.state == UPF::UNDETERMINED);
  always @(posedge openpa_x1_t)
    begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 2: u_gpu/q (LOCAL) -> duo output q_gpu (HOST), not isolated
  bit openpa_x2_t;
  always @(UPF::openpa_dom_u_gpu_LOCAL_ok or UPF::openpa_dom_HOST_ok or UPF::openpa_net_N_VRIGHT or UPF::openpa_net_N_VG) openpa_x2_t = !UPF::openpa_dom_u_gpu_LOCAL_ok && UPF::openpa_dom_HOST_ok && !(1'b0) && !(UPF::openpa_net_N_VRIGHT.state == UPF::UNDETERMINED || UPF::openpa_net_N_VG.state == UPF::UNDETERMINED);
  always @(posedge openpa_x2_t)
    begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 3: duo input clk (HOST) -> u_cpu/clk (LOCAL), not isolated
  bit openpa_x3_t;
  always @(UPF::openpa_dom_HOST_ok or UPF::openpa_dom_u_cpu_LOCAL_ok or UPF::openpa_net_N_VHOST or UPF::openpa_net_N_VG) openpa_x3_t = !UPF::openpa_dom_HOST_ok && UPF::openpa_dom_u_cpu_LOCAL_ok && !(1'b0) && !(UPF::openpa_net_N_VHOST.state == UPF::UNDETERMINED || UPF::openpa_net_N_VG.state == UPF::UNDETERMINED);
  always @(posedge openpa_x3_t)
    begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 4: duo input d (HOST) -> u_cpu/d (LOCAL), not isolated
  bit openpa_x4_t;
  always @(UPF::openpa_dom_HOST_ok or UPF::openpa_dom_u_cpu_LOCAL_ok or UPF::openpa_net_N_VHOST or UPF::openpa_net_N_VG) openpa_x4_t = !UPF::openpa_dom_HOST_ok && UPF::openpa_dom_u_cpu_LOCAL_ok && !(1'b0) && !(UPF::openpa_net_N_VHOST.state == UPF::UNDETERMINED || UPF::openpa_net_N_VG.state == UPF::UNDETERMINED);
  always @(posedge openpa_x4_t)
    begin openpa_sp[4] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 5: duo input en (HOST) -> u_cpu/en (LOCAL), not isolated
  bit openpa_x5_t;
  always @(UPF::openpa_dom_HOST_ok or UPF::openpa_dom_u_cpu_LOCAL_ok or UPF::openpa_net_N_VHOST or UPF::openpa_net_N_VG) openpa_x5_t = !UPF::openpa_dom_HOST_ok && UPF::openpa_dom_u_cpu_LOCAL_ok && !(1'b0) && !(UPF::openpa_net_N_VHOST.state == UPF::UNDETERMINED || UPF::openpa_net_N_VG.state == UPF::UNDETERMINED);
  always @(posedge openpa_x5_t)
    begin openpa_sp[5] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 6: duo input rst_n (HOST) -> u_cpu/rst_n (LOCAL), not isolated
  bit openpa_x6_t;
  always @(UPF::openpa_dom_HOST_ok or UPF::openpa_dom_u_cpu_LOCAL_ok or UPF::openpa_net_N_VHOST or UPF::openpa_net_N_VG) openpa_x6_t = !UPF::openpa_dom_HOST_ok && UPF::openpa_dom_u_cpu_LOCAL_ok && !(1'b0) && !(UPF::openpa_net_N_VHOST.state == UPF::UNDETERMINED || UPF::openpa_net_N_VG.state == UPF::UNDETERMINED);
  always @(posedge openpa_x6_t)
    begin openpa_sp[6] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 7: duo input clk (HOST) -> u_gpu/clk (LOCAL), not isolated
  bit openpa_x7_t;
  always @(UPF::openpa_dom_HOST_ok or UPF::openpa_dom_u_gpu_LOCAL_ok or UPF::openpa_net_N_VHOST or UPF::openpa_net_N_VG) openpa_x7_t = !UPF::openpa_dom_HOST_ok && UPF::openpa_dom_u_gpu_LOCAL_ok && !(1'b0) && !(UPF::openpa_net_N_VHOST.state == UPF::UNDETERMINED || UPF::openpa_net_N_VG.state == UPF::UNDETERMINED);
  always @(posedge openpa_x7_t)
    begin openpa_sp[7] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 8: logic in duo (HOST) -> u_gpu/d (LOCAL), not isolated
  bit openpa_x8_t;
  always @(UPF::openpa_dom_HOST_ok or UPF::openpa_dom_u_gpu_LOCAL_ok or UPF::openpa_net_N_VHOST or UPF::openpa_net_N_VG) openpa_x8_t = !UPF::openpa_dom_HOST_ok && UPF::openpa_dom_u_gpu_LOCAL_ok && !(1'b0) && !(UPF::openpa_net_N_VHOST.state == UPF::UNDETERMINED || UPF::openpa_net_N_VG.state == UPF::UNDETERMINED);
  always @(posedge openpa_x8_t)
    begin openpa_sp[8] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 9: duo input en (HOST) -> u_gpu/en (LOCAL), not isolated
  bit openpa_x9_t;
  always @(UPF::openpa_dom_HOST_ok or UPF::openpa_dom_u_gpu_LOCAL_ok or UPF::openpa_net_N_VHOST or UPF::openpa_net_N_VG) openpa_x9_t = !UPF::openpa_dom_HOST_ok && UPF::openpa_dom_u_gpu_LOCAL_ok && !(1'b0) && !(UPF::openpa_net_N_VHOST.state == UPF::UNDETERMINED || UPF::openpa_net_N_VG.state == UPF::UNDETERMINED);
  always @(posedge openpa_x9_t)
    begin openpa_sp[9] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 10: duo input rst_n (HOST) -> u_gpu/rst_n (LOCAL), not isolated
  bit openpa_x10_t;
  always @(UPF::openpa_dom_HOST_ok or UPF::openpa_dom_u_gpu_LOCAL_ok or UPF::openpa_net_N_VHOST or UPF::openpa_net_N_VG) openpa_x10_t = !UPF::openpa_dom_HOST_ok && UPF::openpa_dom_u_gpu_LOCAL_ok && !(1'b0) && !(UPF::openpa_net_N_VHOST.state == UPF::UNDETERMINED || UPF::openpa_net_N_VG.state == UPF::UNDETERMINED);
  always @(posedge openpa_x10_t)
    begin openpa_sp[10] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 1: LOCAL -> HOST (no level shifter strategy, threshold 0)
  bit openpa_l1_t;
  always @(UPF::openpa_dom_u_cpu_LOCAL_ok or UPF::openpa_dom_HOST_ok or UPF::openpa_net_N_VLEFT or UPF::openpa_net_N_VHOST) openpa_l1_t = UPF::openpa_dom_u_cpu_LOCAL_ok && UPF::openpa_dom_HOST_ok && (UPF::openpa_net_N_VLEFT.voltage - UPF::openpa_net_N_VHOST.voltage > 0 || UPF::openpa_net_N_VHOST.voltage - UPF::openpa_net_N_VLEFT.voltage > 0) && !1'b0;
  always @(posedge openpa_l1_t)
    begin openpa_sp[11] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 2: LOCAL -> HOST (no level shifter strategy, threshold 0)
  bit openpa_l2_t;
  always @(UPF::openpa_dom_u_gpu_LOCAL_ok or UPF::openpa_dom_HOST_ok or UPF::openpa_net_N_VRIGHT or UPF::openpa_net_N_VHOST) openpa_l2_t = UPF::openpa_dom_u_gpu_LOCAL_ok && UPF::openpa_dom_HOST_ok && (UPF::openpa_net_N_VRIGHT.voltage - UPF::openpa_net_N_VHOST.voltage > 0 || UPF::openpa_net_N_VHOST.voltage - UPF::openpa_net_N_VRIGHT.voltage > 0) && !1'b0;
  always @(posedge openpa_l2_t)
    begin openpa_sp[12] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 3: HOST -> LOCAL (no level shifter strategy, threshold 0)
  bit openpa_l3_t;
  always @(UPF::openpa_dom_HOST_ok or UPF::openpa_dom_u_cpu_LOCAL_ok or UPF::openpa_net_N_VHOST or UPF::openpa_net_N_VLEFT) openpa_l3_t = UPF::openpa_dom_HOST_ok && UPF::openpa_dom_u_cpu_LOCAL_ok && (UPF::openpa_net_N_VHOST.voltage - UPF::openpa_net_N_VLEFT.voltage > 0 || UPF::openpa_net_N_VLEFT.voltage - UPF::openpa_net_N_VHOST.voltage > 0) && !1'b0;
  always @(posedge openpa_l3_t)
    begin openpa_sp[13] = 1'b1; openpa_sreq = 1'b1; end
  // level shifter check 4: HOST -> LOCAL (no level shifter strategy, threshold 0)
  bit openpa_l4_t;
  always @(UPF::openpa_dom_HOST_ok or UPF::openpa_dom_u_gpu_LOCAL_ok or UPF::openpa_net_N_VHOST or UPF::openpa_net_N_VRIGHT) openpa_l4_t = UPF::openpa_dom_HOST_ok && UPF::openpa_dom_u_gpu_LOCAL_ok && (UPF::openpa_net_N_VHOST.voltage - UPF::openpa_net_N_VRIGHT.voltage > 0 || UPF::openpa_net_N_VRIGHT.voltage - UPF::openpa_net_N_VHOST.voltage > 0) && !1'b0;
  always @(posedge openpa_l4_t)
    begin openpa_sp[14] = 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 @(q_cpu) if (openpa_obs && UPF::openpa_dom_HOST_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: q_cpu=%h", $time, q_cpu);
  always @(q_gpu) if (openpa_obs && UPF::openpa_dom_HOST_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: q_gpu=%h", $time, q_gpu);
  always @(acks) if (openpa_obs && UPF::openpa_dom_HOST_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: acks=%h", $time, acks);
  `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: 14 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_cpu/q of LOCAL (off) is read by duo output q_cpu in HOST (on) with no active isolation");
    end
    if (openpa_sp[2]) begin
      openpa_sp[2] = 1'b0;
      if (openpa_x2_t) openpa_check(9, "u_gpu/q of LOCAL (off) is read by duo output q_gpu in HOST (on) with no active isolation");
    end
    if (openpa_sp[3]) begin
      openpa_sp[3] = 1'b0;
      if (openpa_x3_t) openpa_check(9, "duo input clk of HOST (off) is read by u_cpu/clk in LOCAL (on) with no active isolation");
    end
    if (openpa_sp[4]) begin
      openpa_sp[4] = 1'b0;
      if (openpa_x4_t) openpa_check(9, "duo input d of HOST (off) is read by u_cpu/d in LOCAL (on) with no active isolation");
    end
    if (openpa_sp[5]) begin
      openpa_sp[5] = 1'b0;
      if (openpa_x5_t) openpa_check(9, "duo input en of HOST (off) is read by u_cpu/en in LOCAL (on) with no active isolation");
    end
    if (openpa_sp[6]) begin
      openpa_sp[6] = 1'b0;
      if (openpa_x6_t) openpa_check(9, "duo input rst_n of HOST (off) is read by u_cpu/rst_n in LOCAL (on) with no active isolation");
    end
    if (openpa_sp[7]) begin
      openpa_sp[7] = 1'b0;
      if (openpa_x7_t) openpa_check(9, "duo input clk of HOST (off) is read by u_gpu/clk in LOCAL (on) with no active isolation");
    end
    if (openpa_sp[8]) begin
      openpa_sp[8] = 1'b0;
      if (openpa_x8_t) openpa_check(9, "logic in duo of HOST (off) is read by u_gpu/d in LOCAL (on) with no active isolation");
    end
    if (openpa_sp[9]) begin
      openpa_sp[9] = 1'b0;
      if (openpa_x9_t) openpa_check(9, "duo input en of HOST (off) is read by u_gpu/en in LOCAL (on) with no active isolation");
    end
    if (openpa_sp[10]) begin
      openpa_sp[10] = 1'b0;
      if (openpa_x10_t) openpa_check(9, "duo input rst_n of HOST (off) is read by u_gpu/rst_n in LOCAL (on) with no active isolation");
    end
    if (openpa_sp[11]) begin
      openpa_sp[11] = 1'b0;
      if (openpa_l1_t) openpa_check(11, $sformatf("LOCAL (%0d uV) drives HOST (%0d uV) on 1 port(s) with no level shifter for this direction", UPF::openpa_net_N_VLEFT.voltage, UPF::openpa_net_N_VHOST.voltage));
    end
    if (openpa_sp[12]) begin
      openpa_sp[12] = 1'b0;
      if (openpa_l2_t) openpa_check(11, $sformatf("LOCAL (%0d uV) drives HOST (%0d uV) on 1 port(s) with no level shifter for this direction", UPF::openpa_net_N_VRIGHT.voltage, UPF::openpa_net_N_VHOST.voltage));
    end
    if (openpa_sp[13]) begin
      openpa_sp[13] = 1'b0;
      if (openpa_l3_t) openpa_check(11, $sformatf("HOST (%0d uV) drives LOCAL (%0d uV) on 4 port(s) with no level shifter for this direction", UPF::openpa_net_N_VHOST.voltage, UPF::openpa_net_N_VLEFT.voltage));
    end
    if (openpa_sp[14]) begin
      openpa_sp[14] = 1'b0;
      if (openpa_l4_t) openpa_check(11, $sformatf("HOST (%0d uV) drives LOCAL (%0d uV) on 4 port(s) with no level shifter for this direction", UPF::openpa_net_N_VHOST.voltage, UPF::openpa_net_N_VRIGHT.voltage));
    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 19 "duo.sv" 0
endmodule

`line 1 "acc.sv" 0
// acc: an 8-bit accumulator.
module acc (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       en,
  input  logic [7:0] d,
  output logic [7:0] q
);
  always_ff @(posedge clk or negedge rst_n)
    if (!rst_n)  q <= '0;
    else if (en) q <= q + d;
endmodule

Predict the outputHow many guarded falling edges does the PMU observer sample?
`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=1; 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(.*);
 integer checks=0;
 always @(negedge clk) if (rst_n && dut.iso_en===1'b1) begin
   checks++;
   if (led!==1'b0) $fatal(1,"LED escaped during isolation");
 end
 always #5 clk=~clk;
 task sample(input string phase);
   $display("%s switch=%b guard=%b raw=%b led=%b",phase,dut.pwr_en,dut.iso_en,dut.u_core.busy,led);
 endtask
 initial begin
   void'(supply_on("VDD")); void'(supply_on("VDD_LO",0.8)); void'(supply_on("VSS",0.0));
   repeat(2) @(negedge clk); rst_n=1; en=1; @(negedge clk); sample("work");
   sleep_req=1; @(negedge clk); sleep_req=0; sample("prepare");
   wait(pmu_state==3); #1; sample("park");
   @(negedge clk); wake_req=1; @(negedge clk); wake_req=0; wait(pmu_state==0); #1; sample("return"); $display("observed guarded_edges=%0d",checks); $finish;
 end
endmodule
Read included file: pa_pmu_soc.sv
// pa_pmu_soc.sv: power-aware copy of pmu_soc, generated by OpenPA from assembly.upf, soc.upf, ip.upf, technology.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 (soc.upf:9)
  supply_net_type openpa_port_VDD_LO;   // supply port VDD_LO (soc.upf:10)
  supply_net_type openpa_port_VSS;   // supply port VSS (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 (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_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 (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 (ip.upf:1)
  // 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)
  logic openpa_ctl_1_u_pmu_iso_en;   // copy of u_pmu.iso_en (isolation NOTICE)
  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 == "HOST.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): HOST.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 == "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 == "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 == "HOST.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): HOST.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 == "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 == "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 == "HOST.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): HOST.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 == "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 == "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 == "HOST.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): HOST.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 == "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 == "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 == "HOST.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 == "HOST.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; wire [3:0] openpa_u_core_beats_raw; wire [0:0] openpa_u_core_busy_raw, openpa_u_core_busy_s1; 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(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(268435473)) 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_HOST_sim == 0)), .sup_ep(UPF::openpa_ss_HOST_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 assembly.upf, soc.upf, ip.upf, technology.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_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_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_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:2];   // good-form sequence bins (coverage)
  bit openpa_sreq; bit openpa_sp [1:20];   // 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;

  // ---- 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 (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 HOST: 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_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_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
    // 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 (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 (ip.upf:1): 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

  // D7 reset check for PD_CORE: resets u_core.rst_n active 0
  bit openpa_PD_CORE_rprev, openpa_PD_CORE_rp0;
  always @(posedge UPF::openpa_dom_PD_CORE_ok or negedge UPF::openpa_dom_PD_CORE_ok or posedge u_core.rst_n or negedge u_core.rst_n) begin
    if (UPF::openpa_dom_PD_CORE_ok && !openpa_PD_CORE_rprev) openpa_PD_CORE_rp0 = 1'b1;
    if (!UPF::openpa_dom_PD_CORE_ok || u_core.rst_n === 1'b0) openpa_PD_CORE_rp0 = 1'b0;
    openpa_PD_CORE_rprev = UPF::openpa_dom_PD_CORE_ok;
  end

  // ---- checks for set_isolation NOTICE (ip.upf:2): 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[1] = 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[2] = 1'b1; openpa_sreq = 1'b1; end
    if (openpa_ig1_act != (UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_t({"NOTICE 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_HOST_ok) if (!UPF::openpa_ss_HOST_ok)
    begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; 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[4] = 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[5] = 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[6] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 4: u_core/busy (PD_CORE) -> logic in pmu_soc (PD_TOP), isolated by NOTICE
  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_HOST_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_HOST_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[7] = 1'b1; openpa_sreq = 1'b1; end
  // crossing 5: u_core/busy (PD_CORE) -> pmu_soc output led (PD_TOP), isolated by NOTICE
  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_HOST_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_HOST_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[8] = 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[9] = 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[10] = 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[11] = 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[12] = 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[13] = 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[14] = 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[15] = 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[16] = 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[17] = 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[18] = 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[19] = 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[20] = 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 sequence D1 NOTICE: PD_CORE isolated before power-down %0d", openpa_seq[1]);
      $display("OPENPA-COVER sequence D2/D7 NOTICE: isolation released only after PD_CORE was back and reset %0d", openpa_seq[2]);
      if (openpa_seq[1]) hq = hq + 1;
      if (openpa_seq[2]) hq = hq + 1;
      $display("OPENPA-COVER-SUMMARY states=%0d/0 declared_transitions=%0d/0 sequences=%0d/2", hs, ht, hq);
  endfunction

  // ---- settle process: 20 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 && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_1_u_pmu_iso_en === 1'b1)) openpa_check(1, "set_isolation NOTICE (ip.upf:2): 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[1] = openpa_seq[1] + 1; openpa_ig1_cyc = 1'b1; end
    end
    if (openpa_sp[2]) begin
      openpa_sp[2] = 1'b0;
          if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation NOTICE (ip.upf:2): isolation released while PD_CORE is still off");
          else if (openpa_PD_CORE_rp0) openpa_check(7, "set_isolation NOTICE (ip.upf:2): isolation released after PD_CORE powered up but before its reset u_core.rst_n was asserted");
          else if (openpa_ig1_cyc) openpa_seq[2] = openpa_seq[2] + 1;
          openpa_ig1_cyc = 1'b0;
    end
    if (openpa_sp[3]) begin
      openpa_sp[3] = 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 NOTICE (ip.upf:2): isolation supply HOST lost while clamping");
    end
    if (openpa_sp[4]) begin
      openpa_sp[4] = 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[5]) begin
      openpa_sp[5] = 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[6]) begin
      openpa_sp[6] = 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[7]) begin
      openpa_sp[7] = 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[8]) begin
      openpa_sp[8] = 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[9]) begin
      openpa_sp[9] = 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[10]) begin
      openpa_sp[10] = 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[11]) begin
      openpa_sp[11] = 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[12]) begin
      openpa_sp[12] = 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[13]) begin
      openpa_sp[13] = 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[14]) begin
      openpa_sp[14] = 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[15]) begin
      openpa_sp[15] = 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[16]) begin
      openpa_sp[16] = 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[17]) begin
      openpa_sp[17] = 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[18]) begin
      openpa_sp[18] = 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 (soc.upf:24)");
    end
    if (openpa_sp[19]) begin
      openpa_sp[19] = 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[20]) begin
      openpa_sp[20] = 1'b0;
      if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_CORE_ok)) openpa_check(12, "u_pmu.iso_en (isolation NOTICE) 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

ConceptWhich evidence shows that an IP file reached two different instances?
ConceptWhy keep the board control out of the locked delivery?
ConceptA scoped load worked. What still needs separate evidence?
ConceptThe package was loaded, but this socket cannot use its conversion method by its short name. What is missing?

Common Mistakes

Wrong Edit the delivered IP file to name each new socket.

A board path then travels with the IP and can select the wrong instance elsewhere.

Fix Keep local names in the IP. Supply the instance at the load site.

Wrong Repeat a strategy declaration in the board file.

A second declaration collides with the strategy already present in that scope.

Fix Name the same strategy and domain in an update.

Wrong Call two supplies equivalent after one matching sample.

Independent regulators can produce the same voltage during normal work and separate during shutdown.

Fix Trace their source connections and exercise independent power transitions.

Wrong Use a library load to instantiate the IP in both sockets.

Library visibility and instance-relative execution serve different purposes.

Fix Use a scoped instance load for each copy of the design.

Remember

  • Keep the reusable requirement local and record each board or technology choice in its own layer.
  • Resolve an update by scope, object name and strategy domain.
  • Exercise independent rail cuts to test scoped supply connections.
  • Treat macro boundaries, library visibility and electrical equivalence as distinct integration decisions.

Practice

Report a problem with this page