Power States with add_power_state
A sleeping core can still have voltage. Give its rail and its controller separate state names, then find a missing mode.
You Will Be Able To
- Read a regulator value, a supply set state and a domain state from one sample.
- Distinguish an illegal mode, overlapping modes and a gap using the D8 message.
- Extend an IP state inventory in a second UPF file and close its list of fundamental states.
- Lesson
- W4.11
- Time
- 32 min
- Runs on
- Your browser
- Check
- 5 questions
- work
WORK with no request selects RUN.
- busy
en rises within RUN.
- park
The request selects SLEEP on the same LIVE rail.
- retain
HOLD with a request selects RET.
- fault
Early release on LOW selects UNSAFE.
- down
CORE off selects DOWN.
- gap
The final voltage leaves SYSTEM unclassified.
Read the diagram as text
- RUN: LIVE, no request
- RUN.BUSY: RUN with en high
- SLEEP: LIVE, request high
- RET: LOW, request high
- UNSAFE: LOW, request low
- OFF: TILE is DOWN
- UNDEFINED: no user mode
- RUN → RUN.BUSY
- RUN.BUSY → SLEEP
- SLEEP → RET
- RET → UNSAFE
- UNSAFE → OFF
- OFF → UNDEFINED
Drawn from the recorded pmu_soc samples. Each arrow follows one change in the bench.
After a failed wake, the pmu_soc log shows CORE at 0.60 V twice.
retain core=0.60 on=1 request=1 enabled=1 tile=LOW system=RET sim=5
OPENPA-CHECK D8 @ 8000: power domain SYSTEM reached illegal state UNSAFE (system.upf:4)
fault core=0.60 on=1 request=0 enabled=1 tile=LOW system=UNSAFE sim=5The request distinguishes allowed standby in retain from early release in fault.
The bench drives CORE and sleep_req independently.
Name the Regulator Settings with add_supply_state
When u_core enters standby, which voltage should the board engineer apply to CORE?
Before: a connection
connect_supply_net CORE_N -ports {CORE}
CORE drives the power function of TILE.
After: values with names
add_supply_state CORE -state {WORK 0.9} -state {HOLD 0.6}
WORK and HOLD can now appear in supply comparisons.
The board calls 0.90 V WORK and 0.60 V HOLD. Use add_supply_state to share those settings by name (6.8).
At work, CORE reads 0.90 V. At retain, it reads 0.60 V and on stays high.
work core=0.90 on=1 request=0 enabled=0 tile=LIVE system=RUN sim=0
retain core=0.60 on=1 request=1 enabled=1 tile=LOW system=RET sim=5
down core=0.60 on=0 request=0 enabled=1 tile=DOWN system=OFF sim=5In down, 0.60 remains in the voltage field, but on has fallen. HOLD requires power.
| Supply value form | What you specify | Use on this board |
|---|---|---|
| A nominal voltage | A FULL_ON supply at that voltage | WORK identifies the operating point used in work and busy. |
| A net state and a voltage | Both fields of the supply value | Use this form when the state also needs spelling out. |
| off | The supply is OFF | Use the supply state to distinguish a cut rail from powered ground. |
Use HOLD to classify TILE next.
Match the Supply Set with -supply_expr
Before calling u_core ready, check its return path as well as CORE.
create_supply_set TILE -function {power CORE_N} -function {ground GND_N}
add_power_state TILE -supply -state {LIVE -supply_expr {power == WORK && ground == {FULL_ON 0.0}} -simstate NORMAL}
add_power_state TILE -supply -update -state {LOW -supply_expr {power == HOLD} -simstate CORRUPT}
add_power_state TILE -supply -update -state {DOWN -supply_expr {power == OFF} -simstate CORRUPT}LIVE needs power at WORK and ground fully on at zero volts. Inside the braces, power and ground belong to TILE (6.5.4).
The busy row keeps TILE at LIVE because neither supply function changed when en rose.
work core=0.90 on=1 request=0 enabled=0 tile=LIVE system=RUN sim=0
busy core=0.90 on=1 request=0 enabled=1 tile=LIVE system=RUN.BUSY sim=0
gap core=0.70 on=1 request=0 enabled=1 tile=<none> system=<none> sim=0LOW tests power against HOLD. DOWN tests whether power is OFF.
Try changing the final voltage from 0.7 to 0.899999. At two decimal places, the printed voltage looks like WORK.
near core=0.90 on=1 request=0 enabled=1 tile=<none> system=<none> sim=0The near row prints 0.90, yet TILE has no matching named state. The comparison uses the supply value before display rounding.
TILE stays LIVE at busy. Can sleep_req still change SYSTEM?
Read the Request with -logic_expr
At park, u_core still has power. To recognize the sleep request, look beyond the rail.
add_power_state SYSTEM -domain -state {RUN -logic_expr {TILE == LIVE && !sleep_req}}
add_power_state SYSTEM -domain -update -state {SLEEP -logic_expr {TILE == LIVE && sleep_req}}
add_power_state SYSTEM -domain -update -state {OFF -logic_expr {TILE == DOWN}}SYSTEM can read a named state of TILE and a logic signal. A domain state uses -logic_expr for that combination (6.5.2, 6.5.6).
Between busy and park, TILE stays LIVE while SYSTEM moves from RUN.BUSY to SLEEP.
- Cycle 0
At WORK, the request is low.
- Cycle 1
en rises within RUN.
- Cycle 2
The request selects SLEEP.
- Cycle 3
HOLD selects LOW.
- Cycle 4
Early release selects UNSAFE.
- Cycle 5
CORE switches off.
- Cycle 6
The voltage matches no named mode.
Recorded OpenPA and Icarus samples, one per column.
At down, SYSTEM reports OFF because TILE is DOWN. VIN still powers the controller.
SLEEP names the mode. What determines how u_core behaves?
Give a Supply State Its Simstate
During retain, CORE carries voltage below the level needed for ordinary logic operation.
Working voltage
add_power_state TILE -supply -state {LIVE -supply_expr {power == WORK && ground == {FULL_ON 0.0}} -simstate NORMAL}
The modeled logic can operate normally.
Standby voltage
add_power_state TILE -supply -update -state {LOW -supply_expr {power == HOLD} -simstate CORRUPT}
The supply is powered, but its logic uses CORRUPT.
Attach -simstate to a supply set state (4.8, 6.5.3). The primary supply of CORE_PD is TILE, so the choice reaches u_core.
The retain row has on=1 and sim=5, the OpenPA code for CORRUPT.
park core=0.90 on=1 request=1 enabled=1 tile=LIVE system=SLEEP sim=0
retain core=0.60 on=1 request=1 enabled=1 tile=LOW system=RET sim=5
gap core=0.70 on=1 request=0 enabled=1 tile=<none> system=<none> sim=0At gap, TILE has no matching user mode. Its powered functions still satisfy predefined ON, so sim reads 0 (4.7.4).
RET names the board mode. Saving a register across that mode still needs a retention strategy, as in W4.9.
system.upf:6: add_power_state SYSTEM state RUN: -simstate on a power state of a domain is an error (IEEE 1801-2024 6.5.6 g); a simstate belongs to a power state of a supply setThe refusal names RUN because a domain mode cannot carry a simstate (6.5.6).
| Choice in a supply state | Meaning for this exercise |
|---|---|
| NORMAL | Use normal operation at LIVE. |
| CORRUPT | Allow corruption when LOW or DOWN holds. |
| No -simstate | This definition supplies no simstate of its own. Other active states still matter. |
| Other simstates (4.8) | Some delay corruption until activity or a change. This lab selects NORMAL and CORRUPT. |
LOW and CORRUPT can be intentional. To report a design error, identify which use of LOW the board forbids.
Flag an Unsafe Mode with -illegal
In fault, the controller releases sleep_req before CORE returns to WORK. Label that combination so a failure tells you what happened.
add_power_state SYSTEM -domain -update -state {RET -logic_expr {TILE == LOW && sleep_req}}
add_power_state SYSTEM -domain -update -state {UNSAFE -logic_expr {TILE == LOW && !sleep_req} -illegal}RET requires a request. UNSAFE requires its absence. The -illegal option asks the checker to report the second condition whenever it holds (6.5.6).
At 8000 ps, D8 names UNSAFE because the request fell while TILE stayed LOW.
retain core=0.60 on=1 request=1 enabled=1 tile=LOW system=RET sim=5
OPENPA-CHECK D8 @ 8000: power domain SYSTEM reached illegal state UNSAFE (system.upf:4)
fault core=0.60 on=1 request=0 enabled=1 tile=LOW system=UNSAFE sim=5Remove -illegal and UNSAFE still matches. A state is legal by default.
fault core=0.60 on=1 request=0 enabled=1 tile=LOW system=UNSAFE sim=5
OPENPA-CHECK D8 @ 12000: power domain SYSTEM is in none of its defined power states (UNDEFINED), which were declared -complete (system.upf:5)
OPENPA-COVER state domain SYSTEM UNSAFE 1The legal run counts one UNSAFE visit. Its only D8 report comes later, at the voltage gap.
What happens when two definitions claim the fault?
Find an Overlap or a Gap
Suppose the board team widens UNSAFE to cover every LOW sample, including valid standby.
Disjoint conditions
add_power_state SYSTEM -domain -update -state {RET -logic_expr {TILE == LOW && sleep_req}}
add_power_state SYSTEM -domain -update -state {UNSAFE -logic_expr {TILE == LOW && !sleep_req} -illegal}
At HOLD, sleep_req chooses one mode.
Overlapping conditions
add_power_state SYSTEM -domain -update -state {RET -logic_expr {TILE == LOW && sleep_req}}
add_power_state SYSTEM -domain -update -state {UNSAFE -logic_expr {TILE == LOW} -illegal}
A requested standby now satisfies two fundamental states.
At 6000 ps, the overlap run reports ERROR because RET and the widened UNSAFE both hold.
OPENPA-CHECK D8 @ 6000: power domain SYSTEM: more than one power state holds (the ERROR state)
retain core=0.60 on=1 request=1 enabled=1 tile=LOW system=RET sim=5
OPENPA-CHECK D8 @ 8000: power domain SYSTEM reached illegal state UNSAFE (system.upf:4)
OPENPA-CHECK D8 @ 12000: power domain SYSTEM is in none of its defined power states (UNDEFINED), which were declared -complete (system.upf:5)Standard behavior gives SYSTEM the current state ERROR when competing fundamental states hold (4.7.3).
OpenPA 0.3.0 reports that overlap in D8, but its retain row prints system=RET. Read both lines together.
Restore UNSAFE and remove RET. Now neither condition matches requested standby.
OPENPA-CHECK D8 @ 6000: power domain SYSTEM is in none of its defined power states (UNDEFINED), which were declared -complete (system.upf:4)
retain core=0.60 on=1 request=1 enabled=1 tile=LOW system=<none> sim=5| At the sampled moment | What held | What to inspect first |
|---|---|---|
| Requested standby in the overlap run | Two competing root states | Find the extra inputs accepted by the wider predicate. |
| Requested standby without RET | No named domain state | Determine whether the board permits that combination. |
| Early release in the original run | One named, forbidden state | Trace the request and regulator order before editing the UPF. |
A parent and its own child may hold together. The integration file uses that relationship to describe one kind of running more precisely.
Refine the IP States with -update
The board team wants to identify a busy core within the IP team’s RUN mode.
IP file: parent mode
add_power_state SYSTEM -domain -state {RUN -logic_expr {TILE == LIVE && !sleep_req}}
The IP uses LIVE and the absence of a sleep request.
Integration file: a child
add_power_state SYSTEM -domain -update -state {RUN.BUSY -logic_expr {en}}
Within RUN, en distinguishes the busy case.
Load ip.upf first. Then use -update on the same object in the same scope. RUN.BUSY refines RUN (4.7.3, 6.5.1).
In busy, adding RUN.BUSY changes the current name from RUN to RUN.BUSY without changing CORE.
busy core=0.90 on=1 request=0 enabled=1 tile=LIVE system=RUN sim=0
park core=0.90 on=1 request=1 enabled=1 tile=LIVE system=SLEEP sim=0busy core=0.90 on=1 request=0 enabled=1 tile=LIVE system=RUN.BUSY sim=0
park core=0.90 on=1 request=1 enabled=1 tile=LIVE system=SLEEP sim=0At park, en stays high, but sleep_req rules out both parent and child.
| What the integrator knows | Change to the inventory | Effect |
|---|---|---|
| There is a more specific kind of RUN | Define RUN.BUSY under RUN | The earlier RUN condition still applies to the child. |
| The board permits standby at HOLD | Add RET as another fundamental state | The new state can match outside the parent RUN. |
| The first file accepted every FULL_ON voltage | Update the existing supply predicate with a compatible nominal value | A later definition may narrow an earlier FULL_ON condition (6.5.4). |
Narrow an IP voltage in the second file
IP accepts any working voltage
add_power_state TILE -supply -state {LIVE -supply_expr {power == FULL_ON && ground == {FULL_ON 0.0}} -simstate NORMAL}
Read the gap sample.
Board supplies the nominal voltage
add_power_state TILE -supply -update -state {LIVE -supply_expr {power == {FULL_ON 0.9}}}
Keep the original ground test.
OPENPA-CHECK D8 @ 6000: supply set TILE: more than one power state holds (the ERROR state)
retain core=0.60 on=1 request=1 enabled=1 tile=LIVE system=SLEEP sim=5
gap core=0.70 on=1 request=0 enabled=1 tile=LIVE system=RUN.BUSY sim=0gap core=0.70 on=1 request=0 enabled=1 tile=<none> system=<none> sim=0Before the update, LIVE even accepts HOLD. At retain, D8 reports that LIVE and LOW overlap.
After the update, only 0.90 V qualifies for LIVE. At gap, the 0.70 V rail loses its LIVE match.
system.upf:6: add_power_state SYSTEM: state RUN is already defined at line 23; use -updateThe refusal points to RUN in the first file. Use -update for each later command on SYSTEM, including new names (5.10).
OpenPA 0.3.0 accepts a new state name without that option. The next example closes SYSTEM after its last addition.
Close the Inventory with -complete
At the final 0.70 V sample, the board expects a diagnosis when no SYSTEM mode fits.
An open inventory
add_power_state SYSTEM -domain -update -state {UNSAFE -logic_expr {TILE == LOW && !sleep_req} -illegal}
Gaps may remain.
The board closes the list
add_power_state SYSTEM -domain -update -complete
Report gaps.
With -complete, the gap at 12000 ps raises D8 because SYSTEM has no defined mode.
OPENPA-CHECK D8 @ 12000: power domain SYSTEM is in none of its defined power states (UNDEFINED), which were declared -complete (system.upf:5)
gap core=0.70 on=1 request=0 enabled=1 tile=<none> system=<none> sim=0OPENPA-CHECK D8 @ 8000: power domain SYSTEM reached illegal state UNSAFE (system.upf:4)
gap core=0.70 on=1 request=0 enabled=1 tile=<none> system=<none> sim=0Completeness also constrains later edits. A new fundamental state after closure is an error. A refinement of an existing state is allowed (6.5.6).
system.upf:6: add_power_state SYSTEM: state SPARE is a new fundamental power state, but the states were declared complete at line 5 (IEEE 1801-2024 6.5.6 p)Remove RET locally. Run once, then restore it before closure.
sed '/-state {RET /d' content/openpa/modes/system.upf > /tmp/standby.upf
node tools/probes/lowpower/probe-W4-modes.mjs --intent /tmp/standby.upfRestoring RET clears the 6000 ps error. Early release and voltage drift still fail.
Read the command forms
| Form or option | How to read it in IEEE 1801-2024 |
|---|---|
| add_supply_state object -state {...} | 6.8 names supply values. The object may be a supply port, net or set function. |
| add_power_state object -state {...} | 6.5 names states of an object. -supply and -domain identify the two object kinds in this lab. |
| -group, -model, -instance | Other object kinds in 6.5. W4.12 draws a group. The current lab uses sets and domains. |
| -supply_expr and -logic_expr | Supply conditions read the functions of the set. Logic conditions read eligible signals or object states. |
| -power_expr | Specifies state-dependent consumption inside a power model (6.5.5). OpenPA 0.3.0 refuses this option. |
| -legal or -illegal | Choose the legality of the named state. The default is legal. |
| -simstate | Supply set simulation behavior (6.5.3). A domain power state cannot carry it. |
| -update and -complete | Extend an earlier definition or close the fundamental state inventory. These options apply to the object. |
In W4.11.1, name the camera modes and leave its real failures visible. In W4.11.2, refine an IP inventory from a second file.
Try It
Run the original stimulus. Compare park with busy before you read the D8 lines. Which signal changed their domain state?
Change the 0.7 V gap stimulus to 0.9 V. Predict TILE, SYSTEM and sim. Keep en high and the request low.
The bench reads state names from OpenPA’s generated monitors. The sim field uses OpenPA codes. The regulator drives come from the bench.
To edit the intent itself, use the local RET exercise above or open the graded UPF editor in W4.11.2.
OPENPA-INFO corruption=x seed=1 work core=0.90 on=1 request=0 enabled=0 tile=LIVE system=RUN sim=0 busy core=0.90 on=1 request=0 enabled=1 tile=LIVE system=RUN.BUSY sim=0 park core=0.90 on=1 request=1 enabled=1 tile=LIVE system=SLEEP sim=0 retain core=0.60 on=1 request=1 enabled=1 tile=LOW system=RET sim=5 OPENPA-CHECK D8 @ 8000: power domain SYSTEM reached illegal state UNSAFE (system.upf:4) fault core=0.60 on=1 request=0 enabled=1 tile=LOW system=UNSAFE sim=5 down core=0.60 on=0 request=0 enabled=1 tile=DOWN system=OFF sim=5 OPENPA-CHECK D8 @ 12000: power domain SYSTEM is in none of its defined power states (UNDEFINED), which were declared -complete (system.upf:5) gap core=0.70 on=1 request=0 enabled=1 tile=<none> system=<none> sim=0 OPENPA-SUMMARY D1=0 D2=0 D3=0 D4=0 D5=0 D6=0 D7=0 D8=2 D9=0 D10=0 D11=0 D12=0 D13=0 D14=0 OPENPA-COVER state supply_set TILE LIVE 1 OPENPA-COVER state supply_set TILE LOW 1 OPENPA-COVER state supply_set TILE DOWN 1 OPENPA-COVER state supply_set TILE <none> 1 OPENPA-COVER transition supply_set TILE LIVE -> LOW 1 OPENPA-COVER transition supply_set TILE LOW -> DOWN 1 OPENPA-COVER transition supply_set TILE DOWN -> <none> 1 OPENPA-COVER state domain SYSTEM RUN 1 OPENPA-COVER state domain SYSTEM SLEEP 1 OPENPA-COVER state domain SYSTEM OFF 1 OPENPA-COVER state domain SYSTEM RUN.BUSY 1 OPENPA-COVER state domain SYSTEM RET 1 OPENPA-COVER state domain SYSTEM UNSAFE (illegal) 1 OPENPA-COVER state domain SYSTEM <none> 1 OPENPA-COVER transition domain SYSTEM RUN -> RUN.BUSY 1 OPENPA-COVER transition domain SYSTEM SLEEP -> RET 1 OPENPA-COVER transition domain SYSTEM OFF -> <none> 1 OPENPA-COVER transition domain SYSTEM RUN.BUSY -> SLEEP 1 OPENPA-COVER transition domain SYSTEM RET -> UNSAFE 1 OPENPA-COVER transition domain SYSTEM UNSAFE -> OFF 1 OPENPA-COVER sequence D1 PAD: CORE_PD isolated before power-down 1 OPENPA-COVER sequence D2/D7 PAD: isolation released only after CORE_PD was back and reset 0 OPENPA-COVER-SUMMARY states=8/8 declared_transitions=0/0 sequences=1/2Read the power intent: system.upf
load_upf ip.upf
add_power_state SYSTEM -domain -update -state {RUN.BUSY -logic_expr {en}}
add_power_state SYSTEM -domain -update -state {RET -logic_expr {TILE == LOW && sleep_req}}
add_power_state SYSTEM -domain -update -state {UNSAFE -logic_expr {TILE == LOW && !sleep_req} -illegal}
add_power_state SYSTEM -domain -update -complete
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
upf_version 4.0
set_design_top pmu_soc
create_power_domain SYSTEM -include_scope
create_supply_port VIN
create_supply_net VIN_N
connect_supply_net VIN_N -ports {VIN}
create_supply_port CORE
create_supply_net CORE_N
connect_supply_net CORE_N -ports {CORE}
create_supply_port GND
create_supply_net GND_N
connect_supply_net GND_N -ports {GND}
create_supply_set BOARD -function {power VIN_N} -function {ground GND_N}
associate_supply_set BOARD -handle SYSTEM.primary
create_supply_set TILE -function {power CORE_N} -function {ground GND_N}
create_power_domain CORE_PD -elements {u_core} -supply {primary TILE}
set_level_shifter XING -domain CORE_PD -applies_to both -rule both -threshold 0
set_isolation PAD -domain CORE_PD -applies_to outputs -clamp_value 0 -isolation_signal en -isolation_supply BOARD
add_supply_state CORE -state {WORK 0.9} -state {HOLD 0.6}
add_power_state TILE -supply -state {LIVE -supply_expr {power == WORK && ground == {FULL_ON 0.0}} -simstate NORMAL}
add_power_state TILE -supply -update -state {LOW -supply_expr {power == HOLD} -simstate CORRUPT}
add_power_state TILE -supply -update -state {DOWN -supply_expr {power == OFF} -simstate CORRUPT}
add_power_state SYSTEM -domain -state {RUN -logic_expr {TILE == LIVE && !sleep_req}}
add_power_state SYSTEM -domain -update -state {SLEEP -logic_expr {TILE == LIVE && sleep_req}}
add_power_state SYSTEM -domain -update -state {OFF -logic_expr {TILE == DOWN}}
What UPF added: 52 objects
3 supply port, 3 supply net, 10 level shifter, 10 output corruption, 4 isolation cell, 2 supply set, 4 register corruption, 1 memory corruption, 15 dynamic check.
| Object | Where | Detail | Rule | UPF line |
|---|---|---|---|---|
| Supply port | VIN | ip.upf:4 | ||
| Supply port | CORE | ip.upf:7 | ||
| Supply port | GND | ip.upf:10 | ||
| Supply net | VIN_N | ip.upf:4 | ||
| Supply net | CORE_N | ip.upf:7 | ||
| Supply net | GND_N | ip.upf:10 | ||
| Level shifter | u_core/acc | XING · folded away: it can never act where anything can see it | both | ip.upf:17 |
| Level shifter | u_core/beats | XING · folded away: it can never act where anything can see it | both | ip.upf:17 |
| Level shifter | u_core/busy | XING · folded away: it can never act where anything can see it | both | ip.upf:17 |
| Level shifter | u_core/rf_rd | XING · folded away: it can never act where anything can see it | both | ip.upf:17 |
| Level shifter | u_core/clk | XING · folded away: it can never act where anything can see it | both | ip.upf:17 |
| Level shifter | u_core/d | XING · folded away: it can never act where anything can see it | both | ip.upf:17 |
| Level shifter | u_core/en | XING · folded away: it can never act where anything can see it | both | ip.upf:17 |
| Level shifter | u_core/rf_addr | XING · folded away: it can never act where anything can see it | both | ip.upf:17 |
| Level shifter | u_core/rf_we | XING · folded away: it can never act where anything can see it | both | ip.upf:17 |
| Level shifter | u_core/rst_n | XING · folded away: it can never act where anything can see it | both | ip.upf:17 |
| Output corruption | u_core/acc | C2 | ip.upf:16 | |
| Isolation cell | u_core/acc | PAD · clamp 0 | I1-I5 | ip.upf:18 |
| Output corruption | u_core/beats | C2 | ip.upf:16 | |
| Isolation cell | u_core/beats | PAD · clamp 0 | I1-I5 | ip.upf:18 |
| Output corruption | u_core/busy | C2 | ip.upf:16 | |
| Isolation cell | u_core/busy | PAD · clamp 0 | I1-I5 | ip.upf:18 |
| Output corruption | u_core/rf_rd | C2 | ip.upf:16 | |
| Isolation cell | u_core/rf_rd | PAD · clamp 0 | I1-I5 | ip.upf:18 |
| Output corruption | u_core/clk | C2 | ip.upf:3 | |
| Output corruption | u_core/d | C2 | ip.upf:3 | |
| Output corruption | u_core/en | C2 | ip.upf:3 | |
| Output corruption | u_core/rf_addr | C2 | ip.upf:3 | |
| Output corruption | u_core/rf_we | C2 | ip.upf:3 | |
| Output corruption | u_core/rst_n | C2 | ip.upf:3 | |
| Supply set | BOARD | ip.upf:13 | ||
| Supply set | TILE | ip.upf:15 | ||
| Register corruption | status | C1 | ip.upf:3 | |
| Register corruption | u_pmu.st | C1 | ip.upf:3 | |
| Register corruption | u_core.acc | C1 | ip.upf:16 | |
| Register corruption | u_core.beats | C1 | ip.upf:16 | |
| Memory corruption | u_core.rf | C1 | ip.upf:16 | |
| Dynamic check | D1/D2/D7/D6 PAD | D1, D2, D7, D6 | ip.upf:18 | |
| Dynamic check | D9 crossing 1 | D9 | ip.upf:16 | |
| Dynamic check | D9 crossing 2 | D9 | ip.upf:16 | |
| Dynamic check | D9 crossing 3 | D9 | ip.upf:16 | |
| Dynamic check | D9 crossing 4 | D9 | ip.upf:16 | |
| Dynamic check | D9 crossing 5 | D9 | ip.upf:16 | |
| Dynamic check | D9 crossing 6 | D9 | ip.upf:16 | |
| Dynamic check | D9 crossing 7 | D9 | ip.upf:3 | |
| Dynamic check | D9 crossing 8 | D9 | ip.upf:3 | |
| Dynamic check | D9 crossing 9 | D9 | ip.upf:3 | |
| Dynamic check | D9 crossing 10 | D9 | ip.upf:3 | |
| Dynamic check | D9 crossing 11 | D9 | ip.upf:3 | |
| Dynamic check | D9 crossing 12 | D9 | ip.upf:3 | |
| Dynamic check | D11 CORE_PD->SYSTEM | XING · D11 | ip.upf:17 | |
| Dynamic check | D11 SYSTEM->CORE_PD | XING · D11 | ip.upf:17 |
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 system.upf, ip.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_VIN; // supply port VIN (ip.upf:4)
supply_net_type openpa_port_CORE; // supply port CORE (ip.upf:7)
supply_net_type openpa_port_GND; // supply port GND (ip.upf:10)
supply_net_type openpa_net_VIN_N; // supply net VIN_N
supply_net_type openpa_net_CORE_N; // supply net CORE_N
supply_net_type openpa_net_GND_N; // supply net GND_N
bit openpa_ss_TILE_ok; int unsigned openpa_ss_TILE_ep; int openpa_ss_TILE_st = -1; bit openpa_ss_TILE_multi; int openpa_ss_TILE_sim = 5; bit [2:0] openpa_ss_TILE_a; // supply set TILE
bit openpa_ss_BOARD_ok; int unsigned openpa_ss_BOARD_ep; int openpa_ss_BOARD_st = -1; bit openpa_ss_BOARD_multi; int openpa_ss_BOARD_sim = 5; // supply set BOARD
bit openpa_dom_SYSTEM_ok; int unsigned openpa_dom_SYSTEM_ep; int openpa_dom_SYSTEM_sim = 5; // power domain SYSTEM: ok = powered (simstate not CORRUPT); sim = simstate code (ip.upf:3)
bit openpa_dom_CORE_PD_ok; int unsigned openpa_dom_CORE_PD_ep; int openpa_dom_CORE_PD_sim = 5; // power domain CORE_PD: ok = powered (simstate not CORRUPT); sim = simstate code (ip.upf:16)
// simstate codes, by IEEE 1801-2024 4.8 precedence: 0 NORMAL, 1 CORRUPT_STATE_ON_CHANGE, 2 CORRUPT_STATE_ON_ACTIVITY,
// 3 CORRUPT_ON_CHANGE, 4 CORRUPT_ON_ACTIVITY, 5 CORRUPT (and NOT_NORMAL, 9.5.8); README "Simstates"
int openpa_ds_SYSTEM_st = -1; bit openpa_ds_SYSTEM_multi; bit [5:0] openpa_ds_SYSTEM_a; // power state of domain SYSTEM
logic openpa_ctl_0_en; // copy of en (isolation PAD; power state SYSTEM RUN.BUSY)
logic openpa_ctl_1_sleep_req; // copy of sleep_req (power state SYSTEM RUN; power state SYSTEM SLEEP; power state SYSTEM RET; power state SYSTEM UNSAFE)
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 == "VIN") begin openpa_port_VIN.state = FULL_ON; openpa_port_VIN.voltage = openpa_uv(value); return 1; end
if (pad_name == "CORE") begin openpa_port_CORE.state = FULL_ON; openpa_port_CORE.voltage = openpa_uv(value); return 1; end
if (pad_name == "GND") begin openpa_port_GND.state = FULL_ON; openpa_port_GND.voltage = openpa_uv(value); return 1; end
if (pad_name == "VIN_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VIN_N already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "BOARD.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): BOARD.power already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SYSTEM.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): SYSTEM.primary.power already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): CORE_N already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "TILE.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): TILE.power already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_PD.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): CORE_PD.primary.power already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "GND_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): GND_N already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "BOARD.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): BOARD.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "TILE.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): TILE.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SYSTEM.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): SYSTEM.primary.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_PD.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): CORE_PD.primary.ground already has a driver (port GND); 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: VIN CORE GND)", 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 == "VIN") begin openpa_port_VIN.state = OFF; return 1; end
if (pad_name == "CORE") begin openpa_port_CORE.state = OFF; return 1; end
if (pad_name == "GND") begin openpa_port_GND.state = OFF; return 1; end
if (pad_name == "VIN_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VIN_N already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "BOARD.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): BOARD.power already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SYSTEM.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): SYSTEM.primary.power already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): CORE_N already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "TILE.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): TILE.power already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_PD.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): CORE_PD.primary.power already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "GND_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): GND_N already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "BOARD.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): BOARD.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "TILE.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): TILE.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SYSTEM.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): SYSTEM.primary.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_PD.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): CORE_PD.primary.ground already has a driver (port GND); 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: VIN CORE GND)", 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 == "VIN") begin openpa_port_VIN.state = PARTIAL_ON; openpa_port_VIN.voltage = openpa_uv(value); return 1; end
if (pad_name == "CORE") begin openpa_port_CORE.state = PARTIAL_ON; openpa_port_CORE.voltage = openpa_uv(value); return 1; end
if (pad_name == "GND") begin openpa_port_GND.state = PARTIAL_ON; openpa_port_GND.voltage = openpa_uv(value); return 1; end
if (pad_name == "VIN_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VIN_N already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "BOARD.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): BOARD.power already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SYSTEM.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): SYSTEM.primary.power already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): CORE_N already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "TILE.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): TILE.power already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_PD.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): CORE_PD.primary.power already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "GND_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): GND_N already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "BOARD.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): BOARD.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "TILE.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): TILE.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SYSTEM.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): SYSTEM.primary.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_PD.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): CORE_PD.primary.ground already has a driver (port GND); 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: VIN CORE GND)", 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 == "VIN") begin openpa_port_VIN.state = supply_state; return 1; end
if (pad_name == "CORE") begin openpa_port_CORE.state = supply_state; return 1; end
if (pad_name == "GND") begin openpa_port_GND.state = supply_state; return 1; end
if (pad_name == "VIN_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VIN_N already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "BOARD.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): BOARD.power already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SYSTEM.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): SYSTEM.primary.power already has a driver (port VIN); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): CORE_N already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "TILE.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): TILE.power already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_PD.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): CORE_PD.primary.power already has a driver (port CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "GND_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): GND_N already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "BOARD.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): BOARD.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "TILE.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): TILE.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "SYSTEM.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): SYSTEM.primary.ground already has a driver (port GND); drive its root supply instead", pad_name); return 0; end
if (pad_name == "CORE_PD.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): CORE_PD.primary.ground already has a driver (port GND); 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: VIN CORE GND)", 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 == "VIN" || name == "VIN_N" || name == "BOARD.power" || name == "SYSTEM.primary.power") return openpa_net_VIN_N;
if (name == "CORE" || name == "CORE_N" || name == "TILE.power" || name == "CORE_PD.primary.power") return openpa_net_CORE_N;
if (name == "GND" || name == "GND_N" || name == "BOARD.ground" || name == "TILE.ground" || name == "SYSTEM.primary.ground" || name == "CORE_PD.primary.ground") return openpa_net_GND_N;
$display("OPENPA-ERROR get_supply_value(\"%s\"): no supply net, port or supply set function of that name", name);
return 0;
endfunction
function automatic upfRealT get_supply_voltage(upfSupplyTypeT arg); return arg.voltage / 1.0e6; endfunction
// 11.2.4: 1 for FULL_ON; 0 otherwise.
function automatic upfBooleanT get_supply_on_state(upfSupplyTypeT arg); return arg.state == FULL_ON; endfunction
function automatic upfSupplyStateE get_supply_state(upfSupplyTypeT arg); return arg.state; endfunction
endpackage
// ---------------------------------------------------------------------------
// OpenPA cells (generated; do not edit)
// ---------------------------------------------------------------------------
// openpa_corrupt: rule C2. Passes d while the driving domain is NORMAL; otherwise drives X (4-state)
// or a seeded value (2-state). The value is computed ahead for the episode the next power-down starts
// (ep + 1 while ok), so at power-down the output goes straight from d to the new value: no delta glitch
// through the previous episode's value (Icarus would turn one into a clock edge).
module openpa_corrupt #(parameter int W = 1, parameter int unsigned ID = 0) (
input logic [W-1:0] d,
output logic [W-1:0] q,
input bit ok,
input int unsigned ep
);
localparam int L = (W + 63) / 64;
logic [L*64-1:0] cv;
always @(ep or ok or UPF::openpa_kick)
for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
assign q = ok ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule
// openpa_corrupt_sim: rule C2 for a domain that has intermediate simstates (IEEE 1801-2024 9.5). As
// openpa_corrupt, and also corrupt while lhit is set (CORRUPT_ON_ACTIVITY after input activity), or after d
// changed while coc is set (CORRUPT_ON_CHANGE); leaving CORRUPT_ON_CHANGE clears that.
module openpa_corrupt_sim #(parameter int W = 1, parameter int unsigned ID = 0) (
input logic [W-1:0] d,
output logic [W-1:0] q,
input bit ok,
input int unsigned ep,
input bit lhit,
input bit coc
);
localparam int L = (W + 63) / 64;
logic [L*64-1:0] cv;
bit chg;
always @(ep or ok or UPF::openpa_kick)
for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID, ok ? ep + 1 : ep, i);
// verilator lint_off MULTIDRIVEN
for (genvar i = 0; i < W; i++) begin : g_chg
always @(posedge d[i] or negedge d[i]) if (coc && ok) chg = 1'b1;
end
always @(negedge coc) chg = 1'b0;
// verilator lint_on MULTIDRIVEN
assign q = (ok && !lhit && !chg) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule
// openpa_iso: rules I1-I4 (IEEE 1801-2024 9.8). CLAMP 0, 1, 2 (latch: the value the input had while the enable
// was inactive) or 3 (Z: high impedance on 4-state; 0 on 2-state backends, which cannot represent Z).
// sup_ok is 1 while the isolation supply is NORMAL (always, for a strategy with no supply); otherwise the output,
// and a latched value, are corrupt. An enable at X or Z corrupts the output and the latched value.
module openpa_iso #(parameter int W = 1, parameter int CLAMP = 0, parameter bit SENSE = 1'b1, parameter int unsigned ID = 0) (
input logic [W-1:0] d,
output logic [W-1:0] q,
input logic en,
input bit sup_ok,
input int unsigned sup_ep
);
localparam int L = (W + 63) / 64;
logic [L*64-1:0] cv;
logic [W-1:0] held;
always @(sup_ep or sup_ok or UPF::openpa_kick)
for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h4000_0000, sup_ok ? sup_ep + 1 : sup_ep, i);
wire active = (en === SENSE);
wire inactive = (en === !SENSE);
wire [W-1:0] bad = UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0];
if (CLAMP == 2) begin : g_latch
always @(d or en or sup_ok or bad) if (!sup_ok || !(active || inactive)) held = bad; else if (inactive) held = d;
end
wire [W-1:0] clampv = (CLAMP == 3) ? (UPF::openpa_xmode ? {W{1'bz}} : {W{1'b0}}) : (CLAMP == 2) ? held : (CLAMP == 1) ? {W{1'b1}} : {W{1'b0}};
assign q = !sup_ok ? bad : active ? clampv : inactive ? d : bad;
endmodule
// openpa_ls: rule L1 (IEEE 1801-2024 9.9). Passes d while every supply set of the cell is NORMAL; otherwise corrupt.
module openpa_ls #(parameter int W = 1, parameter int unsigned ID = 0) (
input logic [W-1:0] d,
output logic [W-1:0] q,
input bit src_ok,
input bit dst_ok,
input int unsigned ep
);
localparam int L = (W + 63) / 64;
logic [L*64-1:0] cv;
always @(ep or src_ok or dst_ok or UPF::openpa_kick)
for (int i = 0; i < L; i++) cv[i*64 +: 64] = UPF::openpa_mix(ID + 32'h8000_0000, (src_ok && dst_ok) ? ep + 1 : ep, i);
assign q = (src_ok && dst_ok) ? d : (UPF::openpa_xmode ? {W{1'bx}} : cv[W-1:0]);
endmodule
`line 1 "pmu_soc.sv" 0
// pmu_soc: two power domains. The top and the controller are always on; u_core can be switched off.
// The RTL is power-unaware: no isolation cell, no supply, no retention register is written here.
module pmu_soc (
input logic clk,
input logic rst_n,
input logic sleep_req,
input logic wake_req,
input logic en,
input logic [7:0] d,
input logic [1:0] rf_addr,
input logic rf_we,
output logic [7:0] total,
output logic led,
output logic [7:0] rd,
output logic [3:0] beats,
output logic [7:0] status,
output logic [2:0] pmu_state
);
logic iso_en, save, restore, pwr_en, core_rst_n;
logic [7:0] acc, rf_rd;
logic busy;
logic [3:0] core_beats;
pmu u_pmu (
.clk (clk),
.rst_n (rst_n),
.sleep_req (sleep_req),
.wake_req (wake_req),
.iso_en (iso_en),
.save (save),
.restore (restore),
.pwr_en (pwr_en),
.core_rst_n (core_rst_n),
.state_o (pmu_state)
);
wire [7:0] openpa_u_core_acc_raw, openpa_u_core_acc_s1; wire [3:0] openpa_u_core_beats_raw, openpa_u_core_beats_s1; wire [0:0] openpa_u_core_busy_raw, openpa_u_core_busy_s1; wire [7:0] openpa_u_core_rf_rd_raw, openpa_u_core_rf_rd_s1; wire [0:0] openpa_u_core_clk_s1; wire [7:0] openpa_u_core_d_s1; wire [0:0] openpa_u_core_en_s1; wire [1:0] openpa_u_core_rf_addr_s1; wire [0:0] openpa_u_core_rf_we_s1; wire [0:0] openpa_u_core_rst_n_s1; core u_core (
.clk (openpa_u_core_clk_s1),
.rst_n (openpa_u_core_rst_n_s1),
.en (openpa_u_core_en_s1),
.d (openpa_u_core_d_s1),
.rf_addr (openpa_u_core_rf_addr_s1),
.rf_we (openpa_u_core_rf_we_s1),
.acc (openpa_u_core_acc_raw),
.rf_rd (openpa_u_core_rf_rd_raw),
.busy (openpa_u_core_busy_raw),
.beats (openpa_u_core_beats_raw)
); openpa_corrupt #(.W(8), .ID(268435456)) openpa_u_core_acc_cor (.d(openpa_u_core_acc_raw), .q(openpa_u_core_acc_s1), .ok(UPF::openpa_dom_CORE_PD_ok), .ep(UPF::openpa_dom_CORE_PD_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435458)) openpa_u_core_acc_iso (.d(openpa_u_core_acc_s1), .q(acc), .en(UPF::openpa_ctl_0_en), .sup_ok((UPF::openpa_ss_BOARD_sim == 0)), .sup_ep(UPF::openpa_ss_BOARD_ep)); openpa_corrupt #(.W(4), .ID(268435464)) openpa_u_core_beats_cor (.d(openpa_u_core_beats_raw), .q(openpa_u_core_beats_s1), .ok(UPF::openpa_dom_CORE_PD_ok), .ep(UPF::openpa_dom_CORE_PD_ep)); openpa_iso #(.W(4), .CLAMP(0), .SENSE(1'b1), .ID(268435466)) openpa_u_core_beats_iso (.d(openpa_u_core_beats_s1), .q(core_beats), .en(UPF::openpa_ctl_0_en), .sup_ok((UPF::openpa_ss_BOARD_sim == 0)), .sup_ep(UPF::openpa_ss_BOARD_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_CORE_PD_ok), .ep(UPF::openpa_dom_CORE_PD_ep)); openpa_iso #(.W(1), .CLAMP(0), .SENSE(1'b1), .ID(268435474)) openpa_u_core_busy_iso (.d(openpa_u_core_busy_s1), .q(busy), .en(UPF::openpa_ctl_0_en), .sup_ok((UPF::openpa_ss_BOARD_sim == 0)), .sup_ep(UPF::openpa_ss_BOARD_ep)); openpa_corrupt #(.W(8), .ID(268435480)) openpa_u_core_rf_rd_cor (.d(openpa_u_core_rf_rd_raw), .q(openpa_u_core_rf_rd_s1), .ok(UPF::openpa_dom_CORE_PD_ok), .ep(UPF::openpa_dom_CORE_PD_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435482)) openpa_u_core_rf_rd_iso (.d(openpa_u_core_rf_rd_s1), .q(rf_rd), .en(UPF::openpa_ctl_0_en), .sup_ok((UPF::openpa_ss_BOARD_sim == 0)), .sup_ep(UPF::openpa_ss_BOARD_ep)); openpa_corrupt #(.W(1), .ID(268435488)) openpa_u_core_clk_cor (.d(clk), .q(openpa_u_core_clk_s1), .ok(UPF::openpa_dom_SYSTEM_ok), .ep(UPF::openpa_dom_SYSTEM_ep)); openpa_corrupt #(.W(8), .ID(268435496)) openpa_u_core_d_cor (.d(d), .q(openpa_u_core_d_s1), .ok(UPF::openpa_dom_SYSTEM_ok), .ep(UPF::openpa_dom_SYSTEM_ep)); openpa_corrupt #(.W(1), .ID(268435504)) openpa_u_core_en_cor (.d(en), .q(openpa_u_core_en_s1), .ok(UPF::openpa_dom_SYSTEM_ok), .ep(UPF::openpa_dom_SYSTEM_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_SYSTEM_ok), .ep(UPF::openpa_dom_SYSTEM_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_SYSTEM_ok), .ep(UPF::openpa_dom_SYSTEM_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_SYSTEM_ok), .ep(UPF::openpa_dom_SYSTEM_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 system.upf, ip.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_en;
import UPF::openpa_ctl_1_sleep_req;
import UPF::openpa_dom_CORE_PD_ep;
import UPF::openpa_dom_CORE_PD_ok;
import UPF::openpa_dom_CORE_PD_sim;
import UPF::openpa_dom_SYSTEM_ep;
import UPF::openpa_dom_SYSTEM_ok;
import UPF::openpa_dom_SYSTEM_sim;
import UPF::openpa_ds_SYSTEM_a;
import UPF::openpa_ds_SYSTEM_multi;
import UPF::openpa_ds_SYSTEM_st;
import UPF::openpa_kick;
import UPF::openpa_net_CORE_N;
import UPF::openpa_net_GND_N;
import UPF::openpa_net_VIN_N;
import UPF::openpa_seed;
import UPF::openpa_ss_BOARD_ep;
import UPF::openpa_ss_BOARD_multi;
import UPF::openpa_ss_BOARD_ok;
import UPF::openpa_ss_BOARD_sim;
import UPF::openpa_ss_BOARD_st;
import UPF::openpa_ss_TILE_a;
import UPF::openpa_ss_TILE_ep;
import UPF::openpa_ss_TILE_multi;
import UPF::openpa_ss_TILE_ok;
import UPF::openpa_ss_TILE_sim;
import UPF::openpa_ss_TILE_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:23]; // 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 @(en or openpa_kick) openpa_ctl_0_en = en;
always @(sleep_req or openpa_kick) openpa_ctl_1_sleep_req = sleep_req;
// ---- supply network, switches, supply sets, simstates, power states (one block, evaluated in order)
bit openpa_tg_ss_TILE_st; int openpa_pv_ss_TILE_st = -2;
bit openpa_tg_ss_TILE_multi; int openpa_pv_ss_TILE_multi = -2;
bit openpa_tg_ds_SYSTEM_st; int openpa_pv_ds_SYSTEM_st = -2;
bit openpa_tg_ds_SYSTEM_multi; int openpa_pv_ds_SYSTEM_multi = -2;
always @(openpa_kick or UPF::openpa_port_VIN or UPF::openpa_port_CORE or UPF::openpa_port_GND or UPF::openpa_ctl_1_sleep_req or UPF::openpa_ctl_0_en) begin : openpa_network
openpa_net_VIN_N = UPF::openpa_port_VIN; // VIN_N <- port VIN
openpa_net_CORE_N = UPF::openpa_port_CORE; // CORE_N <- port CORE
openpa_net_GND_N = UPF::openpa_port_GND; // GND_N <- port GND
// supply set BOARD (also SYSTEM.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_BOARD
bit nx; int sm;
sm = (UPF::openpa_net_VIN_N.state == UPF::FULL_ON && UPF::openpa_net_GND_N.state == UPF::FULL_ON) ? 0 : 5; // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
openpa_ss_BOARD_sim = sm;
nx = sm < 5;
if (openpa_ss_BOARD_ok && !nx) openpa_ss_BOARD_ep = openpa_ss_BOARD_ep + 1;
openpa_ss_BOARD_ok = nx;
end
// supply set TILE (also CORE_PD.primary): IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_TILE
bit nx; int sm;
openpa_ss_TILE_a = '0; openpa_ss_TILE_st = -1;
begin int dm; dm = -1;
openpa_ss_TILE_a[0] = (((UPF::openpa_net_CORE_N.state == UPF::FULL_ON && UPF::openpa_net_CORE_N.voltage == 900000) && (UPF::openpa_net_GND_N.state == UPF::FULL_ON && UPF::openpa_net_GND_N.voltage == 0))); // LIVE
if (openpa_ss_TILE_a[0] && 0 > dm) begin dm = 0; openpa_ss_TILE_st = 0; end
openpa_ss_TILE_a[1] = ((UPF::openpa_net_CORE_N.state == UPF::FULL_ON && UPF::openpa_net_CORE_N.voltage == 600000)); // LOW
if (openpa_ss_TILE_a[1] && 0 > dm) begin dm = 0; openpa_ss_TILE_st = 1; end
openpa_ss_TILE_a[2] = ((UPF::openpa_net_CORE_N.state == UPF::OFF)); // DOWN
if (openpa_ss_TILE_a[2] && 0 > dm) begin dm = 0; openpa_ss_TILE_st = 2; end
end
openpa_ss_TILE_multi = (openpa_ss_TILE_a[0] + openpa_ss_TILE_a[1] + openpa_ss_TILE_a[2]) > 1;
sm = (UPF::openpa_net_CORE_N.state == UPF::FULL_ON && UPF::openpa_net_GND_N.state == UPF::FULL_ON) ? 0 : -1;
if (openpa_ss_TILE_a[0] && 0 > sm) sm = 0; // LIVE NORMAL
if (openpa_ss_TILE_a[1] && 5 > sm) sm = 5; // LOW CORRUPT
if (openpa_ss_TILE_a[2] && 5 > sm) sm = 5; // DOWN CORRUPT
if (sm < 0) sm = 5;
openpa_ss_TILE_sim = sm;
nx = sm < 5;
if (openpa_ss_TILE_ok && !nx) openpa_ss_TILE_ep = openpa_ss_TILE_ep + 1;
openpa_ss_TILE_ok = nx;
end
// domain SYSTEM: simstate of its primary supply set BOARD
if (openpa_dom_SYSTEM_ok && !UPF::openpa_ss_BOARD_ok) openpa_dom_SYSTEM_ep = openpa_dom_SYSTEM_ep + 1;
openpa_dom_SYSTEM_ok = UPF::openpa_ss_BOARD_ok;
openpa_dom_SYSTEM_sim = openpa_ss_BOARD_sim;
// domain CORE_PD: simstate of its primary supply set TILE
if (openpa_dom_CORE_PD_ok && !UPF::openpa_ss_TILE_ok) openpa_dom_CORE_PD_ep = openpa_dom_CORE_PD_ep + 1;
openpa_dom_CORE_PD_ok = UPF::openpa_ss_TILE_ok;
openpa_dom_CORE_PD_sim = openpa_ss_TILE_sim;
// power states of domain SYSTEM (rule P1)
begin : openpa_ds_SYSTEM
openpa_ds_SYSTEM_a = '0; openpa_ds_SYSTEM_st = -1;
begin int dm; dm = -1;
openpa_ds_SYSTEM_a[0] = (((UPF::openpa_ss_TILE_a[0]) && !((UPF::openpa_ctl_1_sleep_req === 1'b1)))); // RUN
if (openpa_ds_SYSTEM_a[0] && 0 > dm) begin dm = 0; openpa_ds_SYSTEM_st = 0; end
openpa_ds_SYSTEM_a[1] = (((UPF::openpa_ss_TILE_a[0]) && (UPF::openpa_ctl_1_sleep_req === 1'b1))); // SLEEP
if (openpa_ds_SYSTEM_a[1] && 0 > dm) begin dm = 0; openpa_ds_SYSTEM_st = 1; end
openpa_ds_SYSTEM_a[2] = ((UPF::openpa_ss_TILE_a[2])); // OFF
if (openpa_ds_SYSTEM_a[2] && 0 > dm) begin dm = 0; openpa_ds_SYSTEM_st = 2; end
openpa_ds_SYSTEM_a[3] = openpa_ds_SYSTEM_a[0] && ((UPF::openpa_ctl_0_en === 1'b1)); // RUN.BUSY (refines RUN)
if (openpa_ds_SYSTEM_a[3] && 1 > dm) begin dm = 1; openpa_ds_SYSTEM_st = 3; end
openpa_ds_SYSTEM_a[4] = (((UPF::openpa_ss_TILE_a[1]) && (UPF::openpa_ctl_1_sleep_req === 1'b1))); // RET
if (openpa_ds_SYSTEM_a[4] && 0 > dm) begin dm = 0; openpa_ds_SYSTEM_st = 4; end
openpa_ds_SYSTEM_a[5] = (((UPF::openpa_ss_TILE_a[1]) && !((UPF::openpa_ctl_1_sleep_req === 1'b1)))); // UNSAFE (illegal)
if (openpa_ds_SYSTEM_a[5] && 0 > dm) begin dm = 0; openpa_ds_SYSTEM_st = 5; end
end
openpa_ds_SYSTEM_multi = (openpa_ds_SYSTEM_a[0] + openpa_ds_SYSTEM_a[1] + openpa_ds_SYSTEM_a[2] + openpa_ds_SYSTEM_a[4] + openpa_ds_SYSTEM_a[5]) > 1;
end
if (openpa_ss_TILE_st != openpa_pv_ss_TILE_st) begin openpa_tg_ss_TILE_st = ~openpa_tg_ss_TILE_st; openpa_pv_ss_TILE_st = openpa_ss_TILE_st; end
if (openpa_ss_TILE_multi != openpa_pv_ss_TILE_multi) begin openpa_tg_ss_TILE_multi = ~openpa_tg_ss_TILE_multi; openpa_pv_ss_TILE_multi = openpa_ss_TILE_multi; end
if (openpa_ds_SYSTEM_st != openpa_pv_ds_SYSTEM_st) begin openpa_tg_ds_SYSTEM_st = ~openpa_tg_ds_SYSTEM_st; openpa_pv_ds_SYSTEM_st = openpa_ds_SYSTEM_st; end
if (openpa_ds_SYSTEM_multi != openpa_pv_ds_SYSTEM_multi) begin openpa_tg_ds_SYSTEM_multi = ~openpa_tg_ds_SYSTEM_multi; openpa_pv_ds_SYSTEM_multi = openpa_ds_SYSTEM_multi; end
end
// ---- corruption: registers forced, memories overwritten (rules C1, C3)
// domain SYSTEM (ip.upf:3): 2 register(s), 0 memory(ies)
bit openpa_SYSTEM_applied, openpa_SYSTEM_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_SYSTEM_ok or openpa_kick) if (!openpa_SYSTEM_valid || openpa_SYSTEM_applied != UPF::openpa_dom_SYSTEM_ok) begin
openpa_t({"SYSTEM ", UPF::openpa_dom_SYSTEM_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_SYSTEM_ok || !openpa_SYSTEM_valid) begin
if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_SYSTEM_ep, 0);
force status = openpa_cv1;
if (openpa_xmode) openpa_cv2 = 'x; else openpa_cv2 = UPF::openpa_mix(2, UPF::openpa_dom_SYSTEM_ep, 0);
force u_pmu.st = openpa_cv2;
end
if (UPF::openpa_dom_SYSTEM_ok) begin
release status;
release u_pmu.st;
end
openpa_SYSTEM_valid = 1'b1; openpa_SYSTEM_applied = UPF::openpa_dom_SYSTEM_ok;
end
// domain CORE_PD (ip.upf:16): 2 register(s), 1 memory(ies)
bit openpa_CORE_PD_applied, openpa_CORE_PD_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_CORE_PD_ok or openpa_kick) if (!openpa_CORE_PD_valid || openpa_CORE_PD_applied != UPF::openpa_dom_CORE_PD_ok) begin
openpa_t({"CORE_PD ", UPF::openpa_dom_CORE_PD_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_CORE_PD_ok || !openpa_CORE_PD_valid) begin
if (openpa_xmode) openpa_cv3 = 'x; else openpa_cv3 = UPF::openpa_mix(3, UPF::openpa_dom_CORE_PD_ep, 0);
force u_core.acc = openpa_cv3;
if (openpa_xmode) openpa_cv4 = 'x; else openpa_cv4 = UPF::openpa_mix(4, UPF::openpa_dom_CORE_PD_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_CORE_PD_ep, (i) * 1 + 0);
end
if (UPF::openpa_dom_CORE_PD_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_CORE_PD_ep, (i) * 1 + 0);
release u_core.acc;
release u_core.beats;
end
openpa_CORE_PD_valid = 1'b1; openpa_CORE_PD_applied = UPF::openpa_dom_CORE_PD_ok;
end
// D7 reset check for CORE_PD: resets u_core.rst_n active 0
bit openpa_CORE_PD_rprev, openpa_CORE_PD_rp0;
always @(posedge UPF::openpa_dom_CORE_PD_ok or negedge UPF::openpa_dom_CORE_PD_ok or posedge u_core.rst_n or negedge u_core.rst_n) begin
if (UPF::openpa_dom_CORE_PD_ok && !openpa_CORE_PD_rprev) openpa_CORE_PD_rp0 = 1'b1;
if (!UPF::openpa_dom_CORE_PD_ok || u_core.rst_n === 1'b0) openpa_CORE_PD_rp0 = 1'b0;
openpa_CORE_PD_rprev = UPF::openpa_dom_CORE_PD_ok;
end
// ---- checks for set_isolation PAD (ip.upf:18): CORE_PD -> SYSTEM on 4 port(s)
bit openpa_ig1_act, openpa_ig1_cyc;
always @(negedge UPF::openpa_dom_CORE_PD_ok) if (!UPF::openpa_dom_CORE_PD_ok)
begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge UPF::openpa_ctl_0_en or negedge UPF::openpa_ctl_0_en or posedge openpa_kick) begin
if (openpa_ig1_act && !(UPF::openpa_ctl_0_en === 1'b1))
begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
if (openpa_ig1_act != (UPF::openpa_ctl_0_en === 1'b1)) openpa_t({"PAD enable ", (UPF::openpa_ctl_0_en === 1'b1) ? "active" : "inactive"});
openpa_ig1_act = (UPF::openpa_ctl_0_en === 1'b1);
end
always @(negedge UPF::openpa_ss_BOARD_ok) if (!UPF::openpa_ss_BOARD_ok)
begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; end
// crossing 1: u_core/acc (CORE_PD) -> logic in pmu_soc (SYSTEM), isolated by PAD
bit openpa_x1_t;
always @(UPF::openpa_dom_CORE_PD_ok or UPF::openpa_dom_SYSTEM_ok or UPF::openpa_ctl_0_en or UPF::openpa_ss_BOARD_sim or UPF::openpa_net_CORE_N or UPF::openpa_net_GND_N) openpa_x1_t = !UPF::openpa_dom_CORE_PD_ok && UPF::openpa_dom_SYSTEM_ok && !(((UPF::openpa_ctl_0_en === 1'b1) && (UPF::openpa_ss_BOARD_sim == 0))) && !(UPF::openpa_net_CORE_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (CORE_PD) -> pmu_soc output total (SYSTEM), isolated by PAD
bit openpa_x2_t;
always @(UPF::openpa_dom_CORE_PD_ok or UPF::openpa_dom_SYSTEM_ok or UPF::openpa_ctl_0_en or UPF::openpa_ss_BOARD_sim or UPF::openpa_net_CORE_N or UPF::openpa_net_GND_N) openpa_x2_t = !UPF::openpa_dom_CORE_PD_ok && UPF::openpa_dom_SYSTEM_ok && !(((UPF::openpa_ctl_0_en === 1'b1) && (UPF::openpa_ss_BOARD_sim == 0))) && !(UPF::openpa_net_CORE_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (CORE_PD) -> pmu_soc output beats (SYSTEM), isolated by PAD
bit openpa_x3_t;
always @(UPF::openpa_dom_CORE_PD_ok or UPF::openpa_dom_SYSTEM_ok or UPF::openpa_ctl_0_en or UPF::openpa_ss_BOARD_sim or UPF::openpa_net_CORE_N or UPF::openpa_net_GND_N) openpa_x3_t = !UPF::openpa_dom_CORE_PD_ok && UPF::openpa_dom_SYSTEM_ok && !(((UPF::openpa_ctl_0_en === 1'b1) && (UPF::openpa_ss_BOARD_sim == 0))) && !(UPF::openpa_net_CORE_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (CORE_PD) -> logic in pmu_soc (SYSTEM), isolated by PAD
bit openpa_x4_t;
always @(UPF::openpa_dom_CORE_PD_ok or UPF::openpa_dom_SYSTEM_ok or UPF::openpa_ctl_0_en or UPF::openpa_ss_BOARD_sim or UPF::openpa_net_CORE_N or UPF::openpa_net_GND_N) openpa_x4_t = !UPF::openpa_dom_CORE_PD_ok && UPF::openpa_dom_SYSTEM_ok && !(((UPF::openpa_ctl_0_en === 1'b1) && (UPF::openpa_ss_BOARD_sim == 0))) && !(UPF::openpa_net_CORE_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (CORE_PD) -> pmu_soc output led (SYSTEM), isolated by PAD
bit openpa_x5_t;
always @(UPF::openpa_dom_CORE_PD_ok or UPF::openpa_dom_SYSTEM_ok or UPF::openpa_ctl_0_en or UPF::openpa_ss_BOARD_sim or UPF::openpa_net_CORE_N or UPF::openpa_net_GND_N) openpa_x5_t = !UPF::openpa_dom_CORE_PD_ok && UPF::openpa_dom_SYSTEM_ok && !(((UPF::openpa_ctl_0_en === 1'b1) && (UPF::openpa_ss_BOARD_sim == 0))) && !(UPF::openpa_net_CORE_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (CORE_PD) -> pmu_soc output rd (SYSTEM), isolated by PAD
bit openpa_x6_t;
always @(UPF::openpa_dom_CORE_PD_ok or UPF::openpa_dom_SYSTEM_ok or UPF::openpa_ctl_0_en or UPF::openpa_ss_BOARD_sim or UPF::openpa_net_CORE_N or UPF::openpa_net_GND_N) openpa_x6_t = !UPF::openpa_dom_CORE_PD_ok && UPF::openpa_dom_SYSTEM_ok && !(((UPF::openpa_ctl_0_en === 1'b1) && (UPF::openpa_ss_BOARD_sim == 0))) && !(UPF::openpa_net_CORE_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (SYSTEM) -> u_core/clk (CORE_PD), not isolated
bit openpa_x7_t;
always @(UPF::openpa_dom_SYSTEM_ok or UPF::openpa_dom_CORE_PD_ok or UPF::openpa_net_VIN_N or UPF::openpa_net_GND_N) openpa_x7_t = !UPF::openpa_dom_SYSTEM_ok && UPF::openpa_dom_CORE_PD_ok && !(1'b0) && !(UPF::openpa_net_VIN_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (SYSTEM) -> u_core/d (CORE_PD), not isolated
bit openpa_x8_t;
always @(UPF::openpa_dom_SYSTEM_ok or UPF::openpa_dom_CORE_PD_ok or UPF::openpa_net_VIN_N or UPF::openpa_net_GND_N) openpa_x8_t = !UPF::openpa_dom_SYSTEM_ok && UPF::openpa_dom_CORE_PD_ok && !(1'b0) && !(UPF::openpa_net_VIN_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (SYSTEM) -> u_core/en (CORE_PD), not isolated
bit openpa_x9_t;
always @(UPF::openpa_dom_SYSTEM_ok or UPF::openpa_dom_CORE_PD_ok or UPF::openpa_net_VIN_N or UPF::openpa_net_GND_N) openpa_x9_t = !UPF::openpa_dom_SYSTEM_ok && UPF::openpa_dom_CORE_PD_ok && !(1'b0) && !(UPF::openpa_net_VIN_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (SYSTEM) -> u_core/rf_addr (CORE_PD), not isolated
bit openpa_x10_t;
always @(UPF::openpa_dom_SYSTEM_ok or UPF::openpa_dom_CORE_PD_ok or UPF::openpa_net_VIN_N or UPF::openpa_net_GND_N) openpa_x10_t = !UPF::openpa_dom_SYSTEM_ok && UPF::openpa_dom_CORE_PD_ok && !(1'b0) && !(UPF::openpa_net_VIN_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (SYSTEM) -> u_core/rf_we (CORE_PD), not isolated
bit openpa_x11_t;
always @(UPF::openpa_dom_SYSTEM_ok or UPF::openpa_dom_CORE_PD_ok or UPF::openpa_net_VIN_N or UPF::openpa_net_GND_N) openpa_x11_t = !UPF::openpa_dom_SYSTEM_ok && UPF::openpa_dom_CORE_PD_ok && !(1'b0) && !(UPF::openpa_net_VIN_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_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 (SYSTEM) -> u_core/rst_n (CORE_PD), not isolated
bit openpa_x12_t;
always @(UPF::openpa_dom_SYSTEM_ok or UPF::openpa_dom_CORE_PD_ok or UPF::openpa_net_VIN_N or UPF::openpa_net_GND_N) openpa_x12_t = !UPF::openpa_dom_SYSTEM_ok && UPF::openpa_dom_CORE_PD_ok && !(1'b0) && !(UPF::openpa_net_VIN_N.state == UPF::UNDETERMINED || UPF::openpa_net_GND_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x12_t)
begin openpa_sp[15] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 1: CORE_PD -> SYSTEM (set_level_shifter XING, rule both, threshold 0 uV)
bit openpa_l1_t;
always @(UPF::openpa_dom_CORE_PD_ok or UPF::openpa_dom_SYSTEM_ok or UPF::openpa_net_CORE_N or UPF::openpa_net_VIN_N) openpa_l1_t = UPF::openpa_dom_CORE_PD_ok && UPF::openpa_dom_SYSTEM_ok && (UPF::openpa_net_CORE_N.voltage - UPF::openpa_net_VIN_N.voltage > 0 || UPF::openpa_net_VIN_N.voltage - UPF::openpa_net_CORE_N.voltage > 0) && !1'b1;
always @(posedge openpa_l1_t)
begin openpa_sp[16] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 2: SYSTEM -> CORE_PD (set_level_shifter XING, rule both, threshold 0 uV)
bit openpa_l2_t;
always @(UPF::openpa_dom_SYSTEM_ok or UPF::openpa_dom_CORE_PD_ok or UPF::openpa_net_VIN_N or UPF::openpa_net_CORE_N) openpa_l2_t = UPF::openpa_dom_SYSTEM_ok && UPF::openpa_dom_CORE_PD_ok && (UPF::openpa_net_VIN_N.voltage - UPF::openpa_net_CORE_N.voltage > 0 || UPF::openpa_net_CORE_N.voltage - UPF::openpa_net_VIN_N.voltage > 0) && !1'b1;
always @(posedge openpa_l2_t)
begin openpa_sp[17] = 1'b1; openpa_sreq = 1'b1; end
// ---- power states (D8): checked once the bench has driven a supply, after the time step settles
always @(posedge openpa_tg_ss_TILE_st or negedge openpa_tg_ss_TILE_st or posedge openpa_tg_ss_TILE_multi or negedge openpa_tg_ss_TILE_multi or posedge UPF::openpa_armed) if (UPF::openpa_armed)
begin openpa_sp[18] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge openpa_tg_ds_SYSTEM_st or negedge openpa_tg_ds_SYSTEM_st or posedge openpa_tg_ds_SYSTEM_multi or negedge openpa_tg_ds_SYSTEM_multi or posedge UPF::openpa_armed) if (UPF::openpa_armed)
begin openpa_sp[19] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge openpa_tg_ds_SYSTEM_st or negedge openpa_tg_ds_SYSTEM_st) if (openpa_tr) openpa_t($sformatf("SYSTEM state %0s", (UPF::openpa_ds_SYSTEM_st == 0) ? "RUN" : (UPF::openpa_ds_SYSTEM_st == 1) ? "SLEEP" : (UPF::openpa_ds_SYSTEM_st == 2) ? "OFF" : (UPF::openpa_ds_SYSTEM_st == 3) ? "RUN.BUSY" : (UPF::openpa_ds_SYSTEM_st == 4) ? "RET" : (UPF::openpa_ds_SYSTEM_st == 5) ? "UNSAFE" : "<none>"));
always @(posedge openpa_tg_ss_TILE_st or negedge openpa_tg_ss_TILE_st) if (openpa_tr) openpa_t($sformatf("TILE state %0s", (UPF::openpa_ss_TILE_st == 0) ? "LIVE" : (UPF::openpa_ss_TILE_st == 1) ? "LOW" : (UPF::openpa_ss_TILE_st == 2) ? "DOWN" : "<none>"));
int openpa_cs1 [0:3]; int openpa_ct1 [0:3][0:3]; int openpa_cp1 = -1, openpa_cc1; // coverage of supply set TILE
function automatic string openpa_cn1(int i); case (i) 0: return "LIVE"; 1: return "LOW"; 2: return "DOWN"; default: return "<none>"; endcase endfunction
always @(posedge openpa_tg_ss_TILE_st or negedge openpa_tg_ss_TILE_st or posedge UPF::openpa_armed) if (UPF::openpa_armed)
begin openpa_sp[20] = 1'b1; openpa_sreq = 1'b1; end
int openpa_cs2 [0:6]; int openpa_ct2 [0:6][0:6]; int openpa_cp2 = -1, openpa_cc2; // coverage of domain SYSTEM
function automatic string openpa_cn2(int i); case (i) 0: return "RUN"; 1: return "SLEEP"; 2: return "OFF"; 3: return "RUN.BUSY"; 4: return "RET"; 5: return "UNSAFE"; default: return "<none>"; endcase endfunction
always @(posedge openpa_tg_ds_SYSTEM_st or negedge openpa_tg_ds_SYSTEM_st or posedge UPF::openpa_armed) if (UPF::openpa_armed)
begin openpa_sp[21] = 1'b1; openpa_sreq = 1'b1; end
always @(negedge UPF::openpa_dom_SYSTEM_ok) if (!UPF::openpa_dom_SYSTEM_ok)
begin openpa_sp[22] = 1'b1; openpa_sreq = 1'b1; end
always @(negedge UPF::openpa_dom_SYSTEM_ok) if (!UPF::openpa_dom_SYSTEM_ok)
begin openpa_sp[23] = 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_SYSTEM_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: total=%h", $time, total);
always @(led) if (openpa_obs && UPF::openpa_dom_SYSTEM_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: led=%h", $time, led);
always @(rd) if (openpa_obs && UPF::openpa_dom_SYSTEM_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: rd=%h", $time, rd);
always @(beats) if (openpa_obs && UPF::openpa_dom_SYSTEM_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: beats=%h", $time, beats);
always @(status) if (openpa_obs && UPF::openpa_dom_SYSTEM_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: status=%h", $time, status);
always @(pmu_state) if (openpa_obs && UPF::openpa_dom_SYSTEM_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: pmu_state=%h", $time, pmu_state);
`else
initial if ($test$plusargs("openpa_obs")) $display("OPENPA-ERROR +openpa_obs needs the copy compiled with OPENPA_OBS defined (-DOPENPA_OBS or +define+OPENPA_OBS)");
`endif
// Icarus 12 runs no named block inside a final block, so the report is a function.
function automatic void openpa_cover_report();
int hs, ht, hq;
hs = 0; ht = 0; hq = 0;
$display("OPENPA-COVER state supply_set TILE LIVE %0d", openpa_cs1[0]);
$display("OPENPA-COVER state supply_set TILE LOW %0d", openpa_cs1[1]);
$display("OPENPA-COVER state supply_set TILE DOWN %0d", openpa_cs1[2]);
if (openpa_cs1[3]) $display("OPENPA-COVER state supply_set TILE <none> %0d", openpa_cs1[3]);
for (int i = 0; i <= 3; i++) for (int j = 0; j <= 3; j++) if (openpa_ct1[i][j]) $display("OPENPA-COVER transition supply_set TILE %0s -> %0s %0d", openpa_cn1(i), openpa_cn1(j), openpa_ct1[i][j]);
$display("OPENPA-COVER state domain SYSTEM RUN %0d", openpa_cs2[0]);
$display("OPENPA-COVER state domain SYSTEM SLEEP %0d", openpa_cs2[1]);
$display("OPENPA-COVER state domain SYSTEM OFF %0d", openpa_cs2[2]);
$display("OPENPA-COVER state domain SYSTEM RUN.BUSY %0d", openpa_cs2[3]);
$display("OPENPA-COVER state domain SYSTEM RET %0d", openpa_cs2[4]);
$display("OPENPA-COVER state domain SYSTEM UNSAFE (illegal) %0d", openpa_cs2[5]);
if (openpa_cs2[6]) $display("OPENPA-COVER state domain SYSTEM <none> %0d", openpa_cs2[6]);
for (int i = 0; i <= 6; i++) for (int j = 0; j <= 6; j++) if (openpa_ct2[i][j]) $display("OPENPA-COVER transition domain SYSTEM %0s -> %0s %0d", openpa_cn2(i), openpa_cn2(j), openpa_ct2[i][j]);
$display("OPENPA-COVER sequence D1 PAD: CORE_PD isolated before power-down %0d", openpa_seq[1]);
$display("OPENPA-COVER sequence D2/D7 PAD: isolation released only after CORE_PD was back and reset %0d", openpa_seq[2]);
if (openpa_cs1[0]) hs = hs + 1;
if (openpa_cs1[1]) hs = hs + 1;
if (openpa_cs1[2]) hs = hs + 1;
if (openpa_cs2[0]) hs = hs + 1;
if (openpa_cs2[1]) hs = hs + 1;
if (openpa_cs2[2]) hs = hs + 1;
if (openpa_cs2[3]) hs = hs + 1;
if (openpa_cs2[4]) hs = hs + 1;
if (openpa_seq[1]) hq = hq + 1;
if (openpa_seq[2]) hq = hq + 1;
$display("OPENPA-COVER-SUMMARY states=%0d/8 declared_transitions=%0d/0 sequences=%0d/2", hs, ht, hq);
endfunction
// ---- settle process: 23 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_CORE_PD_ok && (UPF::openpa_dom_SYSTEM_ok) && !(UPF::openpa_ctl_0_en === 1'b1)) openpa_check(1, "set_isolation PAD (ip.upf:18): CORE_PD went off while the isolation enable en was inactive");
else if (!UPF::openpa_dom_CORE_PD_ok && (UPF::openpa_dom_SYSTEM_ok) && (UPF::openpa_ctl_0_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_CORE_PD_ok && (UPF::openpa_dom_SYSTEM_ok)) openpa_check(2, "set_isolation PAD (ip.upf:18): isolation released while CORE_PD is still off");
else if (openpa_CORE_PD_rp0) openpa_check(7, "set_isolation PAD (ip.upf:18): isolation released after CORE_PD 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_0_en === 1'b1) && !UPF::openpa_dom_CORE_PD_ok && (UPF::openpa_dom_SYSTEM_ok)) openpa_check(6, "set_isolation PAD (ip.upf:18): isolation supply BOARD 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 CORE_PD (off) is read by logic in pmu_soc in SYSTEM (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 CORE_PD (off) is read by pmu_soc output total in SYSTEM (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 CORE_PD (off) is read by pmu_soc output beats in SYSTEM (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 CORE_PD (off) is read by logic in pmu_soc in SYSTEM (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 CORE_PD (off) is read by pmu_soc output led in SYSTEM (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 CORE_PD (off) is read by pmu_soc output rd in SYSTEM (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 SYSTEM (off) is read by u_core/clk in CORE_PD (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 SYSTEM (off) is read by u_core/d in CORE_PD (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 SYSTEM (off) is read by u_core/en in CORE_PD (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 SYSTEM (off) is read by u_core/rf_addr in CORE_PD (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 SYSTEM (off) is read by u_core/rf_we in CORE_PD (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 SYSTEM (off) is read by u_core/rst_n in CORE_PD (on) with no active isolation");
end
if (openpa_sp[16]) begin
openpa_sp[16] = 1'b0;
if (openpa_l1_t) openpa_check(11, $sformatf("CORE_PD (%0d uV) drives SYSTEM (%0d uV) on 6 port(s) with no level shifter for this direction", UPF::openpa_net_CORE_N.voltage, UPF::openpa_net_VIN_N.voltage));
end
if (openpa_sp[17]) begin
openpa_sp[17] = 1'b0;
if (openpa_l2_t) openpa_check(11, $sformatf("SYSTEM (%0d uV) drives CORE_PD (%0d uV) on 6 port(s) with no level shifter for this direction", UPF::openpa_net_VIN_N.voltage, UPF::openpa_net_CORE_N.voltage));
end
if (openpa_sp[18]) begin
openpa_sp[18] = 1'b0;
if (!1'b0) // suspended while a power switch is undetermined (D10 reports that)
begin
if (UPF::openpa_ss_TILE_multi) openpa_check(8, "supply set TILE: more than one power state holds (the ERROR state)");
end
end
if (openpa_sp[19]) begin
openpa_sp[19] = 1'b0;
if (!1'b0) // suspended while a power switch is undetermined (D10 reports that)
begin
if (UPF::openpa_ds_SYSTEM_st == -1) openpa_check(8, "power domain SYSTEM is in none of its defined power states (UNDEFINED), which were declared -complete (system.upf:5)");
if (UPF::openpa_ds_SYSTEM_st == 5) openpa_check(8, "power domain SYSTEM reached illegal state UNSAFE (system.upf:4)");
if (UPF::openpa_ds_SYSTEM_multi) openpa_check(8, "power domain SYSTEM: more than one power state holds (the ERROR state)");
end
end
if (openpa_sp[20]) begin
openpa_sp[20] = 1'b0;
if (!1'b0) begin
openpa_cc1 = (UPF::openpa_ss_TILE_st < 0) ? 3 : UPF::openpa_ss_TILE_st;
if (openpa_cc1 != openpa_cp1) begin
openpa_cs1[openpa_cc1] = openpa_cs1[openpa_cc1] + 1;
if (openpa_cp1 >= 0) openpa_ct1[openpa_cp1][openpa_cc1] = openpa_ct1[openpa_cp1][openpa_cc1] + 1;
openpa_cp1 = openpa_cc1;
end
end
end
if (openpa_sp[21]) begin
openpa_sp[21] = 1'b0;
if (!1'b0) begin
openpa_cc2 = (UPF::openpa_ds_SYSTEM_st < 0) ? 6 : UPF::openpa_ds_SYSTEM_st;
if (openpa_cc2 != openpa_cp2) begin
openpa_cs2[openpa_cc2] = openpa_cs2[openpa_cc2] + 1;
if (openpa_cp2 >= 0) openpa_ct2[openpa_cp2][openpa_cc2] = openpa_ct2[openpa_cp2][openpa_cc2] + 1;
openpa_cp2 = openpa_cc2;
end
end
end
if (openpa_sp[22]) begin
openpa_sp[22] = 1'b0;
if (!UPF::openpa_dom_SYSTEM_ok && (UPF::openpa_dom_CORE_PD_ok)) openpa_check(12, "en (isolation PAD; power state SYSTEM RUN.BUSY) comes from SYSTEM, which is off while other domains are on");
end
if (openpa_sp[23]) begin
openpa_sp[23] = 1'b0;
if (!UPF::openpa_dom_SYSTEM_ok && (UPF::openpa_dom_CORE_PD_ok)) openpa_check(12, "sleep_req (power state SYSTEM RUN; power state SYSTEM SLEEP; power state SYSTEM RET; power state SYSTEM UNSAFE) comes from SYSTEM, 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");
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
Common Mistakes
Wrong Use the voltage field alone to decide that CORE is powered.
In the down row, CORE keeps its last voltage field even though its on bit falls.
Fix Match the supply state as well as the nominal voltage.
Wrong Mark LOW illegal because one use of it is unsafe.
LOW also powers the requested standby mode. That use is allowed.
Fix Classify the rail and request together on SYSTEM.
Wrong Call every second match an overlap.
RUN.BUSY needs RUN to hold. A child and its parent can be active together.
Fix Look for competing states at the same level before diagnosing ERROR.
Wrong Close the IP inventory before the board adds RET.
RET is a new fundamental state. A completed inventory cannot gain another root.
Fix Add RET before the final completeness declaration.
Remember
- Read CORE and ground together to decide whether TILE is LIVE.
- Simstate governs supply behavior. Legality classifies a mode.
- Read the D8 text to distinguish an overlap, a gap and a forbidden match.
- An update can refine a parent after the root inventory closes.