Scope and Names: set_scope, load_upf and find_objects
Every name in a UPF file is read from a current scope. Move that scope, run a block's file inside an instance, and know which name a tool will look for.
You Will Be Able To
- Predict the current scope after each set_scope line, including ., .. and /.
- Name an object created in another scope from the top, and say why a simple name fails.
- Apply a block's own UPF file inside an instance with load_upf -scope, and wire its supply ports from the top.
- Describe what find_objects, name_format and save_upf do, and which of them change a simulation.
- Lesson
- W4.2
- Time
- 25 min
- Runs on
- Your browser
- Check
- 6 questions
One line, two meanings. The same create_power_domain PD_CPU0 -elements {u_cpu0} is right inside u_cluster and wrong at the top:
soc.upf:12: create_power_domain PD_CPU0 -elements: no instance "u_cpu0" under scope "soc"UPF reads every name from a current scope, like a shell reads a path from its current directory.
The Current Scope and set_scope
A UPF file starts with the design top as its current scope. set_scope moves it to an instance (IEEE 1801-2024 6.55). It returns the scope it left.
- Design
- Processor
- Structure
- Start
The current scope is the design top, soc.
- set_scope u_cluster
A simple name: a child of the current scope.
- set_scope u_cpu0
Again a child of the current scope, now u_cluster.
- set_scope ..
Up one level, to u_cluster.
- set_scope /
Straight back to the design top, from anywhere.
Read the diagram as text
- soc: design top
- u_cluster: module cluster
- u_cpu0: module cpu
- u_cpu1: module cpu
- soc → u_cluster
- u_cluster → u_cpu0
- u_cluster → u_cpu1
set_scope u_cluster/u_cpu0 would reach u_cpu0 in one step: a path relative to the current scope.
| Argument | New current scope | Rule (6.55) |
|---|---|---|
u_cluster | the child u_cluster | a simple name, looked up in the current scope |
u_cluster/u_cpu0 | two levels down | a path relative to the current scope |
. | unchanged | the current scope itself |
.. | the parent | an error at the design top |
/ | the design top | from anywhere |
A leaf cell instance cannot become the scope, except in a late phase of processing (6.55, 8.3.6).
At the design top there is no parent. OpenPA refuses set_scope .. there:
soc.upf:12: set_scope ..: already at the design topA path names the same instance as a move does. These lines put u_cpu1 in its own domain from two levels deep:
set_scope u_cluster/u_cpu0
set_scope ..
create_power_domain PD_CPU1 -elements {u_cpu1}
set_scope /Power domains
PD_TOP (soc.upf:4): soc, u_cluster, u_cluster/u_cpu0
primary supply PD_TOP.primary: power VDD_N, ground VSS_N
2 register(s): u_cluster.sum, u_cluster.u_cpu0.acc; 0 memory(ies)
PD_CPU1 (soc.upf:14): u_cluster/u_cpu1
primary supply PD_CPU1.primary: power PD_CPU1.primary.power, ground PD_CPU1.primary.ground
1 register(s): u_cluster.u_cpu1.acc; 0 memory(ies)Names Belong to the Scope That Made Them
A name without a / is a simple name. For the instances and domains here, it is looked up in the current scope (IEEE 1801-2024 5.3.3.2). A hierarchical name without a leading / starts at the current scope (5.3.3.4).
This matters for UPF objects too. A domain made while the scope is u_cluster lives in u_cluster. From the top it is u_cluster/PD_CPU0.
set_scope u_cluster
create_power_domain PD_CPU0 -elements {u_cpu0}
create_power_domain PD_CPU1 -elements {u_cpu1}
set_scope ..
# Back at the top: a domain made in u_cluster is named u_cluster/PD_CPU0 here
set_domain_supply_net u_cluster/PD_CPU0 -primary_power_net VDD_C0 -primary_ground_net VSS_NWrite the simple name at the top instead, and the domain is not found:
PD_CPU0 in place of u_cluster/PD_CPU0 (recorded).soc.upf:28: no power domain "PD_CPU0"Power domains
PD_TOP (soc.upf:4): soc, u_cluster
primary supply PD_TOP.primary: power VDD_N, ground VSS_N
1 register(s): u_cluster.sum; 0 memory(ies)
PD_CPU0 (soc.upf:23): u_cluster/u_cpu0
primary supply PD_CPU0.primary: power VDD_C0, ground VSS_N [switchable]
1 register(s): u_cluster.u_cpu0.acc; 0 memory(ies)
PD_CPU1 (soc.upf:24): u_cluster/u_cpu1
primary supply PD_CPU1.primary: power VDD_C1, ground VSS_N [switchable]
1 register(s): u_cluster.u_cpu1.acc; 0 memory(ies)| Rule | Source |
|---|---|
A UPF identifier starts with a letter, then letters, digits or _. | IEEE 1801-2024 5.3.2 |
| Names are case-sensitive: PD_CPU0 and pd_cpu0 differ. | IEEE 1801-2024 5.3.2 |
| A UPF object must not take the name of an instance or a port in the same scope. | 5.3.3.2 |
A design-relative name starts with / and is read from the design top. Few commands accept it. | IEEE 1801-2024 5.3.3.4, 5.3.3.5 |
Rules for UPF object identifiers and name references. HDL names can contain other characters (5.3.3.1).
load_upf: A Block's File, Run Inside an Instance
A block team writes its UPF from inside its own module. The names in it start at the block: VDD, u_cpu0, iso0. load_upf -scope runs that file inside an instance (6.35).
The -scope names must start in the current scope: a simple instance name or a rooted path. A leading / is not allowed (6.35).
- File
- Processor
- Structure
- Enter
The current scope and the design top become the instance.
- Run
Every command in the file runs there. Its PD_CPU and VDD are made inside u_cpu0.
- Return
The scope and the design top go back. The second load does the same in u_cpu1.
Read the diagram as text
- soc.upf: top file
- cpu.upf: names start at a cpu
- u_cluster/u_cpu0: PD_CPU, VDD, VSS
- u_cluster/u_cpu1: PD_CPU, VDD, VSS
- soc.upf → cpu.upf: load_upf -scope
- cpu.upf → u_cluster/u_cpu0
- cpu.upf → u_cluster/u_cpu1
IEEE 1801-2024 6.35: the current scope, design top instance and design top module are set for the file, then restored.
# Power intent of module cpu: one domain on the cpu's own supply ports.
create_power_domain PD_CPU -include_scope
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_CPU -primary_power_net VDD_N -primary_ground_net VSS_N# One file, run once inside each CPU
load_upf cpu.upf -scope u_cluster/u_cpu0
load_upf cpu.upf -scope u_cluster/u_cpu1
connect_supply_net VDD_C0 -ports {u_cluster/u_cpu0/VDD}
connect_supply_net VDD_C1 -ports {u_cluster/u_cpu1/VDD}
connect_supply_net VSS_N -ports {u_cluster/u_cpu0/VSS u_cluster/u_cpu1/VSS}Power domains
PD_TOP (soc.upf:4): soc, u_cluster
primary supply PD_TOP.primary: power VDD_N, ground VSS_N
1 register(s): u_cluster.sum; 0 memory(ies)
PD_CPU (cpu.upf:2): u_cluster/u_cpu0
primary supply PD_CPU.primary: power VDD_C0, ground VSS_N [switchable]
1 register(s): u_cluster.u_cpu0.acc; 0 memory(ies)
PD_CPU (cpu.upf:2): u_cluster/u_cpu1
primary supply PD_CPU.primary: power VDD_C1, ground VSS_N [switchable]
1 register(s): u_cluster.u_cpu1.acc; 0 memory(ies)Both domains are called PD_CPU, and that is fine: each lives in its own instance. From the top they are u_cluster/u_cpu0/PD_CPU and u_cluster/u_cpu1/PD_CPU.
The standard makes a second load into the same instance an error (6.35). OpenPA reports the clash:
cpu.upf:2: create_power_domain PD_CPU: already created at line 2Without -scope, load_upf runs the file in the current scope and changes nothing else. That is the same as the Tcl source command, which OpenPA refuses (W4.1).
find_objects, name_format and save_upf
find_objects searches the design below a scope and returns a list of names (6.33). It is the only way a UPF file may read the design from Tcl (5.1). The list can feed -elements.
| Option | Meaning (6.33) | Default |
|---|---|---|
| scope (first argument) | where the search starts: . or a scope below the current one | required |
-pattern | the names to match (a Tcl glob pattern unless changed) | required |
-object_type | model, inst, port, supply_port, net or process | instances, processes, ports and nets |
-direction | in, out or inout, for ports and supply ports | every direction |
-transitive | also search every scope below | FALSE; the bare flag means TRUE |
-regexp or -exact | read the pattern as a regular expression, or literally | glob |
-ignore_case | match without case | case-sensitive |
-leaf_only or -non_leaf | keep only leaf, or only non-leaf, objects | both |
-traverse_macros | search through hard, soft and refinable macros too (implies -transitive) | stop at leaf cells |
-expand_to_bits | list each bit of a multi-bit port or net (6.33) | whole objects |
Names come back relative to the current scope. Nothing found gives an empty string.
| Query, run at the top of soc (drawn) | Result |
|---|---|
find_objects u_cluster -pattern u_cpu* -object_type inst | u_cluster/u_cpu0 u_cluster/u_cpu1 |
find_objects . -pattern u_cpu* -object_type inst | empty: the top has no u_cpu instance, and the search is not transitive |
find_objects . -pattern u_cpu* -object_type inst -transitive | u_cluster/u_cpu0 u_cluster/u_cpu1 |
Drawn from the rules of 6.33 for the soc hierarchy of this page. Not an OpenPA run.
soc.upf:12: find_objects is not supported (IEEE 1801-2024 6.33); list the objects by namename_format sets how a tool names the objects it creates, such as isolation cells (6.41). The defaults are the suffixes _UPF_ISO for isolation and _UPF_LS for level shifters.
save_upf file -scope inst writes the power intent of a scope back out as UPF (6.42). It is the same as moving there with set_scope, saving, and moving back.
Notes (4)
soc.upf:36: name_format is recorded with no effect in simulation: names of inserted objects (6.41); OpenPA names its cells itself (pa_map.json)
soc.upf:37: save_upf is recorded with no effect in simulation: writes the UPF back (6.42); OpenPA writes pa_map.json and pa_report.txt insteadAsked in interviews
What is the current scope in UPF?
The instance from which names are read. It starts at the design top. set_scope moves it, and load_upf -scope moves it for one file and then restores it.
Why use load_upf -scope instead of writing everything at the top?
A block team can write its file once, from inside its own module. The integrator runs it inside each instance and wires its supply ports from the top.
How does find_objects help?
It builds element lists from the design by pattern, so a file need not list every instance by hand. It is the only design query UPF allows from Tcl.
Try It
Run it. Both CPUs count. Then the bench raises iso1 and switches u_cpu1 off.
Read the line cpu1 off cpu0.acc=20 cpu1.acc=xx q1=0 sum=21. u_cpu1's accumulator is X, and its output q1 reads the clamp value 0.
Open What UPF added. Each isolation cell points to its UPF line. The domains themselves were made on the two lines after set_scope u_cluster.
Change the bench to switch u_cpu0 off instead. Predict which register goes to X, then run.
OPENPA-INFO corruption=x seed=1 both run cpu0.acc=20 cpu1.acc=22 q1=22 sum=21 cpu1 off cpu0.acc=20 cpu1.acc=xx q1=0 sum=21 one beat cpu0.acc=25 cpu1.acc=xx q1=0 sum=25 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 ISO0: PD_CPU0 isolated before power-down 0 OPENPA-COVER sequence D2/D7 ISO0: isolation released only after PD_CPU0 was back and reset 0 OPENPA-COVER sequence D1 ISO1: PD_CPU1 isolated before power-down 1 OPENPA-COVER sequence D2/D7 ISO1: isolation released only after PD_CPU1 was back and reset 0 OPENPA-COVER-SUMMARY states=0/0 declared_transitions=0/0 sequences=1/4Read the power intent: soc.upf
upf_version 4.0
set_design_top soc
create_power_domain PD_TOP -include_scope
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
# Supplies for the two CPUs live at the top
create_supply_net VDD_C0
create_supply_net VDD_C1
create_power_switch SW0 -domain PD_TOP -input_supply_port {i VDD_N} -output_supply_port {o VDD_C0} \
-control_port {c pwr0} -on_state {on i {c}} -off_state {off {!c}}
create_power_switch SW1 -domain PD_TOP -input_supply_port {i VDD_N} -output_supply_port {o VDD_C1} \
-control_port {c pwr1} -on_state {on i {c}} -off_state {off {!c}}
# The CPU domains, named from inside the cluster
set_scope u_cluster
create_power_domain PD_CPU0 -elements {u_cpu0}
create_power_domain PD_CPU1 -elements {u_cpu1}
set_scope ..
# Back at the top: a domain made in u_cluster is named u_cluster/PD_CPU0 here
set_domain_supply_net u_cluster/PD_CPU0 -primary_power_net VDD_C0 -primary_ground_net VSS_N
set_domain_supply_net u_cluster/PD_CPU1 -primary_power_net VDD_C1 -primary_ground_net VSS_N
set_isolation ISO0 -domain u_cluster/PD_CPU0 -applies_to outputs -clamp_value 0 \
-isolation_power_net VDD_N -isolation_ground_net VSS_N \
-isolation_signal iso0 -isolation_sense high -location parent
set_isolation ISO1 -domain u_cluster/PD_CPU1 -applies_to outputs -clamp_value 0 \
-isolation_power_net VDD_N -isolation_ground_net VSS_N \
-isolation_signal iso1 -isolation_sense high -location parent
Read the power-unaware RTL: soc.sv
// soc: an always-on top around a cluster of two CPUs. Power-unaware RTL.
module soc (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr0,
input logic pwr1,
input logic iso0,
input logic iso1,
output logic [7:0] q0,
output logic [7:0] q1,
output logic [7:0] sum
);
cluster u_cluster (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .pwr0(pwr0), .pwr1(pwr1),
.iso0(iso0), .iso1(iso1), .q0(q0), .q1(q1), .sum(sum));
endmodule
Read the power-unaware RTL: cluster.sv
// cluster: two identical CPUs and an always-on sum register. The power controls pass through.
module cluster (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr0,
input logic pwr1,
input logic iso0,
input logic iso1,
output logic [7:0] q0,
output logic [7:0] q1,
output logic [7:0] sum
);
cpu u_cpu0 (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(q0));
cpu u_cpu1 (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd1), .q(q1));
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) sum <= '0;
else sum <= q0 + q1;
endmodule
Read the power-unaware RTL: cpu.sv
// cpu: an 8-bit accumulator. Power-unaware RTL.
module cpu (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
output logic [7:0] q
);
logic [7:0] acc;
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) acc <= '0;
else if (en) acc <= acc + d;
assign q = acc;
endmodule
What UPF added: 45 objects
2 supply port, 4 supply net, 10 output corruption, 2 isolation cell, 2 power switch, 4 supply set, 3 register corruption, 18 dynamic check.
| Object | Where | Detail | Rule | UPF line |
|---|---|---|---|---|
| Supply port | VDD | soc.upf:5 | ||
| Supply port | VSS | soc.upf:6 | ||
| Supply net | VDD_N | soc.upf:5 | ||
| Supply net | VSS_N | soc.upf:6 | ||
| Supply net | VDD_C0 | soc.upf:16 | ||
| Supply net | VDD_C1 | soc.upf:18 | ||
| Output corruption | u_cluster/u_cpu0/clk | folded away: it can never act where anything can see it | C2 | soc.upf:4 |
| Output corruption | u_cluster/u_cpu0/d | folded away: it can never act where anything can see it | C2 | soc.upf:4 |
| Output corruption | u_cluster/u_cpu0/en | folded away: it can never act where anything can see it | C2 | soc.upf:4 |
| Output corruption | u_cluster/u_cpu0/rst_n | folded away: it can never act where anything can see it | C2 | soc.upf:4 |
| Output corruption | u_cluster/u_cpu1/clk | folded away: it can never act where anything can see it | C2 | soc.upf:4 |
| Output corruption | u_cluster/u_cpu1/d | folded away: it can never act where anything can see it | C2 | soc.upf:4 |
| Output corruption | u_cluster/u_cpu1/en | folded away: it can never act where anything can see it | C2 | soc.upf:4 |
| Output corruption | u_cluster/u_cpu1/rst_n | folded away: it can never act where anything can see it | C2 | soc.upf:4 |
| Output corruption | u_cluster/u_cpu0/q | C2 | soc.upf:23 | |
| Isolation cell | u_cluster/u_cpu0/q | ISO0 · clamp 0 | I1-I5 | soc.upf:30 |
| Output corruption | u_cluster/u_cpu1/q | C2 | soc.upf:24 | |
| Isolation cell | u_cluster/u_cpu1/q | ISO1 · clamp 0 | I1-I5 | soc.upf:33 |
| Power switch | SW0 | S3 (IEEE 1801-2024 6.23) | soc.upf:16 | |
| Power switch | SW1 | S3 (IEEE 1801-2024 6.23) | soc.upf:18 | |
| Supply set | PD_TOP.primary | soc.upf:4 | ||
| Supply set | PD_CPU0.primary | soc.upf:23 | ||
| Supply set | PD_CPU1.primary | soc.upf:24 | ||
| Supply set | {VDD_N VSS_N} | soc.upf:31 | ||
| Register corruption | u_cluster.sum | C1 | soc.upf:4 | |
| Register corruption | u_cluster.u_cpu0.acc | C1 | soc.upf:23 | |
| Register corruption | u_cluster.u_cpu1.acc | C1 | soc.upf:24 | |
| Dynamic check | D1/D2/D7/D6 ISO0 | D1, D2, D7, D6 | soc.upf:30 | |
| Dynamic check | D1/D2/D7/D6 ISO1 | D1, D2, D7, D6 | soc.upf:33 | |
| Dynamic check | D9 crossing 1 | D9 | soc.upf:23 | |
| Dynamic check | D9 crossing 2 | D9 | soc.upf:23 | |
| Dynamic check | D9 crossing 3 | D9 | soc.upf:24 | |
| Dynamic check | D9 crossing 4 | D9 | soc.upf:24 | |
| Dynamic check | D9 crossing 5 | D9 | soc.upf:4 | |
| Dynamic check | D9 crossing 6 | D9 | soc.upf:4 | |
| Dynamic check | D9 crossing 7 | D9 | soc.upf:4 | |
| Dynamic check | D9 crossing 8 | D9 | soc.upf:4 | |
| Dynamic check | D9 crossing 9 | D9 | soc.upf:4 | |
| Dynamic check | D9 crossing 10 | D9 | soc.upf:4 | |
| Dynamic check | D9 crossing 11 | D9 | soc.upf:4 | |
| Dynamic check | D9 crossing 12 | D9 | soc.upf:4 | |
| Dynamic check | D11 PD_CPU0->PD_TOP | D11 | soc.upf:23 | |
| Dynamic check | D11 PD_CPU1->PD_TOP | D11 | soc.upf:24 | |
| Dynamic check | D11 PD_TOP->PD_CPU0 | D11 | soc.upf:4 | |
| Dynamic check | D11 PD_TOP->PD_CPU1 | D11 | soc.upf:4 |
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_soc.sv
// pa_soc.sv: power-aware copy of soc, generated by OpenPA from soc.upf.
// Do not edit: regenerate. Simulators: Icarus 12 (4-state, X corruption) or Verilator 5 with --timing (2-state).
// Build with -Wno-fatal on Verilator: forced registers raise MULTIDRIVEN warnings.
// ---------------------------------------------------------------------------
// package UPF: generated by OpenPA. Supply types, supply_on/supply_off and the power
// state of the design. Names starting with openpa_ are internal.
// ---------------------------------------------------------------------------
package UPF;
typedef string upfStringT; typedef int upfIntegerT; typedef bit upfBooleanT; typedef logic upfLogicT; typedef real upfRealT; typedef int upfHandleT;
typedef enum { OFF, FULL_ON, PARTIAL_ON, UNDETERMINED } upfSupplyStateE;
typedef struct packed { upfSupplyStateE state; int voltage; } upfSupplyTypeT; // voltage in microvolts
typedef upfSupplyTypeT supply_net_type;
bit openpa_armed; // set by the first call that drives a supply
bit openpa_kick; // pulsed once at time 0 to evaluate everything
bit openpa_xmode; // 1: corrupt to X; 0: seeded 2-state values
int unsigned openpa_seed = 1;
int openpa_cmode; // 2-state corruption: 0 random, 1 all zero, 2 all one
supply_net_type openpa_port_VDD; // supply port VDD (soc.upf:5)
supply_net_type openpa_port_VSS; // supply port VSS (soc.upf:6)
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_C0; // supply net VDD_C0
supply_net_type openpa_net_VDD_C1; // supply net VDD_C1
int openpa_sw_SW0_st = -1; // switch SW0: -1 undetermined, 0 off, k on-state k (soc.upf:16)
int openpa_sw_SW1_st = -1; // switch SW1: -1 undetermined, 0 off, k on-state k (soc.upf:18)
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_u_cluster_PD_CPU0_primary_ok; int unsigned openpa_ss_u_cluster_PD_CPU0_primary_ep; int openpa_ss_u_cluster_PD_CPU0_primary_st = -1; bit openpa_ss_u_cluster_PD_CPU0_primary_multi; int openpa_ss_u_cluster_PD_CPU0_primary_sim = 5; // supply set PD_CPU0.primary
bit openpa_ss_u_cluster_PD_CPU1_primary_ok; int unsigned openpa_ss_u_cluster_PD_CPU1_primary_ep; int openpa_ss_u_cluster_PD_CPU1_primary_st = -1; bit openpa_ss_u_cluster_PD_CPU1_primary_multi; int openpa_ss_u_cluster_PD_CPU1_primary_sim = 5; // supply set PD_CPU1.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 (soc.upf:4)
bit openpa_dom_u_cluster_PD_CPU0_ok; int unsigned openpa_dom_u_cluster_PD_CPU0_ep; int openpa_dom_u_cluster_PD_CPU0_sim = 5; // power domain PD_CPU0: ok = powered (simstate not CORRUPT); sim = simstate code (soc.upf:23)
bit openpa_dom_u_cluster_PD_CPU1_ok; int unsigned openpa_dom_u_cluster_PD_CPU1_ep; int openpa_dom_u_cluster_PD_CPU1_sim = 5; // power domain PD_CPU1: ok = powered (simstate not CORRUPT); sim = simstate code (soc.upf:24)
// simstate codes, by IEEE 1801-2024 4.8 precedence: 0 NORMAL, 1 CORRUPT_STATE_ON_CHANGE, 2 CORRUPT_STATE_ON_ACTIVITY,
// 3 CORRUPT_ON_CHANGE, 4 CORRUPT_ON_ACTIVITY, 5 CORRUPT (and NOT_NORMAL, 9.5.8); README "Simstates"
logic openpa_ctl_0_pwr0; // copy of pwr0 (switch SW0)
logic openpa_ctl_1_pwr1; // copy of pwr1 (switch SW1)
logic openpa_ctl_2_iso0; // copy of iso0 (isolation ISO0)
logic openpa_ctl_3_iso1; // copy of iso1 (isolation ISO1)
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_CPU0.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CPU0.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU1.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CPU1.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_C0") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_C0 already has a driver (switch SW0); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU0.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CPU0.primary.power already has a driver (switch SW0); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_C1") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_C1 already has a driver (switch SW1); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU1.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_CPU1.primary.power already has a driver (switch SW1); 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_CPU0.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CPU0.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU1.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CPU1.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_C0") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_C0 already has a driver (switch SW0); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU0.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CPU0.primary.power already has a driver (switch SW0); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_C1") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_C1 already has a driver (switch SW1); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU1.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_CPU1.primary.power already has a driver (switch SW1); 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_CPU0.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CPU0.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU1.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CPU1.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_C0") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_C0 already has a driver (switch SW0); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU0.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CPU0.primary.power already has a driver (switch SW0); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_C1") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_C1 already has a driver (switch SW1); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU1.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_CPU1.primary.power already has a driver (switch SW1); 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_CPU0.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CPU0.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU1.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CPU1.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_C0") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_C0 already has a driver (switch SW0); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU0.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CPU0.primary.power already has a driver (switch SW0); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_C1") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_C1 already has a driver (switch SW1); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_CPU1.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_CPU1.primary.power already has a driver (switch SW1); 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_CPU0.primary.ground" || name == "PD_CPU1.primary.ground") return openpa_net_VSS_N;
if (name == "VDD_C0" || name == "PD_CPU0.primary.power") return openpa_net_VDD_C0;
if (name == "VDD_C1" || name == "PD_CPU1.primary.power") return openpa_net_VDD_C1;
$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 "soc.sv" 0
// soc: an always-on top around a cluster of two CPUs. Power-unaware RTL.
module soc (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr0,
input logic pwr1,
input logic iso0,
input logic iso1,
output logic [7:0] q0,
output logic [7:0] q1,
output logic [7:0] sum
);
cluster u_cluster (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .pwr0(pwr0), .pwr1(pwr1),
.iso0(iso0), .iso1(iso1), .q0(q0), .q1(q1), .sum(sum));
`line 1 "openpa_overlay.sv" 0
// ===================================================================================
// OpenPA overlay for soc: generated from soc.upf. Do not edit.
// ===================================================================================
// verilator lint_off MULTIDRIVEN
// verilator lint_off ENUMVALUE
// verilator lint_off WIDTHTRUNC
// verilator lint_off WIDTHEXPAND
// verilator lint_off BLKSEQ
// verilator lint_off IGNOREDRETURN
import UPF::openpa_cmode;
import UPF::openpa_ctl_0_pwr0;
import UPF::openpa_ctl_1_pwr1;
import UPF::openpa_ctl_2_iso0;
import UPF::openpa_ctl_3_iso1;
import UPF::openpa_dom_PD_TOP_ep;
import UPF::openpa_dom_PD_TOP_ok;
import UPF::openpa_dom_PD_TOP_sim;
import UPF::openpa_dom_u_cluster_PD_CPU0_ep;
import UPF::openpa_dom_u_cluster_PD_CPU0_ok;
import UPF::openpa_dom_u_cluster_PD_CPU0_sim;
import UPF::openpa_dom_u_cluster_PD_CPU1_ep;
import UPF::openpa_dom_u_cluster_PD_CPU1_ok;
import UPF::openpa_dom_u_cluster_PD_CPU1_sim;
import UPF::openpa_kick;
import UPF::openpa_net_VDD_C0;
import UPF::openpa_net_VDD_C1;
import UPF::openpa_net_VDD_N;
import UPF::openpa_net_VSS_N;
import UPF::openpa_seed;
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_ss_u_cluster_PD_CPU0_primary_ep;
import UPF::openpa_ss_u_cluster_PD_CPU0_primary_multi;
import UPF::openpa_ss_u_cluster_PD_CPU0_primary_ok;
import UPF::openpa_ss_u_cluster_PD_CPU0_primary_sim;
import UPF::openpa_ss_u_cluster_PD_CPU0_primary_st;
import UPF::openpa_ss_u_cluster_PD_CPU1_primary_ep;
import UPF::openpa_ss_u_cluster_PD_CPU1_primary_multi;
import UPF::openpa_ss_u_cluster_PD_CPU1_primary_ok;
import UPF::openpa_ss_u_cluster_PD_CPU1_primary_sim;
import UPF::openpa_ss_u_cluster_PD_CPU1_primary_st;
import UPF::openpa_sw_SW0_st;
import UPF::openpa_sw_SW1_st;
import UPF::openpa_xmode;
// ---- mode, seed, trace
bit openpa_tr, openpa_obs;
int openpa_n [1:14];
int openpa_seq [1:4]; // good-form sequence bins (coverage)
bit openpa_sreq; bit openpa_sp [1:28]; // deferred checks: request and pending flags
string openpa_mode_arg;
initial begin
`ifdef VERILATOR
openpa_xmode = 1'b0;
`else
openpa_xmode = 1'b1;
`endif
openpa_cmode = 0;
if ($value$plusargs("openpa_corrupt=%s", openpa_mode_arg)) begin
if (openpa_mode_arg == "x") openpa_xmode = 1'b1;
else if (openpa_mode_arg == "random") openpa_xmode = 1'b0;
else if (openpa_mode_arg == "zero") begin openpa_xmode = 1'b0; openpa_cmode = 1; end
else if (openpa_mode_arg == "one") begin openpa_xmode = 1'b0; openpa_cmode = 2; end
else $display("OPENPA-ERROR +openpa_corrupt=%s: use x, random, zero or one", openpa_mode_arg);
end
if (!$value$plusargs("openpa_seed=%d", openpa_seed)) openpa_seed = 1;
openpa_tr = $test$plusargs("openpa_trace");
openpa_obs = $test$plusargs("openpa_obs");
$display("OPENPA-INFO corruption=%0s seed=%0d", openpa_xmode ? "x" : (openpa_cmode == 1 ? "zero" : openpa_cmode == 2 ? "one" : "random"), openpa_seed);
#0 openpa_kick = 1'b1;
end
task automatic openpa_check(input int id, input string msg);
openpa_n[id] = openpa_n[id] + 1;
$display("OPENPA-CHECK D%0d @ %0t: %s", id, $time, msg);
endtask
task automatic openpa_t(input string msg);
if (openpa_tr) $display("OPENPA-TRACE @ %0t: %s", $time, msg);
endtask
// ---- copies of the design signals the UPF names (4-state, so X is visible)
always @(pwr0 or openpa_kick) openpa_ctl_0_pwr0 = pwr0;
always @(pwr1 or openpa_kick) openpa_ctl_1_pwr1 = pwr1;
always @(iso0 or openpa_kick) openpa_ctl_2_iso0 = iso0;
always @(iso1 or openpa_kick) openpa_ctl_3_iso1 = iso1;
// ---- supply network, switches, supply sets, simstates, power states (one block, evaluated in order)
bit openpa_tg_sw_SW0_st; int openpa_pv_sw_SW0_st = -2;
bit openpa_tg_sw_SW1_st; int openpa_pv_sw_SW1_st = -2;
UPF::supply_net_type openpa_swv_SW0_f, openpa_swv_SW0_p; bit openpa_swv_SW0_u, openpa_swv_SW0_hf, openpa_swv_SW0_hp, openpa_swv_SW0_vd, openpa_swv_SW0_on, openpa_swv_SW0_pt; int openpa_swv_SW0_k; // switch SW0
UPF::supply_net_type openpa_swv_SW1_f, openpa_swv_SW1_p; bit openpa_swv_SW1_u, openpa_swv_SW1_hf, openpa_swv_SW1_hp, openpa_swv_SW1_vd, openpa_swv_SW1_on, openpa_swv_SW1_pt; int openpa_swv_SW1_k; // switch SW1
always @(openpa_kick or UPF::openpa_port_VDD or UPF::openpa_port_VSS or UPF::openpa_ctl_0_pwr0 or UPF::openpa_ctl_1_pwr1) 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 SW0 (soc.upf:16): IEEE 1801-2024 6.23
openpa_swv_SW0_u = 1'b0; openpa_swv_SW0_hf = 1'b0; openpa_swv_SW0_hp = 1'b0; openpa_swv_SW0_vd = 1'b0; openpa_swv_SW0_on = 1'b0; openpa_swv_SW0_pt = 1'b0; openpa_swv_SW0_k = 0;
if (($isunknown(openpa_ctl_0_pwr0)) && UPF::openpa_net_VDD_N.state != UPF::OFF) openpa_swv_SW0_u = 1'b1; // on state on: a control is X or Z
else if ((openpa_ctl_0_pwr0 === 1'b1)) begin
if (!openpa_swv_SW0_on) openpa_swv_SW0_k = 1;
openpa_swv_SW0_on = 1'b1;
if (UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED) openpa_swv_SW0_u = 1'b1;
else if (UPF::openpa_net_VDD_N.state == UPF::FULL_ON) begin
if ((openpa_swv_SW0_hf && openpa_swv_SW0_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW0_hp && openpa_swv_SW0_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW0_vd = 1'b1;
openpa_swv_SW0_f = UPF::openpa_net_VDD_N; openpa_swv_SW0_hf = 1'b1;
end
else if (UPF::openpa_net_VDD_N.state == UPF::PARTIAL_ON) begin
if ((openpa_swv_SW0_hf && openpa_swv_SW0_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW0_hp && openpa_swv_SW0_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW0_vd = 1'b1;
openpa_swv_SW0_p = UPF::openpa_net_VDD_N; openpa_swv_SW0_hp = 1'b1;
end
end
if ((1'b0) || (((!((openpa_ctl_0_pwr0 === 1'b1)))) && (openpa_swv_SW0_on || openpa_swv_SW0_pt)) || openpa_swv_SW0_u || openpa_swv_SW0_vd || (!($isunknown(openpa_ctl_0_pwr0)) && !openpa_swv_SW0_on && !openpa_swv_SW0_pt && !((!((openpa_ctl_0_pwr0 === 1'b1)))) && !(1'b0))) begin openpa_sw_SW0_st = -1; openpa_net_VDD_C0.state = UPF::UNDETERMINED; openpa_net_VDD_C0.voltage = 0; end
else begin openpa_sw_SW0_st = openpa_swv_SW0_k; if (openpa_swv_SW0_hf) openpa_net_VDD_C0 = openpa_swv_SW0_f; else if (openpa_swv_SW0_hp) openpa_net_VDD_C0 = openpa_swv_SW0_p; else begin openpa_net_VDD_C0.state = UPF::OFF; openpa_net_VDD_C0.voltage = 0; end end
// switch SW1 (soc.upf:18): IEEE 1801-2024 6.23
openpa_swv_SW1_u = 1'b0; openpa_swv_SW1_hf = 1'b0; openpa_swv_SW1_hp = 1'b0; openpa_swv_SW1_vd = 1'b0; openpa_swv_SW1_on = 1'b0; openpa_swv_SW1_pt = 1'b0; openpa_swv_SW1_k = 0;
if (($isunknown(openpa_ctl_1_pwr1)) && UPF::openpa_net_VDD_N.state != UPF::OFF) openpa_swv_SW1_u = 1'b1; // on state on: a control is X or Z
else if ((openpa_ctl_1_pwr1 === 1'b1)) begin
if (!openpa_swv_SW1_on) openpa_swv_SW1_k = 1;
openpa_swv_SW1_on = 1'b1;
if (UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED) openpa_swv_SW1_u = 1'b1;
else if (UPF::openpa_net_VDD_N.state == UPF::FULL_ON) begin
if ((openpa_swv_SW1_hf && openpa_swv_SW1_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW1_hp && openpa_swv_SW1_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW1_vd = 1'b1;
openpa_swv_SW1_f = UPF::openpa_net_VDD_N; openpa_swv_SW1_hf = 1'b1;
end
else if (UPF::openpa_net_VDD_N.state == UPF::PARTIAL_ON) begin
if ((openpa_swv_SW1_hf && openpa_swv_SW1_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW1_hp && openpa_swv_SW1_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW1_vd = 1'b1;
openpa_swv_SW1_p = UPF::openpa_net_VDD_N; openpa_swv_SW1_hp = 1'b1;
end
end
if ((1'b0) || (((!((openpa_ctl_1_pwr1 === 1'b1)))) && (openpa_swv_SW1_on || openpa_swv_SW1_pt)) || openpa_swv_SW1_u || openpa_swv_SW1_vd || (!($isunknown(openpa_ctl_1_pwr1)) && !openpa_swv_SW1_on && !openpa_swv_SW1_pt && !((!((openpa_ctl_1_pwr1 === 1'b1)))) && !(1'b0))) begin openpa_sw_SW1_st = -1; openpa_net_VDD_C1.state = UPF::UNDETERMINED; openpa_net_VDD_C1.voltage = 0; end
else begin openpa_sw_SW1_st = openpa_swv_SW1_k; if (openpa_swv_SW1_hf) openpa_net_VDD_C1 = openpa_swv_SW1_f; else if (openpa_swv_SW1_hp) openpa_net_VDD_C1 = openpa_swv_SW1_p; else begin openpa_net_VDD_C1.state = UPF::OFF; openpa_net_VDD_C1.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_CPU0.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_u_cluster_PD_CPU0_primary
bit nx; int sm;
sm = (UPF::openpa_net_VDD_C0.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_u_cluster_PD_CPU0_primary_sim = sm;
nx = sm < 5;
if (openpa_ss_u_cluster_PD_CPU0_primary_ok && !nx) openpa_ss_u_cluster_PD_CPU0_primary_ep = openpa_ss_u_cluster_PD_CPU0_primary_ep + 1;
openpa_ss_u_cluster_PD_CPU0_primary_ok = nx;
end
// supply set PD_CPU1.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_u_cluster_PD_CPU1_primary
bit nx; int sm;
sm = (UPF::openpa_net_VDD_C1.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_u_cluster_PD_CPU1_primary_sim = sm;
nx = sm < 5;
if (openpa_ss_u_cluster_PD_CPU1_primary_ok && !nx) openpa_ss_u_cluster_PD_CPU1_primary_ep = openpa_ss_u_cluster_PD_CPU1_primary_ep + 1;
openpa_ss_u_cluster_PD_CPU1_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_CPU0: simstate of its primary supply set PD_CPU0.primary
if (openpa_dom_u_cluster_PD_CPU0_ok && !UPF::openpa_ss_u_cluster_PD_CPU0_primary_ok) openpa_dom_u_cluster_PD_CPU0_ep = openpa_dom_u_cluster_PD_CPU0_ep + 1;
openpa_dom_u_cluster_PD_CPU0_ok = UPF::openpa_ss_u_cluster_PD_CPU0_primary_ok;
openpa_dom_u_cluster_PD_CPU0_sim = openpa_ss_u_cluster_PD_CPU0_primary_sim;
// domain PD_CPU1: simstate of its primary supply set PD_CPU1.primary
if (openpa_dom_u_cluster_PD_CPU1_ok && !UPF::openpa_ss_u_cluster_PD_CPU1_primary_ok) openpa_dom_u_cluster_PD_CPU1_ep = openpa_dom_u_cluster_PD_CPU1_ep + 1;
openpa_dom_u_cluster_PD_CPU1_ok = UPF::openpa_ss_u_cluster_PD_CPU1_primary_ok;
openpa_dom_u_cluster_PD_CPU1_sim = openpa_ss_u_cluster_PD_CPU1_primary_sim;
if (openpa_sw_SW0_st != openpa_pv_sw_SW0_st) begin openpa_tg_sw_SW0_st = ~openpa_tg_sw_SW0_st; openpa_pv_sw_SW0_st = openpa_sw_SW0_st; end
if (openpa_sw_SW1_st != openpa_pv_sw_SW1_st) begin openpa_tg_sw_SW1_st = ~openpa_tg_sw_SW1_st; openpa_pv_sw_SW1_st = openpa_sw_SW1_st; end
end
// ---- corruption: registers forced, memories overwritten (rules C1, C3)
// domain PD_TOP (soc.upf:4): 1 register(s), 0 memory(ies)
bit openpa_PD_TOP_applied, openpa_PD_TOP_valid;
logic [7:0] openpa_cv1; // corruption value for u_cluster.sum
// 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 u_cluster.sum = openpa_cv1;
end
if (UPF::openpa_dom_PD_TOP_ok) begin
release u_cluster.sum;
end
openpa_PD_TOP_valid = 1'b1; openpa_PD_TOP_applied = UPF::openpa_dom_PD_TOP_ok;
end
// domain PD_CPU0 (soc.upf:23): 1 register(s), 0 memory(ies)
bit openpa_u_cluster_PD_CPU0_applied, openpa_u_cluster_PD_CPU0_valid;
logic [7:0] openpa_cv2; // corruption value for u_cluster.u_cpu0.acc
// The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
// supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
always @(UPF::openpa_dom_u_cluster_PD_CPU0_ok or openpa_kick) if (!openpa_u_cluster_PD_CPU0_valid || openpa_u_cluster_PD_CPU0_applied != UPF::openpa_dom_u_cluster_PD_CPU0_ok) begin
openpa_t({"PD_CPU0 ", UPF::openpa_dom_u_cluster_PD_CPU0_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_u_cluster_PD_CPU0_ok || !openpa_u_cluster_PD_CPU0_valid) begin
if (openpa_xmode) openpa_cv2 = 'x; else openpa_cv2 = UPF::openpa_mix(2, UPF::openpa_dom_u_cluster_PD_CPU0_ep, 0);
force u_cluster.u_cpu0.acc = openpa_cv2;
end
if (UPF::openpa_dom_u_cluster_PD_CPU0_ok) begin
release u_cluster.u_cpu0.acc;
end
openpa_u_cluster_PD_CPU0_valid = 1'b1; openpa_u_cluster_PD_CPU0_applied = UPF::openpa_dom_u_cluster_PD_CPU0_ok;
end
// domain PD_CPU1 (soc.upf:24): 1 register(s), 0 memory(ies)
bit openpa_u_cluster_PD_CPU1_applied, openpa_u_cluster_PD_CPU1_valid;
logic [7:0] openpa_cv3; // corruption value for u_cluster.u_cpu1.acc
// The first evaluation counts as a power-up from OFF: registers take the corruption value even when the
// supplies are already on at time 0 (rule C3), so 4-state and 2-state runs start alike.
always @(UPF::openpa_dom_u_cluster_PD_CPU1_ok or openpa_kick) if (!openpa_u_cluster_PD_CPU1_valid || openpa_u_cluster_PD_CPU1_applied != UPF::openpa_dom_u_cluster_PD_CPU1_ok) begin
openpa_t({"PD_CPU1 ", UPF::openpa_dom_u_cluster_PD_CPU1_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_u_cluster_PD_CPU1_ok || !openpa_u_cluster_PD_CPU1_valid) begin
if (openpa_xmode) openpa_cv3 = 'x; else openpa_cv3 = UPF::openpa_mix(3, UPF::openpa_dom_u_cluster_PD_CPU1_ep, 0);
force u_cluster.u_cpu1.acc = openpa_cv3;
end
if (UPF::openpa_dom_u_cluster_PD_CPU1_ok) begin
release u_cluster.u_cpu1.acc;
end
openpa_u_cluster_PD_CPU1_valid = 1'b1; openpa_u_cluster_PD_CPU1_applied = UPF::openpa_dom_u_cluster_PD_CPU1_ok;
end
// D7 reset check for PD_CPU0: resets u_cluster.u_cpu0.rst_n active 0
bit openpa_u_cluster_PD_CPU0_rprev, openpa_u_cluster_PD_CPU0_rp0;
always @(posedge UPF::openpa_dom_u_cluster_PD_CPU0_ok or negedge UPF::openpa_dom_u_cluster_PD_CPU0_ok or posedge u_cluster.u_cpu0.rst_n or negedge u_cluster.u_cpu0.rst_n) begin
if (UPF::openpa_dom_u_cluster_PD_CPU0_ok && !openpa_u_cluster_PD_CPU0_rprev) openpa_u_cluster_PD_CPU0_rp0 = 1'b1;
if (!UPF::openpa_dom_u_cluster_PD_CPU0_ok || u_cluster.u_cpu0.rst_n === 1'b0) openpa_u_cluster_PD_CPU0_rp0 = 1'b0;
openpa_u_cluster_PD_CPU0_rprev = UPF::openpa_dom_u_cluster_PD_CPU0_ok;
end
// D7 reset check for PD_CPU1: resets u_cluster.u_cpu1.rst_n active 0
bit openpa_u_cluster_PD_CPU1_rprev, openpa_u_cluster_PD_CPU1_rp0;
always @(posedge UPF::openpa_dom_u_cluster_PD_CPU1_ok or negedge UPF::openpa_dom_u_cluster_PD_CPU1_ok or posedge u_cluster.u_cpu1.rst_n or negedge u_cluster.u_cpu1.rst_n) begin
if (UPF::openpa_dom_u_cluster_PD_CPU1_ok && !openpa_u_cluster_PD_CPU1_rprev) openpa_u_cluster_PD_CPU1_rp0 = 1'b1;
if (!UPF::openpa_dom_u_cluster_PD_CPU1_ok || u_cluster.u_cpu1.rst_n === 1'b0) openpa_u_cluster_PD_CPU1_rp0 = 1'b0;
openpa_u_cluster_PD_CPU1_rprev = UPF::openpa_dom_u_cluster_PD_CPU1_ok;
end
// ---- checks for set_isolation ISO0 (soc.upf:30): PD_CPU0 -> PD_TOP on 1 port(s)
bit openpa_ig1_act, openpa_ig1_cyc;
always @(negedge UPF::openpa_dom_u_cluster_PD_CPU0_ok) if (!UPF::openpa_dom_u_cluster_PD_CPU0_ok)
begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge UPF::openpa_ctl_2_iso0 or negedge UPF::openpa_ctl_2_iso0 or posedge openpa_kick) begin
if (openpa_ig1_act && !(UPF::openpa_ctl_2_iso0 === 1'b1))
begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
if (openpa_ig1_act != (UPF::openpa_ctl_2_iso0 === 1'b1)) openpa_t({"ISO0 enable ", (UPF::openpa_ctl_2_iso0 === 1'b1) ? "active" : "inactive"});
openpa_ig1_act = (UPF::openpa_ctl_2_iso0 === 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 ISO1 (soc.upf:33): PD_CPU1 -> PD_TOP on 1 port(s)
bit openpa_ig2_act, openpa_ig2_cyc;
always @(negedge UPF::openpa_dom_u_cluster_PD_CPU1_ok) if (!UPF::openpa_dom_u_cluster_PD_CPU1_ok)
begin openpa_sp[4] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge UPF::openpa_ctl_3_iso1 or negedge UPF::openpa_ctl_3_iso1 or posedge openpa_kick) begin
if (openpa_ig2_act && !(UPF::openpa_ctl_3_iso1 === 1'b1))
begin openpa_sp[5] = 1'b1; openpa_sreq = 1'b1; end
if (openpa_ig2_act != (UPF::openpa_ctl_3_iso1 === 1'b1)) openpa_t({"ISO1 enable ", (UPF::openpa_ctl_3_iso1 === 1'b1) ? "active" : "inactive"});
openpa_ig2_act = (UPF::openpa_ctl_3_iso1 === 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_cluster/u_cpu0/q (PD_CPU0) -> logic in u_cluster (PD_TOP), isolated by ISO0
bit openpa_x1_t;
always @(UPF::openpa_dom_u_cluster_PD_CPU0_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_2_iso0 or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_C0 or UPF::openpa_net_VSS_N) openpa_x1_t = !UPF::openpa_dom_u_cluster_PD_CPU0_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_2_iso0 === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_C0.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_cluster/u_cpu0/q (PD_CPU0) -> u_cluster output q0 (PD_TOP), isolated by ISO0
bit openpa_x2_t;
always @(UPF::openpa_dom_u_cluster_PD_CPU0_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_2_iso0 or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_C0 or UPF::openpa_net_VSS_N) openpa_x2_t = !UPF::openpa_dom_u_cluster_PD_CPU0_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_2_iso0 === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_C0.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_cluster/u_cpu1/q (PD_CPU1) -> logic in u_cluster (PD_TOP), isolated by ISO1
bit openpa_x3_t;
always @(UPF::openpa_dom_u_cluster_PD_CPU1_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_3_iso1 or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_C1 or UPF::openpa_net_VSS_N) openpa_x3_t = !UPF::openpa_dom_u_cluster_PD_CPU1_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_3_iso1 === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_C1.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_cluster/u_cpu1/q (PD_CPU1) -> u_cluster output q1 (PD_TOP), isolated by ISO1
bit openpa_x4_t;
always @(UPF::openpa_dom_u_cluster_PD_CPU1_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_3_iso1 or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_C1 or UPF::openpa_net_VSS_N) openpa_x4_t = !UPF::openpa_dom_u_cluster_PD_CPU1_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_3_iso1 === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_C1.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_cluster input clk (PD_TOP) -> u_cluster/u_cpu0/clk (PD_CPU0), not isolated
bit openpa_x5_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_u_cluster_PD_CPU0_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x5_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_u_cluster_PD_CPU0_ok && !(1'b0) && !(UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED || UPF::openpa_net_VSS_N.state == UPF::UNDETERMINED);
always @(posedge openpa_x5_t)
begin openpa_sp[11] = 1'b1; openpa_sreq = 1'b1; end
// crossing 6: u_cluster input d (PD_TOP) -> u_cluster/u_cpu0/d (PD_CPU0), not isolated
bit openpa_x6_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_u_cluster_PD_CPU0_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_u_cluster_PD_CPU0_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: u_cluster input en (PD_TOP) -> u_cluster/u_cpu0/en (PD_CPU0), not isolated
bit openpa_x7_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_u_cluster_PD_CPU0_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_u_cluster_PD_CPU0_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: u_cluster input rst_n (PD_TOP) -> u_cluster/u_cpu0/rst_n (PD_CPU0), not isolated
bit openpa_x8_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_u_cluster_PD_CPU0_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_u_cluster_PD_CPU0_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: u_cluster input clk (PD_TOP) -> u_cluster/u_cpu1/clk (PD_CPU1), not isolated
bit openpa_x9_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_u_cluster_PD_CPU1_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_u_cluster_PD_CPU1_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: logic in u_cluster (PD_TOP) -> u_cluster/u_cpu1/d (PD_CPU1), not isolated
bit openpa_x10_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_u_cluster_PD_CPU1_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_u_cluster_PD_CPU1_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: u_cluster input en (PD_TOP) -> u_cluster/u_cpu1/en (PD_CPU1), not isolated
bit openpa_x11_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_u_cluster_PD_CPU1_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_u_cluster_PD_CPU1_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: u_cluster input rst_n (PD_TOP) -> u_cluster/u_cpu1/rst_n (PD_CPU1), not isolated
bit openpa_x12_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_u_cluster_PD_CPU1_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_u_cluster_PD_CPU1_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
// level shifter check 1: PD_CPU0 -> PD_TOP (no level shifter strategy, threshold 0)
bit openpa_l1_t;
always @(UPF::openpa_dom_u_cluster_PD_CPU0_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_C0 or UPF::openpa_net_VDD_N) openpa_l1_t = UPF::openpa_dom_u_cluster_PD_CPU0_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_C0.voltage - UPF::openpa_net_VDD_N.voltage > 0 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_C0.voltage > 0) && !1'b0;
always @(posedge openpa_l1_t)
begin openpa_sp[19] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 2: PD_CPU1 -> PD_TOP (no level shifter strategy, threshold 0)
bit openpa_l2_t;
always @(UPF::openpa_dom_u_cluster_PD_CPU1_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_C1 or UPF::openpa_net_VDD_N) openpa_l2_t = UPF::openpa_dom_u_cluster_PD_CPU1_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_C1.voltage - UPF::openpa_net_VDD_N.voltage > 0 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_C1.voltage > 0) && !1'b0;
always @(posedge openpa_l2_t)
begin openpa_sp[20] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 3: PD_TOP -> PD_CPU0 (no level shifter strategy, threshold 0)
bit openpa_l3_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_u_cluster_PD_CPU0_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_C0) openpa_l3_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_u_cluster_PD_CPU0_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_C0.voltage > 0 || UPF::openpa_net_VDD_C0.voltage - UPF::openpa_net_VDD_N.voltage > 0) && !1'b0;
always @(posedge openpa_l3_t)
begin openpa_sp[21] = 1'b1; openpa_sreq = 1'b1; end
// level shifter check 4: PD_TOP -> PD_CPU1 (no level shifter strategy, threshold 0)
bit openpa_l4_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_u_cluster_PD_CPU1_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_C1) openpa_l4_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_u_cluster_PD_CPU1_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_C1.voltage > 0 || UPF::openpa_net_VDD_C1.voltage - UPF::openpa_net_VDD_N.voltage > 0) && !1'b0;
always @(posedge openpa_l4_t)
begin openpa_sp[22] = 1'b1; openpa_sreq = 1'b1; end
bit openpa_SW0_def;
always @(posedge openpa_tg_sw_SW0_st or negedge openpa_tg_sw_SW0_st)
begin openpa_sp[23] = 1'b1; openpa_sreq = 1'b1; end
bit openpa_SW1_def;
always @(posedge openpa_tg_sw_SW1_st or negedge openpa_tg_sw_SW1_st)
begin openpa_sp[24] = 1'b1; openpa_sreq = 1'b1; end
always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
begin openpa_sp[25] = 1'b1; openpa_sreq = 1'b1; end
always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
begin openpa_sp[26] = 1'b1; openpa_sreq = 1'b1; end
always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
begin openpa_sp[27] = 1'b1; openpa_sreq = 1'b1; end
always @(negedge UPF::openpa_dom_PD_TOP_ok) if (!UPF::openpa_dom_PD_TOP_ok)
begin openpa_sp[28] = 1'b1; openpa_sreq = 1'b1; end
// ---- observation for differential corruption (+openpa_obs): design-top outputs while the top domain is on
`ifdef OPENPA_OBS
longint openpa_obs_after;
initial if (!$value$plusargs("openpa_obs_after=%d", openpa_obs_after)) openpa_obs_after = 0;
always @(q0) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: q0=%h", $time, q0);
always @(q1) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: q1=%h", $time, q1);
always @(sum) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: sum=%h", $time, sum);
`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 ISO0: PD_CPU0 isolated before power-down %0d", openpa_seq[1]);
$display("OPENPA-COVER sequence D2/D7 ISO0: isolation released only after PD_CPU0 was back and reset %0d", openpa_seq[2]);
$display("OPENPA-COVER sequence D1 ISO1: PD_CPU1 isolated before power-down %0d", openpa_seq[3]);
$display("OPENPA-COVER sequence D2/D7 ISO1: isolation released only after PD_CPU1 was back and reset %0d", openpa_seq[4]);
if (openpa_seq[1]) hq = hq + 1;
if (openpa_seq[2]) hq = hq + 1;
if (openpa_seq[3]) hq = hq + 1;
if (openpa_seq[4]) hq = hq + 1;
$display("OPENPA-COVER-SUMMARY states=%0d/0 declared_transitions=%0d/0 sequences=%0d/4", hs, ht, hq);
endfunction
// ---- settle process: 28 deferred check(s), run after one #0 in a fixed order
initial forever begin
wait (openpa_sreq && openpa_kick);
#0;
openpa_sreq = 1'b0;
if (openpa_sp[1]) begin
openpa_sp[1] = 1'b0;
if (!UPF::openpa_dom_u_cluster_PD_CPU0_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_2_iso0 === 1'b1)) openpa_check(1, "set_isolation ISO0 (soc.upf:30): PD_CPU0 went off while the isolation enable iso0 was inactive");
else if (!UPF::openpa_dom_u_cluster_PD_CPU0_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_2_iso0 === 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_u_cluster_PD_CPU0_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation ISO0 (soc.upf:30): isolation released while PD_CPU0 is still off");
else if (openpa_u_cluster_PD_CPU0_rp0) openpa_check(7, "set_isolation ISO0 (soc.upf:30): isolation released after PD_CPU0 powered up but before its reset u_cluster.u_cpu0.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_iso0 === 1'b1) && !UPF::openpa_dom_u_cluster_PD_CPU0_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation ISO0 (soc.upf:30): isolation supply {VDD_N VSS_N} lost while clamping");
end
if (openpa_sp[4]) begin
openpa_sp[4] = 1'b0;
if (!UPF::openpa_dom_u_cluster_PD_CPU1_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_3_iso1 === 1'b1)) openpa_check(1, "set_isolation ISO1 (soc.upf:33): PD_CPU1 went off while the isolation enable iso1 was inactive");
else if (!UPF::openpa_dom_u_cluster_PD_CPU1_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_3_iso1 === 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_u_cluster_PD_CPU1_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation ISO1 (soc.upf:33): isolation released while PD_CPU1 is still off");
else if (openpa_u_cluster_PD_CPU1_rp0) openpa_check(7, "set_isolation ISO1 (soc.upf:33): isolation released after PD_CPU1 powered up but before its reset u_cluster.u_cpu1.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_iso1 === 1'b1) && !UPF::openpa_dom_u_cluster_PD_CPU1_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation ISO1 (soc.upf:33): 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_cluster/u_cpu0/q of PD_CPU0 (off) is read by logic in u_cluster 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_cluster/u_cpu0/q of PD_CPU0 (off) is read by u_cluster output q0 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_cluster/u_cpu1/q of PD_CPU1 (off) is read by logic in u_cluster 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_cluster/u_cpu1/q of PD_CPU1 (off) is read by u_cluster output q1 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_cluster input clk of PD_TOP (off) is read by u_cluster/u_cpu0/clk in PD_CPU0 (on) with no active isolation");
end
if (openpa_sp[12]) begin
openpa_sp[12] = 1'b0;
if (openpa_x6_t) openpa_check(9, "u_cluster input d of PD_TOP (off) is read by u_cluster/u_cpu0/d in PD_CPU0 (on) with no active isolation");
end
if (openpa_sp[13]) begin
openpa_sp[13] = 1'b0;
if (openpa_x7_t) openpa_check(9, "u_cluster input en of PD_TOP (off) is read by u_cluster/u_cpu0/en in PD_CPU0 (on) with no active isolation");
end
if (openpa_sp[14]) begin
openpa_sp[14] = 1'b0;
if (openpa_x8_t) openpa_check(9, "u_cluster input rst_n of PD_TOP (off) is read by u_cluster/u_cpu0/rst_n in PD_CPU0 (on) with no active isolation");
end
if (openpa_sp[15]) begin
openpa_sp[15] = 1'b0;
if (openpa_x9_t) openpa_check(9, "u_cluster input clk of PD_TOP (off) is read by u_cluster/u_cpu1/clk in PD_CPU1 (on) with no active isolation");
end
if (openpa_sp[16]) begin
openpa_sp[16] = 1'b0;
if (openpa_x10_t) openpa_check(9, "logic in u_cluster of PD_TOP (off) is read by u_cluster/u_cpu1/d in PD_CPU1 (on) with no active isolation");
end
if (openpa_sp[17]) begin
openpa_sp[17] = 1'b0;
if (openpa_x11_t) openpa_check(9, "u_cluster input en of PD_TOP (off) is read by u_cluster/u_cpu1/en in PD_CPU1 (on) with no active isolation");
end
if (openpa_sp[18]) begin
openpa_sp[18] = 1'b0;
if (openpa_x12_t) openpa_check(9, "u_cluster input rst_n of PD_TOP (off) is read by u_cluster/u_cpu1/rst_n in PD_CPU1 (on) with no active isolation");
end
if (openpa_sp[19]) begin
openpa_sp[19] = 1'b0;
if (openpa_l1_t) openpa_check(11, $sformatf("PD_CPU0 (%0d uV) drives PD_TOP (%0d uV) on 2 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_C0.voltage, UPF::openpa_net_VDD_N.voltage));
end
if (openpa_sp[20]) begin
openpa_sp[20] = 1'b0;
if (openpa_l2_t) openpa_check(11, $sformatf("PD_CPU1 (%0d uV) drives PD_TOP (%0d uV) on 2 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_C1.voltage, UPF::openpa_net_VDD_N.voltage));
end
if (openpa_sp[21]) begin
openpa_sp[21] = 1'b0;
if (openpa_l3_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_CPU0 (%0d uV) on 4 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_C0.voltage));
end
if (openpa_sp[22]) begin
openpa_sp[22] = 1'b0;
if (openpa_l4_t) openpa_check(11, $sformatf("PD_TOP (%0d uV) drives PD_CPU1 (%0d uV) on 4 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_C1.voltage));
end
if (openpa_sp[23]) begin
openpa_sp[23] = 1'b0;
if (UPF::openpa_sw_SW0_st != -1) openpa_SW0_def = 1'b1; else if (openpa_SW0_def) openpa_check(10, "power switch SW0 is undetermined: a control is X, or no state (or more than one) holds (soc.upf:16)");
end
if (openpa_sp[24]) begin
openpa_sp[24] = 1'b0;
if (UPF::openpa_sw_SW1_st != -1) openpa_SW1_def = 1'b1; else if (openpa_SW1_def) openpa_check(10, "power switch SW1 is undetermined: a control is X, or no state (or more than one) holds (soc.upf:18)");
end
if (openpa_sp[25]) begin
openpa_sp[25] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_u_cluster_PD_CPU0_ok || UPF::openpa_dom_u_cluster_PD_CPU1_ok)) openpa_check(12, "pwr0 (switch SW0) comes from PD_TOP, which is off while other domains are on");
end
if (openpa_sp[26]) begin
openpa_sp[26] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_u_cluster_PD_CPU0_ok || UPF::openpa_dom_u_cluster_PD_CPU1_ok)) openpa_check(12, "pwr1 (switch SW1) 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_u_cluster_PD_CPU0_ok || UPF::openpa_dom_u_cluster_PD_CPU1_ok)) openpa_check(12, "iso0 (isolation ISO0) 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_u_cluster_PD_CPU0_ok || UPF::openpa_dom_u_cluster_PD_CPU1_ok)) openpa_check(12, "iso1 (isolation ISO1) 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_SW0_def) $display("OPENPA-WARNING power switch SW0 never reached a defined state");
if (!openpa_SW1_def) $display("OPENPA-WARNING power switch SW1 never reached a defined state");
end
// verilator lint_on MULTIDRIVEN
`line 17 "soc.sv" 0
endmodule
`line 1 "cluster.sv" 0
// cluster: two identical CPUs and an always-on sum register. The power controls pass through.
module cluster (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr0,
input logic pwr1,
input logic iso0,
input logic iso1,
output logic [7:0] q0,
output logic [7:0] q1,
output logic [7:0] sum
);
wire [7:0] openpa_u_cpu0_q_raw, openpa_u_cpu0_q_s1; cpu u_cpu0 (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(openpa_u_cpu0_q_raw)); openpa_corrupt #(.W(8), .ID(268435456)) openpa_u_cpu0_q_cor (.d(openpa_u_cpu0_q_raw), .q(openpa_u_cpu0_q_s1), .ok(UPF::openpa_dom_u_cluster_PD_CPU0_ok), .ep(UPF::openpa_dom_u_cluster_PD_CPU0_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435457)) openpa_u_cpu0_q_iso (.d(openpa_u_cpu0_q_s1), .q(q0), .en(UPF::openpa_ctl_2_iso0), .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_cpu1_q_raw, openpa_u_cpu1_q_s1; cpu u_cpu1 (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd1), .q(openpa_u_cpu1_q_raw)); openpa_corrupt #(.W(8), .ID(268435464)) openpa_u_cpu1_q_cor (.d(openpa_u_cpu1_q_raw), .q(openpa_u_cpu1_q_s1), .ok(UPF::openpa_dom_u_cluster_PD_CPU1_ok), .ep(UPF::openpa_dom_u_cluster_PD_CPU1_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435465)) openpa_u_cpu1_q_iso (.d(openpa_u_cpu1_q_s1), .q(q1), .en(UPF::openpa_ctl_3_iso1), .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) sum <= '0;
else sum <= q0 + q1;
endmodule
`line 1 "cpu.sv" 0
// cpu: an 8-bit accumulator. Power-unaware RTL.
module cpu (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
output logic [7:0] q
);
logic [7:0] acc;
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) acc <= '0;
else if (en) acc <= acc + d;
assign q = acc;
endmodule
Check Yourself
Common Mistakes
Wrong Write -elements {u_cpu0} in the top file for an instance inside u_cluster.
A simple name is looked up in the current scope only. The top has no u_cpu0.
Fix Write the path from the current scope, u_cluster/u_cpu0, or move there with set_scope first.
Wrong Leave the scope inside a block after set_scope.
Every later line is then read in the block. Names of the top's nets and ports are not found there.
Fix Return with set_scope .. or set_scope /, or use load_upf -scope, which returns by itself.
Wrong Load a block's UPF file with plain load_upf from the top.
Without -scope the file runs in the current scope. Its names then clash with the top's, or point at the wrong instances.
Fix Use load_upf file -scope instance, once per instance.
Remember
- Every UPF name is read from the current scope. It starts at the design top.
- set_scope moves the scope: a child or a path,
.,..(an error at the top) or/. - An object belongs to the scope that made it. From above, reach it with a path.
- load_upf -scope runs a block's file inside an instance, then restores the scope. Load it once per instance.
- find_objects builds element lists by pattern, name_format names created cells, and save_upf writes intent back out.