Power Domains: create_power_domain and Its Extent
A power domain is a set of instances that share a primary supply. Draw the set with -elements, put the top in it, then grow, merge or carve it.
You Will Be Able To
- Predict the extent of each domain from its -elements list and the rule that children follow their parent.
- Put the design top in a domain with -elements {.}, and say what UPF 1.0 wrote instead.
- Find the upper and lower boundary of a domain, and the crossings that need a strategy.
- Grow a domain with -update, merge domains that share a supply, and say what -exclude_elements and composites do.
- Lesson
- W4.3
- Time
- 30 min
- Runs on
- Your browser
- Check
- 5 questions
Three lines decide who loses power. Each create_power_domain line moves instances out of the domain above:
After line 1: one domain
PD_TOP (media.upf:3): media, u_core, u_core/u_alu, u_core/u_wdt, u_dsp, u_dsp/u_mac
Every instance follows the top.
After line 3: three domains
PD_TOP (media.upf:3): media
PD_CORE (media.upf:4): u_core, u_core/u_alu, u_core/u_wdt
PD_DSP (media.upf:5): u_dsp, u_dsp/u_mac
u_core and u_dsp take their children with them.
OpenPA domain maps of media after the first and the third line of the lab file (recorded).
In the lab, switching PD_CORE off turns both of its registers to X: core off alu=xx wdt=xx mac=22 | q_core=0 q_dsp=22 total=21.
A Domain Is a Set of Instances
create_power_domain names a domain and the instances in its extent (IEEE 1801-2024 6.21). Each instance in -elements brings its children, unless a child is already in another domain.
- Design
- Datapath
- Storage
- Structure
- PD_TOP -elements {.}
Line 1 alone: the top and all five instances below it.
- PD_CORE -elements {u_core}
Line 2 claims u_core. u_alu and u_wdt follow it.
- PD_DSP -elements {u_dsp}
Line 3 claims u_dsp, and u_mac follows.
- What PD_TOP keeps
Only media itself, with its total register.
Read the diagram as text
- media: design top
- u_core: module core
- u_dsp: module dsp
- u_alu: accumulator
- u_wdt: tick counter
- u_mac: accumulator
- media → u_core
- media → u_dsp
- u_core → u_alu
- u_core → u_wdt
- u_dsp → u_mac
Drawn from recorded maps. Children follow their parent into its domain (6.21). The order of the lines does not change the result.
| Lines run so far | Domain map (OpenPA, recorded) |
|---|---|
| line 1 | PD_TOP: media, u_core, u_core/u_alu, u_core/u_wdt, u_dsp, u_dsp/u_mac |
| lines 1 and 2 | PD_TOP: media, u_dsp, u_dsp/u_mac; PD_CORE: u_core, u_core/u_alu, u_core/u_wdt |
| lines 1 to 3 | PD_TOP: media; PD_CORE: u_core, u_core/u_alu, u_core/u_wdt; PD_DSP: u_dsp, u_dsp/u_mac |
What each line creates. These runs have no supply lines yet, so each domain uses its implicit primary supply.
create_power_domain PD_TOP -elements {.}
create_power_domain PD_CORE -elements {u_core}
create_power_domain PD_DSP -elements {u_dsp}Power domains
PD_TOP (media.upf:5): media
primary supply PD_TOP.primary: power VDD_N, ground VSS_N
1 register(s): total; 0 memory(ies)
PD_CORE (media.upf:6): u_core, u_core/u_alu, u_core/u_wdt
primary supply PD_CORE.primary: power VDD_CORE, ground VSS_N [switchable]
2 register(s): u_core.u_alu.q, u_core.u_wdt.q; 0 memory(ies)
PD_DSP (media.upf:7): u_dsp, u_dsp/u_mac
primary supply PD_DSP.primary: power VDD_DSP, ground VSS_N [switchable]
1 register(s): u_dsp.u_mac.q; 0 memory(ies)The Design Top: -elements {.}
The design top is an instance too, and it needs a domain. . names the current scope, so -elements {.} puts the top in the domain (6.21, NOTE 1).
The scope of a domain is where it is made, not what it holds. -elements {u_core u_dsp} at the top leaves the top itself out (6.21, NOTE 2):
create_power_domain PD_TOP -elements {u_core u_dsp} and nothing else (recorded).media.upf:1: instance "media" is in no power domain; add -include_scope to a domain at the design top, or list it in -elements| How the file puts the top in a domain | UPF 1.0 (2007) | IEEE 1801-2024 | OpenPA 0.3.0 |
|---|---|---|---|
-elements {.} | not defined | yes (6.21, NOTE 1) | yes |
-include_scope | yes (6.8) | not an option of 6.21 | accepted |
| no -elements and no -include_scope | the scope and its children not claimed elsewhere (6.8) | an error: -elements is required at least once (6.21) | refused |
Three ways a file has said "this domain holds the top". Write -elements {.} in a 1801-2024 file.
create_power_domain PD_TOP -include_scope gives the same map as -elements {.} (recorded).PD_TOP (media.upf:3): media, u_dsp, u_dsp/u_mac
PD_CORE (media.upf:4): u_core, u_core/u_alu, u_core/u_wdtcreate_power_domain PD_TOP with no options (recorded).media.upf:3: power domain PD_TOP has no elements: give -elements or -include_scope, or add them with add_domain_elementsOne Domain per Instance, Named from the Scope
Each instance is in exactly one domain (6.21). Two domains that both list an instance are refused:
create_power_domain PD_ALU -elements {u_core u_core/u_alu} (recorded).media.upf:6: instance "u_core" is in two power domains: PD_CORE (media.upf:4) and PD_ALUA child can be claimed on purpose. Name it in its own domain, and it leaves its parent's domain. The path starts at the current scope, like every name (W4.2).
UPF 1.0 also had create_power_domain -scope, which made a domain inside an instance (6.8). It is not an option of 1801-2024 6.21. Use set_scope instead:
media.upf:4: create_power_domain: unknown option "-scope"; this command takes -elements -include_scope -supply -update -exclude_elements -atomic -available_supplies -boundary_supplies -define_func_typecreate_power_domain PD_TOP -elements {.}
set_scope u_core
create_power_domain PD_ALU -elements {u_alu}
set_scope ..PD_TOP (media.upf:3): media, u_core, u_core/u_wdt, u_dsp, u_dsp/u_mac
PD_ALU (media.upf:5): u_core/u_aluAn always-on child inside a switchable parent is the hard case. Here the watchdog u_core/u_wdt is claimed by PD_TOP:
create_power_domain PD_TOP -elements {. u_core/u_wdt} (recorded).Power domains
PD_TOP (media.upf:5): media, u_core/u_wdt
2 register(s): total, u_core.u_wdt.q; 0 memory(ies)
PD_CORE (media.upf:6): u_core, u_core/u_alu
1 register(s): u_core.u_alu.q; 0 memory(ies)
PD_DSP (media.upf:7): u_dsp, u_dsp/u_mac
Crossings
u_core/q [PD_CORE] -> logic in media [PD_TOP]: isolation ISO_CORE
u_core/q [PD_CORE] -> media output q_core [PD_TOP]: isolation ISO_CORE
u_core/ticks [PD_CORE] -> media output ticks [PD_TOP]: isolation ISO_CORE
media input clk [PD_TOP] -> u_core/clk [PD_CORE]: no isolation
media input d [PD_TOP] -> u_core/d [PD_CORE]: no isolation
media input en [PD_TOP] -> u_core/en [PD_CORE]: no isolation
media input rst_n [PD_TOP] -> u_core/rst_n [PD_CORE]: no isolation
u_core/u_wdt/q [PD_TOP] -> u_core output ticks [PD_CORE]: no isolation
u_core input clk [PD_CORE] -> u_core/u_wdt/clk [PD_TOP]: isolation ISO_CORE
u_core input rst_n [PD_CORE] -> u_core/u_wdt/rst_n [PD_TOP]: isolation ISO_COREThe watchdog's clock, reset and output still pass through the ports of u_core, which belongs to PD_CORE. The crossings now run both ways across PD_CORE's ports.
The Boundary and Its Ports
A boundary instance is one whose parent is in another domain, or that has no parent (6.21). Its ports form the domain's boundary.
- Design
- I/O
- Data
- Inputs
clk, rst_n, en and d enter PD_CORE at u_core's ports.
- Outputs
q and ticks leave PD_CORE there. ISO_CORE clamps them while the core is off.
Read the diagram as text
- media: PD_TOP: total
- u_core inputs: clk, rst_n, en, d
- u_core: PD_CORE: alu, wdt
- u_core outputs: q, ticks: ISO_CORE
- media → u_core inputs
- u_core inputs → u_core
- u_core → u_core outputs
- u_core outputs → media
Drawn. Upper boundary: the inner side of each boundary instance's ports. Lower boundary: the outer side of the ports of a child in another domain (6.21).
Crossings
u_core/q [PD_CORE] -> logic in media [PD_TOP]: isolation ISO_CORE
u_core/q [PD_CORE] -> media output q_core [PD_TOP]: isolation ISO_CORE
u_core/ticks [PD_CORE] -> media output ticks [PD_TOP]: isolation ISO_CORE
media input clk [PD_TOP] -> u_core/clk [PD_CORE]: no isolation
media input d [PD_TOP] -> u_core/d [PD_CORE]: no isolation
media input en [PD_TOP] -> u_core/en [PD_CORE]: no isolation
media input rst_n [PD_TOP] -> u_core/rst_n [PD_CORE]: no isolation-applies_to outputs takes the output ports of the upper boundary and the input ports of the lower boundary (6.48). Inputs into a powered-down domain need no clamp here.
Growing a Domain: -update and add_domain_elements
A domain can be made first and filled later. IEEE 1801-2024 refines a command with -update (6.21). UPF 1.0 had add_domain_elements (6.2).
IEEE 1801-2024
create_power_domain PD_DSP -elements {}
create_power_domain PD_DSP -update -elements {u_dsp}
The current way.
UPF 1.0
create_power_domain PD_DSP
add_domain_elements PD_DSP -elements {u_dsp}
Not in 1801-2024; OpenPA accepts it.
Two ways to grow PD_DSP (OpenPA, recorded). The right form uses its legacy extension in a 4.0 file.
PD_TOP (media.upf:5): media
PD_CORE (media.upf:6): u_core, u_core/u_alu, u_core/u_wdt
PD_DSP (media.upf:7): u_dsp, u_dsp/u_macA domain that stays empty is refused by OpenPA:
create_power_domain PD_DSP -elements {} with no -update after it (recorded).media.upf:7: power domain PD_DSP has no elements: give -elements or -include_scope, or add them with add_domain_elementsMerging Domains That Share a Supply
merge_power_domains makes one domain from two or more (UPF 1.0 6.20). The new extent is the union of the old ones. The old names cannot be used again.
The domains must share their primary supplies. In the lab, PD_CORE and PD_DSP have their own rails, so the merge is refused.
merge_power_domains PD_MAIN -power_domains {PD_CORE PD_DSP} on the lab file (recorded).media.upf:34: merge_power_domains PD_MAIN: PD_DSP is not sourced from the same primary supply as the other merged domains (UPF 1.0 6.20 requires a shared primary power and ground)Put PD_DSP on VDD_CORE as well, and the same line merges them.
Power domains
PD_TOP (media.upf:5): media
PD_MAIN (media.upf:34): u_core, u_core/u_alu, u_core/u_wdt, u_dsp, u_dsp/u_mac
Crossings
u_core/q [PD_MAIN] -> logic in media [PD_TOP]: isolation ISO_CORE
u_core/q [PD_MAIN] -> media output q_core [PD_TOP]: isolation ISO_CORE
u_dsp/q [PD_MAIN] -> logic in media [PD_TOP]: isolation ISO_DSP
u_dsp/q [PD_MAIN] -> media output q_dsp [PD_TOP]: isolation ISO_DSPISO_CORE and ISO_DSP were written before the merge, so each still clamps its own part's outputs. UPF 1.0 6.20 asks for every strategy of the merged domains before the merge. After it, only PD_MAIN can be named:
media.upf:35: power domain PD_CORE was merged into PD_MAIN (line 34); use the merged domain| merge_power_domains option | UPF 1.0 6.20 | OpenPA 0.3.0 |
|---|---|---|
| new domain name | required | supported |
-power_domains | the domains to merge | supported (two or more) |
-scope | the instance where the new domain is made (default: the current scope) | supported |
-all_equivalent | also merge every domain equivalent to the listed ones | refused: "merge_power_domains -all_equivalent: not supported by OpenPA (a UPF 2.0 option); list the domains with -power_domains" |
merge_power_domains and add_domain_elements are UPF 1.0 commands. IEEE 1801-2024 does not define them; OpenPA accepts them as extensions.
-exclude_elements and Composite Domains
-exclude_elements removes instances from the list a command gives (6.21). The effective list is the elements minus the excludes (5.9).
create_power_domain PD_CORE -elements {u_core} -exclude_elements {u_core/u_wdt} (recorded).Power domains
PD_TOP (media.upf:5): media, u_core/u_wdt
PD_CORE (media.upf:6): u_core, u_core/u_alu
PD_DSP (media.upf:7): u_dsp, u_dsp/u_mac
Notes (3)
media.upf:6: create_power_domain PD_CORE -exclude_elements u_core/u_wdt: the instance belongs to PD_TOP (an OpenPA reading of IEEE 1801-2024 6.21 and 5.9)A composite domain is a simple container for other domains (6.17). It has no region on the silicon, and each subdomain keeps its extent. create_power_domain -subdomains means the same (6.21).
| A drawn example (not run) | Meaning (6.17) |
|---|---|
create_composite_domain PD_WORK -subdomains {PD_CORE PD_DSP} | PD_WORK contains PD_CORE and PD_DSP. Both keep their own instances. |
set_isolation ISO_W -domain PD_WORK ... | applied to each subdomain only if none reports an error |
-supply {primary SS_WORK} | its own primary supply; subdomain primaries must be electrically equivalent or functionally equivalent and interchangeable |
| a composite as a subdomain | allowed: composites may nest |
Drawn from IEEE 1801-2024 6.17. OpenPA 0.3.0 refuses composite domains, so nothing here is graded.
media.upf:34: create_composite_domain is not supported (IEEE 1801-2024 6.17)
media.upf:34: create_power_domain -subdomains: not supported by OpenPA (IEEE 1801-2024 6.21: composite domains)Asked in interviews
What is a power domain?
A set of instances that share a primary supply. Every instance, the design top included, is in exactly one domain.
Why does the design top need -elements {.}?
The top is an instance too. Listing its children does not include it, so the file must name the current scope itself.
When can two domains be merged?
When their primary power and ground come from a shared supply. Strategies for the parts go before the merge.
Try It
Run it. All three accumulators count. Then the bench raises iso_core and switches PD_CORE off.
Read core off alu=xx wdt=xx mac=22 | q_core=0 q_dsp=22 total=21. Both PD_CORE registers are X. q_core reads the clamp value 0, and the DSP runs on.
Open What UPF added. The isolation cells sit on u_core's and u_dsp's output ports: the upper boundaries of PD_CORE and PD_DSP.
Change the bench to switch the DSP off instead. Predict which registers go to X, then run.
OPENPA-INFO corruption=x seed=1 both run alu=20 wdt=2 mac=22 | q_core=20 q_dsp=22 total=21 core off alu=xx wdt=xx mac=22 | q_core=0 q_dsp=22 total=21 one beat alu=xx wdt=xx mac=25 | q_core=0 q_dsp=25 total=22 OPENPA-SUMMARY D1=0 D2=0 D3=0 D4=0 D5=0 D6=0 D7=0 D8=0 D9=0 D10=0 D11=0 D12=0 D13=0 D14=0 OPENPA-COVER sequence D1 ISO_CORE: PD_CORE isolated before power-down 1 OPENPA-COVER sequence D2/D7 ISO_CORE: isolation released only after PD_CORE was back and reset 0 OPENPA-COVER sequence D1 ISO_DSP: PD_DSP isolated before power-down 0 OPENPA-COVER sequence D2/D7 ISO_DSP: isolation released only after PD_DSP was back and reset 0 OPENPA-COVER-SUMMARY states=0/0 declared_transitions=0/0 sequences=1/4Read the power intent: media.upf
upf_version 4.0
set_design_top media
# Three domains: the always-on top, the core and the DSP
create_power_domain PD_TOP -elements {.}
create_power_domain PD_CORE -elements {u_core}
create_power_domain PD_DSP -elements {u_dsp}
create_supply_port VDD -direction in
create_supply_port VSS -direction in
create_supply_net VDD_N
create_supply_net VSS_N
connect_supply_net VDD_N -ports {VDD}
connect_supply_net VSS_N -ports {VSS}
set_domain_supply_net PD_TOP -primary_power_net VDD_N -primary_ground_net VSS_N
# Each switchable domain gets a switched rail
create_supply_net VDD_CORE
create_supply_net VDD_DSP
create_power_switch SW_CORE -domain PD_TOP -input_supply_port {i VDD_N} -output_supply_port {o VDD_CORE} \
-control_port {c pwr_core} -on_state {on i {c}} -off_state {off {!c}}
create_power_switch SW_DSP -domain PD_TOP -input_supply_port {i VDD_N} -output_supply_port {o VDD_DSP} \
-control_port {c pwr_dsp} -on_state {on i {c}} -off_state {off {!c}}
set_domain_supply_net PD_CORE -primary_power_net VDD_CORE -primary_ground_net VSS_N
set_domain_supply_net PD_DSP -primary_power_net VDD_DSP -primary_ground_net VSS_N
# Clamp each switchable domain's outputs to 0 while it is off
set_isolation ISO_CORE -domain PD_CORE -applies_to outputs -clamp_value 0 \
-isolation_power_net VDD_N -isolation_ground_net VSS_N \
-isolation_signal iso_core -isolation_sense high -location parent
set_isolation ISO_DSP -domain PD_DSP -applies_to outputs -clamp_value 0 \
-isolation_power_net VDD_N -isolation_ground_net VSS_N \
-isolation_signal iso_dsp -isolation_sense high -location parent
Read the power-unaware RTL: media.sv
// media: an always-on top with a core and a DSP. Power-unaware RTL.
module media (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr_core,
input logic pwr_dsp,
input logic iso_core,
input logic iso_dsp,
output logic [7:0] q_core,
output logic [7:0] q_dsp,
output logic [7:0] ticks,
output logic [7:0] total
);
core u_core (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(q_core), .ticks(ticks));
dsp u_dsp (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(q_dsp));
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) total <= '0;
else total <= q_core + q_dsp;
endmodule
Read the power-unaware RTL: core.sv
// core: an accumulator and a watchdog tick counter.
module core (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
output logic [7:0] q,
output logic [7:0] ticks
);
acc u_alu (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(q));
tick u_wdt (.clk(clk), .rst_n(rst_n), .q(ticks));
endmodule
Read the power-unaware RTL: dsp.sv
// dsp: one accumulator fed with d + 1.
module dsp (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
output logic [7:0] q
);
acc u_mac (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd1), .q(q));
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
Read the power-unaware RTL: tick.sv
// tick: counts every clock edge.
module tick (
input logic clk,
input logic rst_n,
output logic [7:0] q
);
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) q <= '0;
else q <= q + 8'd1;
endmodule
What UPF added: 49 objects
2 supply port, 4 supply net, 11 output corruption, 3 isolation cell, 2 power switch, 4 supply set, 4 register corruption, 19 dynamic check.
| Object | Where | Detail | Rule | UPF line |
|---|---|---|---|---|
| Supply port | VDD | media.upf:9 | ||
| Supply port | VSS | media.upf:10 | ||
| Supply net | VDD_N | media.upf:9 | ||
| Supply net | VSS_N | media.upf:10 | ||
| Supply net | VDD_CORE | media.upf:20 | ||
| Supply net | VDD_DSP | media.upf:22 | ||
| Output corruption | u_core/clk | folded away: it can never act where anything can see it | C2 | media.upf:5 |
| Output corruption | u_core/d | folded away: it can never act where anything can see it | C2 | media.upf:5 |
| Output corruption | u_core/en | folded away: it can never act where anything can see it | C2 | media.upf:5 |
| Output corruption | u_core/rst_n | folded away: it can never act where anything can see it | C2 | media.upf:5 |
| Output corruption | u_dsp/clk | folded away: it can never act where anything can see it | C2 | media.upf:5 |
| Output corruption | u_dsp/d | folded away: it can never act where anything can see it | C2 | media.upf:5 |
| Output corruption | u_dsp/en | folded away: it can never act where anything can see it | C2 | media.upf:5 |
| Output corruption | u_dsp/rst_n | folded away: it can never act where anything can see it | C2 | media.upf:5 |
| Output corruption | u_core/q | C2 | media.upf:6 | |
| Isolation cell | u_core/q | ISO_CORE · clamp 0 | I1-I5 | media.upf:28 |
| Output corruption | u_core/ticks | C2 | media.upf:6 | |
| Isolation cell | u_core/ticks | ISO_CORE · clamp 0 | I1-I5 | media.upf:28 |
| Output corruption | u_dsp/q | C2 | media.upf:7 | |
| Isolation cell | u_dsp/q | ISO_DSP · clamp 0 | I1-I5 | media.upf:31 |
| Power switch | SW_CORE | S3 (IEEE 1801-2024 6.23) | media.upf:20 | |
| Power switch | SW_DSP | S3 (IEEE 1801-2024 6.23) | media.upf:22 | |
| Supply set | PD_TOP.primary | media.upf:5 | ||
| Supply set | PD_CORE.primary | media.upf:6 | ||
| Supply set | PD_DSP.primary | media.upf:7 | ||
| Supply set | {VDD_N VSS_N} | media.upf:29 | ||
| Register corruption | total | C1 | media.upf:5 | |
| Register corruption | u_core.u_alu.q | C1 | media.upf:6 | |
| Register corruption | u_core.u_wdt.q | C1 | media.upf:6 | |
| Register corruption | u_dsp.u_mac.q | C1 | media.upf:7 | |
| Dynamic check | D1/D2/D7/D6 ISO_CORE | D1, D2, D7, D6 | media.upf:28 | |
| Dynamic check | D1/D2/D7/D6 ISO_DSP | D1, D2, D7, D6 | media.upf:31 | |
| Dynamic check | D9 crossing 1 | D9 | media.upf:6 | |
| Dynamic check | D9 crossing 2 | D9 | media.upf:6 | |
| Dynamic check | D9 crossing 3 | D9 | media.upf:6 | |
| Dynamic check | D9 crossing 4 | D9 | media.upf:7 | |
| Dynamic check | D9 crossing 5 | D9 | media.upf:7 | |
| Dynamic check | D9 crossing 6 | D9 | media.upf:5 | |
| Dynamic check | D9 crossing 7 | D9 | media.upf:5 | |
| Dynamic check | D9 crossing 8 | D9 | media.upf:5 | |
| Dynamic check | D9 crossing 9 | D9 | media.upf:5 | |
| Dynamic check | D9 crossing 10 | D9 | media.upf:5 | |
| Dynamic check | D9 crossing 11 | D9 | media.upf:5 | |
| Dynamic check | D9 crossing 12 | D9 | media.upf:5 | |
| Dynamic check | D9 crossing 13 | D9 | media.upf:5 | |
| Dynamic check | D11 PD_CORE->PD_TOP | D11 | media.upf:6 | |
| Dynamic check | D11 PD_DSP->PD_TOP | D11 | media.upf:7 | |
| Dynamic check | D11 PD_TOP->PD_CORE | D11 | media.upf:5 | |
| Dynamic check | D11 PD_TOP->PD_DSP | D11 | media.upf:5 |
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_media.sv
// pa_media.sv: power-aware copy of media, generated by OpenPA from media.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 (media.upf:9)
supply_net_type openpa_port_VSS; // supply port VSS (media.upf:10)
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_VDD_CORE; // supply net VDD_CORE
supply_net_type openpa_net_VDD_DSP; // supply net VDD_DSP
int openpa_sw_SW_CORE_st = -1; // switch SW_CORE: -1 undetermined, 0 off, k on-state k (media.upf:20)
int openpa_sw_SW_DSP_st = -1; // switch SW_DSP: -1 undetermined, 0 off, k on-state k (media.upf:22)
bit openpa_ss_PD_TOP_primary_ok; int unsigned openpa_ss_PD_TOP_primary_ep; int openpa_ss_PD_TOP_primary_st = -1; bit openpa_ss_PD_TOP_primary_multi; int openpa_ss_PD_TOP_primary_sim = 5; // supply set PD_TOP.primary
bit openpa_ss_PD_CORE_primary_ok; int unsigned openpa_ss_PD_CORE_primary_ep; int openpa_ss_PD_CORE_primary_st = -1; bit openpa_ss_PD_CORE_primary_multi; int openpa_ss_PD_CORE_primary_sim = 5; // supply set PD_CORE.primary
bit openpa_ss_PD_DSP_primary_ok; int unsigned openpa_ss_PD_DSP_primary_ep; int openpa_ss_PD_DSP_primary_st = -1; bit openpa_ss_PD_DSP_primary_multi; int openpa_ss_PD_DSP_primary_sim = 5; // supply set PD_DSP.primary
bit openpa_ss_anon_VDD_N_VSS_N_ok; int unsigned openpa_ss_anon_VDD_N_VSS_N_ep; int openpa_ss_anon_VDD_N_VSS_N_st = -1; bit openpa_ss_anon_VDD_N_VSS_N_multi; int openpa_ss_anon_VDD_N_VSS_N_sim = 5; // supply set {VDD_N VSS_N}
bit openpa_dom_PD_TOP_ok; int unsigned openpa_dom_PD_TOP_ep; int openpa_dom_PD_TOP_sim = 5; // power domain PD_TOP: ok = powered (simstate not CORRUPT); sim = simstate code (media.upf:5)
bit openpa_dom_PD_CORE_ok; int unsigned openpa_dom_PD_CORE_ep; int openpa_dom_PD_CORE_sim = 5; // power domain PD_CORE: ok = powered (simstate not CORRUPT); sim = simstate code (media.upf:6)
bit openpa_dom_PD_DSP_ok; int unsigned openpa_dom_PD_DSP_ep; int openpa_dom_PD_DSP_sim = 5; // power domain PD_DSP: ok = powered (simstate not CORRUPT); sim = simstate code (media.upf:7)
// 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_core; // copy of pwr_core (switch SW_CORE)
logic openpa_ctl_1_pwr_dsp; // copy of pwr_dsp (switch SW_DSP)
logic openpa_ctl_2_iso_core; // copy of iso_core (isolation ISO_CORE)
logic openpa_ctl_3_iso_dsp; // copy of iso_dsp (isolation ISO_DSP)
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 == "VDD_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_on(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_DSP.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_DSP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_DSP") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_DSP already has a driver (switch SW_DSP); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_DSP.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_DSP.primary.power already has a driver (switch SW_DSP); 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)", 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 == "VDD_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_off(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_DSP.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_DSP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_DSP") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_DSP already has a driver (switch SW_DSP); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_DSP.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_DSP.primary.power already has a driver (switch SW_DSP); 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)", 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 == "VDD_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VSS_N") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_DSP.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_DSP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_DSP") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_DSP already has a driver (switch SW_DSP); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_DSP.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_DSP.primary.power already has a driver (switch SW_DSP); 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)", 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 == "VDD_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_N already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.power already has a driver (port VDD); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VSS_N") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VSS_N already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_TOP.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_TOP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CORE.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CORE.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_DSP.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_DSP.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_CORE") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_CORE already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CORE.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CORE.primary.power already has a driver (switch SW_CORE); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_DSP") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_DSP already has a driver (switch SW_DSP); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_DSP.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_DSP.primary.power already has a driver (switch SW_DSP); 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)", pad_name);
return 0;
endfunction
// set_power_state (9.3.1) is not supported: OpenPA has no deferred power states. A call is reported, never ignored.
function automatic upfBooleanT set_power_state(string object_name, string power_state);
$display("OPENPA-ERROR set_power_state(\"%s\", \"%s\"): not supported by OpenPA; drive the supplies with supply_on, supply_off or set_supply_state", object_name, power_state);
return 0;
endfunction
// Supply queries (11.2.4). Names: supply ports, supply nets and supply set functions as the UPF wrote them.
function automatic upfSupplyTypeT get_supply_value(string name);
if (name == "VDD" || name == "VDD_N" || name == "PD_TOP.primary.power") return openpa_net_VDD_N;
if (name == "VSS" || name == "VSS_N" || name == "PD_TOP.primary.ground" || name == "PD_CORE.primary.ground" || name == "PD_DSP.primary.ground") return openpa_net_VSS_N;
if (name == "VDD_CORE" || name == "PD_CORE.primary.power") return openpa_net_VDD_CORE;
if (name == "VDD_DSP" || name == "PD_DSP.primary.power") return openpa_net_VDD_DSP;
$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 "media.sv" 0
// media: an always-on top with a core and a DSP. Power-unaware RTL.
module media (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr_core,
input logic pwr_dsp,
input logic iso_core,
input logic iso_dsp,
output logic [7:0] q_core,
output logic [7:0] q_dsp,
output logic [7:0] ticks,
output logic [7:0] total
);
wire [7:0] openpa_u_core_q_raw, openpa_u_core_q_s1; wire [7:0] openpa_u_core_ticks_raw, openpa_u_core_ticks_s1; core u_core (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(openpa_u_core_q_raw), .ticks(openpa_u_core_ticks_raw)); openpa_corrupt #(.W(8), .ID(268435456)) openpa_u_core_q_cor (.d(openpa_u_core_q_raw), .q(openpa_u_core_q_s1), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435457)) openpa_u_core_q_iso (.d(openpa_u_core_q_s1), .q(q_core), .en(UPF::openpa_ctl_2_iso_core), .sup_ok((UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0)), .sup_ep(UPF::openpa_ss_anon_VDD_N_VSS_N_ep)); openpa_corrupt #(.W(8), .ID(268435464)) openpa_u_core_ticks_cor (.d(openpa_u_core_ticks_raw), .q(openpa_u_core_ticks_s1), .ok(UPF::openpa_dom_PD_CORE_ok), .ep(UPF::openpa_dom_PD_CORE_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435465)) openpa_u_core_ticks_iso (.d(openpa_u_core_ticks_s1), .q(ticks), .en(UPF::openpa_ctl_2_iso_core), .sup_ok((UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0)), .sup_ep(UPF::openpa_ss_anon_VDD_N_VSS_N_ep));
wire [7:0] openpa_u_dsp_q_raw, openpa_u_dsp_q_s1; dsp u_dsp (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(openpa_u_dsp_q_raw)); openpa_corrupt #(.W(8), .ID(268435472)) openpa_u_dsp_q_cor (.d(openpa_u_dsp_q_raw), .q(openpa_u_dsp_q_s1), .ok(UPF::openpa_dom_PD_DSP_ok), .ep(UPF::openpa_dom_PD_DSP_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435473)) openpa_u_dsp_q_iso (.d(openpa_u_dsp_q_s1), .q(q_dsp), .en(UPF::openpa_ctl_3_iso_dsp), .sup_ok((UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0)), .sup_ep(UPF::openpa_ss_anon_VDD_N_VSS_N_ep));
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) total <= '0;
else total <= q_core + q_dsp;
`line 1 "openpa_overlay.sv" 0
// ===================================================================================
// OpenPA overlay for media: generated from media.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_core;
import UPF::openpa_ctl_1_pwr_dsp;
import UPF::openpa_ctl_2_iso_core;
import UPF::openpa_ctl_3_iso_dsp;
import UPF::openpa_dom_PD_CORE_ep;
import UPF::openpa_dom_PD_CORE_ok;
import UPF::openpa_dom_PD_CORE_sim;
import UPF::openpa_dom_PD_DSP_ep;
import UPF::openpa_dom_PD_DSP_ok;
import UPF::openpa_dom_PD_DSP_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_CORE;
import UPF::openpa_net_VDD_DSP;
import UPF::openpa_net_VDD_N;
import UPF::openpa_net_VSS_N;
import UPF::openpa_seed;
import UPF::openpa_ss_PD_CORE_primary_ep;
import UPF::openpa_ss_PD_CORE_primary_multi;
import UPF::openpa_ss_PD_CORE_primary_ok;
import UPF::openpa_ss_PD_CORE_primary_sim;
import UPF::openpa_ss_PD_CORE_primary_st;
import UPF::openpa_ss_PD_DSP_primary_ep;
import UPF::openpa_ss_PD_DSP_primary_multi;
import UPF::openpa_ss_PD_DSP_primary_ok;
import UPF::openpa_ss_PD_DSP_primary_sim;
import UPF::openpa_ss_PD_DSP_primary_st;
import UPF::openpa_ss_PD_TOP_primary_ep;
import UPF::openpa_ss_PD_TOP_primary_multi;
import UPF::openpa_ss_PD_TOP_primary_ok;
import UPF::openpa_ss_PD_TOP_primary_sim;
import UPF::openpa_ss_PD_TOP_primary_st;
import UPF::openpa_ss_anon_VDD_N_VSS_N_ep;
import UPF::openpa_ss_anon_VDD_N_VSS_N_multi;
import UPF::openpa_ss_anon_VDD_N_VSS_N_ok;
import UPF::openpa_ss_anon_VDD_N_VSS_N_sim;
import UPF::openpa_ss_anon_VDD_N_VSS_N_st;
import UPF::openpa_sw_SW_CORE_st;
import UPF::openpa_sw_SW_DSP_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:29]; // 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_core or openpa_kick) openpa_ctl_0_pwr_core = pwr_core;
always @(pwr_dsp or openpa_kick) openpa_ctl_1_pwr_dsp = pwr_dsp;
always @(iso_core or openpa_kick) openpa_ctl_2_iso_core = iso_core;
always @(iso_dsp or openpa_kick) openpa_ctl_3_iso_dsp = iso_dsp;
// ---- supply network, switches, supply sets, simstates, power states (one block, evaluated in order)
bit openpa_tg_sw_SW_CORE_st; int openpa_pv_sw_SW_CORE_st = -2;
bit openpa_tg_sw_SW_DSP_st; int openpa_pv_sw_SW_DSP_st = -2;
UPF::supply_net_type openpa_swv_SW_CORE_f, openpa_swv_SW_CORE_p; bit openpa_swv_SW_CORE_u, openpa_swv_SW_CORE_hf, openpa_swv_SW_CORE_hp, openpa_swv_SW_CORE_vd, openpa_swv_SW_CORE_on, openpa_swv_SW_CORE_pt; int openpa_swv_SW_CORE_k; // switch SW_CORE
UPF::supply_net_type openpa_swv_SW_DSP_f, openpa_swv_SW_DSP_p; bit openpa_swv_SW_DSP_u, openpa_swv_SW_DSP_hf, openpa_swv_SW_DSP_hp, openpa_swv_SW_DSP_vd, openpa_swv_SW_DSP_on, openpa_swv_SW_DSP_pt; int openpa_swv_SW_DSP_k; // switch SW_DSP
always @(openpa_kick or UPF::openpa_port_VDD or UPF::openpa_port_VSS or UPF::openpa_ctl_0_pwr_core or UPF::openpa_ctl_1_pwr_dsp) 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
// switch SW_CORE (media.upf:20): IEEE 1801-2024 6.23
openpa_swv_SW_CORE_u = 1'b0; openpa_swv_SW_CORE_hf = 1'b0; openpa_swv_SW_CORE_hp = 1'b0; openpa_swv_SW_CORE_vd = 1'b0; openpa_swv_SW_CORE_on = 1'b0; openpa_swv_SW_CORE_pt = 1'b0; openpa_swv_SW_CORE_k = 0;
if (($isunknown(openpa_ctl_0_pwr_core)) && UPF::openpa_net_VDD_N.state != UPF::OFF) openpa_swv_SW_CORE_u = 1'b1; // on state on: a control is X or Z
else if ((openpa_ctl_0_pwr_core === 1'b1)) begin
if (!openpa_swv_SW_CORE_on) openpa_swv_SW_CORE_k = 1;
openpa_swv_SW_CORE_on = 1'b1;
if (UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED) openpa_swv_SW_CORE_u = 1'b1;
else if (UPF::openpa_net_VDD_N.state == UPF::FULL_ON) begin
if ((openpa_swv_SW_CORE_hf && openpa_swv_SW_CORE_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_CORE_hp && openpa_swv_SW_CORE_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_CORE_vd = 1'b1;
openpa_swv_SW_CORE_f = UPF::openpa_net_VDD_N; openpa_swv_SW_CORE_hf = 1'b1;
end
else if (UPF::openpa_net_VDD_N.state == UPF::PARTIAL_ON) begin
if ((openpa_swv_SW_CORE_hf && openpa_swv_SW_CORE_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_CORE_hp && openpa_swv_SW_CORE_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_CORE_vd = 1'b1;
openpa_swv_SW_CORE_p = UPF::openpa_net_VDD_N; openpa_swv_SW_CORE_hp = 1'b1;
end
end
if ((1'b0) || (((!((openpa_ctl_0_pwr_core === 1'b1)))) && (openpa_swv_SW_CORE_on || openpa_swv_SW_CORE_pt)) || openpa_swv_SW_CORE_u || openpa_swv_SW_CORE_vd || (!($isunknown(openpa_ctl_0_pwr_core)) && !openpa_swv_SW_CORE_on && !openpa_swv_SW_CORE_pt && !((!((openpa_ctl_0_pwr_core === 1'b1)))) && !(1'b0))) begin openpa_sw_SW_CORE_st = -1; openpa_net_VDD_CORE.state = UPF::UNDETERMINED; openpa_net_VDD_CORE.voltage = 0; end
else begin openpa_sw_SW_CORE_st = openpa_swv_SW_CORE_k; if (openpa_swv_SW_CORE_hf) openpa_net_VDD_CORE = openpa_swv_SW_CORE_f; else if (openpa_swv_SW_CORE_hp) openpa_net_VDD_CORE = openpa_swv_SW_CORE_p; else begin openpa_net_VDD_CORE.state = UPF::OFF; openpa_net_VDD_CORE.voltage = 0; end end
// switch SW_DSP (media.upf:22): IEEE 1801-2024 6.23
openpa_swv_SW_DSP_u = 1'b0; openpa_swv_SW_DSP_hf = 1'b0; openpa_swv_SW_DSP_hp = 1'b0; openpa_swv_SW_DSP_vd = 1'b0; openpa_swv_SW_DSP_on = 1'b0; openpa_swv_SW_DSP_pt = 1'b0; openpa_swv_SW_DSP_k = 0;
if (($isunknown(openpa_ctl_1_pwr_dsp)) && UPF::openpa_net_VDD_N.state != UPF::OFF) openpa_swv_SW_DSP_u = 1'b1; // on state on: a control is X or Z
else if ((openpa_ctl_1_pwr_dsp === 1'b1)) begin
if (!openpa_swv_SW_DSP_on) openpa_swv_SW_DSP_k = 1;
openpa_swv_SW_DSP_on = 1'b1;
if (UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED) openpa_swv_SW_DSP_u = 1'b1;
else if (UPF::openpa_net_VDD_N.state == UPF::FULL_ON) begin
if ((openpa_swv_SW_DSP_hf && openpa_swv_SW_DSP_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_DSP_hp && openpa_swv_SW_DSP_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_DSP_vd = 1'b1;
openpa_swv_SW_DSP_f = UPF::openpa_net_VDD_N; openpa_swv_SW_DSP_hf = 1'b1;
end
else if (UPF::openpa_net_VDD_N.state == UPF::PARTIAL_ON) begin
if ((openpa_swv_SW_DSP_hf && openpa_swv_SW_DSP_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_DSP_hp && openpa_swv_SW_DSP_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_DSP_vd = 1'b1;
openpa_swv_SW_DSP_p = UPF::openpa_net_VDD_N; openpa_swv_SW_DSP_hp = 1'b1;
end
end
if ((1'b0) || (((!((openpa_ctl_1_pwr_dsp === 1'b1)))) && (openpa_swv_SW_DSP_on || openpa_swv_SW_DSP_pt)) || openpa_swv_SW_DSP_u || openpa_swv_SW_DSP_vd || (!($isunknown(openpa_ctl_1_pwr_dsp)) && !openpa_swv_SW_DSP_on && !openpa_swv_SW_DSP_pt && !((!((openpa_ctl_1_pwr_dsp === 1'b1)))) && !(1'b0))) begin openpa_sw_SW_DSP_st = -1; openpa_net_VDD_DSP.state = UPF::UNDETERMINED; openpa_net_VDD_DSP.voltage = 0; end
else begin openpa_sw_SW_DSP_st = openpa_swv_SW_DSP_k; if (openpa_swv_SW_DSP_hf) openpa_net_VDD_DSP = openpa_swv_SW_DSP_f; else if (openpa_swv_SW_DSP_hp) openpa_net_VDD_DSP = openpa_swv_SW_DSP_p; else begin openpa_net_VDD_DSP.state = UPF::OFF; openpa_net_VDD_DSP.voltage = 0; end end
// supply set PD_TOP.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_PD_TOP_primary
bit nx; int sm;
sm = (UPF::openpa_net_VDD_N.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5; // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
openpa_ss_PD_TOP_primary_sim = sm;
nx = sm < 5;
if (openpa_ss_PD_TOP_primary_ok && !nx) openpa_ss_PD_TOP_primary_ep = openpa_ss_PD_TOP_primary_ep + 1;
openpa_ss_PD_TOP_primary_ok = nx;
end
// supply set PD_CORE.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_PD_CORE_primary
bit nx; int sm;
sm = (UPF::openpa_net_VDD_CORE.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5; // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
openpa_ss_PD_CORE_primary_sim = sm;
nx = sm < 5;
if (openpa_ss_PD_CORE_primary_ok && !nx) openpa_ss_PD_CORE_primary_ep = openpa_ss_PD_CORE_primary_ep + 1;
openpa_ss_PD_CORE_primary_ok = nx;
end
// supply set PD_DSP.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_PD_DSP_primary
bit nx; int sm;
sm = (UPF::openpa_net_VDD_DSP.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5; // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
openpa_ss_PD_DSP_primary_sim = sm;
nx = sm < 5;
if (openpa_ss_PD_DSP_primary_ok && !nx) openpa_ss_PD_DSP_primary_ep = openpa_ss_PD_DSP_primary_ep + 1;
openpa_ss_PD_DSP_primary_ok = nx;
end
// supply set {VDD_N VSS_N}: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_anon_VDD_N_VSS_N
bit nx; int sm;
sm = (UPF::openpa_net_VDD_N.state == UPF::FULL_ON && UPF::openpa_net_VSS_N.state == UPF::FULL_ON) ? 0 : 5; // predefined ON (NORMAL) or OFF (CORRUPT), IEEE 1801-2024 4.7.4
openpa_ss_anon_VDD_N_VSS_N_sim = sm;
nx = sm < 5;
if (openpa_ss_anon_VDD_N_VSS_N_ok && !nx) openpa_ss_anon_VDD_N_VSS_N_ep = openpa_ss_anon_VDD_N_VSS_N_ep + 1;
openpa_ss_anon_VDD_N_VSS_N_ok = nx;
end
// domain PD_TOP: simstate of its primary supply set PD_TOP.primary
if (openpa_dom_PD_TOP_ok && !UPF::openpa_ss_PD_TOP_primary_ok) openpa_dom_PD_TOP_ep = openpa_dom_PD_TOP_ep + 1;
openpa_dom_PD_TOP_ok = UPF::openpa_ss_PD_TOP_primary_ok;
openpa_dom_PD_TOP_sim = openpa_ss_PD_TOP_primary_sim;
// domain PD_CORE: simstate of its primary supply set PD_CORE.primary
if (openpa_dom_PD_CORE_ok && !UPF::openpa_ss_PD_CORE_primary_ok) openpa_dom_PD_CORE_ep = openpa_dom_PD_CORE_ep + 1;
openpa_dom_PD_CORE_ok = UPF::openpa_ss_PD_CORE_primary_ok;
openpa_dom_PD_CORE_sim = openpa_ss_PD_CORE_primary_sim;
// domain PD_DSP: simstate of its primary supply set PD_DSP.primary
if (openpa_dom_PD_DSP_ok && !UPF::openpa_ss_PD_DSP_primary_ok) openpa_dom_PD_DSP_ep = openpa_dom_PD_DSP_ep + 1;
openpa_dom_PD_DSP_ok = UPF::openpa_ss_PD_DSP_primary_ok;
openpa_dom_PD_DSP_sim = openpa_ss_PD_DSP_primary_sim;
if (openpa_sw_SW_CORE_st != openpa_pv_sw_SW_CORE_st) begin openpa_tg_sw_SW_CORE_st = ~openpa_tg_sw_SW_CORE_st; openpa_pv_sw_SW_CORE_st = openpa_sw_SW_CORE_st; end
if (openpa_sw_SW_DSP_st != openpa_pv_sw_SW_DSP_st) begin openpa_tg_sw_SW_DSP_st = ~openpa_tg_sw_SW_DSP_st; openpa_pv_sw_SW_DSP_st = openpa_sw_SW_DSP_st; end
end
// ---- corruption: registers forced, memories overwritten (rules C1, C3)
// domain PD_TOP (media.upf:5): 1 register(s), 0 memory(ies)
bit openpa_PD_TOP_applied, openpa_PD_TOP_valid;
logic [7:0] openpa_cv1; // corruption value for total
// The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
// supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
always @(UPF::openpa_dom_PD_TOP_ok or openpa_kick) if (!openpa_PD_TOP_valid || openpa_PD_TOP_applied != UPF::openpa_dom_PD_TOP_ok) begin
openpa_t({"PD_TOP ", UPF::openpa_dom_PD_TOP_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_PD_TOP_ok || !openpa_PD_TOP_valid) begin
if (openpa_xmode) openpa_cv1 = 'x; else openpa_cv1 = UPF::openpa_mix(1, UPF::openpa_dom_PD_TOP_ep, 0);
force total = openpa_cv1;
end
if (UPF::openpa_dom_PD_TOP_ok) begin
release total;
end
openpa_PD_TOP_valid = 1'b1; openpa_PD_TOP_applied = UPF::openpa_dom_PD_TOP_ok;
end
// domain PD_CORE (media.upf:6): 2 register(s), 0 memory(ies)
bit openpa_PD_CORE_applied, openpa_PD_CORE_valid;
logic [7:0] openpa_cv2; // corruption value for u_core.u_alu.q
logic [7:0] openpa_cv3; // corruption value for u_core.u_wdt.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_CORE_ok or openpa_kick) if (!openpa_PD_CORE_valid || openpa_PD_CORE_applied != UPF::openpa_dom_PD_CORE_ok) begin
openpa_t({"PD_CORE ", UPF::openpa_dom_PD_CORE_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_PD_CORE_ok || !openpa_PD_CORE_valid) begin
if (openpa_xmode) openpa_cv2 = 'x; else openpa_cv2 = UPF::openpa_mix(2, UPF::openpa_dom_PD_CORE_ep, 0);
force u_core.u_alu.q = openpa_cv2;
if (openpa_xmode) openpa_cv3 = 'x; else openpa_cv3 = UPF::openpa_mix(3, UPF::openpa_dom_PD_CORE_ep, 0);
force u_core.u_wdt.q = openpa_cv3;
end
if (UPF::openpa_dom_PD_CORE_ok) begin
release u_core.u_alu.q;
release u_core.u_wdt.q;
end
openpa_PD_CORE_valid = 1'b1; openpa_PD_CORE_applied = UPF::openpa_dom_PD_CORE_ok;
end
// domain PD_DSP (media.upf:7): 1 register(s), 0 memory(ies)
bit openpa_PD_DSP_applied, openpa_PD_DSP_valid;
logic [7:0] openpa_cv4; // corruption value for u_dsp.u_mac.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_DSP_ok or openpa_kick) if (!openpa_PD_DSP_valid || openpa_PD_DSP_applied != UPF::openpa_dom_PD_DSP_ok) begin
openpa_t({"PD_DSP ", UPF::openpa_dom_PD_DSP_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_PD_DSP_ok || !openpa_PD_DSP_valid) begin
if (openpa_xmode) openpa_cv4 = 'x; else openpa_cv4 = UPF::openpa_mix(4, UPF::openpa_dom_PD_DSP_ep, 0);
force u_dsp.u_mac.q = openpa_cv4;
end
if (UPF::openpa_dom_PD_DSP_ok) begin
release u_dsp.u_mac.q;
end
openpa_PD_DSP_valid = 1'b1; openpa_PD_DSP_applied = UPF::openpa_dom_PD_DSP_ok;
end
// D7 reset check for PD_CORE: resets u_core.u_alu.rst_n active 0, u_core.u_wdt.rst_n active 0
bit openpa_PD_CORE_rprev, openpa_PD_CORE_rp0, openpa_PD_CORE_rp1;
always @(posedge UPF::openpa_dom_PD_CORE_ok or negedge UPF::openpa_dom_PD_CORE_ok or posedge u_core.u_alu.rst_n or negedge u_core.u_alu.rst_n or posedge u_core.u_wdt.rst_n or negedge u_core.u_wdt.rst_n) begin
if (UPF::openpa_dom_PD_CORE_ok && !openpa_PD_CORE_rprev) openpa_PD_CORE_rp0 = 1'b1;
if (!UPF::openpa_dom_PD_CORE_ok || u_core.u_alu.rst_n === 1'b0) openpa_PD_CORE_rp0 = 1'b0;
if (UPF::openpa_dom_PD_CORE_ok && !openpa_PD_CORE_rprev) openpa_PD_CORE_rp1 = 1'b1;
if (!UPF::openpa_dom_PD_CORE_ok || u_core.u_wdt.rst_n === 1'b0) openpa_PD_CORE_rp1 = 1'b0;
openpa_PD_CORE_rprev = UPF::openpa_dom_PD_CORE_ok;
end
// D7 reset check for PD_DSP: resets u_dsp.u_mac.rst_n active 0
bit openpa_PD_DSP_rprev, openpa_PD_DSP_rp0;
always @(posedge UPF::openpa_dom_PD_DSP_ok or negedge UPF::openpa_dom_PD_DSP_ok or posedge u_dsp.u_mac.rst_n or negedge u_dsp.u_mac.rst_n) begin
if (UPF::openpa_dom_PD_DSP_ok && !openpa_PD_DSP_rprev) openpa_PD_DSP_rp0 = 1'b1;
if (!UPF::openpa_dom_PD_DSP_ok || u_dsp.u_mac.rst_n === 1'b0) openpa_PD_DSP_rp0 = 1'b0;
openpa_PD_DSP_rprev = UPF::openpa_dom_PD_DSP_ok;
end
// ---- checks for set_isolation ISO_CORE (media.upf:28): PD_CORE -> PD_TOP on 2 port(s)
bit openpa_ig1_act, openpa_ig1_cyc;
always @(negedge UPF::openpa_dom_PD_CORE_ok) if (!UPF::openpa_dom_PD_CORE_ok)
begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge UPF::openpa_ctl_2_iso_core or negedge UPF::openpa_ctl_2_iso_core or posedge openpa_kick) begin
if (openpa_ig1_act && !(UPF::openpa_ctl_2_iso_core === 1'b1))
begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
if (openpa_ig1_act != (UPF::openpa_ctl_2_iso_core === 1'b1)) openpa_t({"ISO_CORE enable ", (UPF::openpa_ctl_2_iso_core === 1'b1) ? "active" : "inactive"});
openpa_ig1_act = (UPF::openpa_ctl_2_iso_core === 1'b1);
end
always @(negedge UPF::openpa_ss_anon_VDD_N_VSS_N_ok) if (!UPF::openpa_ss_anon_VDD_N_VSS_N_ok)
begin openpa_sp[3] = 1'b1; openpa_sreq = 1'b1; end
// ---- checks for set_isolation ISO_DSP (media.upf:31): PD_DSP -> PD_TOP on 1 port(s)
bit openpa_ig2_act, openpa_ig2_cyc;
always @(negedge UPF::openpa_dom_PD_DSP_ok) if (!UPF::openpa_dom_PD_DSP_ok)
begin openpa_sp[4] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge UPF::openpa_ctl_3_iso_dsp or negedge UPF::openpa_ctl_3_iso_dsp or posedge openpa_kick) begin
if (openpa_ig2_act && !(UPF::openpa_ctl_3_iso_dsp === 1'b1))
begin openpa_sp[5] = 1'b1; openpa_sreq = 1'b1; end
if (openpa_ig2_act != (UPF::openpa_ctl_3_iso_dsp === 1'b1)) openpa_t({"ISO_DSP enable ", (UPF::openpa_ctl_3_iso_dsp === 1'b1) ? "active" : "inactive"});
openpa_ig2_act = (UPF::openpa_ctl_3_iso_dsp === 1'b1);
end
always @(negedge UPF::openpa_ss_anon_VDD_N_VSS_N_ok) if (!UPF::openpa_ss_anon_VDD_N_VSS_N_ok)
begin openpa_sp[6] = 1'b1; openpa_sreq = 1'b1; end
// crossing 1: u_core/q (PD_CORE) -> logic in media (PD_TOP), isolated by ISO_CORE
bit openpa_x1_t;
always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_2_iso_core or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x1_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_2_iso_core === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x1_t)
begin openpa_sp[7] = 1'b1; openpa_sreq = 1'b1; end
// crossing 2: u_core/q (PD_CORE) -> media output q_core (PD_TOP), isolated by ISO_CORE
bit openpa_x2_t;
always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_2_iso_core or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x2_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_2_iso_core === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x2_t)
begin openpa_sp[8] = 1'b1; openpa_sreq = 1'b1; end
// crossing 3: u_core/ticks (PD_CORE) -> media output ticks (PD_TOP), isolated by ISO_CORE
bit openpa_x3_t;
always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_2_iso_core or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VSS_N) openpa_x3_t = !UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_2_iso_core === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_CORE.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x3_t)
begin openpa_sp[9] = 1'b1; openpa_sreq = 1'b1; end
// crossing 4: u_dsp/q (PD_DSP) -> logic in media (PD_TOP), isolated by ISO_DSP
bit openpa_x4_t;
always @(UPF::openpa_dom_PD_DSP_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_3_iso_dsp or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_DSP or UPF::openpa_net_VSS_N) openpa_x4_t = !UPF::openpa_dom_PD_DSP_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_3_iso_dsp === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_DSP.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: u_dsp/q (PD_DSP) -> media output q_dsp (PD_TOP), isolated by ISO_DSP
bit openpa_x5_t;
always @(UPF::openpa_dom_PD_DSP_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_3_iso_dsp or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_DSP or UPF::openpa_net_VSS_N) openpa_x5_t = !UPF::openpa_dom_PD_DSP_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_3_iso_dsp === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_DSP.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: media input clk (PD_TOP) -> u_core/clk (PD_CORE), not isolated
bit openpa_x6_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x6_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x6_t)
begin openpa_sp[12] = 1'b1; openpa_sreq = 1'b1; end
// crossing 7: media input d (PD_TOP) -> u_core/d (PD_CORE), not isolated
bit openpa_x7_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x7_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x7_t)
begin openpa_sp[13] = 1'b1; openpa_sreq = 1'b1; end
// crossing 8: media input en (PD_TOP) -> u_core/en (PD_CORE), not isolated
bit openpa_x8_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x8_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x8_t)
begin openpa_sp[14] = 1'b1; openpa_sreq = 1'b1; end
// crossing 9: media input rst_n (PD_TOP) -> u_core/rst_n (PD_CORE), not isolated
bit openpa_x9_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x9_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x9_t)
begin openpa_sp[15] = 1'b1; openpa_sreq = 1'b1; end
// crossing 10: media input clk (PD_TOP) -> u_dsp/clk (PD_DSP), not isolated
bit openpa_x10_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_DSP_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_DSP_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
// crossing 11: media input d (PD_TOP) -> u_dsp/d (PD_DSP), not isolated
bit openpa_x11_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_DSP_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x11_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_DSP_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x11_t)
begin openpa_sp[17] = 1'b1; openpa_sreq = 1'b1; end
// crossing 12: media input en (PD_TOP) -> u_dsp/en (PD_DSP), not isolated
bit openpa_x12_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_DSP_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x12_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_DSP_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x12_t)
begin openpa_sp[18] = 1'b1; openpa_sreq = 1'b1; end
// crossing 13: media input rst_n (PD_TOP) -> u_dsp/rst_n (PD_DSP), not isolated
bit openpa_x13_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_DSP_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x13_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_DSP_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x13_t)
begin openpa_sp[19] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 1: PD_CORE -> PD_TOP (no level shifter strategy, threshold 0)
bit openpa_l1_t;
always @(UPF::openpa_dom_PD_CORE_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_CORE or UPF::openpa_net_VDD_N) openpa_l1_t = UPF::openpa_dom_PD_CORE_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_CORE.voltage - UPF::openpa_net_VDD_N.voltage > 0 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_CORE.voltage > 0) && !1'b0;
always @(posedge openpa_l1_t)
begin openpa_sp[20] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 2: PD_DSP -> PD_TOP (no level shifter strategy, threshold 0)
bit openpa_l2_t;
always @(UPF::openpa_dom_PD_DSP_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_DSP or UPF::openpa_net_VDD_N) openpa_l2_t = UPF::openpa_dom_PD_DSP_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_DSP.voltage - UPF::openpa_net_VDD_N.voltage > 0 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_DSP.voltage > 0) && !1'b0;
always @(posedge openpa_l2_t)
begin openpa_sp[21] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 3: PD_TOP -> PD_CORE (no level shifter strategy, threshold 0)
bit openpa_l3_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_CORE_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_CORE) openpa_l3_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_CORE.voltage > 0 || UPF::openpa_net_VDD_CORE.voltage - UPF::openpa_net_VDD_N.voltage > 0) && !1'b0;
always @(posedge openpa_l3_t)
begin openpa_sp[22] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 4: PD_TOP -> PD_DSP (no level shifter strategy, threshold 0)
bit openpa_l4_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_DSP_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_DSP) openpa_l4_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_DSP_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_DSP.voltage > 0 || UPF::openpa_net_VDD_DSP.voltage - UPF::openpa_net_VDD_N.voltage > 0) && !1'b0;
always @(posedge openpa_l4_t)
begin openpa_sp[23] = 1'b1; openpa_sreq = 1'b1; end
bit openpa_SW_CORE_def;
always @(posedge openpa_tg_sw_SW_CORE_st or negedge openpa_tg_sw_SW_CORE_st)
begin openpa_sp[24] = 1'b1; openpa_sreq = 1'b1; end
bit openpa_SW_DSP_def;
always @(posedge openpa_tg_sw_SW_DSP_st or negedge openpa_tg_sw_SW_DSP_st)
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
always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
begin openpa_sp[29] = 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_core) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: q_core=%h", $time, q_core);
always @(q_dsp) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: q_dsp=%h", $time, q_dsp);
always @(ticks) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: ticks=%h", $time, ticks);
always @(total) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: total=%h", $time, total);
`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_CORE: PD_CORE isolated before power-down %0d", openpa_seq[1]);
$display("OPENPA-COVER sequence D2/D7 ISO_CORE: isolation released only after PD_CORE was back and reset %0d", openpa_seq[2]);
$display("OPENPA-COVER sequence D1 ISO_DSP: PD_DSP isolated before power-down %0d", openpa_seq[3]);
$display("OPENPA-COVER sequence D2/D7 ISO_DSP: isolation released only after PD_DSP 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: 29 deferred check(s), run after one #0 in a fixed order
initial forever begin
wait (openpa_sreq && openpa_kick);
#0;
openpa_sreq = 1'b0;
if (openpa_sp[1]) begin
openpa_sp[1] = 1'b0;
if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_2_iso_core === 1'b1)) openpa_check(1, "set_isolation ISO_CORE (media.upf:28): PD_CORE went off while the isolation enable iso_core was inactive");
else if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_2_iso_core === 1'b1)) begin openpa_seq[1] = openpa_seq[1] + 1; openpa_ig1_cyc = 1'b1; end
end
if (openpa_sp[2]) begin
openpa_sp[2] = 1'b0;
if (!UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation ISO_CORE (media.upf:28): isolation released while PD_CORE is still off");
else if (openpa_PD_CORE_rp0) openpa_check(7, "set_isolation ISO_CORE (media.upf:28): isolation released after PD_CORE powered up but before its reset u_core.u_alu.rst_n was asserted");
else if (openpa_PD_CORE_rp1) openpa_check(7, "set_isolation ISO_CORE (media.upf:28): isolation released after PD_CORE powered up but before its reset u_core.u_wdt.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_2_iso_core === 1'b1) && !UPF::openpa_dom_PD_CORE_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation ISO_CORE (media.upf:28): isolation supply {VDD_N VSS_N} lost while clamping");
end
if (openpa_sp[4]) begin
openpa_sp[4] = 1'b0;
if (!UPF::openpa_dom_PD_DSP_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_3_iso_dsp === 1'b1)) openpa_check(1, "set_isolation ISO_DSP (media.upf:31): PD_DSP went off while the isolation enable iso_dsp was inactive");
else if (!UPF::openpa_dom_PD_DSP_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_3_iso_dsp === 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_DSP_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation ISO_DSP (media.upf:31): isolation released while PD_DSP is still off");
else if (openpa_PD_DSP_rp0) openpa_check(7, "set_isolation ISO_DSP (media.upf:31): isolation released after PD_DSP powered up but before its reset u_dsp.u_mac.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_3_iso_dsp === 1'b1) && !UPF::openpa_dom_PD_DSP_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation ISO_DSP (media.upf:31): isolation supply {VDD_N VSS_N} lost while clamping");
end
if (openpa_sp[7]) begin
openpa_sp[7] = 1'b0;
if (openpa_x1_t) openpa_check(9, "u_core/q of PD_CORE (off) is read by logic in media 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_core/q of PD_CORE (off) is read by media output q_core 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, "u_core/ticks of PD_CORE (off) is read by media output ticks in PD_TOP (on) with no active isolation");
end
if (openpa_sp[10]) begin
openpa_sp[10] = 1'b0;
if (openpa_x4_t) openpa_check(9, "u_dsp/q of PD_DSP (off) is read by logic in media in PD_TOP (on) with no active isolation");
end
if (openpa_sp[11]) begin
openpa_sp[11] = 1'b0;
if (openpa_x5_t) openpa_check(9, "u_dsp/q of PD_DSP (off) is read by media output q_dsp in PD_TOP (on) with no active isolation");
end
if (openpa_sp[12]) begin
openpa_sp[12] = 1'b0;
if (openpa_x6_t) openpa_check(9, "media input clk of PD_TOP (off) is read by u_core/clk in PD_CORE (on) with no active isolation");
end
if (openpa_sp[13]) begin
openpa_sp[13] = 1'b0;
if (openpa_x7_t) openpa_check(9, "media input d of PD_TOP (off) is read by u_core/d in PD_CORE (on) with no active isolation");
end
if (openpa_sp[14]) begin
openpa_sp[14] = 1'b0;
if (openpa_x8_t) openpa_check(9, "media input en of PD_TOP (off) is read by u_core/en in PD_CORE (on) with no active isolation");
end
if (openpa_sp[15]) begin
openpa_sp[15] = 1'b0;
if (openpa_x9_t) openpa_check(9, "media input rst_n of PD_TOP (off) is read by u_core/rst_n in PD_CORE (on) with no active isolation");
end
if (openpa_sp[16]) begin
openpa_sp[16] = 1'b0;
if (openpa_x10_t) openpa_check(9, "media input clk of PD_TOP (off) is read by u_dsp/clk in PD_DSP (on) with no active isolation");
end
if (openpa_sp[17]) begin
openpa_sp[17] = 1'b0;
if (openpa_x11_t) openpa_check(9, "media input d of PD_TOP (off) is read by u_dsp/d in PD_DSP (on) with no active isolation");
end
if (openpa_sp[18]) begin
openpa_sp[18] = 1'b0;
if (openpa_x12_t) openpa_check(9, "media input en of PD_TOP (off) is read by u_dsp/en in PD_DSP (on) with no active isolation");
end
if (openpa_sp[19]) begin
openpa_sp[19] = 1'b0;
if (openpa_x13_t) openpa_check(9, "media input rst_n of PD_TOP (off) is read by u_dsp/rst_n in PD_DSP (on) with no active isolation");
end
if (openpa_sp[20]) begin
openpa_sp[20] = 1'b0;
if (openpa_l1_t) openpa_check(11, $sformatf("PD_CORE (%0d uV) drives PD_TOP (%0d uV) on 3 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_CORE.voltage, UPF::openpa_net_VDD_N.voltage));
end
if (openpa_sp[21]) begin
openpa_sp[21] = 1'b0;
if (openpa_l2_t) openpa_check(11, $sformatf("PD_DSP (%0d uV) drives PD_TOP (%0d uV) on 2 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_DSP.voltage, UPF::openpa_net_VDD_N.voltage));
end
if (openpa_sp[22]) begin
openpa_sp[22] = 1'b0;
if (openpa_l3_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_CORE (%0d uV) on 4 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_CORE.voltage));
end
if (openpa_sp[23]) begin
openpa_sp[23] = 1'b0;
if (openpa_l4_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_DSP (%0d uV) on 4 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_DSP.voltage));
end
if (openpa_sp[24]) begin
openpa_sp[24] = 1'b0;
if (UPF::openpa_sw_SW_CORE_st != -1) openpa_SW_CORE_def = 1'b1; else if (openpa_SW_CORE_def) openpa_check(10, "power switch SW_CORE is undetermined: a control is X, or no state (or more than one) holds (media.upf:20)");
end
if (openpa_sp[25]) begin
openpa_sp[25] = 1'b0;
if (UPF::openpa_sw_SW_DSP_st != -1) openpa_SW_DSP_def = 1'b1; else if (openpa_SW_DSP_def) openpa_check(10, "power switch SW_DSP is undetermined: a control is X, or no state (or more than one) holds (media.upf:22)");
end
if (openpa_sp[26]) begin
openpa_sp[26] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_CORE_ok || UPF::openpa_dom_PD_DSP_ok)) openpa_check(12, "pwr_core (switch SW_CORE) 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_CORE_ok || UPF::openpa_dom_PD_DSP_ok)) openpa_check(12, "pwr_dsp (switch SW_DSP) 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_CORE_ok || UPF::openpa_dom_PD_DSP_ok)) openpa_check(12, "iso_core (isolation ISO_CORE) comes from PD_TOP, which is off while other domains are on");
end
if (openpa_sp[29]) begin
openpa_sp[29] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_CORE_ok || UPF::openpa_dom_PD_DSP_ok)) openpa_check(12, "iso_dsp (isolation ISO_DSP) comes from PD_TOP, which is off while other domains are on");
end
end
final begin
$display("OPENPA-SUMMARY D1=%0d D2=%0d D3=%0d D4=%0d D5=%0d D6=%0d D7=%0d D8=%0d D9=%0d D10=%0d D11=%0d D12=%0d D13=%0d D14=%0d", openpa_n[1], openpa_n[2], openpa_n[3], openpa_n[4], openpa_n[5], openpa_n[6], openpa_n[7], openpa_n[8], openpa_n[9], openpa_n[10], openpa_n[11], openpa_n[12], openpa_n[13], openpa_n[14]);
openpa_cover_report();
if (!UPF::openpa_armed) $display("OPENPA-WARNING no supply was driven (supply_on/supply_off never called): every domain stayed CORRUPT");
if (!openpa_SW_CORE_def) $display("OPENPA-WARNING power switch SW_CORE never reached a defined state");
if (!openpa_SW_DSP_def) $display("OPENPA-WARNING power switch SW_DSP never reached a defined state");
end
// verilator lint_on MULTIDRIVEN
`line 21 "media.sv" 0
endmodule
`line 1 "core.sv" 0
// core: an accumulator and a watchdog tick counter.
module core (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
output logic [7:0] q,
output logic [7:0] ticks
);
acc u_alu (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(q));
tick u_wdt (.clk(clk), .rst_n(rst_n), .q(ticks));
endmodule
`line 1 "dsp.sv" 0
// dsp: one accumulator fed with d + 1.
module dsp (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
output logic [7:0] q
);
acc u_mac (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd1), .q(q));
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
`line 1 "tick.sv" 0
// tick: counts every clock edge.
module tick (
input logic clk,
input logic rst_n,
output logic [7:0] q
);
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) q <= '0;
else q <= q + 8'd1;
endmodule
Check Yourself
Common Mistakes
Wrong List only the switchable blocks, and leave the design top out.
Every instance, the top included, must be in exactly one domain (IEEE 1801-2024 6.21). The file is refused.
Fix Give the top its own domain with -elements {.}.
Wrong List every child of a block instead of the block itself.
The block's own logic and registers then stay in the parent's domain. They keep power when the children lose it.
Fix List the block. Its children follow it unless another domain claims them.
Wrong Write a strategy for a domain after it was merged.
The merged domains can no longer be named (UPF 1.0 6.20). OpenPA refuses the old name.
Fix Write strategies for the parts before the merge, or for the merged domain after it.
Remember
- A power domain is a set of instances that share a primary supply. Each instance is in exactly one domain.
- Each instance in -elements brings its children, unless another domain claims them.
- -elements {.} puts the current scope, often the design top, in the domain. UPF 1.0 wrote -include_scope.
- The boundary is at the ports of each boundary instance. Strategies place their cells there.
- Grow a domain with -update; merge domains on a shared supply with merge_power_domains, strategies first.