Supply Ports, Supply Nets and Resolution
Supplies enter at ports and travel on nets. Each net carries a state and a voltage, and a net with several sources needs a rule to combine them.
You Will Be Able To
- Create supply ports with the right direction, supply nets and their connections, and give each domain both primary nets.
- Read a supply value: OFF, FULL_ON, PARTIAL_ON or UNDETERMINED, and a voltage in microvolts.
- Choose unresolved, one_hot or parallel for a net, and predict its state from its sources and their roots.
- Lesson
- W4.4
- Time
- 30 min
- Runs on
- Your browser
- Check
- 5 questions
Two regulators can feed one rail, but not at the same moment. In the lab, the bench turns the second one on early:
OPENPA-CHECK D13 @ 16: supply net VDD_RF (-resolve one_hot): more than one source is ON; the net is UNDETERMINED (IEEE 1801-2024 6.25.3)
both regs VDD_RF=UNDETERMINED 0 mV VDD_BB=FULL_ON 1000 mV rf=xx bb=11The rail VDD_RF is now UNDETERMINED, and the RF block is corrupted. The file said "one source at a time", and the bench broke that promise.
Supply Ports and Supply Nets
A supply port is a connection point on an instance. A supply net carries a supply state from a source to its loads (IEEE 1801-2024 6.25, 6.26).
-direction says which way the state flows. An input port brings the outside net's state in; an output port sends the inside net's state out (6.26). The default is in.
- Power
- Power
- Buck on
VBUCK alone feeds VDD_RF: FULL_ON 1000 mV. Both switches are open, so VDD_BB is OFF 0 mV.
- Weak switch on
One of two parallel sources is on: VDD_BB is PARTIAL_ON 1000 mV.
- Main switch on
Both sources are on: VDD_BB is FULL_ON 1000 mV, and PD_BB can run.
- Both regulators on
Two one_hot sources are on: VDD_RF is UNDETERMINED 0 mV.
- LDO only
The buck goes off and VLDO alone feeds the rail: FULL_ON 1000 mV.
Read the diagram as text
- VBUCK: input port
- VLDO: input port
- VDD, VDD_N: input port and its net
- VDD_RF: one_hot net: PD_RF power
- VRF_MON: output port
- SW_WEAK, SW_MAIN: two switches
- VDD_BB: parallel net: PD_BB power
- VBUCK → VDD_RF
- VLDO → VDD_RF
- VDD_RF → VRF_MON
- VDD, VDD_N → SW_WEAK, SW_MAIN
- SW_WEAK, SW_MAIN → VDD_BB: two outputs
States from the lab run on OpenPA and Icarus (recorded). VRF_MON shows VDD_RF's state to the outside.
# Supply ports: where supplies enter (in) or leave (out) the design top
create_supply_port VDD -direction in
create_supply_port VSS -direction in
create_supply_port VBUCK -direction in
create_supply_port VLDO -direction in
create_supply_port VRF_MON -direction out
# Supply nets carry a state and a voltage
create_supply_net VDD_N
create_supply_net VSS_N
create_supply_net VDD_RF -resolve one_hot
create_supply_net VDD_BB -resolve parallel| Command | What it creates | Options (IEEE 1801-2024) |
|---|---|---|
create_supply_port | one port per name, in the current scope | -direction in|out|inout (default in), -virtual; legacy -domain (6.26) |
create_supply_net | one net per name, in the current scope | -resolve, -virtual, -tunneling; legacy -domain, -reuse (6.25) |
connect_supply_net | connections from a net to ports | -ports and more (6.14) |
OpenPA 0.3.0 runs -direction in and out, -resolve unresolved, one_hot and parallel, and connect_supply_net -ports.
An inout port joins resolved nets across a boundary (6.26). OpenPA does not run it:
radio.upf:13: create_supply_port -direction inout: not supported by OpenPA (IEEE 1801-2024 6.26: an inout port joins resolved nets across a boundary)Connections and Primary Nets
connect_supply_net ties a net to ports. One line can name several ports: here, both regulators and the test pin.
connect_supply_net VDD_N -ports {VDD}
connect_supply_net VSS_N -ports {VSS}
connect_supply_net VDD_RF -ports {VBUCK VLDO VRF_MON}set_domain_supply_net gives a domain its primary power and ground nets. IEEE 1801-2024 lists it as legacy (Annex D.2.3.12); a supply set does the same job (W4.5).
set_domain_supply_net PD_TOP -primary_power_net VDD_N -primary_ground_net VSS_N
set_domain_supply_net PD_RF -primary_power_net VDD_RF -primary_ground_net VSS_N
set_domain_supply_net PD_BB -primary_power_net VDD_BB -primary_ground_net VSS_NSupply network
VDD_N: port VDD {port:VDD net:VDD_N sw:SW_WEAK/i sw:SW_MAIN/i fn:PD_TOP.primary.power}
VSS_N: port VSS {port:VSS net:VSS_N fn:PD_TOP.primary.ground fn:PD_RF.primary.ground fn:PD_BB.primary.ground}
VDD_RF: port VBUCK, port VLDO (-resolve one_hot) {port:VBUCK port:VLDO port:VRF_MON net:VDD_RF fn:PD_RF.primary.power}
VDD_BB: switch SW_WEAK, switch SW_MAIN (-resolve parallel) {net:VDD_BB sw:SW_WEAK/o sw:SW_MAIN/o fn:PD_BB.primary.power}Leave out a ground net, and OpenPA warns:
Warnings (2)
radio.upf:6: power domain PD_BB: the primary supply has no ground net; only power decides its stateThe Supply Value: State and Voltage
Every supply port, net and set function has a value: a state and a voltage (IEEE 1801-2024 4.7.2). The voltage is an integer number of microvolts.
| State | Meaning (4.7.2, 6.25.3) | In the lab |
|---|---|---|
| FULL_ON | the root supply gives full power | VDD_RF after "buck on": FULL_ON 1000 mV |
| PARTIAL_ON | some power: for example one of two parallel sources | VDD_BB after "weak on": PARTIAL_ON 1000 mV |
| OFF | no power | VDD_BB after "buck on": OFF 0 mV |
| UNDETERMINED | the state cannot be known: for example a one_hot conflict | VDD_RF after "both regs": UNDETERMINED 0 mV |
Lab values are recorded. Voltage is defined only for PARTIAL_ON and FULL_ON (4.7.2). OpenPA prints 0 mV otherwise; that value has no meaning.
The bench drives and reads supplies with functions of package UPF. The power-aware copy brings that package.
void'(supply_on("VBUCK", 1.0)); // a top-level input port, in volts
v = get_supply_value("VDD_RF"); // state and voltage of a net
s = get_supply_state(v); // OFF, FULL_ON, PARTIAL_ON or UNDETERMINED
mv = get_supply_voltage(v) * 1000.0;UPF 1.0 stored the value differently: an on/off bit, a full/partial bit and a voltage (5.1.4). OpenPA keeps that form for files that declare upf_version 1.0.
In OpenPA, a domain runs only while its primary power is FULL_ON. A PARTIAL_ON rail corrupts it, as the lab shows for u_bb. set_partial_on_translation FULL_ON makes PARTIAL_ON count as FULL_ON when power states are evaluated (6.50).
Resolution: Unresolved, one_hot and Parallel
A net with several sources needs a rule that turns their states into one. create_supply_net -resolve picks it (6.25.3).
| -resolve | Sources allowed | IEEE 1801-2024 (6.25.3) | UPF 1.0 (5.1.5) |
|---|---|---|---|
unresolved (default) | one | a second source is an error | the same |
one_hot | several, each with its own driver | two or more not OFF: UNDETERMINED; one on: its state and voltage; none: OFF | two or more ON: OFF |
parallel | several, all tracing to one root supply | all FULL_ON: FULL_ON; any PARTIAL_ON or a mix of OFF and on: PARTIAL_ON; all OFF: OFF | any ON at one voltage: ON, partial if any is partial |
parallel_one_hot | several roots, each with parallel paths | one_hot across roots, parallel within each | not defined |
One UNDETERMINED source makes a one_hot or parallel net UNDETERMINED. A user-defined function may replace the rule (6.25.3).
buck on VDD_RF=FULL_ON 1000 mV VDD_BB=OFF 0 mV rf=0 bb=xx
weak on VDD_RF=FULL_ON 1000 mV VDD_BB=PARTIAL_ON 1000 mV rf=0 bb=xx
main on VDD_RF=FULL_ON 1000 mV VDD_BB=FULL_ON 1000 mV rf=0 bb=xx
one beat VDD_RF=FULL_ON 1000 mV VDD_BB=FULL_ON 1000 mV rf=10 bb=11
OPENPA-CHECK D13 @ 16: supply net VDD_RF (-resolve one_hot): more than one source is ON; the net is UNDETERMINED (IEEE 1801-2024 6.25.3)
both regs VDD_RF=UNDETERMINED 0 mV VDD_BB=FULL_ON 1000 mV rf=xx bb=11
ldo only VDD_RF=FULL_ON 1000 mV VDD_BB=FULL_ON 1000 mV rf=xx bb=11Read the baseband rail. With one of two switches closed it is PARTIAL_ON, and u_bb stays X. Only with both closed is it FULL_ON.
Now the refusals. A plain net with two sources:
radio.upf:12: supply net VDD_RF has 2 sources: port VBUCK (radio.upf:11), port VLDO (radio.upf:12); an unresolved net takes one (use create_supply_net -resolve one_hot or parallel for several)A parallel net whose sources trace to two roots. Here the weak switch is fed from VDD_RF instead of VDD_N:
radio.upf:27: supply net VDD_BB (-resolve parallel): its sources trace to 3 root supply drivers (port VBUCK, port VLDO, port VDD); parallel resolution needs one (IEEE 1801-2024 6.25.3 c). Use one_hot, or declare upf_version 1.0 for the UPF 1.0 ruleradio.upf:18: create_supply_net -resolve parallel_one_hot: not supported by OpenPA (IEEE 1801-2024 6.25.3 d); use one_hot or parallel
radio.upf:18: create_supply_net -resolve my_resolve: user-defined resolution functions are not supported by OpenPA (IEEE 1801-2024 6.25.3); write unresolved, one_hot or parallelLegacy Forms: -domain, -reuse and get_supply_net
UPF 1.0 tied nets and ports to a domain. create_supply_net -domain made the net in the domain's scope; -reuse extended an existing net into another domain (UPF 1.0 6.11).
IEEE 1801-2024 keeps these options as legacy (Annex D.2.3.9, D.2.3.10). -reuse needs -domain on this command and on the one that created the net (6.25).
create_supply_net VSS_N -domain PD_TOP
create_supply_net VSS_N -domain PD_BB -reuse
create_supply_port VRF_MON -direction out -domain PD_RFSupply network
VDD_N: port VDD {port:VDD net:VDD_N sw:SW_WEAK/i sw:SW_MAIN/i fn:PD_TOP.primary.power}
VSS_N: port VSS {port:VSS net:VSS_N fn:PD_TOP.primary.ground fn:PD_RF.primary.ground fn:PD_BB.primary.ground}
VDD_RF: port VBUCK, port VLDO (-resolve one_hot) {port:VBUCK port:VLDO port:VRF_MON net:VDD_RF fn:PD_RF.primary.power}
VDD_BB: switch SW_WEAK, switch SW_MAIN (-resolve parallel) {net:VDD_BB sw:SW_WEAK/o sw:SW_MAIN/o fn:PD_BB.primary.power}radio.upf:18: create_supply_net VSS_BB -reuse: no supply net or port "VSS_BB" exists to reuseget_supply_net returned the name a supply net has in another scope (UPF 1.0 6.14). OpenPA does not know it:
radio.upf:40: unknown command "get_supply_net" (not an IEEE 1801-2024 command that OpenPA knows; CONFORMANCE.md lists them)| A drawn example (not run) | Result (UPF 1.0 6.14) |
|---|---|
get_supply_net VDD -domain PD_RF | the net VDD as seen from PD_RF's scope |
get_supply_net VDD -domain PD_RF -scope u_rf | the name of that net inside u_rf |
get_supply_net VDD | the logical net name as seen from the current scope |
Drawn from UPF 1.0 6.14. Nothing here is graded.
Asked in interviews
What is the difference between a supply port and a supply net?
A port is a connection point with a direction. A net carries the supply state, a state and a voltage, from its source to its loads.
When do you use one_hot and when parallel?
Use one_hot for sources from different supplies that take turns, like two regulators. Use parallel for several switches from one supply that conduct together.
What is PARTIAL_ON?
A supply that gives some but not full power, such as one of two parallel switches. OpenPA does not let a domain run on it.
Try It
Run it. The bench turns the buck on, then closes the weak switch and the main switch of the baseband rail.
Read weak on VDD_RF=FULL_ON 1000 mV VDD_BB=PARTIAL_ON 1000 mV rf=0 bb=xx. One of two parallel sources makes VDD_BB PARTIAL_ON, and u_bb stays X.
Then the bench turns the LDO on while the buck is still on. Find the D13 line and the UNDETERMINED rail.
Change the bench so that it turns the buck off before the LDO comes on. Predict the D13 count, then run.
OPENPA-INFO corruption=x seed=1 buck on VDD_RF=FULL_ON 1000 mV VDD_BB=OFF 0 mV rf=0 bb=xx weak on VDD_RF=FULL_ON 1000 mV VDD_BB=PARTIAL_ON 1000 mV rf=0 bb=xx main on VDD_RF=FULL_ON 1000 mV VDD_BB=FULL_ON 1000 mV rf=0 bb=xx one beat VDD_RF=FULL_ON 1000 mV VDD_BB=FULL_ON 1000 mV rf=10 bb=11 OPENPA-CHECK D13 @ 16: supply net VDD_RF (-resolve one_hot): more than one source is ON; the net is UNDETERMINED (IEEE 1801-2024 6.25.3) both regs VDD_RF=UNDETERMINED 0 mV VDD_BB=FULL_ON 1000 mV rf=xx bb=11 ldo only VDD_RF=FULL_ON 1000 mV VDD_BB=FULL_ON 1000 mV rf=xx bb=11 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=1 D14=0 OPENPA-COVER sequence D1 ISO_BB: PD_BB isolated before power-down 0 OPENPA-COVER sequence D2/D7 ISO_BB: isolation released only after PD_BB was back and reset 0 OPENPA-COVER sequence D1 ISO_RF: PD_RF isolated before power-down 1 OPENPA-COVER sequence D2/D7 ISO_RF: isolation released only after PD_RF was back and reset 0 OPENPA-COVER-SUMMARY states=0/0 declared_transitions=0/0 sequences=1/4Read the power intent: radio.upf
upf_version 4.0
set_design_top radio
create_power_domain PD_TOP -elements {.}
create_power_domain PD_RF -elements {u_rf}
create_power_domain PD_BB -elements {u_bb}
# Supply ports: where supplies enter (in) or leave (out) the design top
create_supply_port VDD -direction in
create_supply_port VSS -direction in
create_supply_port VBUCK -direction in
create_supply_port VLDO -direction in
create_supply_port VRF_MON -direction out
# Supply nets carry a state and a voltage
create_supply_net VDD_N
create_supply_net VSS_N
create_supply_net VDD_RF -resolve one_hot
create_supply_net VDD_BB -resolve parallel
connect_supply_net VDD_N -ports {VDD}
connect_supply_net VSS_N -ports {VSS}
connect_supply_net VDD_RF -ports {VBUCK VLDO VRF_MON}
create_power_switch SW_WEAK -domain PD_TOP -input_supply_port {i VDD_N} -output_supply_port {o VDD_BB} \
-control_port {c pwr_weak} -on_state {on i {c}} -off_state {off {!c}}
create_power_switch SW_MAIN -domain PD_TOP -input_supply_port {i VDD_N} -output_supply_port {o VDD_BB} \
-control_port {c pwr_main} -on_state {on i {c}} -off_state {off {!c}}
set_domain_supply_net PD_TOP -primary_power_net VDD_N -primary_ground_net VSS_N
set_domain_supply_net PD_RF -primary_power_net VDD_RF -primary_ground_net VSS_N
set_domain_supply_net PD_BB -primary_power_net VDD_BB -primary_ground_net VSS_N
set_isolation ISO_RF -domain PD_RF -applies_to outputs -clamp_value 0 \
-isolation_power_net VDD_N -isolation_ground_net VSS_N \
-isolation_signal iso_rf -isolation_sense high -location parent
set_isolation ISO_BB -domain PD_BB -applies_to outputs -clamp_value 0 \
-isolation_power_net VDD_N -isolation_ground_net VSS_N \
-isolation_signal iso_bb -isolation_sense high -location parent
Read the power-unaware RTL: radio.sv
// radio: an always-on top with an RF block and a baseband block. Power-unaware RTL.
module radio (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr_weak,
input logic pwr_main,
input logic iso_rf,
input logic iso_bb,
output logic [7:0] q_rf,
output logic [7:0] q_bb,
output logic [7:0] total
);
acc u_rf (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(q_rf));
acc u_bb (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd1), .q(q_bb));
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) total <= '0;
else total <= q_rf + q_bb;
endmodule
Read the power-unaware RTL: acc.sv
// acc: an 8-bit accumulator.
module acc (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
output logic [7:0] q
);
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) q <= '0;
else if (en) q <= q + d;
endmodule
What UPF added: 47 objects
4 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 | radio.upf:9 | ||
| Supply port | VSS | radio.upf:10 | ||
| Supply port | VBUCK | radio.upf:11 | ||
| Supply port | VLDO | radio.upf:12 | ||
| Supply net | VDD_N | radio.upf:9 | ||
| Supply net | VSS_N | radio.upf:10 | ||
| Supply net | VDD_RF | radio.upf:11 | ||
| Supply net | VDD_BB | radio.upf:25 | ||
| Output corruption | u_bb/q | C2 | radio.upf:6 | |
| Isolation cell | u_bb/q | ISO_BB · clamp 0 | I1-I5 | radio.upf:37 |
| Output corruption | u_rf/q | C2 | radio.upf:5 | |
| Isolation cell | u_rf/q | ISO_RF · clamp 0 | I1-I5 | radio.upf:34 |
| Output corruption | u_bb/clk | C2 | radio.upf:4 | |
| Output corruption | u_bb/d | C2 | radio.upf:4 | |
| Output corruption | u_bb/en | C2 | radio.upf:4 | |
| Output corruption | u_bb/rst_n | C2 | radio.upf:4 | |
| Output corruption | u_rf/clk | C2 | radio.upf:4 | |
| Output corruption | u_rf/d | C2 | radio.upf:4 | |
| Output corruption | u_rf/en | C2 | radio.upf:4 | |
| Output corruption | u_rf/rst_n | C2 | radio.upf:4 | |
| Power switch | SW_WEAK | S3 (IEEE 1801-2024 6.23) | radio.upf:25 | |
| Power switch | SW_MAIN | S3 (IEEE 1801-2024 6.23) | radio.upf:27 | |
| Supply set | PD_TOP.primary | radio.upf:4 | ||
| Supply set | PD_RF.primary | radio.upf:5 | ||
| Supply set | PD_BB.primary | radio.upf:6 | ||
| Supply set | {VDD_N VSS_N} | radio.upf:35 | ||
| Register corruption | total | C1 | radio.upf:4 | |
| Register corruption | u_rf.q | C1 | radio.upf:5 | |
| Register corruption | u_bb.q | C1 | radio.upf:6 | |
| Dynamic check | D1/D2/D7/D6 ISO_BB | D1, D2, D7, D6 | radio.upf:37 | |
| Dynamic check | D1/D2/D7/D6 ISO_RF | D1, D2, D7, D6 | radio.upf:34 | |
| Dynamic check | D9 crossing 1 | D9 | radio.upf:6 | |
| Dynamic check | D9 crossing 2 | D9 | radio.upf:6 | |
| Dynamic check | D9 crossing 3 | D9 | radio.upf:5 | |
| Dynamic check | D9 crossing 4 | D9 | radio.upf:5 | |
| Dynamic check | D9 crossing 5 | D9 | radio.upf:4 | |
| Dynamic check | D9 crossing 6 | D9 | radio.upf:4 | |
| Dynamic check | D9 crossing 7 | D9 | radio.upf:4 | |
| Dynamic check | D9 crossing 8 | D9 | radio.upf:4 | |
| Dynamic check | D9 crossing 9 | D9 | radio.upf:4 | |
| Dynamic check | D9 crossing 10 | D9 | radio.upf:4 | |
| Dynamic check | D9 crossing 11 | D9 | radio.upf:4 | |
| Dynamic check | D9 crossing 12 | D9 | radio.upf:4 | |
| Dynamic check | D11 PD_BB->PD_TOP | D11 | radio.upf:6 | |
| Dynamic check | D11 PD_RF->PD_TOP | D11 | radio.upf:5 | |
| Dynamic check | D11 PD_TOP->PD_BB | D11 | radio.upf:4 | |
| Dynamic check | D11 PD_TOP->PD_RF | D11 | radio.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_radio.sv
// pa_radio.sv: power-aware copy of radio, generated by OpenPA from radio.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 (radio.upf:9)
supply_net_type openpa_port_VSS; // supply port VSS (radio.upf:10)
supply_net_type openpa_port_VBUCK; // supply port VBUCK (radio.upf:11)
supply_net_type openpa_port_VLDO; // supply port VLDO (radio.upf:12)
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_RF; // supply net VDD_RF
supply_net_type openpa_net_VDD_BB; // supply net VDD_BB
int openpa_sw_SW_WEAK_st = -1; // switch SW_WEAK: -1 undetermined, 0 off, k on-state k (radio.upf:25)
int openpa_sw_SW_MAIN_st = -1; // switch SW_MAIN: -1 undetermined, 0 off, k on-state k (radio.upf:27)
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_RF_primary_ok; int unsigned openpa_ss_PD_RF_primary_ep; int openpa_ss_PD_RF_primary_st = -1; bit openpa_ss_PD_RF_primary_multi; int openpa_ss_PD_RF_primary_sim = 5; // supply set PD_RF.primary
bit openpa_ss_PD_BB_primary_ok; int unsigned openpa_ss_PD_BB_primary_ep; int openpa_ss_PD_BB_primary_st = -1; bit openpa_ss_PD_BB_primary_multi; int openpa_ss_PD_BB_primary_sim = 5; // supply set PD_BB.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 (radio.upf:4)
bit openpa_dom_PD_RF_ok; int unsigned openpa_dom_PD_RF_ep; int openpa_dom_PD_RF_sim = 5; // power domain PD_RF: ok = powered (simstate not CORRUPT); sim = simstate code (radio.upf:5)
bit openpa_dom_PD_BB_ok; int unsigned openpa_dom_PD_BB_ep; int openpa_dom_PD_BB_sim = 5; // power domain PD_BB: ok = powered (simstate not CORRUPT); sim = simstate code (radio.upf:6)
// 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_weak; // copy of pwr_weak (switch SW_WEAK)
logic openpa_ctl_1_pwr_main; // copy of pwr_main (switch SW_MAIN)
logic openpa_ctl_2_iso_rf; // copy of iso_rf (isolation ISO_RF)
logic openpa_ctl_3_iso_bb; // copy of iso_bb (isolation ISO_BB)
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 == "VBUCK") begin openpa_port_VBUCK.state = FULL_ON; openpa_port_VBUCK.voltage = openpa_uv(value); return 1; end
if (pad_name == "VLDO") begin openpa_port_VLDO.state = FULL_ON; openpa_port_VLDO.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_RF.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_RF.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BB.primary.ground") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_BB.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VRF_MON") begin $display("OPENPA-ERROR supply_on(\"%s\"): VRF_MON already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_RF") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_RF already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_RF.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_RF.primary.power already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_BB") begin $display("OPENPA-ERROR supply_on(\"%s\"): VDD_BB already has a driver (switch SW_WEAK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BB.primary.power") begin $display("OPENPA-ERROR supply_on(\"%s\"): PD_BB.primary.power already has a driver (switch SW_WEAK); 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 VBUCK VLDO)", 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 == "VBUCK") begin openpa_port_VBUCK.state = OFF; return 1; end
if (pad_name == "VLDO") begin openpa_port_VLDO.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_RF.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_RF.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BB.primary.ground") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_BB.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VRF_MON") begin $display("OPENPA-ERROR supply_off(\"%s\"): VRF_MON already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_RF") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_RF already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_RF.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_RF.primary.power already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_BB") begin $display("OPENPA-ERROR supply_off(\"%s\"): VDD_BB already has a driver (switch SW_WEAK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BB.primary.power") begin $display("OPENPA-ERROR supply_off(\"%s\"): PD_BB.primary.power already has a driver (switch SW_WEAK); 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 VBUCK VLDO)", 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 == "VBUCK") begin openpa_port_VBUCK.state = PARTIAL_ON; openpa_port_VBUCK.voltage = openpa_uv(value); return 1; end
if (pad_name == "VLDO") begin openpa_port_VLDO.state = PARTIAL_ON; openpa_port_VLDO.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_RF.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_RF.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BB.primary.ground") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_BB.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VRF_MON") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VRF_MON already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_RF") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_RF already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_RF.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_RF.primary.power already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_BB") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): VDD_BB already has a driver (switch SW_WEAK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BB.primary.power") begin $display("OPENPA-ERROR supply_partial_on(\"%s\"): PD_BB.primary.power already has a driver (switch SW_WEAK); 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 VBUCK VLDO)", 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 == "VBUCK") begin openpa_port_VBUCK.state = supply_state; return 1; end
if (pad_name == "VLDO") begin openpa_port_VLDO.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_RF.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_RF.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BB.primary.ground") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_BB.primary.ground already has a driver (port VSS); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VRF_MON") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VRF_MON already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_RF") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_RF already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_RF.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_RF.primary.power already has a driver (port VBUCK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "VDD_BB") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): VDD_BB already has a driver (switch SW_WEAK); drive its root supply instead", pad_name); return 0; end
if (pad_name == "PD_BB.primary.power") begin $display("OPENPA-ERROR set_supply_state(\"%s\"): PD_BB.primary.power already has a driver (switch SW_WEAK); 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 VBUCK VLDO)", 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_RF.primary.ground" || name == "PD_BB.primary.ground") return openpa_net_VSS_N;
if (name == "VBUCK" || name == "VLDO" || name == "VRF_MON" || name == "VDD_RF" || name == "PD_RF.primary.power") return openpa_net_VDD_RF;
if (name == "VDD_BB" || name == "PD_BB.primary.power") return openpa_net_VDD_BB;
$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 "radio.sv" 0
// radio: an always-on top with an RF block and a baseband block. Power-unaware RTL.
module radio (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr_weak,
input logic pwr_main,
input logic iso_rf,
input logic iso_bb,
output logic [7:0] q_rf,
output logic [7:0] q_bb,
output logic [7:0] total
);
wire [7:0] openpa_u_rf_q_raw, openpa_u_rf_q_s1; wire [0:0] openpa_u_rf_clk_s1; wire [7:0] openpa_u_rf_d_s1; wire [0:0] openpa_u_rf_en_s1; wire [0:0] openpa_u_rf_rst_n_s1; acc u_rf (.clk(openpa_u_rf_clk_s1), .rst_n(openpa_u_rf_rst_n_s1), .en(openpa_u_rf_en_s1), .d(openpa_u_rf_d_s1), .q(openpa_u_rf_q_raw)); openpa_corrupt #(.W(8), .ID(268435464)) openpa_u_rf_q_cor (.d(openpa_u_rf_q_raw), .q(openpa_u_rf_q_s1), .ok(UPF::openpa_dom_PD_RF_ok), .ep(UPF::openpa_dom_PD_RF_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435465)) openpa_u_rf_q_iso (.d(openpa_u_rf_q_s1), .q(q_rf), .en(UPF::openpa_ctl_2_iso_rf), .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(1), .ID(268435504)) openpa_u_rf_clk_cor (.d(clk), .q(openpa_u_rf_clk_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(8), .ID(268435512)) openpa_u_rf_d_cor (.d(d), .q(openpa_u_rf_d_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435520)) openpa_u_rf_en_cor (.d(en), .q(openpa_u_rf_en_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435528)) openpa_u_rf_rst_n_cor (.d(rst_n), .q(openpa_u_rf_rst_n_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep));
wire [7:0] openpa_u_bb_q_raw, openpa_u_bb_q_s1; wire [0:0] openpa_u_bb_clk_s1; wire [7:0] openpa_u_bb_d_s1; wire [0:0] openpa_u_bb_en_s1; wire [0:0] openpa_u_bb_rst_n_s1; acc u_bb (.clk(openpa_u_bb_clk_s1), .rst_n(openpa_u_bb_rst_n_s1), .en(openpa_u_bb_en_s1), .d(openpa_u_bb_d_s1), .q(openpa_u_bb_q_raw)); openpa_corrupt #(.W(8), .ID(268435456)) openpa_u_bb_q_cor (.d(openpa_u_bb_q_raw), .q(openpa_u_bb_q_s1), .ok(UPF::openpa_dom_PD_BB_ok), .ep(UPF::openpa_dom_PD_BB_ep)); openpa_iso #(.W(8), .CLAMP(0), .SENSE(1'b1), .ID(268435457)) openpa_u_bb_q_iso (.d(openpa_u_bb_q_s1), .q(q_bb), .en(UPF::openpa_ctl_3_iso_bb), .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(1), .ID(268435472)) openpa_u_bb_clk_cor (.d(clk), .q(openpa_u_bb_clk_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(8), .ID(268435480)) openpa_u_bb_d_cor (.d(d + 8'd1), .q(openpa_u_bb_d_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435488)) openpa_u_bb_en_cor (.d(en), .q(openpa_u_bb_en_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep)); openpa_corrupt #(.W(1), .ID(268435496)) openpa_u_bb_rst_n_cor (.d(rst_n), .q(openpa_u_bb_rst_n_s1), .ok(UPF::openpa_dom_PD_TOP_ok), .ep(UPF::openpa_dom_PD_TOP_ep));
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) total <= '0;
else total <= q_rf + q_bb;
`line 1 "openpa_overlay.sv" 0
// ===================================================================================
// OpenPA overlay for radio: generated from radio.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_weak;
import UPF::openpa_ctl_1_pwr_main;
import UPF::openpa_ctl_2_iso_rf;
import UPF::openpa_ctl_3_iso_bb;
import UPF::openpa_dom_PD_BB_ep;
import UPF::openpa_dom_PD_BB_ok;
import UPF::openpa_dom_PD_BB_sim;
import UPF::openpa_dom_PD_RF_ep;
import UPF::openpa_dom_PD_RF_ok;
import UPF::openpa_dom_PD_RF_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_BB;
import UPF::openpa_net_VDD_N;
import UPF::openpa_net_VDD_RF;
import UPF::openpa_net_VSS_N;
import UPF::openpa_seed;
import UPF::openpa_ss_PD_BB_primary_ep;
import UPF::openpa_ss_PD_BB_primary_multi;
import UPF::openpa_ss_PD_BB_primary_ok;
import UPF::openpa_ss_PD_BB_primary_sim;
import UPF::openpa_ss_PD_BB_primary_st;
import UPF::openpa_ss_PD_RF_primary_ep;
import UPF::openpa_ss_PD_RF_primary_multi;
import UPF::openpa_ss_PD_RF_primary_ok;
import UPF::openpa_ss_PD_RF_primary_sim;
import UPF::openpa_ss_PD_RF_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_MAIN_st;
import UPF::openpa_sw_SW_WEAK_st;
import UPF::openpa_xmode;
// ---- mode, seed, trace
bit openpa_tr, openpa_obs;
int openpa_n [1:14];
int openpa_seq [1:4]; // good-form sequence bins (coverage)
bit openpa_sreq; bit openpa_sp [1:28]; // deferred checks: request and pending flags
string openpa_mode_arg;
initial begin
`ifdef VERILATOR
openpa_xmode = 1'b0;
`else
openpa_xmode = 1'b1;
`endif
openpa_cmode = 0;
if ($value$plusargs("openpa_corrupt=%s", openpa_mode_arg)) begin
if (openpa_mode_arg == "x") openpa_xmode = 1'b1;
else if (openpa_mode_arg == "random") openpa_xmode = 1'b0;
else if (openpa_mode_arg == "zero") begin openpa_xmode = 1'b0; openpa_cmode = 1; end
else if (openpa_mode_arg == "one") begin openpa_xmode = 1'b0; openpa_cmode = 2; end
else $display("OPENPA-ERROR +openpa_corrupt=%s: use x, random, zero or one", openpa_mode_arg);
end
if (!$value$plusargs("openpa_seed=%d", openpa_seed)) openpa_seed = 1;
openpa_tr = $test$plusargs("openpa_trace");
openpa_obs = $test$plusargs("openpa_obs");
$display("OPENPA-INFO corruption=%0s seed=%0d", openpa_xmode ? "x" : (openpa_cmode == 1 ? "zero" : openpa_cmode == 2 ? "one" : "random"), openpa_seed);
#0 openpa_kick = 1'b1;
end
task automatic openpa_check(input int id, input string msg);
openpa_n[id] = openpa_n[id] + 1;
$display("OPENPA-CHECK D%0d @ %0t: %s", id, $time, msg);
endtask
task automatic openpa_t(input string msg);
if (openpa_tr) $display("OPENPA-TRACE @ %0t: %s", $time, msg);
endtask
// ---- copies of the design signals the UPF names (4-state, so X is visible)
always @(pwr_weak or openpa_kick) openpa_ctl_0_pwr_weak = pwr_weak;
always @(pwr_main or openpa_kick) openpa_ctl_1_pwr_main = pwr_main;
always @(iso_rf or openpa_kick) openpa_ctl_2_iso_rf = iso_rf;
always @(iso_bb or openpa_kick) openpa_ctl_3_iso_bb = iso_bb;
// ---- supply network, switches, supply sets, simstates, power states (one block, evaluated in order)
bit openpa_tg_sw_SW_WEAK_st; int openpa_pv_sw_SW_WEAK_st = -2;
bit openpa_tg_sw_SW_MAIN_st; int openpa_pv_sw_SW_MAIN_st = -2;
UPF::supply_net_type openpa_rv_VDD_RF_0;
UPF::supply_net_type openpa_rv_VDD_RF_1;
bit openpa_rc_VDD_RF; // VDD_RF: resolution conflict (D13)
UPF::supply_net_type openpa_rv_VDD_BB_0;
UPF::supply_net_type openpa_swv_SW_WEAK_f, openpa_swv_SW_WEAK_p; bit openpa_swv_SW_WEAK_u, openpa_swv_SW_WEAK_hf, openpa_swv_SW_WEAK_hp, openpa_swv_SW_WEAK_vd, openpa_swv_SW_WEAK_on, openpa_swv_SW_WEAK_pt; int openpa_swv_SW_WEAK_k; // switch SW_WEAK
UPF::supply_net_type openpa_rv_VDD_BB_1;
UPF::supply_net_type openpa_swv_SW_MAIN_f, openpa_swv_SW_MAIN_p; bit openpa_swv_SW_MAIN_u, openpa_swv_SW_MAIN_hf, openpa_swv_SW_MAIN_hp, openpa_swv_SW_MAIN_vd, openpa_swv_SW_MAIN_on, openpa_swv_SW_MAIN_pt; int openpa_swv_SW_MAIN_k; // switch SW_MAIN
bit openpa_rc_VDD_BB; // VDD_BB: resolution conflict (D13)
always @(openpa_kick or UPF::openpa_port_VDD or UPF::openpa_port_VSS or UPF::openpa_port_VBUCK or UPF::openpa_port_VLDO or UPF::openpa_ctl_0_pwr_weak or UPF::openpa_ctl_1_pwr_main) begin : openpa_network
openpa_net_VDD_N = UPF::openpa_port_VDD; // VDD_N <- port VDD
openpa_net_VSS_N = UPF::openpa_port_VSS; // VSS_N <- port VSS
openpa_rv_VDD_RF_0 = UPF::openpa_port_VBUCK; // VDD_RF <- port VBUCK
openpa_rv_VDD_RF_1 = UPF::openpa_port_VLDO; // VDD_RF <- port VLDO
// supply net VDD_RF: -resolve one_hot over port VBUCK, port VLDO (IEEE 1801-2024 6.25.3)
openpa_rc_VDD_RF = 1'b0; openpa_net_VDD_RF.state = UPF::OFF; openpa_net_VDD_RF.voltage = 0;
begin
int n, nf, np; int uv; bit vd; n = 0; nf = 0; np = 0; uv = 0; vd = 1'b0;
if ((openpa_rv_VDD_RF_0.state == UPF::FULL_ON || openpa_rv_VDD_RF_0.state == UPF::PARTIAL_ON)) begin if (n > 0 && openpa_rv_VDD_RF_0.voltage != uv) vd = 1'b1; uv = openpa_rv_VDD_RF_0.voltage; n = n + 1; if (openpa_rv_VDD_RF_0.state == UPF::FULL_ON) nf = nf + 1; else np = np + 1; end
if ((openpa_rv_VDD_RF_1.state == UPF::FULL_ON || openpa_rv_VDD_RF_1.state == UPF::PARTIAL_ON)) begin if (n > 0 && openpa_rv_VDD_RF_1.voltage != uv) vd = 1'b1; uv = openpa_rv_VDD_RF_1.voltage; n = n + 1; if (openpa_rv_VDD_RF_1.state == UPF::FULL_ON) nf = nf + 1; else np = np + 1; end
if (openpa_rv_VDD_RF_0.state == UPF::UNDETERMINED || openpa_rv_VDD_RF_1.state == UPF::UNDETERMINED) openpa_net_VDD_RF.state = UPF::UNDETERMINED;
else if (n > 1) begin openpa_net_VDD_RF.state = UPF::UNDETERMINED; openpa_rc_VDD_RF = 1'b1; end // more than one source not OFF
else if (n == 1) begin openpa_net_VDD_RF.state = nf ? UPF::FULL_ON : UPF::PARTIAL_ON; openpa_net_VDD_RF.voltage = uv; end
end
// switch SW_WEAK (radio.upf:25): IEEE 1801-2024 6.23
openpa_swv_SW_WEAK_u = 1'b0; openpa_swv_SW_WEAK_hf = 1'b0; openpa_swv_SW_WEAK_hp = 1'b0; openpa_swv_SW_WEAK_vd = 1'b0; openpa_swv_SW_WEAK_on = 1'b0; openpa_swv_SW_WEAK_pt = 1'b0; openpa_swv_SW_WEAK_k = 0;
if (($isunknown(openpa_ctl_0_pwr_weak)) && UPF::openpa_net_VDD_N.state != UPF::OFF) openpa_swv_SW_WEAK_u = 1'b1; // on state on: a control is X or Z
else if ((openpa_ctl_0_pwr_weak === 1'b1)) begin
if (!openpa_swv_SW_WEAK_on) openpa_swv_SW_WEAK_k = 1;
openpa_swv_SW_WEAK_on = 1'b1;
if (UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED) openpa_swv_SW_WEAK_u = 1'b1;
else if (UPF::openpa_net_VDD_N.state == UPF::FULL_ON) begin
if ((openpa_swv_SW_WEAK_hf && openpa_swv_SW_WEAK_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_WEAK_hp && openpa_swv_SW_WEAK_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_WEAK_vd = 1'b1;
openpa_swv_SW_WEAK_f = UPF::openpa_net_VDD_N; openpa_swv_SW_WEAK_hf = 1'b1;
end
else if (UPF::openpa_net_VDD_N.state == UPF::PARTIAL_ON) begin
if ((openpa_swv_SW_WEAK_hf && openpa_swv_SW_WEAK_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_WEAK_hp && openpa_swv_SW_WEAK_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_WEAK_vd = 1'b1;
openpa_swv_SW_WEAK_p = UPF::openpa_net_VDD_N; openpa_swv_SW_WEAK_hp = 1'b1;
end
end
if ((1'b0) || (((!((openpa_ctl_0_pwr_weak === 1'b1)))) && (openpa_swv_SW_WEAK_on || openpa_swv_SW_WEAK_pt)) || openpa_swv_SW_WEAK_u || openpa_swv_SW_WEAK_vd || (!($isunknown(openpa_ctl_0_pwr_weak)) && !openpa_swv_SW_WEAK_on && !openpa_swv_SW_WEAK_pt && !((!((openpa_ctl_0_pwr_weak === 1'b1)))) && !(1'b0))) begin openpa_sw_SW_WEAK_st = -1; openpa_rv_VDD_BB_0.state = UPF::UNDETERMINED; openpa_rv_VDD_BB_0.voltage = 0; end
else begin openpa_sw_SW_WEAK_st = openpa_swv_SW_WEAK_k; if (openpa_swv_SW_WEAK_hf) openpa_rv_VDD_BB_0 = openpa_swv_SW_WEAK_f; else if (openpa_swv_SW_WEAK_hp) openpa_rv_VDD_BB_0 = openpa_swv_SW_WEAK_p; else begin openpa_rv_VDD_BB_0.state = UPF::OFF; openpa_rv_VDD_BB_0.voltage = 0; end end
// switch SW_MAIN (radio.upf:27): IEEE 1801-2024 6.23
openpa_swv_SW_MAIN_u = 1'b0; openpa_swv_SW_MAIN_hf = 1'b0; openpa_swv_SW_MAIN_hp = 1'b0; openpa_swv_SW_MAIN_vd = 1'b0; openpa_swv_SW_MAIN_on = 1'b0; openpa_swv_SW_MAIN_pt = 1'b0; openpa_swv_SW_MAIN_k = 0;
if (($isunknown(openpa_ctl_1_pwr_main)) && UPF::openpa_net_VDD_N.state != UPF::OFF) openpa_swv_SW_MAIN_u = 1'b1; // on state on: a control is X or Z
else if ((openpa_ctl_1_pwr_main === 1'b1)) begin
if (!openpa_swv_SW_MAIN_on) openpa_swv_SW_MAIN_k = 1;
openpa_swv_SW_MAIN_on = 1'b1;
if (UPF::openpa_net_VDD_N.state == UPF::UNDETERMINED) openpa_swv_SW_MAIN_u = 1'b1;
else if (UPF::openpa_net_VDD_N.state == UPF::FULL_ON) begin
if ((openpa_swv_SW_MAIN_hf && openpa_swv_SW_MAIN_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_MAIN_hp && openpa_swv_SW_MAIN_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_MAIN_vd = 1'b1;
openpa_swv_SW_MAIN_f = UPF::openpa_net_VDD_N; openpa_swv_SW_MAIN_hf = 1'b1;
end
else if (UPF::openpa_net_VDD_N.state == UPF::PARTIAL_ON) begin
if ((openpa_swv_SW_MAIN_hf && openpa_swv_SW_MAIN_f.voltage != UPF::openpa_net_VDD_N.voltage) || (openpa_swv_SW_MAIN_hp && openpa_swv_SW_MAIN_p.voltage != UPF::openpa_net_VDD_N.voltage)) openpa_swv_SW_MAIN_vd = 1'b1;
openpa_swv_SW_MAIN_p = UPF::openpa_net_VDD_N; openpa_swv_SW_MAIN_hp = 1'b1;
end
end
if ((1'b0) || (((!((openpa_ctl_1_pwr_main === 1'b1)))) && (openpa_swv_SW_MAIN_on || openpa_swv_SW_MAIN_pt)) || openpa_swv_SW_MAIN_u || openpa_swv_SW_MAIN_vd || (!($isunknown(openpa_ctl_1_pwr_main)) && !openpa_swv_SW_MAIN_on && !openpa_swv_SW_MAIN_pt && !((!((openpa_ctl_1_pwr_main === 1'b1)))) && !(1'b0))) begin openpa_sw_SW_MAIN_st = -1; openpa_rv_VDD_BB_1.state = UPF::UNDETERMINED; openpa_rv_VDD_BB_1.voltage = 0; end
else begin openpa_sw_SW_MAIN_st = openpa_swv_SW_MAIN_k; if (openpa_swv_SW_MAIN_hf) openpa_rv_VDD_BB_1 = openpa_swv_SW_MAIN_f; else if (openpa_swv_SW_MAIN_hp) openpa_rv_VDD_BB_1 = openpa_swv_SW_MAIN_p; else begin openpa_rv_VDD_BB_1.state = UPF::OFF; openpa_rv_VDD_BB_1.voltage = 0; end end
// supply net VDD_BB: -resolve parallel over switch SW_WEAK, switch SW_MAIN (IEEE 1801-2024 6.25.3)
openpa_rc_VDD_BB = 1'b0; openpa_net_VDD_BB.state = UPF::OFF; openpa_net_VDD_BB.voltage = 0;
begin
int n, nf, np; int uv; bit vd; n = 0; nf = 0; np = 0; uv = 0; vd = 1'b0;
if ((openpa_rv_VDD_BB_0.state == UPF::FULL_ON || openpa_rv_VDD_BB_0.state == UPF::PARTIAL_ON)) begin if (n > 0 && openpa_rv_VDD_BB_0.voltage != uv) vd = 1'b1; uv = openpa_rv_VDD_BB_0.voltage; n = n + 1; if (openpa_rv_VDD_BB_0.state == UPF::FULL_ON) nf = nf + 1; else np = np + 1; end
if ((openpa_rv_VDD_BB_1.state == UPF::FULL_ON || openpa_rv_VDD_BB_1.state == UPF::PARTIAL_ON)) begin if (n > 0 && openpa_rv_VDD_BB_1.voltage != uv) vd = 1'b1; uv = openpa_rv_VDD_BB_1.voltage; n = n + 1; if (openpa_rv_VDD_BB_1.state == UPF::FULL_ON) nf = nf + 1; else np = np + 1; end
if (openpa_rv_VDD_BB_0.state == UPF::UNDETERMINED || openpa_rv_VDD_BB_1.state == UPF::UNDETERMINED) openpa_net_VDD_BB.state = UPF::UNDETERMINED;
else if (vd) begin openpa_net_VDD_BB.state = UPF::UNDETERMINED; openpa_rc_VDD_BB = 1'b1; end // ON sources at different voltages: more than one root supply
else if (nf == 2) begin openpa_net_VDD_BB.state = UPF::FULL_ON; openpa_net_VDD_BB.voltage = uv; end
else if (n > 0) begin openpa_net_VDD_BB.state = UPF::PARTIAL_ON; openpa_net_VDD_BB.voltage = uv; end // a PARTIAL_ON source, or some sources OFF
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_RF.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_PD_RF_primary
bit nx; int sm;
sm = (UPF::openpa_net_VDD_RF.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_RF_primary_sim = sm;
nx = sm < 5;
if (openpa_ss_PD_RF_primary_ok && !nx) openpa_ss_PD_RF_primary_ep = openpa_ss_PD_RF_primary_ep + 1;
openpa_ss_PD_RF_primary_ok = nx;
end
// supply set PD_BB.primary: IEEE 1801-2024 4.7.3, 4.7.4, 6.5.6, 9.3.2, 5.7.8
begin : openpa_ss_PD_BB_primary
bit nx; int sm;
sm = (UPF::openpa_net_VDD_BB.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_BB_primary_sim = sm;
nx = sm < 5;
if (openpa_ss_PD_BB_primary_ok && !nx) openpa_ss_PD_BB_primary_ep = openpa_ss_PD_BB_primary_ep + 1;
openpa_ss_PD_BB_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_RF: simstate of its primary supply set PD_RF.primary
if (openpa_dom_PD_RF_ok && !UPF::openpa_ss_PD_RF_primary_ok) openpa_dom_PD_RF_ep = openpa_dom_PD_RF_ep + 1;
openpa_dom_PD_RF_ok = UPF::openpa_ss_PD_RF_primary_ok;
openpa_dom_PD_RF_sim = openpa_ss_PD_RF_primary_sim;
// domain PD_BB: simstate of its primary supply set PD_BB.primary
if (openpa_dom_PD_BB_ok && !UPF::openpa_ss_PD_BB_primary_ok) openpa_dom_PD_BB_ep = openpa_dom_PD_BB_ep + 1;
openpa_dom_PD_BB_ok = UPF::openpa_ss_PD_BB_primary_ok;
openpa_dom_PD_BB_sim = openpa_ss_PD_BB_primary_sim;
if (openpa_sw_SW_WEAK_st != openpa_pv_sw_SW_WEAK_st) begin openpa_tg_sw_SW_WEAK_st = ~openpa_tg_sw_SW_WEAK_st; openpa_pv_sw_SW_WEAK_st = openpa_sw_SW_WEAK_st; end
if (openpa_sw_SW_MAIN_st != openpa_pv_sw_SW_MAIN_st) begin openpa_tg_sw_SW_MAIN_st = ~openpa_tg_sw_SW_MAIN_st; openpa_pv_sw_SW_MAIN_st = openpa_sw_SW_MAIN_st; end
end
always @(posedge openpa_rc_VDD_RF) openpa_check(13, "supply net VDD_RF (-resolve one_hot): more than one source is ON; the net is UNDETERMINED (IEEE 1801-2024 6.25.3)");
always @(posedge openpa_rc_VDD_BB) openpa_check(13, "supply net VDD_BB (-resolve parallel): ON sources drive different voltages; the net is UNDETERMINED (IEEE 1801-2024 6.25.3)");
// ---- corruption: registers forced, memories overwritten (rules C1, C3)
// domain PD_TOP (radio.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 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_RF (radio.upf:5): 1 register(s), 0 memory(ies)
bit openpa_PD_RF_applied, openpa_PD_RF_valid;
logic [7:0] openpa_cv2; // corruption value for u_rf.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_RF_ok or openpa_kick) if (!openpa_PD_RF_valid || openpa_PD_RF_applied != UPF::openpa_dom_PD_RF_ok) begin
openpa_t({"PD_RF ", UPF::openpa_dom_PD_RF_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_PD_RF_ok || !openpa_PD_RF_valid) begin
if (openpa_xmode) openpa_cv2 = 'x; else openpa_cv2 = UPF::openpa_mix(2, UPF::openpa_dom_PD_RF_ep, 0);
force u_rf.q = openpa_cv2;
end
if (UPF::openpa_dom_PD_RF_ok) begin
release u_rf.q;
end
openpa_PD_RF_valid = 1'b1; openpa_PD_RF_applied = UPF::openpa_dom_PD_RF_ok;
end
// domain PD_BB (radio.upf:6): 1 register(s), 0 memory(ies)
bit openpa_PD_BB_applied, openpa_PD_BB_valid;
logic [7:0] openpa_cv3; // corruption value for u_bb.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_BB_ok or openpa_kick) if (!openpa_PD_BB_valid || openpa_PD_BB_applied != UPF::openpa_dom_PD_BB_ok) begin
openpa_t({"PD_BB ", UPF::openpa_dom_PD_BB_ok ? "NORMAL" : "CORRUPT"});
if (!UPF::openpa_dom_PD_BB_ok || !openpa_PD_BB_valid) begin
if (openpa_xmode) openpa_cv3 = 'x; else openpa_cv3 = UPF::openpa_mix(3, UPF::openpa_dom_PD_BB_ep, 0);
force u_bb.q = openpa_cv3;
end
if (UPF::openpa_dom_PD_BB_ok) begin
release u_bb.q;
end
openpa_PD_BB_valid = 1'b1; openpa_PD_BB_applied = UPF::openpa_dom_PD_BB_ok;
end
// D7 reset check for PD_BB: resets u_bb.rst_n active 0
bit openpa_PD_BB_rprev, openpa_PD_BB_rp0;
always @(posedge UPF::openpa_dom_PD_BB_ok or negedge UPF::openpa_dom_PD_BB_ok or posedge u_bb.rst_n or negedge u_bb.rst_n) begin
if (UPF::openpa_dom_PD_BB_ok && !openpa_PD_BB_rprev) openpa_PD_BB_rp0 = 1'b1;
if (!UPF::openpa_dom_PD_BB_ok || u_bb.rst_n === 1'b0) openpa_PD_BB_rp0 = 1'b0;
openpa_PD_BB_rprev = UPF::openpa_dom_PD_BB_ok;
end
// D7 reset check for PD_RF: resets u_rf.rst_n active 0
bit openpa_PD_RF_rprev, openpa_PD_RF_rp0;
always @(posedge UPF::openpa_dom_PD_RF_ok or negedge UPF::openpa_dom_PD_RF_ok or posedge u_rf.rst_n or negedge u_rf.rst_n) begin
if (UPF::openpa_dom_PD_RF_ok && !openpa_PD_RF_rprev) openpa_PD_RF_rp0 = 1'b1;
if (!UPF::openpa_dom_PD_RF_ok || u_rf.rst_n === 1'b0) openpa_PD_RF_rp0 = 1'b0;
openpa_PD_RF_rprev = UPF::openpa_dom_PD_RF_ok;
end
// ---- checks for set_isolation ISO_BB (radio.upf:37): PD_BB -> PD_TOP on 1 port(s)
bit openpa_ig1_act, openpa_ig1_cyc;
always @(negedge UPF::openpa_dom_PD_BB_ok) if (!UPF::openpa_dom_PD_BB_ok)
begin openpa_sp[1] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge UPF::openpa_ctl_3_iso_bb or negedge UPF::openpa_ctl_3_iso_bb or posedge openpa_kick) begin
if (openpa_ig1_act && !(UPF::openpa_ctl_3_iso_bb === 1'b1))
begin openpa_sp[2] = 1'b1; openpa_sreq = 1'b1; end
if (openpa_ig1_act != (UPF::openpa_ctl_3_iso_bb === 1'b1)) openpa_t({"ISO_BB enable ", (UPF::openpa_ctl_3_iso_bb === 1'b1) ? "active" : "inactive"});
openpa_ig1_act = (UPF::openpa_ctl_3_iso_bb === 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_RF (radio.upf:34): PD_RF -> PD_TOP on 1 port(s)
bit openpa_ig2_act, openpa_ig2_cyc;
always @(negedge UPF::openpa_dom_PD_RF_ok) if (!UPF::openpa_dom_PD_RF_ok)
begin openpa_sp[4] = 1'b1; openpa_sreq = 1'b1; end
always @(posedge UPF::openpa_ctl_2_iso_rf or negedge UPF::openpa_ctl_2_iso_rf or posedge openpa_kick) begin
if (openpa_ig2_act && !(UPF::openpa_ctl_2_iso_rf === 1'b1))
begin openpa_sp[5] = 1'b1; openpa_sreq = 1'b1; end
if (openpa_ig2_act != (UPF::openpa_ctl_2_iso_rf === 1'b1)) openpa_t({"ISO_RF enable ", (UPF::openpa_ctl_2_iso_rf === 1'b1) ? "active" : "inactive"});
openpa_ig2_act = (UPF::openpa_ctl_2_iso_rf === 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_bb/q (PD_BB) -> logic in radio (PD_TOP), isolated by ISO_BB
bit openpa_x1_t;
always @(UPF::openpa_dom_PD_BB_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_3_iso_bb or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_BB or UPF::openpa_net_VSS_N) openpa_x1_t = !UPF::openpa_dom_PD_BB_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_3_iso_bb === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_BB.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_bb/q (PD_BB) -> radio output q_bb (PD_TOP), isolated by ISO_BB
bit openpa_x2_t;
always @(UPF::openpa_dom_PD_BB_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_3_iso_bb or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_BB or UPF::openpa_net_VSS_N) openpa_x2_t = !UPF::openpa_dom_PD_BB_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_3_iso_bb === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_BB.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_rf/q (PD_RF) -> logic in radio (PD_TOP), isolated by ISO_RF
bit openpa_x3_t;
always @(UPF::openpa_dom_PD_RF_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_2_iso_rf or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_RF or UPF::openpa_net_VSS_N) openpa_x3_t = !UPF::openpa_dom_PD_RF_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_2_iso_rf === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_RF.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_rf/q (PD_RF) -> radio output q_rf (PD_TOP), isolated by ISO_RF
bit openpa_x4_t;
always @(UPF::openpa_dom_PD_RF_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_ctl_2_iso_rf or UPF::openpa_ss_anon_VDD_N_VSS_N_sim or UPF::openpa_net_VDD_RF or UPF::openpa_net_VSS_N) openpa_x4_t = !UPF::openpa_dom_PD_RF_ok && UPF::openpa_dom_PD_TOP_ok && !(((UPF::openpa_ctl_2_iso_rf === 1'b1) && (UPF::openpa_ss_anon_VDD_N_VSS_N_sim == 0))) && !(UPF::openpa_net_VDD_RF.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: radio input clk (PD_TOP) -> u_bb/clk (PD_BB), not isolated
bit openpa_x5_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_BB_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VSS_N) openpa_x5_t = !UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_BB_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: logic in radio (PD_TOP) -> u_bb/d (PD_BB), not isolated
bit openpa_x6_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_BB_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_BB_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: radio input en (PD_TOP) -> u_bb/en (PD_BB), not isolated
bit openpa_x7_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_BB_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_BB_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: radio input rst_n (PD_TOP) -> u_bb/rst_n (PD_BB), not isolated
bit openpa_x8_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_BB_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_BB_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: radio input clk (PD_TOP) -> u_rf/clk (PD_RF), not isolated
bit openpa_x9_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_RF_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_RF_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: radio input d (PD_TOP) -> u_rf/d (PD_RF), not isolated
bit openpa_x10_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_RF_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_RF_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: radio input en (PD_TOP) -> u_rf/en (PD_RF), not isolated
bit openpa_x11_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_RF_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_RF_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: radio input rst_n (PD_TOP) -> u_rf/rst_n (PD_RF), not isolated
bit openpa_x12_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_RF_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_RF_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_BB -> PD_TOP (no level shifter strategy, threshold 0)
bit openpa_l1_t;
always @(UPF::openpa_dom_PD_BB_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_BB or UPF::openpa_net_VDD_N) openpa_l1_t = UPF::openpa_dom_PD_BB_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_BB.voltage - UPF::openpa_net_VDD_N.voltage > 0 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_BB.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_RF -> PD_TOP (no level shifter strategy, threshold 0)
bit openpa_l2_t;
always @(UPF::openpa_dom_PD_RF_ok or UPF::openpa_dom_PD_TOP_ok or UPF::openpa_net_VDD_RF or UPF::openpa_net_VDD_N) openpa_l2_t = UPF::openpa_dom_PD_RF_ok && UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_net_VDD_RF.voltage - UPF::openpa_net_VDD_N.voltage > 0 || UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_RF.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_BB (no level shifter strategy, threshold 0)
bit openpa_l3_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_BB_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_BB) openpa_l3_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_BB_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_BB.voltage > 0 || UPF::openpa_net_VDD_BB.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_RF (no level shifter strategy, threshold 0)
bit openpa_l4_t;
always @(UPF::openpa_dom_PD_TOP_ok or UPF::openpa_dom_PD_RF_ok or UPF::openpa_net_VDD_N or UPF::openpa_net_VDD_RF) openpa_l4_t = UPF::openpa_dom_PD_TOP_ok && UPF::openpa_dom_PD_RF_ok && (UPF::openpa_net_VDD_N.voltage - UPF::openpa_net_VDD_RF.voltage > 0 || UPF::openpa_net_VDD_RF.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_SW_WEAK_def;
always @(posedge openpa_tg_sw_SW_WEAK_st or negedge openpa_tg_sw_SW_WEAK_st)
begin openpa_sp[23] = 1'b1; openpa_sreq = 1'b1; end
bit openpa_SW_MAIN_def;
always @(posedge openpa_tg_sw_SW_MAIN_st or negedge openpa_tg_sw_SW_MAIN_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 @(q_rf) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: q_rf=%h", $time, q_rf);
always @(q_bb) if (openpa_obs && UPF::openpa_dom_PD_TOP_ok && $time >= openpa_obs_after) $display("OPENPA-OBS @ %0t: q_bb=%h", $time, q_bb);
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_BB: PD_BB isolated before power-down %0d", openpa_seq[1]);
$display("OPENPA-COVER sequence D2/D7 ISO_BB: isolation released only after PD_BB was back and reset %0d", openpa_seq[2]);
$display("OPENPA-COVER sequence D1 ISO_RF: PD_RF isolated before power-down %0d", openpa_seq[3]);
$display("OPENPA-COVER sequence D2/D7 ISO_RF: isolation released only after PD_RF was back and reset %0d", openpa_seq[4]);
if (openpa_seq[1]) hq = hq + 1;
if (openpa_seq[2]) hq = hq + 1;
if (openpa_seq[3]) hq = hq + 1;
if (openpa_seq[4]) hq = hq + 1;
$display("OPENPA-COVER-SUMMARY states=%0d/0 declared_transitions=%0d/0 sequences=%0d/4", hs, ht, hq);
endfunction
// ---- settle process: 28 deferred check(s), run after one #0 in a fixed order
initial forever begin
wait (openpa_sreq && openpa_kick);
#0;
openpa_sreq = 1'b0;
if (openpa_sp[1]) begin
openpa_sp[1] = 1'b0;
if (!UPF::openpa_dom_PD_BB_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_3_iso_bb === 1'b1)) openpa_check(1, "set_isolation ISO_BB (radio.upf:37): PD_BB went off while the isolation enable iso_bb was inactive");
else if (!UPF::openpa_dom_PD_BB_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_3_iso_bb === 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_BB_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation ISO_BB (radio.upf:37): isolation released while PD_BB is still off");
else if (openpa_PD_BB_rp0) openpa_check(7, "set_isolation ISO_BB (radio.upf:37): isolation released after PD_BB powered up but before its reset u_bb.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_3_iso_bb === 1'b1) && !UPF::openpa_dom_PD_BB_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation ISO_BB (radio.upf:37): 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_RF_ok && (UPF::openpa_dom_PD_TOP_ok) && !(UPF::openpa_ctl_2_iso_rf === 1'b1)) openpa_check(1, "set_isolation ISO_RF (radio.upf:34): PD_RF went off while the isolation enable iso_rf was inactive");
else if (!UPF::openpa_dom_PD_RF_ok && (UPF::openpa_dom_PD_TOP_ok) && (UPF::openpa_ctl_2_iso_rf === 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_RF_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(2, "set_isolation ISO_RF (radio.upf:34): isolation released while PD_RF is still off");
else if (openpa_PD_RF_rp0) openpa_check(7, "set_isolation ISO_RF (radio.upf:34): isolation released after PD_RF powered up but before its reset u_rf.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_2_iso_rf === 1'b1) && !UPF::openpa_dom_PD_RF_ok && (UPF::openpa_dom_PD_TOP_ok)) openpa_check(6, "set_isolation ISO_RF (radio.upf:34): 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_bb/q of PD_BB (off) is read by logic in radio 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_bb/q of PD_BB (off) is read by radio output q_bb 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_rf/q of PD_RF (off) is read by logic in radio 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_rf/q of PD_RF (off) is read by radio output q_rf 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, "radio input clk of PD_TOP (off) is read by u_bb/clk in PD_BB (on) with no active isolation");
end
if (openpa_sp[12]) begin
openpa_sp[12] = 1'b0;
if (openpa_x6_t) openpa_check(9, "logic in radio of PD_TOP (off) is read by u_bb/d in PD_BB (on) with no active isolation");
end
if (openpa_sp[13]) begin
openpa_sp[13] = 1'b0;
if (openpa_x7_t) openpa_check(9, "radio input en of PD_TOP (off) is read by u_bb/en in PD_BB (on) with no active isolation");
end
if (openpa_sp[14]) begin
openpa_sp[14] = 1'b0;
if (openpa_x8_t) openpa_check(9, "radio input rst_n of PD_TOP (off) is read by u_bb/rst_n in PD_BB (on) with no active isolation");
end
if (openpa_sp[15]) begin
openpa_sp[15] = 1'b0;
if (openpa_x9_t) openpa_check(9, "radio input clk of PD_TOP (off) is read by u_rf/clk in PD_RF (on) with no active isolation");
end
if (openpa_sp[16]) begin
openpa_sp[16] = 1'b0;
if (openpa_x10_t) openpa_check(9, "radio input d of PD_TOP (off) is read by u_rf/d in PD_RF (on) with no active isolation");
end
if (openpa_sp[17]) begin
openpa_sp[17] = 1'b0;
if (openpa_x11_t) openpa_check(9, "radio input en of PD_TOP (off) is read by u_rf/en in PD_RF (on) with no active isolation");
end
if (openpa_sp[18]) begin
openpa_sp[18] = 1'b0;
if (openpa_x12_t) openpa_check(9, "radio input rst_n of PD_TOP (off) is read by u_rf/rst_n in PD_RF (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_BB (%0d uV) drives PD_TOP (%0d uV) on 2 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_BB.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_RF (%0d uV) drives PD_TOP (%0d uV) on 2 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_RF.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_BB (%0d uV) on 4 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_BB.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_RF (%0d uV) on 4 port(s) with no level shifter for this direction", UPF::openpa_net_VDD_N.voltage, UPF::openpa_net_VDD_RF.voltage));
end
if (openpa_sp[23]) begin
openpa_sp[23] = 1'b0;
if (UPF::openpa_sw_SW_WEAK_st != -1) openpa_SW_WEAK_def = 1'b1; else if (openpa_SW_WEAK_def) openpa_check(10, "power switch SW_WEAK is undetermined: a control is X, or no state (or more than one) holds (radio.upf:25)");
end
if (openpa_sp[24]) begin
openpa_sp[24] = 1'b0;
if (UPF::openpa_sw_SW_MAIN_st != -1) openpa_SW_MAIN_def = 1'b1; else if (openpa_SW_MAIN_def) openpa_check(10, "power switch SW_MAIN is undetermined: a control is X, or no state (or more than one) holds (radio.upf:27)");
end
if (openpa_sp[25]) begin
openpa_sp[25] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_RF_ok || UPF::openpa_dom_PD_BB_ok)) openpa_check(12, "pwr_weak (switch SW_WEAK) comes from PD_TOP, which is off while other domains are on");
end
if (openpa_sp[26]) begin
openpa_sp[26] = 1'b0;
if (!UPF::openpa_dom_PD_TOP_ok && (UPF::openpa_dom_PD_RF_ok || UPF::openpa_dom_PD_BB_ok)) openpa_check(12, "pwr_main (switch SW_MAIN) 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_RF_ok || UPF::openpa_dom_PD_BB_ok)) openpa_check(12, "iso_rf (isolation ISO_RF) 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_RF_ok || UPF::openpa_dom_PD_BB_ok)) openpa_check(12, "iso_bb (isolation ISO_BB) 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_WEAK_def) $display("OPENPA-WARNING power switch SW_WEAK never reached a defined state");
if (!openpa_SW_MAIN_def) $display("OPENPA-WARNING power switch SW_MAIN never reached a defined state");
end
// verilator lint_on MULTIDRIVEN
`line 20 "radio.sv" 0
endmodule
`line 1 "acc.sv" 0
// acc: an 8-bit accumulator.
module acc (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
output logic [7:0] q
);
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) q <= '0;
else if (en) q <= q + d;
endmodule
Check Yourself
Common Mistakes
Wrong Connect two sources to a net made without -resolve.
An unresolved net takes one source (IEEE 1801-2024 6.25.3). The file is refused.
Fix Choose -resolve one_hot or parallel for a net with several sources.
Wrong Use -resolve parallel for two regulators outside the chip.
parallel needs every source to trace to one root supply. Two regulators are two roots, so the file is refused.
Fix Use one_hot for sources from different supplies, and switch them so that only one is on.
Wrong Give a domain only a primary power net.
Then only power decides the domain's state, and OpenPA warns. A ground that goes off would go unseen.
Fix Name both -primary_power_net and -primary_ground_net.
Remember
- A supply port is a connection point with a direction; a supply net carries a state and a voltage.
- The state is OFF, PARTIAL_ON, FULL_ON or UNDETERMINED; the voltage, in microvolts, has a meaning only when on.
- An unresolved net takes one source. one_hot takes several that take turns; parallel takes several from one root.
- set_domain_supply_net gives a domain both primary nets; leave out the ground and OpenPA warns.
- -domain, -reuse and get_supply_net are UPF 1.0 forms; 1801-2024 keeps the first two as legacy.