Power Switches in UPF
A power switch passes an input supply to its output while a control expression is true. UPF describes its ports, its states and its acknowledge.
You Will Be Able To
- Write create_power_switch with its supply ports, control ports, on and off states, and an acknowledge on an always-on supply.
- Predict a switch output from the IEEE 1801-2024 rules: full and partial on, off, error, and X controls.
- Use two inputs as a voltage multiplexer, and time an acknowledge with -ack_delay.
- Lesson
- W4.6
- Time
- 30 min
- Runs on
- Your browser
- Check
- 5 questions
A switch that closes too fast draws a current spike, so some switches start softly and report when they are done. Here is the lab switch:
t=2 soft start VDD_BLK=PARTIAL_ON 1000 mV ready=0 VDD_MUX=OFF 0 mV
t=5 ack VDD_BLK=PARTIAL_ON 1000 mV ready=1 VDD_MUX=OFF 0 mV
t=6 full on VDD_BLK=FULL_ON 1000 mV ready=1 VDD_MUX=OFF 0 mVThe rail is PARTIAL_ON first, the acknowledge ready rises 3 time units later, and then the rail is FULL_ON.
The Switch Model: Ports and Controls
create_power_switch makes an abstract switch in the current scope (IEEE 1801-2024 6.23). It has supply ports for its input and output, and control ports driven by logic.
- Power
- Control / FSM
- Power
- Control
- Supply ports
The supply ports are -input_supply_port {i VDD_N} and -output_supply_port {o VDD_BLK}.
- Control ports
The control ports are {c pwr_en} and {r rush}: logic drives the switch.
- States
The states are full {c && !r}, soft {c && r}, off {!c && !r} and bad {!c && r}. In the lab, soft gives PARTIAL_ON and full gives FULL_ON.
- Acknowledge
SS_AON powers the acknowledge logic; the ack port drives pwr_ack.
Read the diagram as text
- VDD_N: input supply net
- SW_BLK: ports i, o, c, r, ack
- VDD_BLK: output: PD_BLK power
- pwr_en, rush: logic nets
- SS_AON: powers the acknowledge logic
- pwr_ack: logic net, read as ready
- VDD_N → SW_BLK: i
- SW_BLK → VDD_BLK: o
- pwr_en, rush → SW_BLK: c, r
- SS_AON → SW_BLK: -supply_set
- SW_BLK → pwr_ack: ack
Drawn from the lab file tile.upf. The states in step 3 are from the recorded lab run.
create_power_switch SW_BLK -supply_set SS_AON \
-input_supply_port {i VDD_N} -output_supply_port {o VDD_BLK} \
-control_port {c pwr_en} -control_port {r rush} \
-on_state {full i {c && !r}} -on_partial_state {soft i {c && r}} \
-off_state {off {!c && !r}} -error_state {bad {!c && r}} \
-ack_port {ack pwr_ack} -ack_delay {ack 3}| Option | What it gives the switch |
|---|---|
-input_supply_port {i VDD_N} | an input port i, connected to the supply net VDD_N; repeat it for more inputs |
-output_supply_port {o VDD_BLK} | the output port o and the net it drives |
-control_port {c pwr_en} | a control port c, driven by the logic net pwr_en |
-on_state {full i {c && !r}} | a named state: input i reaches the output while the expression is true |
-on_partial_state, -off_state, -error_state | a current-limited state, the off state, an illegal state |
-supply_set, -ack_port, -ack_delay | the supply of the acknowledge logic, the acknowledge net and its delay |
All from IEEE 1801-2024 6.23. Expressions use the switch's own port names, not the nets.
Supply network
VDD_N: port VDD {port:VDD net:VDD_N sw:SW_BLK/i fn:SS_AON.power fn:PD_TOP.primary.power}
VSS_N: port VSS {port:VSS net:VSS_N fn:SS_AON.ground fn:SS_BLK.ground fn:SS_MUX.ground fn:PD_TOP.primary.ground fn:PD_BLK.primary.ground fn:PD_MUX.primary.ground}
VHI_N: port VHI {port:VHI net:VHI_N sw:SW_MUX/hi}
VLO_N: port VLO {port:VLO net:VLO_N sw:SW_MUX/lo}
VDD_BLK: switch SW_BLK {net:VDD_BLK sw:SW_BLK/o fn:SS_BLK.power fn:PD_BLK.primary.power}
VDD_MUX: switch SW_MUX {net:VDD_MUX sw:SW_MUX/o fn:SS_MUX.power fn:PD_MUX.primary.power}A state names an input port of the switch. A net name there is refused:
tile.upf:30: create_power_switch SW_BLK -on_state full: "vin" is not an input supply port of the switchOn, off and the Output Rules
Each on state passes its input's value to the output while its expression is true. IEEE 1801-2024 6.23 then combines the states:
| Order | If | The output is |
|---|---|---|
| a | an error state is true, or no defined state covers the controls. Or an explicit off state and an on state are both true. Or a contribution is UNDETERMINED, or two differ in voltage. | UNDETERMINED |
| b | otherwise, some contribution is FULL_ON | that value |
| c | otherwise, some contribution is PARTIAL_ON | that value |
| d | otherwise | OFF |
A switch has at most one off state. With none, the off state is every value that no on, partial or error state covers.
An X or Z control in an on-state expression makes that contribution UNDETERMINED, unless its input is OFF (6.23).
- Cycle 1
c && r: the partial state holds, so the rail is PARTIAL_ON.
- Cycle 2
The acknowledge rises 3 units after the switch began to turn on.
- Cycle 3
c && !r: the full on state holds. The rail is FULL_ON.
- Cycle 4
The off state holds. The rail is OFF at once; ready falls only after the delay.
- Cycle 6
!c && r is the error state: UNDETERMINED, and ready is corrupt.
- Cycle 8
An X on c while the input is on: UNDETERMINED again.
Values from the lab run on OpenPA and Icarus (recorded).
OPENPA-CHECK D10 @ 10: power switch SW_BLK is undetermined: a control is X, or no state (or more than one) holds (tile.upf:27)
OPENPA-CHECK D10 @ 12: power switch SW_BLK is undetermined: a control is X, or no state (or more than one) holds (tile.upf:27)
OPENPA-CHECK D10 @ 15: power switch SW_MUX is undetermined: a control is X, or no state (or more than one) holds (tile.upf:35)A second off state is refused:
tile.upf:31: create_power_switch SW_BLK: a switch has a single off state (IEEE 1801-2024 6.23); 2 are givenPartial and Error States
-on_partial_state passes a degraded value: FULL_ON becomes PARTIAL_ON (6.23). It models a current-limited switch, such as a soft start.
In OpenPA a domain on a PARTIAL_ON supply is not running (W4.4). So u_blk stays off during the soft start.
-error_state names control values that must never happen. While one is true, the output is UNDETERMINED and the acknowledge is corrupt at once.
t=2 soft start VDD_BLK=PARTIAL_ON 1000 mV ready=0 VDD_MUX=OFF 0 mV
t=11 bad combo VDD_BLK=UNDETERMINED 0 mV ready=x VDD_MUX=OFF 0 mV
t=12 off again VDD_BLK=OFF 0 mV ready=0 VDD_MUX=OFF 0 mVTwo Inputs: A Voltage Multiplexer
A switch may have several input ports. Each on state names the input it passes. So one switch can pick between two rails.
create_power_switch SW_MUX \
-input_supply_port {hi VHI_N} -input_supply_port {lo VLO_N} \
-output_supply_port {o VDD_MUX} \
-control_port {e mux_en} -control_port {s sel_hi} \
-on_state {high hi {e && s}} -on_state {low lo {e && !s}}| mux_en | sel_hi | VDD_MUX (recorded) |
|---|---|---|
| 1 | 1 | FULL_ON 1000 mV |
| 1 | 0 | FULL_ON 800 mV |
| 1 | x | UNDETERMINED 0 mV |
From the lab run. The X select reaches both on states while both inputs are on.
Two on states may hold at once if their inputs agree in voltage. If the voltages differ, the output is UNDETERMINED (6.23 rule a).
OPENPA-CHECK D11 @ 14: PD_MUX (800000 uV) drives PD_TOP (1000000 uV) on 1 port(s) with no level shifter for this direction
OPENPA-CHECK D11 @ 14: PD_TOP (1000000 uV) drives PD_MUX (800000 uV) on 4 port(s) with no level shifter for this directionAcknowledge: -ack_port, -ack_delay and -supply_set
-ack_port names a port and the logic net it drives. With no expression, it drives a constant 1 after the switch begins to turn on. It drives 0 after the switch begins to turn off (6.23).
-ack_delay sets the delay. It is inertial: a change shorter than the delay is lost. With no delay, it is 0.
Notes (5)
tile.upf:32: create_power_switch SW_BLK -ack_port ack: no expression; the default is the constant 1 (IEEE 1801-2024 6.23): 1 after the switch turns on, 0 after it turns off
tile.upf:32: create_power_switch SW_BLK -ack_port ack: no -ack_delay; the delay is 0 (IEEE 1801-2024 6.23)The acknowledge logic needs power, from -supply_set. While that set is not NORMAL, the acknowledge is corrupt. With no supply set, an acknowledge port is an error:
tile.upf:32: create_power_switch SW_BLK: -ack_port needs -supply_set (IEEE 1801-2024 6.23: it is an error to give acknowledge ports to a switch with no supply set; that set powers the acknowledge logic)Implementation and Refinement (Recorded and Drawn)
Implementation maps the abstract switch to library cells. map_power_switch names the cells (6.37); define_power_switch_cell describes a cell (7.6). OpenPA records both:
Notes (6)
tile.upf:45: map_power_switch is recorded with no effect in simulation: maps the switch to library cells (6.37); OpenPA simulates the abstract switch of create_power_switch
tile.upf:46: define_power_switch_cell is recorded with no effect in simulation: library cell definition (7.6); OpenPA simulates RTL, not library cellsRefinement adds the real switch instances later, with -update and -instances. OpenPA simulates the abstract switch only, so it refuses them, and fine-grain switches too:
tile.upf:45: create_power_switch -update: not supported by OpenPA (IEEE 1801-2024 6.23: it only adds -instances)
tile.upf:35: create_power_switch SW_MUX -switch_type fine_grain: not supported by OpenPA (IEEE 1801-2024 6.23: fine-grain switches are instances inside macros)UPF 1.0 had set_power_switch (6.29). It extended a switch that already existed in the HDL. IEEE 1801-2024 has no such command, and OpenPA does not know it:
tile.upf:45: unknown command "set_power_switch" (not an IEEE 1801-2024 command that OpenPA knows; CONFORMANCE.md lists them)| A drawn example (not run) | Meaning |
|---|---|
set_power_switch u_hdr -input_supply_port {i VDD_N} -output_supply_port {o VDD_BLK} -control_port {c pwr_en} -on_state {on i {c}} (UPF 1.0 6.29) | the HDL instance u_hdr becomes the switch, with these supply ports and states |
create_power_switch SW_BLK -update -instances {u_hdr0 u_hdr1} (IEEE 1801-2024 6.23) | the abstract SW_BLK is built from these cell instances |
Drawn from the standards. Nothing here is graded.
Asked in interviews
What does an X on a power-switch control do in simulation?
If the input is on, the switch output is UNDETERMINED (IEEE 1801-2024 6.23). The domain is corrupted, and a tool such as OpenPA reports it.
Why does a switch acknowledge need a supply set?
The acknowledge is real logic in the switch. It needs power, usually always-on, so the controller can read it while the domain is off.
What is a partial-on state used for?
A current-limited state, such as a soft start that limits rush current. The output is PARTIAL_ON instead of FULL_ON.
Try It
Run it. Follow SW_BLK through its soft start, full on, off, the error combination and an X control.
Read t=7 going off VDD_BLK=OFF 0 mV ready=1 VDD_MUX=OFF 0 mV. The rail is OFF, but ready is still 1: the acknowledge waits for its delay.
Find the three D10 lines. Each one is a moment when the switch output could not be known.
Change mux_en to stay 0 when sel_hi goes to X. Predict VDD_MUX, then compare with the quiz below.
OPENPA-INFO corruption=x seed=1 t=1 all off VDD_BLK=OFF 0 mV ready=0 VDD_MUX=OFF 0 mV t=2 soft start VDD_BLK=PARTIAL_ON 1000 mV ready=0 VDD_MUX=OFF 0 mV t=5 ack VDD_BLK=PARTIAL_ON 1000 mV ready=1 VDD_MUX=OFF 0 mV t=6 full on VDD_BLK=FULL_ON 1000 mV ready=1 VDD_MUX=OFF 0 mV t=7 going off VDD_BLK=OFF 0 mV ready=1 VDD_MUX=OFF 0 mV t=10 off VDD_BLK=OFF 0 mV ready=0 VDD_MUX=OFF 0 mV OPENPA-CHECK D10 @ 10: power switch SW_BLK is undetermined: a control is X, or no state (or more than one) holds (tile.upf:27) t=11 bad combo VDD_BLK=UNDETERMINED 0 mV ready=x VDD_MUX=OFF 0 mV t=12 off again VDD_BLK=OFF 0 mV ready=0 VDD_MUX=OFF 0 mV OPENPA-CHECK D10 @ 12: power switch SW_BLK is undetermined: a control is X, or no state (or more than one) holds (tile.upf:27) t=13 x control VDD_BLK=UNDETERMINED 0 mV ready=x VDD_MUX=OFF 0 mV t=14 mux high VDD_BLK=OFF 0 mV ready=0 VDD_MUX=FULL_ON 1000 mV OPENPA-CHECK D11 @ 14: PD_MUX (800000 uV) drives PD_TOP (1000000 uV) on 1 port(s) with no level shifter for this direction OPENPA-CHECK D11 @ 14: PD_TOP (1000000 uV) drives PD_MUX (800000 uV) on 4 port(s) with no level shifter for this direction t=15 mux low VDD_BLK=OFF 0 mV ready=0 VDD_MUX=FULL_ON 800 mV OPENPA-CHECK D10 @ 15: power switch SW_MUX is undetermined: a control is X, or no state (or more than one) holds (tile.upf:35) t=16 mux x sel VDD_BLK=OFF 0 mV ready=0 VDD_MUX=UNDETERMINED 0 mV OPENPA-SUMMARY D1=0 D2=0 D3=0 D4=0 D5=0 D6=0 D7=0 D8=0 D9=0 D10=3 D11=2 D12=0 D13=0 D14=0 OPENPA-COVER sequence D1 ISO_BLK: PD_BLK isolated before power-down 1 OPENPA-COVER sequence D2/D7 ISO_BLK: isolation released only after PD_BLK was back and reset 0 OPENPA-COVER sequence D1 ISO_MUX: PD_MUX isolated before power-down 1 OPENPA-COVER sequence D2/D7 ISO_MUX: isolation released only after PD_MUX was back and reset 0 OPENPA-COVER-SUMMARY states=0/0 declared_transitions=0/0 sequences=2/4Read the power intent: tile.upf
upf_version 4.0
set_design_top tile
create_supply_port VDD -direction in
create_supply_port VSS -direction in
create_supply_port VHI -direction in
create_supply_port VLO -direction in
create_supply_net VDD_N
create_supply_net VSS_N
create_supply_net VHI_N
create_supply_net VLO_N
create_supply_net VDD_BLK
create_supply_net VDD_MUX
connect_supply_net VDD_N -ports {VDD}
connect_supply_net VSS_N -ports {VSS}
connect_supply_net VHI_N -ports {VHI}
connect_supply_net VLO_N -ports {VLO}
create_supply_set SS_AON -function {power VDD_N} -function {ground VSS_N}
create_supply_set SS_BLK -function {power VDD_BLK} -function {ground VSS_N}
create_supply_set SS_MUX -function {power VDD_MUX} -function {ground VSS_N}
create_power_domain PD_TOP -elements {.} -supply {primary SS_AON}
create_power_domain PD_BLK -elements {u_blk} -supply {primary SS_BLK}
create_power_domain PD_MUX -elements {u_mux} -supply {primary SS_MUX}
# A switch with a soft start, an illegal combination and an acknowledge
create_power_switch SW_BLK -supply_set SS_AON \
-input_supply_port {i VDD_N} -output_supply_port {o VDD_BLK} \
-control_port {c pwr_en} -control_port {r rush} \
-on_state {full i {c && !r}} -on_partial_state {soft i {c && r}} \
-off_state {off {!c && !r}} -error_state {bad {!c && r}} \
-ack_port {ack pwr_ack} -ack_delay {ack 3}
# A voltage multiplexer: two inputs, one output
create_power_switch SW_MUX \
-input_supply_port {hi VHI_N} -input_supply_port {lo VLO_N} \
-output_supply_port {o VDD_MUX} \
-control_port {e mux_en} -control_port {s sel_hi} \
-on_state {high hi {e && s}} -on_state {low lo {e && !s}}
set_isolation ISO_BLK -domain PD_BLK -applies_to outputs -clamp_value 0 \
-isolation_supply SS_AON -isolation_signal iso_blk -isolation_sense high -location parent
set_isolation ISO_MUX -domain PD_MUX -applies_to outputs -clamp_value 0 \
-isolation_supply SS_AON -isolation_signal iso_mux -isolation_sense high -location parent
Read the power-unaware RTL: tile.sv
// tile: an always-on top with two switchable blocks. Power-unaware RTL.
module tile (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr_en,
input logic rush,
input logic mux_en,
input logic sel_hi,
input logic iso_blk,
input logic iso_mux,
output logic [7:0] q_blk,
output logic [7:0] q_mux,
output logic ready
);
wire pwr_ack; // no RTL drives this wire: the UPF switch's -ack_port does
acc u_blk (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(q_blk));
acc u_mux (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd1), .q(q_mux));
assign ready = pwr_ack;
endmodule
Read the power-unaware RTL: acc.sv
// 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
What UPF added: 46 objects
4 supply port, 6 supply net, 10 output corruption, 2 isolation cell, 2 power switch, 3 supply set, 2 register corruption, 16 dynamic check, 1 switch acknowledge.
| Object | Where | Detail | Rule | UPF line |
|---|---|---|---|---|
| Supply port | VDD | tile.upf:4 | ||
| Supply port | VSS | tile.upf:5 | ||
| Supply port | VHI | tile.upf:6 | ||
| Supply port | VLO | tile.upf:7 | ||
| Supply net | VDD_N | tile.upf:4 | ||
| Supply net | VSS_N | tile.upf:5 | ||
| Supply net | VHI_N | tile.upf:6 | ||
| Supply net | VLO_N | tile.upf:7 | ||
| Supply net | VDD_BLK | tile.upf:27 | ||
| Supply net | VDD_MUX | tile.upf:35 | ||
| Output corruption | u_blk/clk | folded away: it can never act where anything can see it | C2 | tile.upf:22 |
| Output corruption | u_blk/d | folded away: it can never act where anything can see it | C2 | tile.upf:22 |
| Output corruption | u_blk/en | folded away: it can never act where anything can see it | C2 | tile.upf:22 |
| Output corruption | u_blk/rst_n | folded away: it can never act where anything can see it | C2 | tile.upf:22 |
| Output corruption | u_blk/q | C2 | tile.upf:23 | |
| Isolation cell | u_blk/q | ISO_BLK · clamp 0 | I1-I5 | tile.upf:41 |
| Output corruption | u_mux/q | C2 | tile.upf:24 | |
| Isolation cell | u_mux/q | ISO_MUX · clamp 0 | I1-I5 | tile.upf:43 |
| Output corruption | u_mux/clk | C2 | tile.upf:22 | |
| Output corruption | u_mux/d | C2 | tile.upf:22 | |
| Output corruption | u_mux/en | C2 | tile.upf:22 | |
| Output corruption | u_mux/rst_n | C2 | tile.upf:22 | |
| Power switch | SW_BLK | S3 (IEEE 1801-2024 6.23) | tile.upf:27 | |
| Power switch | SW_MUX | S3 (IEEE 1801-2024 6.23) | tile.upf:35 | |
| Supply set | SS_AON | tile.upf:19 | ||
| Supply set | SS_BLK | tile.upf:20 | ||
| Supply set | SS_MUX | tile.upf:21 | ||
| Register corruption | u_blk.q | C1 | tile.upf:23 | |
| Register corruption | u_mux.q | C1 | tile.upf:24 | |
| Dynamic check | D1/D2/D7/D6 ISO_BLK | D1, D2, D7, D6 | tile.upf:41 | |
| Dynamic check | D1/D2/D7/D6 ISO_MUX | D1, D2, D7, D6 | tile.upf:43 | |
| Dynamic check | D9 crossing 1 | D9 | tile.upf:23 | |
| Dynamic check | D9 crossing 2 | D9 | tile.upf:24 | |
| Dynamic check | D9 crossing 3 | D9 | tile.upf:22 | |
| Dynamic check | D9 crossing 4 | D9 | tile.upf:22 | |
| Dynamic check | D9 crossing 5 | D9 | tile.upf:22 | |
| Dynamic check | D9 crossing 6 | D9 | tile.upf:22 | |
| Dynamic check | D9 crossing 7 | D9 | tile.upf:22 | |
| Dynamic check | D9 crossing 8 | D9 | tile.upf:22 | |
| Dynamic check | D9 crossing 9 | D9 | tile.upf:22 | |
| Dynamic check | D9 crossing 10 | D9 | tile.upf:22 | |
| Dynamic check | D11 PD_BLK->PD_TOP | D11 | tile.upf:23 | |
| Dynamic check | D11 PD_MUX->PD_TOP | D11 | tile.upf:24 | |
| Dynamic check | D11 PD_TOP->PD_BLK | D11 | tile.upf:22 | |
| Dynamic check | D11 PD_TOP->PD_MUX | D11 | tile.upf:22 | |
| Switch acknowledge | SW_BLK/ack | S6 (IEEE 1801-2024 6.23, 9.2.2) | tile.upf:32 |
OpenPA warnings:
- no `timescale in the design and no --timescale: OpenPA messages print time in the design top's default unit
Read the power-aware copy that runs (generated by OpenPA 0.3.0): pa_tile.sv
// pa_tile.sv: power-aware copy of tile, generated by OpenPA from 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.
// ---------------------------------------------------------------------------
// 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 (tile.upf:4)
supply_net_type openpa_port_VSS; // supply port VSS (tile.upf:5)
supply_net_type openpa_port_VHI; // supply port VHI (tile.upf:6)
supply_net_type openpa_port_VLO; // supply port VLO (tile.upf:7)
supply_net_type openpa_net_VDD_N; // supply net VDD_N
supply_net_type openpa_net_VSS_N; // supply net VSS_N
supply_net_type openpa_net_VHI_N; // supply net VHI_N
supply_net_type openpa_net_VLO_N; // supply net VLO_N
supply_net_type openpa_net_VDD_BLK; // supply net VDD_BLK
supply_net_type openpa_net_VDD_MUX; // supply net VDD_MUX
int openpa_sw_SW_BLK_st = -1; // switch SW_BLK: -1 undetermined, 0 off, k on-state k (tile.upf:27)
int openpa_sw_SW_MUX_st = -1; // switch SW_MUX: -1 undetermined, 0 off, k on-state k (tile.upf:35)
bit openpa_ss_SS_AON_ok; int unsigned openpa_ss_SS_AON_ep; int openpa_ss_SS_AON_st = -1; bit openpa_ss_SS_AON_multi; int openpa_ss_SS_AON_sim = 5; // supply set SS_AON
bit openpa_ss_SS_BLK_ok; int unsigned openpa_ss_SS_BLK_ep; int openpa_ss_SS_BLK_st = -1; bit openpa_ss_SS_BLK_multi; int openpa_ss_SS_BLK_sim = 5; // supply set SS_BLK
bit openpa_ss_SS_MUX_ok; int unsigned openpa_ss_SS_MUX_ep; int openpa_ss_SS_MUX_st = -1; bit openpa_ss_SS_MUX_multi; int openpa_ss_SS_MUX_sim = 5; // supply set SS_MUX
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 (tile.upf:22)
bit openpa_dom_PD_BLK_ok; int unsigned openpa_dom_PD_BLK_ep; int openpa_dom_PD_BLK_sim = 5; // power domain PD_BLK: ok = powered (simstate not CORRUPT); sim = simstate code (tile.upf:23)
bit openpa_dom_PD_MUX_ok; int unsigned openpa_dom_PD_MUX_ep; int openpa_dom_PD_MUX_sim = 5; // power domain PD_MUX: ok = powered (simstate not CORRUPT); sim = simstate code (tile.upf:24)
// 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_pwr_en; // copy of pwr_en (switch SW_BLK)
logic openpa_ctl_1_rush; // copy of rush (switch SW_BLK)
logic openpa_ctl_2_mux_en; // copy of mux_en (switch SW_MUX)
logic openpa_ctl_3_sel_hi; // copy of sel_hi (switch SW_MUX)
logic openpa_ctl_4_iso_blk; // copy of iso_blk (isolation ISO_BLK)
logic openpa_ctl_5_iso_mux; // copy of iso_mux (isolation ISO_MUX)
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 == "VSS") begin openpa_port_VSS.state = FULL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
if (pad_name == "VHI") begin openpa_port_VHI.state = FULL_ON; openpa_port_VHI.voltage = openpa_uv(value); return 1; end
if (pad_name == "VLO") begin openpa_port_VLO.state = FULL_ON; openpa_port_VLO.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 == "SS_AON.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): SS_AON.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "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 == "SS_AON.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): SS_AON.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_BLK.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): SS_BLK.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_MUX.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): SS_MUX.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_BLK.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_BLK.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_MUX.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_MUX.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VHI_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VHI_N already has a driver (port VHI); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VLO_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VLO_N already has a driver (port VLO); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_BLK") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_BLK already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_BLK.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): SS_BLK.power already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BLK.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_BLK.primary.power already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_MUX") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_MUX already has a driver (switch SW_MUX); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_MUX.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): SS_MUX.power already has a driver (switch SW_MUX); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_MUX.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_MUX.primary.power already has a driver (switch SW_MUX); 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 VSS VHI VLO)", 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 == "VSS") begin openpa_port_VSS.state = OFF; return 1; end
if (pad_name == "VHI") begin openpa_port_VHI.state = OFF; return 1; end
if (pad_name == "VLO") begin openpa_port_VLO.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 == "SS_AON.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): SS_AON.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "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 == "SS_AON.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): SS_AON.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_BLK.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): SS_BLK.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_MUX.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): SS_MUX.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_BLK.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_BLK.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_MUX.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_MUX.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VHI_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VHI_N already has a driver (port VHI); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VLO_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VLO_N already has a driver (port VLO); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_BLK") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_BLK already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_BLK.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): SS_BLK.power already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BLK.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_BLK.primary.power already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_MUX") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_MUX already has a driver (switch SW_MUX); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_MUX.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): SS_MUX.power already has a driver (switch SW_MUX); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_MUX.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_MUX.primary.power already has a driver (switch SW_MUX); 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 VSS VHI VLO)", 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 == "VSS") begin openpa_port_VSS.state = PARTIAL_ON; openpa_port_VSS.voltage = openpa_uv(value); return 1; end
if (pad_name == "VHI") begin openpa_port_VHI.state = PARTIAL_ON; openpa_port_VHI.voltage = openpa_uv(value); return 1; end
if (pad_name == "VLO") begin openpa_port_VLO.state = PARTIAL_ON; openpa_port_VLO.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 == "SS_AON.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): SS_AON.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "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 == "SS_AON.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): SS_AON.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_BLK.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): SS_BLK.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_MUX.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): SS_MUX.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_BLK.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_BLK.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_MUX.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_MUX.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VHI_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VHI_N already has a driver (port VHI); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VLO_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VLO_N already has a driver (port VLO); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_BLK") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_BLK already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_BLK.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): SS_BLK.power already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BLK.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_BLK.primary.power already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_MUX") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_MUX already has a driver (switch SW_MUX); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_MUX.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): SS_MUX.power already has a driver (switch SW_MUX); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_MUX.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_MUX.primary.power already has a driver (switch SW_MUX); 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 VSS VHI VLO)", 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 == "VSS") begin openpa_port_VSS.state = supply_state; return 1; end
if (pad_name == "VHI") begin openpa_port_VHI.state = supply_state; return 1; end
if (pad_name == "VLO") begin openpa_port_VLO.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 == "SS_AON.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): SS_AON.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "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 == "SS_AON.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): SS_AON.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_BLK.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): SS_BLK.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_MUX.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): SS_MUX.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_BLK.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_BLK.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_MUX.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_MUX.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VHI_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VHI_N already has a driver (port VHI); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VLO_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VLO_N already has a driver (port VLO); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_BLK") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_BLK already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_BLK.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): SS_BLK.power already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BLK.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_BLK.primary.power already has a driver (switch SW_BLK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_MUX") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_MUX already has a driver (switch SW_MUX); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SS_MUX.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): SS_MUX.power already has a driver (switch SW_MUX); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_MUX.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_MUX.primary.power already has a driver (switch SW_MUX); 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 VSS VHI VLO)", 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 == "SS_AON.power" || name == "PD_TOP.primary.power") return openpa_net_VDD_N;
if (name == "VSS" || name == "VSS_N" || name == "SS_AON.ground" || name == "SS_BLK.ground" || name == "SS_MUX.ground" || name == "PD_TOP.primary.ground" || name == "PD_BLK.primary.ground" || name == "PD_MUX.primary.ground") return openpa_net_VSS_N;
if (name == "VHI" || name == "VHI_N") return openpa_net_VHI_N;
if (name == "VLO" || name == "VLO_N") return openpa_net_VLO_N;
if (name == "VDD_BLK" || name == "SS_BLK.power" || name == "PD_BLK.primary.power") return openpa_net_VDD_BLK;
if (name == "VDD_MUX" || name == "SS_MUX.power" || name == "PD_MUX.primary.power") return openpa_net_VDD_MUX;
$display("OPENPA-ERROR get_supply_value(\"%s\"): no supply net, port or supply set function of that name", name);
return 0;
endfunction
function automatic upfRealT get_supply_voltage(upfSupplyTypeT arg); return arg.voltage / 1.0e6; endfunction
// 11.2.4: 1 for FULL_ON; 0 otherwise.
function automatic upfBooleanT get_supply_on_state(upfSupplyTypeT arg); return arg.state == FULL_ON; endfunction
function automatic upfSupplyStateE get_supply_state(upfSupplyTypeT arg); return arg.state; endfunction
endpackage
// ---------------------------------------------------------------------------
// OpenPA cells (generated; do not edit)
// ---------------------------------------------------------------------------
// openpa_corrupt: rule C2. Passes d while the driving domain is NORMAL; otherwise drives X (4-state)
// or a seeded value (2-state). The value is computed ahead for the episode the next power-down starts
// (ep + 1 while ok), so at power-down the output goes straight from d to the new value: no delta glitch
// through the previous episode's value (Icarus would turn one into a clock edge).
module openpa_corrupt #(parameter int W = 1, parameter int unsigned ID = 0) (
input logic [W-1:0] d,
output logic [W-1:0] q,
input bit ok,
input int unsigned ep
);
localparam int L = (W + 63) / 64;
logic [L*64-1:0] cv;
always @(ep or ok or UPF::openpa_kick)
for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
assign q = ok ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule
// openpa_corrupt_sim: rule C2 for a domain that has intermediate simstates (IEEE 1801-2024 9.5). As
// openpa_corrupt, and also corrupt while lhit is set (CORRUPT_ON_ACTIVITY after input activity), or after d
// changed while coc is set (CORRUPT_ON_CHANGE); leaving CORRUPT_ON_CHANGE clears that.
module openpa_corrupt_sim #(parameter int W = 1, parameter int unsigned ID = 0) (
input logic [W-1:0] d,
output logic [W-1:0] q,
input bit ok,
input int unsigned ep,
input bit lhit,
input bit coc
);
localparam int L = (W + 63) / 64;
logic [L*64-1:0] cv;
bit chg;
always @(ep or ok or UPF::openpa_kick)
for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
// verilator lint_off MULTIDRIVEN
for (genvar i = 0; i < W; i++) begin : g_chg
always @(posedge d[i] or negedge d[i]) if (coc && ok) chg = 1'b1;
end
always @(negedge coc) chg = 1'b0;
// verilator lint_on MULTIDRIVEN
assign q = (ok && !lhit && !chg) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule
// openpa_iso: rules I1-I4 (IEEE 1801-2024 9.8). CLAMP 0, 1, 2 (latch: the value the input had while the enable
// was inactive) or 3 (Z: high impedance on 4-state; 0 on 2-state backends, which cannot represent Z).
// sup_ok is 1 while the isolation supply is NORMAL (always, for a strategy with no supply); otherwise the output,
// and a latched value, are corrupt. An enable at X or Z corrupts the output and the latched value.
module openpa_iso #(parameter int W = 1, parameter int CLAMP = 0, parameter bit SENSE = 1'b1, parameter int unsigned ID = 0) (
input logic [W-1:0] d,
output logic [W-1:0] q,
input logic en,
input bit sup_ok,
input int unsigned sup_ep
);
localparam int L = (W + 63) / 64;
logic [L*64-1:0] cv;
logic [W-1:0] held;
always @(sup_ep or sup_ok or UPF::openpa_kick)
for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h4000_0000, sup_ok ? sup_ep + 1 : sup_ep, i);
wire active = (en === SENSE);
wire inactive = (en === !SENSE);
wire [W-1:0] bad = UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0];
if (CLAMP == 2) begin : g_latch
always @(d or en or sup_ok or bad) if (!sup_ok || !(active || inactive)) held = bad; else if (inactive) held = d;
end
wire [W-1:0] clampv = (CLAMP == 3) ? (UPF::openpa_xmode ? {W{1'bz}} : {W{1'b0}}) : (CLAMP == 2) ? held : (CLAMP == 1) ? {W{1'b1}} : {W{1'b0}};
assign q = !sup_ok ? bad : active ? clampv : inactive ? d : bad;
endmodule
// openpa_ls: rule L1 (IEEE 1801-2024 9.9). Passes d while every supply set of the cell is NORMAL; otherwise corrupt.
module openpa_ls #(parameter int W = 1, parameter int unsigned ID = 0) (
input logic [W-1:0] d,
output logic [W-1:0] q,
input bit src_ok,
input bit dst_ok,
input int unsigned ep
);
localparam int L = (W + 63) / 64;
logic [L*64-1:0] cv;
always @(ep or src_ok or dst_ok or UPF::openpa_kick)
for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h8000_0000, (src_ok && dst_ok) ? ep + 1 : ep, i);
assign q = (src_ok && dst_ok) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule
`line 1 "tile.sv" 0
// tile: an always-on top with two switchable blocks. Power-unaware RTL.
module tile (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr_en,
input logic rush,
input logic mux_en,
input logic sel_hi,
input logic iso_blk,
input logic iso_mux,
output logic [7:0] q_blk,
output logic [7:0] q_mux,
output logic ready
);
wire pwr_ack; // no RTL drives this wire: the UPF switch's -ack_port does
wire [7:0] openpa_u_blk_q_raw, openpa_u_blk_q_s1; acc u_blk (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(openpa_u_blk_q_raw)); openpa_corrupt #(.W(8), .ID(268435456)) openpa_u_blk_q_cor (.d(openpa_u_blk_q_raw), .q(openpa_u_blk_q_s1), .ok(UPF::openpa_dom_PD_BLK_ok), .ep(UPF::openpa_dom_PD_BLK_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435457)) openpa_u_blk_q_iso (.d(openpa_u_blk_q_s1), .q(q_blk), .en(UPF::openpa_ctl_4_iso_blk), .sup_ok((UPF::openpa_ss_SS_AON_sim == 0)), .sup_ep(UPF::openpa_ss_SS_AON_ep));
wire [7:0] openpa_u_mux_q_raw, openpa_u_mux_q_s1; wire [0:0] openpa_u_mux_clk_s1; wire [7:0] openpa_u_mux_d_s1; wire [0:0] openpa_u_mux_en_s1; wire [0:0] openpa_u_mux_rst_n_s1; acc u_mux (.clk(openpa_u_mux_clk_s1), .rst_n(openpa_u_mux_rst_n_s1), .en(openpa_u_mux_en_s1), .d(openpa_u_mux_d_s1), .q(openpa_u_mux_q_raw)); openpa_corrupt #(.W(8), .ID(268435464)) openpa_u_mux_q_cor (.d(openpa_u_mux_q_raw), .q(openpa_u_mux_q_s1), .ok(UPF::openpa_dom_PD_MUX_ok), .ep(UPF::openpa_dom_PD_MUX_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435465)) openpa_u_mux_q_iso (.d(openpa_u_mux_q_s1), .q(q_mux), .en(UPF::openpa_ctl_5_iso_mux), .sup_ok((UPF::openpa_ss_SS_AON_sim == 0)), .sup_ep(UPF::openpa_ss_SS_AON_ep)); openpa_corrupt #(.W(1), .ID(268435504)) openpa_u_mux_clk_cor (.d(clk), .q(openpa_u_mux_clk_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(8), .ID(268435512)) openpa_u_mux_d_cor (.d(d + 8'd1), .q(openpa_u_mux_d_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435520)) openpa_u_mux_en_cor (.d(en), .q(openpa_u_mux_en_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435528)) openpa_u_mux_rst_n_cor (.d(rst_n), .q(openpa_u_mux_rst_n_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep));
assign ready = pwr_ack;
`line 1 "openpa_overlay.sv" 0
// ===================================================================================
// OpenPA overlay for tile: generated from 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_ctl_0_pwr_en;
import UPF::openpa_ctl_1_rush;
import UPF::openpa_ctl_2_mux_en;
import UPF::openpa_ctl_3_sel_hi;
import UPF::openpa_ctl_4_iso_blk;
import UPF::openpa_ctl_5_iso_mux;
import UPF::openpa_dom_PD_BLK_ep;
import UPF::openpa_dom_PD_BLK_ok;
import UPF::openpa_dom_PD_BLK_sim;
import UPF::openpa_dom_PD_MUX_ep;
import UPF::openpa_dom_PD_MUX_ok;
import UPF::openpa_dom_PD_MUX_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_VDD_BLK;
import UPF::openpa_net_VDD_MUX;
import UPF::openpa_net_VDD_N;
import UPF::openpa_net_VHI_N;
import UPF::openpa_net_VLO_N;
import UPF::openpa_net_VSS_N;
import UPF::openpa_seed;
import UPF::openpa_ss_SS_AON_ep;
import UPF::openpa_ss_SS_AON_multi;
import UPF::openpa_ss_SS_AON_ok;
import UPF::openpa_ss_SS_AON_sim;
import UPF::openpa_ss_SS_AON_st;
import UPF::openpa_ss_SS_BLK_ep;
import UPF::openpa_ss_SS_BLK_multi;
import UPF::openpa_ss_SS_BLK_ok;
import UPF::openpa_ss_SS_BLK_sim;
import UPF::openpa_ss_SS_BLK_st;
import UPF::openpa_ss_SS_MUX_ep;
import UPF::openpa_ss_SS_MUX_multi;
import UPF::openpa_ss_SS_MUX_ok;
import UPF::openpa_ss_SS_MUX_sim;
import UPF::openpa_ss_SS_MUX_st;
import UPF::openpa_sw_SW_BLK_st;
import UPF::openpa_sw_SW_MUX_st;
import UPF::openpa_xmode;
// ---- mode, seed, trace
bit openpa_tr, openpa_obs;
int openpa_n [1:14];
int openpa_seq [1:4]; // good-form sequence bins (coverage)
bit openpa_sreq; bit openpa_sp [1:28]; // 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 @(pwr_en or openpa_kick) openpa_ctl_0_pwr_en = pwr_en;
always @(rush or openpa_kick) openpa_ctl_1_rush = rush;
always @(mux_en or openpa_kick) openpa_ctl_2_mux_en = mux_en;
always @(sel_hi or openpa_kick) openpa_ctl_3_sel_hi = sel_hi;
always @(iso_blk or openpa_kick) openpa_ctl_4_iso_blk = iso_blk;
always @(iso_mux or openpa_kick) openpa_ctl_5_iso_mux = iso_mux;
// ---- supply network, switches, supply sets, simstates, power states (one block, evaluated in order)
bit openpa_tg_sw_SW_BLK_st; int openpa_pv_sw_SW_BLK_st = -2;
bit openpa_tg_sw_SW_MUX_st; int openpa_pv_sw_SW_MUX_st = -2;
UPF::supply_net_type openpa_swv_SW_BLK_f, openpa_swv_SW_BLK_p; bit openpa_swv_SW_BLK_u, openpa_swv_SW_BLK_hf, openpa_swv_SW_BLK_hp, openpa_swv_SW_BLK_vd, openpa_swv_SW_BLK_on, openpa_swv_SW_BLK_pt; int openpa_swv_SW_BLK_k; // switch SW_BLK
UPF::supply_net_type openpa_swv_SW_MUX_f, openpa_swv_SW_MUX_p; bit openpa_swv_SW_MUX_u, openpa_swv_SW_MUX_hf, openpa_swv_SW_MUX_hp, openpa_swv_SW_MUX_vd, openpa_swv_SW_MUX_on, openpa_swv_SW_MUX_pt; int openpa_swv_SW_MUX_k; // switch SW_MUX
always @(openpa_kick or UPF::openpa_port_VDD or UPF::openpa_port_VSS or UPF::openpa_port_VHI or UPF::openpa_port_VLO or UPF::openpa_ctl_0_pwr_en or UPF::openpa_ctl_1_rush or UPF::openpa_ctl_2_mux_en or UPF::openpa_ctl_3_sel_hi) begin : openpa_network
openpa_net_VDD_N = UPF::openpa_port_VDD; // VDD_N <- port VDD
openpa_net_VSS_N = UPF::openpa_port_VSS; // VSS_N <- port VSS
openpa_net_VHI_N = UPF::openpa_port_VHI; // VHI_N <- port VHI
openpa_net_VLO_N = UPF::openpa_port_VLO; // VLO_N <- port VLO
// switch SW_BLK (tile.upf:27): IEEE 1801-2024 6.23
openpa_swv_SW_BLK_u = 1'b0; openpa_swv_SW_BLK_hf = 1'b0; openpa_swv_SW_BLK_hp = 1'b0; openpa_swv_SW_BLK_vd = 1'b0; openpa_swv_SW_BLK_on = 1'b0; openpa_swv_SW_BLK_pt = 1'b0; openpa_swv_SW_BLK_k = 0;
if (($isunknown(openpa_ctl_0_pwr_en) || $isunknown(openpa_ctl_1_rush)) && UPF::openpa_net_VDD_N.state != UPF::OFF) openpa_swv_SW_BLK_u = 1'b1; // on state full: a control is X or Z
else if (((openpa_ctl_0_pwr_en === 1'b1) && !((openpa_ctl_1_rush === 1'b1)))) begin
if (!openpa_swv_SW_BLK_on) openpa_swv_SW_BLK_k = 1;
openpa_swv_SW_BLK_on = 1'b1;
if (UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED) openpa_swv_SW_BLK_u = 1'b1;
else if (UPF::openpa_net_VDD_N.state == UPF::FULL_ON) begin
if ((openpa_swv_SW_BLK_hf && openpa_swv_SW_BLK_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_BLK_hp && openpa_swv_SW_BLK_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_BLK_vd = 1'b1;
openpa_swv_SW_BLK_f = UPF::openpa_net_VDD_N; openpa_swv_SW_BLK_hf = 1'b1;
end
else if (UPF::openpa_net_VDD_N.state == UPF::PARTIAL_ON) begin
if ((openpa_swv_SW_BLK_hf && openpa_swv_SW_BLK_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_BLK_hp && openpa_swv_SW_BLK_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_BLK_vd = 1'b1;
openpa_swv_SW_BLK_p = UPF::openpa_net_VDD_N; openpa_swv_SW_BLK_hp = 1'b1;
end
end
if (($isunknown(openpa_ctl_0_pwr_en) || $isunknown(openpa_ctl_1_rush)) && UPF::openpa_net_VDD_N.state != UPF::OFF) openpa_swv_SW_BLK_u = 1'b1; // partial on state soft: a control is X or Z
else if (((openpa_ctl_0_pwr_en === 1'b1) && (openpa_ctl_1_rush === 1'b1))) begin
if (openpa_swv_SW_BLK_k == 0 && !openpa_swv_SW_BLK_on) openpa_swv_SW_BLK_k = 2;
openpa_swv_SW_BLK_pt = 1'b1;
if (UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED) openpa_swv_SW_BLK_u = 1'b1;
else if (UPF::openpa_net_VDD_N.state == UPF::FULL_ON || UPF::openpa_net_VDD_N.state == UPF::PARTIAL_ON) begin
if ((openpa_swv_SW_BLK_hf && openpa_swv_SW_BLK_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_BLK_hp && openpa_swv_SW_BLK_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_BLK_vd = 1'b1;
openpa_swv_SW_BLK_p = UPF::openpa_net_VDD_N; openpa_swv_SW_BLK_p.state = UPF::PARTIAL_ON; openpa_swv_SW_BLK_hp = 1'b1; // degraded value
end
end
if ((((!((openpa_ctl_0_pwr_en === 1'b1)) && (openpa_ctl_1_rush === 1'b1)))) || ((((!((openpa_ctl_0_pwr_en === 1'b1)) && !((openpa_ctl_1_rush === 1'b1))))) && (openpa_swv_SW_BLK_on || openpa_swv_SW_BLK_pt)) || openpa_swv_SW_BLK_u || openpa_swv_SW_BLK_vd || (!($isunknown(openpa_ctl_0_pwr_en) || $isunknown(openpa_ctl_1_rush)) && !openpa_swv_SW_BLK_on && !openpa_swv_SW_BLK_pt && !(((!((openpa_ctl_0_pwr_en === 1'b1)) && !((openpa_ctl_1_rush === 1'b1))))) && !(((!((openpa_ctl_0_pwr_en === 1'b1)) && (openpa_ctl_1_rush === 1'b1)))))) begin openpa_sw_SW_BLK_st = -1; openpa_net_VDD_BLK.state = UPF::UNDETERMINED; openpa_net_VDD_BLK.voltage = 0; end
else begin openpa_sw_SW_BLK_st = openpa_swv_SW_BLK_k; if (openpa_swv_SW_BLK_hf) openpa_net_VDD_BLK = openpa_swv_SW_BLK_f; else if (openpa_swv_SW_BLK_hp) openpa_net_VDD_BLK = openpa_swv_SW_BLK_p; else begin openpa_net_VDD_BLK.state = UPF::OFF; openpa_net_VDD_BLK.voltage = 0; end end
// switch SW_MUX (tile.upf:35): IEEE 1801-2024 6.23
openpa_swv_SW_MUX_u = 1'b0; openpa_swv_SW_MUX_hf = 1'b0; openpa_swv_SW_MUX_hp = 1'b0; openpa_swv_SW_MUX_vd = 1'b0; openpa_swv_SW_MUX_on = 1'b0; openpa_swv_SW_MUX_pt = 1'b0; openpa_swv_SW_MUX_k = 0;
if (($isunknown(openpa_ctl_2_mux_en) || $isunknown(openpa_ctl_3_sel_hi)) && UPF::openpa_net_VHI_N.state != UPF::OFF) openpa_swv_SW_MUX_u = 1'b1; // on state high: a control is X or Z
else if (((openpa_ctl_2_mux_en === 1'b1) && (openpa_ctl_3_sel_hi === 1'b1))) begin
if (!openpa_swv_SW_MUX_on) openpa_swv_SW_MUX_k = 1;
openpa_swv_SW_MUX_on = 1'b1;
if (UPF::openpa_net_VHI_N.state == UPF::UNDETERMINED) openpa_swv_SW_MUX_u = 1'b1;
else if (UPF::openpa_net_VHI_N.state == UPF::FULL_ON) begin
if ((openpa_swv_SW_MUX_hf && openpa_swv_SW_MUX_f.voltage != UPF::openpa_net_VHI_N.voltage) || (openpa_swv_SW_MUX_hp && openpa_swv_SW_MUX_p.voltage != UPF::openpa_net_VHI_N.voltage)) openpa_swv_SW_MUX_vd = 1'b1;
openpa_swv_SW_MUX_f = UPF::openpa_net_VHI_N; openpa_swv_SW_MUX_hf = 1'b1;
end
else if (UPF::openpa_net_VHI_N.state == UPF::PARTIAL_ON) begin
if ((openpa_swv_SW_MUX_hf && openpa_swv_SW_MUX_f.voltage != UPF::openpa_net_VHI_N.voltage) || (openpa_swv_SW_MUX_hp && openpa_swv_SW_MUX_p.voltage != UPF::openpa_net_VHI_N.voltage)) openpa_swv_SW_MUX_vd = 1'b1;
openpa_swv_SW_MUX_p = UPF::openpa_net_VHI_N; openpa_swv_SW_MUX_hp = 1'b1;
end
end
if (($isunknown(openpa_ctl_2_mux_en) || $isunknown(openpa_ctl_3_sel_hi)) && UPF::openpa_net_VLO_N.state != UPF::OFF) openpa_swv_SW_MUX_u = 1'b1; // on state low: a control is X or Z
else if (((openpa_ctl_2_mux_en === 1'b1) && !((openpa_ctl_3_sel_hi === 1'b1)))) begin
if (!openpa_swv_SW_MUX_on) openpa_swv_SW_MUX_k = 2;
openpa_swv_SW_MUX_on = 1'b1;
if (UPF::openpa_net_VLO_N.state == UPF::UNDETERMINED) openpa_swv_SW_MUX_u = 1'b1;
else if (UPF::openpa_net_VLO_N.state == UPF::FULL_ON) begin
if ((openpa_swv_SW_MUX_hf && openpa_swv_SW_MUX_f.voltage != UPF::openpa_net_VLO_N.voltage) || (openpa_swv_SW_MUX_hp && openpa_swv_SW_MUX_p.voltage != UPF::openpa_net_VLO_N.voltage)) openpa_swv_SW_MUX_vd = 1'b1;
openpa_swv_SW_MUX_f = UPF::openpa_net_VLO_N; openpa_swv_SW_MUX_hf = 1'b1;
end
else if (UPF::openpa_net_VLO_N.state == UPF::PARTIAL_ON) begin
if ((openpa_swv_SW_MUX_hf && openpa_swv_SW_MUX_f.voltage != UPF::openpa_net_VLO_N.voltage) || (openpa_swv_SW_MUX_hp && openpa_swv_SW_MUX_p.voltage != UPF::openpa_net_VLO_N.voltage)) openpa_swv_SW_MUX_vd = 1'b1;
openpa_swv_SW_MUX_p = UPF::openpa_net_VLO_N; openpa_swv_SW_MUX_hp = 1'b1;
end
end
if ((1'b0) || openpa_swv_SW_MUX_u || openpa_swv_SW_MUX_vd || 1'b0) begin openpa_sw_SW_MUX_st = -1; openpa_net_VDD_MUX.state = UPF::UNDETERMINED; openpa_net_VDD_MUX.voltage = 0; end
else begin openpa_sw_SW_MUX_st = openpa_swv_SW_MUX_k; if (openpa_swv_SW_MUX_hf) openpa_net_VDD_MUX = openpa_swv_SW_MUX_f; else if (openpa_swv_SW_MUX_hp) openpa_net_VDD_MUX = openpa_swv_SW_MUX_p; else begin openpa_net_VDD_MUX.state = UPF::OFF; openpa_net_VDD_MUX.voltage = 0; end end
// supply set SS_AON (also PD_TOP.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_SS_AON
bit nx; int sm;
sm = (UPF::openpa_net_VDD_N.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5; // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
openpa_ss_SS_AON_sim = sm;
nx = sm < 5;
if (openpa_ss_SS_AON_ok && !nx) openpa_ss_SS_AON_ep = openpa_ss_SS_AON_ep + 1;
openpa_ss_SS_AON_ok = nx;
end
// supply set SS_BLK (also PD_BLK.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_SS_BLK
bit nx; int sm;
sm = (UPF::openpa_net_VDD_BLK.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_SS_BLK_sim = sm;
nx = sm < 5;
if (openpa_ss_SS_BLK_ok && !nx) openpa_ss_SS_BLK_ep = openpa_ss_SS_BLK_ep + 1;
openpa_ss_SS_BLK_ok = nx;
end
// supply set SS_MUX (also PD_MUX.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_SS_MUX
bit nx; int sm;
sm = (UPF::openpa_net_VDD_MUX.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_SS_MUX_sim = sm;
nx = sm < 5;
if (openpa_ss_SS_MUX_ok && !nx) openpa_ss_SS_MUX_ep = openpa_ss_SS_MUX_ep + 1;
openpa_ss_SS_MUX_ok = nx;
end
// domain PD_TOP: simstate of its primary supply set SS_AON
if (openpa_dom_PD_TOP_ok && !UPF::openpa_ss_SS_AON_ok) openpa_dom_PD_TOP_ep = openpa_dom_PD_TOP_ep + 1;
openpa_dom_PD_TOP_ok = UPF::openpa_ss_SS_AON_ok;
openpa_dom_PD_TOP_sim = openpa_ss_SS_AON_sim;
// domain PD_BLK: simstate of its primary supply set SS_BLK
if (openpa_dom_PD_BLK_ok && !UPF::openpa_ss_SS_BLK_ok) openpa_dom_PD_BLK_ep = openpa_dom_PD_BLK_ep + 1;
openpa_dom_PD_BLK_ok = UPF::openpa_ss_SS_BLK_ok;
openpa_dom_PD_BLK_sim = openpa_ss_SS_BLK_sim;
// domain PD_MUX: simstate of its primary supply set SS_MUX
if (openpa_dom_PD_MUX_ok && !UPF::openpa_ss_SS_MUX_ok) openpa_dom_PD_MUX_ep = openpa_dom_PD_MUX_ep + 1;
openpa_dom_PD_MUX_ok = UPF::openpa_ss_SS_MUX_ok;
openpa_dom_PD_MUX_sim = openpa_ss_SS_MUX_sim;
if (openpa_sw_SW_BLK_st != openpa_pv_sw_SW_BLK_st) begin openpa_tg_sw_SW_BLK_st = ~openpa_tg_sw_SW_BLK_st; openpa_pv_sw_SW_BLK_st = openpa_sw_SW_BLK_st; end
if (openpa_sw_SW_MUX_st != openpa_pv_sw_SW_MUX_st) begin openpa_tg_sw_SW_MUX_st = ~openpa_tg_sw_SW_MUX_st; openpa_pv_sw_SW_MUX_st = openpa_sw_SW_MUX_st; end
end
// ---- corruption: registers forced, memories overwritten (rules C1, C3)
// domain PD_TOP (tile.upf:22): 0 register(s), 0 memory(ies)
bit openpa_PD_TOP_applied, openpa_PD_TOP_valid;
// The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
// supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
always @(UPF::openpa_dom_PD_TOP_ok or openpa_kick) if (!openpa_PD_TOP_valid || openpa_PD_TOP_applied != UPF::openpa_dom_PD_TOP_ok) begin
openpa_t({"PD_TOP ", UPF::openpa_dom_PD_TOP_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_PD_TOP_ok || !openpa_PD_TOP_valid) begin
end
if (UPF::openpa_dom_PD_TOP_ok) begin
end
openpa_PD_TOP_valid = 1'b1; openpa_PD_TOP_applied = UPF::openpa_dom_PD_TOP_ok;
end
// domain PD_BLK (tile.upf:23): 1 register(s), 0 memory(ies)
bit openpa_PD_BLK_applied, openpa_PD_BLK_valid;
logic [7:0] openpa_cv1; // corruption value for u_blk.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_PD_BLK_ok or openpa_kick) if (!openpa_PD_BLK_valid || openpa_PD_BLK_applied != UPF::openpa_dom_PD_BLK_ok) begin
openpa_t({"PD_BLK ", UPF::openpa_dom_PD_BLK_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_PD_BLK_ok || !openpa_PD_BLK_valid) begin
if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_PD_BLK_ep, 0);
force u_blk.q = openpa_cv1;
end
if (UPF::openpa_dom_PD_BLK_ok) begin
release u_blk.q;
end
openpa_PD_BLK_valid = 1'b1; openpa_PD_BLK_applied = UPF::openpa_dom_PD_BLK_ok;
end
// domain PD_MUX (tile.upf:24): 1 register(s), 0 memory(ies)
bit openpa_PD_MUX_applied, openpa_PD_MUX_valid;
logic [7:0] openpa_cv2; // corruption value for u_mux.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_PD_MUX_ok or openpa_kick) if (!openpa_PD_MUX_valid || openpa_PD_MUX_applied != UPF::openpa_dom_PD_MUX_ok) begin
openpa_t({"PD_MUX ", UPF::openpa_dom_PD_MUX_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_PD_MUX_ok || !openpa_PD_MUX_valid) begin
if (openpa_xmode) openpa_cv2 = 'x; else openpa_cv2 = UPF::openpa_mix(2, UPF::openpa_dom_PD_MUX_ep, 0);
force u_mux.q = openpa_cv2;
end
if (UPF::openpa_dom_PD_MUX_ok) begin
release u_mux.q;
end
openpa_PD_MUX_valid = 1'b1; openpa_PD_MUX_applied = UPF::openpa_dom_PD_MUX_ok;
end
// D7 reset check for PD_BLK: resets u_blk.rst_n active 0
bit openpa_PD_BLK_rprev, openpa_PD_BLK_rp0;
always @(posedge UPF::openpa_dom_PD_BLK_ok or negedge UPF::openpa_dom_PD_BLK_ok or posedge u_blk.rst_n or negedge u_blk.rst_n) begin
if (UPF::openpa_dom_PD_BLK_ok && !openpa_PD_BLK_rprev) openpa_PD_BLK_rp0 = 1'b1;
if (!UPF::openpa_dom_PD_BLK_ok || u_blk.rst_n === 1'b0) openpa_PD_BLK_rp0 = 1'b0;
openpa_PD_BLK_rprev = UPF::openpa_dom_PD_BLK_ok;
end
// D7 reset check for PD_MUX: resets u_mux.rst_n active 0
bit openpa_PD_MUX_rprev, openpa_PD_MUX_rp0;
always @(posedge UPF::openpa_dom_PD_MUX_ok or negedge UPF::openpa_dom_PD_MUX_ok or posedge u_mux.rst_n or negedge u_mux.rst_n) begin
if (UPF::openpa_dom_PD_MUX_ok && !openpa_PD_MUX_rprev) openpa_PD_MUX_rp0 = 1'b1;
if (!UPF::openpa_dom_PD_MUX_ok || u_mux.rst_n === 1'b0) openpa_PD_MUX_rp0 = 1'b0;
openpa_PD_MUX_rprev = UPF::openpa_dom_PD_MUX_ok;
end
// ---- checks for set_isolation ISO_BLK (tile.upf:41): PD_BLK -> PD_TOP on 1 port(s)
bit openpa_ig1_act, openpa_ig1_cyc;
always @(negedge UPF::openpa_dom_PD_BLK_ok) if (!UPF::openpa_dom_PD_BLK_ok)
begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge UPF::openpa_ctl_4_iso_blk or negedge UPF::openpa_ctl_4_iso_blk or posedge openpa_kick) begin
if (openpa_ig1_act && !(UPF::openpa_ctl_4_iso_blk === 1'b1))
begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
if (openpa_ig1_act != (UPF::openpa_ctl_4_iso_blk === 1'b1)) openpa_t({"ISO_BLK enable ", (UPF::openpa_ctl_4_iso_blk === 1'b1) ? "active" : "inactive"});
openpa_ig1_act = (UPF::openpa_ctl_4_iso_blk === 1'b1);
end
always @(negedge UPF::openpa_ss_SS_AON_ok) if (!UPF::openpa_ss_SS_AON_ok)
begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; end
// ---- checks for set_isolation ISO_MUX (tile.upf:43): PD_MUX -> PD_TOP on 1 port(s)
bit openpa_ig2_act, openpa_ig2_cyc;
always @(negedge UPF::openpa_dom_PD_MUX_ok) if (!UPF::openpa_dom_PD_MUX_ok)
begin openpa_sp[4] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge UPF::openpa_ctl_5_iso_mux or negedge UPF::openpa_ctl_5_iso_mux or posedge openpa_kick) begin
if (openpa_ig2_act && !(UPF::openpa_ctl_5_iso_mux === 1'b1))
begin openpa_sp[5] = 1'b1; openpa_sreq = 1'b1; end
if (openpa_ig2_act != (UPF::openpa_ctl_5_iso_mux === 1'b1)) openpa_t({"ISO_MUX enable ", (UPF::openpa_ctl_5_iso_mux === 1'b1) ? "active" : "inactive"});
openpa_ig2_act = (UPF::openpa_ctl_5_iso_mux === 1'b1);
end
always @(negedge UPF::openpa_ss_SS_AON_ok) if (!UPF::openpa_ss_SS_AON_ok)
begin openpa_sp[6] = 1'b1; openpa_sreq = 1'b1; end
// crossing 1: u_blk/q (PD_BLK) -> tile output q_blk (PD_TOP), isolated by ISO_BLK
bit openpa_x1_t;
always @(UPF::openpa_dom_PD_BLK_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_4_iso_blk or UPF::openpa_ss_SS_AON_sim or UPF::openpa_net_VDD_BLK or UPF::openpa_net_VSS_N) openpa_x1_t = !UPF::openpa_dom_PD_BLK_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_4_iso_blk === 1'b1) && (UPF::openpa_ss_SS_AON_sim == 0))) && !(UPF::openpa_net_VDD_BLK.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x1_t)
begin openpa_sp[7] = 1'b1; openpa_sreq = 1'b1; end
// crossing 2: u_mux/q (PD_MUX) -> tile output q_mux (PD_TOP), isolated by ISO_MUX
bit openpa_x2_t;
always @(UPF::openpa_dom_PD_MUX_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_5_iso_mux or UPF::openpa_ss_SS_AON_sim or UPF::openpa_net_VDD_MUX or UPF::openpa_net_VSS_N) openpa_x2_t = !UPF::openpa_dom_PD_MUX_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_5_iso_mux === 1'b1) && (UPF::openpa_ss_SS_AON_sim == 0))) && !(UPF::openpa_net_VDD_MUX.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x2_t)
begin openpa_sp[8] = 1'b1; openpa_sreq = 1'b1; end
// crossing 3: tile input clk (PD_TOP) -> u_blk/clk (PD_BLK), not isolated
bit openpa_x3_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_BLK_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x3_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_BLK_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x3_t)
begin openpa_sp[9] = 1'b1; openpa_sreq = 1'b1; end
// crossing 4: tile input d (PD_TOP) -> u_blk/d (PD_BLK), not isolated
bit openpa_x4_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_BLK_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x4_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_BLK_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x4_t)
begin openpa_sp[10] = 1'b1; openpa_sreq = 1'b1; end
// crossing 5: tile input en (PD_TOP) -> u_blk/en (PD_BLK), not isolated
bit openpa_x5_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_BLK_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x5_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_BLK_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x5_t)
begin openpa_sp[11] = 1'b1; openpa_sreq = 1'b1; end
// crossing 6: tile input rst_n (PD_TOP) -> u_blk/rst_n (PD_BLK), not isolated
bit openpa_x6_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_BLK_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x6_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_BLK_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x6_t)
begin openpa_sp[12] = 1'b1; openpa_sreq = 1'b1; end
// crossing 7: tile input clk (PD_TOP) -> u_mux/clk (PD_MUX), not isolated
bit openpa_x7_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_MUX_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_MUX_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[13] = 1'b1; openpa_sreq = 1'b1; end
// crossing 8: logic in tile (PD_TOP) -> u_mux/d (PD_MUX), not isolated
bit openpa_x8_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_MUX_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_MUX_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[14] = 1'b1; openpa_sreq = 1'b1; end
// crossing 9: tile input en (PD_TOP) -> u_mux/en (PD_MUX), not isolated
bit openpa_x9_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_MUX_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_MUX_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[15] = 1'b1; openpa_sreq = 1'b1; end
// crossing 10: tile input rst_n (PD_TOP) -> u_mux/rst_n (PD_MUX), not isolated
bit openpa_x10_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_MUX_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_MUX_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[16] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 1: PD_BLK -> PD_TOP (no level shifter strategy, threshold 0)
bit openpa_l1_t;
always @(UPF::openpa_dom_PD_BLK_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_BLK or UPF::openpa_net_VDD_N) openpa_l1_t = UPF::openpa_dom_PD_BLK_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_BLK.voltage - UPF::openpa_net_VDD_N.voltage > 0 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_BLK.voltage > 0) && !1'b0;
always @(posedge openpa_l1_t)
begin openpa_sp[17] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 2: PD_MUX -> PD_TOP (no level shifter strategy, threshold 0)
bit openpa_l2_t;
always @(UPF::openpa_dom_PD_MUX_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_MUX or UPF::openpa_net_VDD_N) openpa_l2_t = UPF::openpa_dom_PD_MUX_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_MUX.voltage - UPF::openpa_net_VDD_N.voltage > 0 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_MUX.voltage > 0) && !1'b0;
always @(posedge openpa_l2_t)
begin openpa_sp[18] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 3: PD_TOP -> PD_BLK (no level shifter strategy, threshold 0)
bit openpa_l3_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_BLK_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_BLK) openpa_l3_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_BLK_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_BLK.voltage > 0 || UPF::openpa_net_VDD_BLK.voltage - UPF::openpa_net_VDD_N.voltage > 0) && !1'b0;
always @(posedge openpa_l3_t)
begin openpa_sp[19] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 4: PD_TOP -> PD_MUX (no level shifter strategy, threshold 0)
bit openpa_l4_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_MUX_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_MUX) openpa_l4_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_MUX_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_MUX.voltage > 0 || UPF::openpa_net_VDD_MUX.voltage - UPF::openpa_net_VDD_N.voltage > 0) && !1'b0;
always @(posedge openpa_l4_t)
begin openpa_sp[20] = 1'b1; openpa_sreq = 1'b1; end
bit openpa_SW_BLK_def;
always @(posedge openpa_tg_sw_SW_BLK_st or negedge openpa_tg_sw_SW_BLK_st)
begin openpa_sp[21] = 1'b1; openpa_sreq = 1'b1; end
bit openpa_SW_MUX_def;
always @(posedge openpa_tg_sw_SW_MUX_st or negedge openpa_tg_sw_SW_MUX_st)
begin openpa_sp[22] = 1'b1; openpa_sreq = 1'b1; end
// switch SW_BLK -ack_port ack -> pwr_ack, delay 3, constant 1 (tile.upf:32)
logic openpa_ack1_v, openpa_ack1_d, openpa_ack1; int openpa_ack1_pm = 0; int unsigned openpa_ack1_g;
initial begin openpa_ack1_v = 1'b0; openpa_ack1_d = 1'b0; end // the switch is OFF at time 0
always @(posedge openpa_tg_sw_SW_BLK_st or negedge openpa_tg_sw_SW_BLK_st or openpa_kick) begin
int m; m = (openpa_sw_SW_BLK_st < 0) ? -1 : (openpa_sw_SW_BLK_st == 0) ? 0 : (openpa_sw_SW_BLK_st <= 1) ? 1 : 2;
if (m == 0) openpa_ack1_v = 1'b0; else if (m == 1) openpa_ack1_v = 1'b1;
else if (m == 2 && openpa_ack1_pm == 1) openpa_ack1_v = 1'b0; else if (m == 2 && openpa_ack1_pm == 0) openpa_ack1_v = 1'b1;
if (m >= 0 && m != 2) openpa_ack1_pm = m;
end
task automatic openpa_ack1_after(input int unsigned g, input logic v); #(3) if (g == openpa_ack1_g) openpa_ack1_d = v; endtask
always @(openpa_ack1_v) begin openpa_ack1_g = openpa_ack1_g + 1; fork openpa_ack1_after(openpa_ack1_g, openpa_ack1_v); join_none end // inertial
always @(openpa_ack1_d or posedge openpa_tg_sw_SW_BLK_st or negedge openpa_tg_sw_SW_BLK_st or UPF::openpa_ss_SS_AON_sim or openpa_kick) openpa_ack1 = (openpa_sw_SW_BLK_st == -1 || !(UPF::openpa_ss_SS_AON_sim == 0)) ? (openpa_xmode ? 1'bx : UPF::openpa_bit(200001, UPF::openpa_ss_SS_AON_ep)) : openpa_ack1_d;
initial force pwr_ack = openpa_ack1;
always @(posedge openpa_ack1 or negedge openpa_ack1) openpa_t($sformatf("SW_BLK ack ack %b", openpa_ack1));
always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
begin openpa_sp[23] = 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[24] = 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[25] = 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[26] = 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[27] = 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[28] = 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_blk) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: q_blk=%h", $time, q_blk);
always @(q_mux) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: q_mux=%h", $time, q_mux);
always @(ready) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: ready=%h", $time, ready);
`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 ISO_BLK: PD_BLK isolated before power-down %0d", openpa_seq[1]);
$display("OPENPA-COVER sequence D2/D7 ISO_BLK: isolation released only after PD_BLK was back and reset %0d", openpa_seq[2]);
$display("OPENPA-COVER sequence D1 ISO_MUX: PD_MUX isolated before power-down %0d", openpa_seq[3]);
$display("OPENPA-COVER sequence D2/D7 ISO_MUX: isolation released only after PD_MUX was back and reset %0d", openpa_seq[4]);
if (openpa_seq[1]) hq = hq + 1;
if (openpa_seq[2]) hq = hq + 1;
if (openpa_seq[3]) hq = hq + 1;
if (openpa_seq[4]) hq = hq + 1;
$display("OPENPA-COVER-SUMMARY states=%0d/0 declared_transitions=%0d/0 sequences=%0d/4", hs, ht, hq);
endfunction
// ---- settle process: 28 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_BLK_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_4_iso_blk === 1'b1)) openpa_check(1, "set_isolation ISO_BLK (tile.upf:41): PD_BLK went off while the isolation enable iso_blk was inactive");
else if (!UPF::openpa_dom_PD_BLK_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_4_iso_blk === 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_BLK_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation ISO_BLK (tile.upf:41): isolation released while PD_BLK is still off");
else if (openpa_PD_BLK_rp0) openpa_check(7, "set_isolation ISO_BLK (tile.upf:41): isolation released after PD_BLK powered up but before its reset u_blk.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_4_iso_blk === 1'b1) && !UPF::openpa_dom_PD_BLK_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation ISO_BLK (tile.upf:41): isolation supply SS_AON lost while clamping");
end
if (openpa_sp[4]) begin
openpa_sp[4] = 1'b0;
if (!UPF::openpa_dom_PD_MUX_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_5_iso_mux === 1'b1)) openpa_check(1, "set_isolation ISO_MUX (tile.upf:43): PD_MUX went off while the isolation enable iso_mux was inactive");
else if (!UPF::openpa_dom_PD_MUX_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_5_iso_mux === 1'b1)) begin openpa_seq[3] = openpa_seq[3] + 1; openpa_ig2_cyc = 1'b1; end
end
if (openpa_sp[5]) begin
openpa_sp[5] = 1'b0;
if (!UPF::openpa_dom_PD_MUX_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation ISO_MUX (tile.upf:43): isolation released while PD_MUX is still off");
else if (openpa_PD_MUX_rp0) openpa_check(7, "set_isolation ISO_MUX (tile.upf:43): isolation released after PD_MUX powered up but before its reset u_mux.rst_n was asserted");
else if (openpa_ig2_cyc) openpa_seq[4] = openpa_seq[4] + 1;
openpa_ig2_cyc = 1'b0;
end
if (openpa_sp[6]) begin
openpa_sp[6] = 1'b0;
if ((UPF::openpa_ctl_5_iso_mux === 1'b1) && !UPF::openpa_dom_PD_MUX_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation ISO_MUX (tile.upf:43): isolation supply SS_AON lost while clamping");
end
if (openpa_sp[7]) begin
openpa_sp[7] = 1'b0;
if (openpa_x1_t) openpa_check(9, "u_blk/q of PD_BLK (off) is read by tile output q_blk in PD_TOP (on) with no active isolation");
end
if (openpa_sp[8]) begin
openpa_sp[8] = 1'b0;
if (openpa_x2_t) openpa_check(9, "u_mux/q of PD_MUX (off) is read by tile output q_mux in PD_TOP (on) with no active isolation");
end
if (openpa_sp[9]) begin
openpa_sp[9] = 1'b0;
if (openpa_x3_t) openpa_check(9, "tile input clk of PD_TOP (off) is read by u_blk/clk in PD_BLK (on) with no active isolation");
end
if (openpa_sp[10]) begin
openpa_sp[10] = 1'b0;
if (openpa_x4_t) openpa_check(9, "tile input d of PD_TOP (off) is read by u_blk/d in PD_BLK (on) with no active isolation");
end
if (openpa_sp[11]) begin
openpa_sp[11] = 1'b0;
if (openpa_x5_t) openpa_check(9, "tile input en of PD_TOP (off) is read by u_blk/en in PD_BLK (on) with no active isolation");
end
if (openpa_sp[12]) begin
openpa_sp[12] = 1'b0;
if (openpa_x6_t) openpa_check(9, "tile input rst_n of PD_TOP (off) is read by u_blk/rst_n in PD_BLK (on) with no active isolation");
end
if (openpa_sp[13]) begin
openpa_sp[13] = 1'b0;
if (openpa_x7_t) openpa_check(9, "tile input clk of PD_TOP (off) is read by u_mux/clk in PD_MUX (on) with no active isolation");
end
if (openpa_sp[14]) begin
openpa_sp[14] = 1'b0;
if (openpa_x8_t) openpa_check(9, "logic in tile of PD_TOP (off) is read by u_mux/d in PD_MUX (on) with no active isolation");
end
if (openpa_sp[15]) begin
openpa_sp[15] = 1'b0;
if (openpa_x9_t) openpa_check(9, "tile input en of PD_TOP (off) is read by u_mux/en in PD_MUX (on) with no active isolation");
end
if (openpa_sp[16]) begin
openpa_sp[16] = 1'b0;
if (openpa_x10_t) openpa_check(9, "tile input rst_n of PD_TOP (off) is read by u_mux/rst_n in PD_MUX (on) with no active isolation");
end
if (openpa_sp[17]) begin
openpa_sp[17] = 1'b0;
if (openpa_l1_t) openpa_check(11, $sformatf("PD_BLK (%0d uV) drives PD_TOP (%0d uV) on 1 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_BLK.voltage, UPF::openpa_net_VDD_N.voltage));
end
if (openpa_sp[18]) begin
openpa_sp[18] = 1'b0;
if (openpa_l2_t) openpa_check(11, $sformatf("PD_MUX (%0d uV) drives PD_TOP (%0d uV) on 1 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_MUX.voltage, UPF::openpa_net_VDD_N.voltage));
end
if (openpa_sp[19]) begin
openpa_sp[19] = 1'b0;
if (openpa_l3_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_BLK (%0d uV) on 4 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_BLK.voltage));
end
if (openpa_sp[20]) begin
openpa_sp[20] = 1'b0;
if (openpa_l4_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_MUX (%0d uV) on 4 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_MUX.voltage));
end
if (openpa_sp[21]) begin
openpa_sp[21] = 1'b0;
if (UPF::openpa_sw_SW_BLK_st != -1) openpa_SW_BLK_def = 1'b1; else if (openpa_SW_BLK_def) openpa_check(10, "power switch SW_BLK is undetermined: a control is X, or no state (or more than one) holds (tile.upf:27)");
end
if (openpa_sp[22]) begin
openpa_sp[22] = 1'b0;
if (UPF::openpa_sw_SW_MUX_st != -1) openpa_SW_MUX_def = 1'b1; else if (openpa_SW_MUX_def) openpa_check(10, "power switch SW_MUX is undetermined: a control is X, or no state (or more than one) holds (tile.upf:35)");
end
if (openpa_sp[23]) begin
openpa_sp[23] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_BLK_ok || UPF::openpa_dom_PD_MUX_ok)) openpa_check(12, "pwr_en (switch SW_BLK) comes from PD_TOP, which is off while other domains are on");
end
if (openpa_sp[24]) begin
openpa_sp[24] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_BLK_ok || UPF::openpa_dom_PD_MUX_ok)) openpa_check(12, "rush (switch SW_BLK) comes from PD_TOP, which is off while other domains are on");
end
if (openpa_sp[25]) begin
openpa_sp[25] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_BLK_ok || UPF::openpa_dom_PD_MUX_ok)) openpa_check(12, "mux_en (switch SW_MUX) comes from PD_TOP, which is off while other domains are on");
end
if (openpa_sp[26]) begin
openpa_sp[26] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_BLK_ok || UPF::openpa_dom_PD_MUX_ok)) openpa_check(12, "sel_hi (switch SW_MUX) comes from PD_TOP, which is off while other domains are on");
end
if (openpa_sp[27]) begin
openpa_sp[27] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_BLK_ok || UPF::openpa_dom_PD_MUX_ok)) openpa_check(12, "iso_blk (isolation ISO_BLK) comes from PD_TOP, which is off while other domains are on");
end
if (openpa_sp[28]) begin
openpa_sp[28] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_BLK_ok || UPF::openpa_dom_PD_MUX_ok)) openpa_check(12, "iso_mux (isolation ISO_MUX) 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_BLK_def) $display("OPENPA-WARNING power switch SW_BLK never reached a defined state");
if (!openpa_SW_MUX_def) $display("OPENPA-WARNING power switch SW_MUX never reached a defined state");
end
// verilator lint_on MULTIDRIVEN
`line 21 "tile.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
Check Yourself
Common Mistakes
Wrong Write an off state that is also true while an on state is true.
Then the output is UNDETERMINED (IEEE 1801-2024 6.23), and OpenPA's D10 check fires.
Fix Make the off state the exact opposite of the on states, or leave it out.
Wrong Give an acknowledge port to a switch with no -supply_set.
The acknowledge logic needs a supply. IEEE 1801-2024 6.23 makes this an error, and OpenPA refuses the file.
Fix Add -supply_set with an always-on set, so the acknowledge stays valid while the switch is off.
Wrong Write -ack_delay {ack 5} and expect 5 ns.
IEEE 1801-2024 6.23 counts a bare number in the simulator's precision. With a timescale of 1ns/1ps, that is 5 ps.
Fix Write the unit: -ack_delay {ack 5ns}.
Remember
- create_power_switch: input and output supply ports, control ports, and states written with the switch's port names.
- Output rules: error, on-off overlap, an UNDETERMINED contribution or differing voltages give UNDETERMINED; else FULL_ON, then PARTIAL_ON, then OFF.
- An X control on a live input makes the output UNDETERMINED.
- Several inputs make a voltage multiplexer; on states at one voltage may overlap.
- An acknowledge needs -supply_set; -ack_delay is inertial; write its unit.