W4.5.2 Translate a UPF 1.0 File

MediumImplementOpenPA + Icarus · serverReview the topic

Rewrite an old net-based power intent file with supply sets, so that it says the same thing and runs the same way.

Hardware context: The same radio, its supplies bundled into supply sets with an n-well bias on the RF block. Name each supply once as a set, hand it to domains and strategies through handles, and check that a rewrite keeps the intent.

The power intent of pmu_soc (the design of W4.1) was written years ago in UPF 1.0 forms. Your team now writes IEEE 1801-2024. Translate it.

The power team has already put the rails into pmu_rails.upf: the ports, the nets, the switch and two supply sets. The core's set SS_CORE has no ground yet. Load that file and build the rest on it.

The translation must not change the intent. The grader compares it with the old file's domains, supplies, isolation and retention, and runs the old file's sleep and wake scenarios. The old file is the first item of the full specification.

Full specification
pmu_soc_10.upf: the file to translate.
upf_version 1.0
set_design_top pmu_soc

# Two domains: the always-on top and the switchable core
create_power_domain PD_TOP -include_scope
create_power_domain PD_CORE -elements {u_core}

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

# The core's supply goes through a switch that the PMU controls
create_supply_net VDD_CORE
create_power_switch SW_CORE -domain PD_CORE \
    -input_supply_port {vin VDD_N} -output_supply_port {vout VDD_CORE} \
    -control_port {ctrl u_pmu/pwr_en} -on_state {on vin {ctrl}} -off_state {off {!ctrl}}
set_domain_supply_net PD_CORE -primary_power_net VDD_CORE -primary_ground_net VSS_N

# Clamp the core's outputs to 0 while it is off
set_isolation ISO_CORE -domain PD_CORE -applies_to outputs -clamp_value 0 \
    -isolation_power_net VDD_N -isolation_ground_net VSS_N
set_isolation_control ISO_CORE -domain PD_CORE \
    -isolation_signal u_pmu/iso_en -isolation_sense high -location parent

# Keep the accumulator through power-down
set_retention RET_CORE -domain PD_CORE -elements {u_core/acc} \
    -retention_power_net VDD_N -retention_ground_net VSS_N
set_retention_control RET_CORE -domain PD_CORE \
    -save_signal {u_pmu/save posedge} -restore_signal {u_pmu/restore posedge}

UPF 1.0 form in the old fileWhat it means
set_domain_supply_neta domain's primary power and ground nets
-isolation_power_net, -isolation_ground_netthe nets that power the clamps
set_isolation_controlthe clamp enable, its sense and where the cells go, set apart from set_isolation
-retention_power_net, -retention_ground_netthe nets that power the saved copy
set_retention_controlthe save and restore signals, set apart from set_retention
RuleWhat the grader checks
The editionThe file declares IEEE 1801-2024 (upf_version 4.0).
No UPF 1.0 formsNone of the five forms in the table above, and no default_isolation or default_retention handle (older UPF).
Build on the given filepmu_rails.upf is loaded, and SS_CORE gets its ground there by refinement, not by a second set.
The same intentDomains, supply sets, primary supplies, isolation (clamp, enable, sense, supply, placement) and retention (controls, supply) equal the old file's.
The same runsThe old file's sleep and wake run, and two hidden runs, print the same lines with no check firing.

What the Grader Checks

OpenPA reads your file. A refusal ends the check with OpenPA's message and line. Otherwise every row below must pass.

RowRule
Three beats, sleep, wake: the accumulator comes backpublic scenario: Run shows it
The core is off and the bench raises enhidden scenario
Two sleep and wake cycles with work betweenhidden scenario
Intent equals the referencethe domain of every instance; supply sets and switches; the primary supply of every domain; isolation cells (clamp, enable, sense, supply); where each isolation cell is placed; retained registers and their controls; supply ports, nets and their connections
Editiondeclares upf_version 4.0
UPF formsno set_domain_supply_net; no strategy net pairs (-isolation_power_net and the like); no set_isolation_control or set_retention_control; no default_isolation or default_retention handles; uses create_supply_set -update; uses set_isolation ISO_CORE; uses set_retention RET_CORE
Static reportno forbidden finding

The Design

The power-unaware RTL your UPF describes (top pmu_soc). Open a file to read it.

pmu_soc.sv
// pmu_soc: two power domains. The top and the controller are always on; u_core can be switched off.
// The RTL is power-unaware: no isolation cell, no supply, no retention register is written here.
module pmu_soc (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       sleep_req,
  input  logic       wake_req,
  input  logic       en,
  input  logic [7:0] d,
  input  logic [1:0] rf_addr,
  input  logic       rf_we,
  output logic [7:0] total,
  output logic       led,
  output logic [7:0] rd,
  output logic [3:0] beats,
  output logic [7:0] status,
  output logic [2:0] pmu_state
);
  logic iso_en, save, restore, pwr_en, core_rst_n;
  logic [7:0] acc, rf_rd;
  logic busy;
  logic [3:0] core_beats;

  pmu u_pmu (
    .clk        (clk),
    .rst_n      (rst_n),
    .sleep_req  (sleep_req),
    .wake_req   (wake_req),
    .iso_en     (iso_en),
    .save       (save),
    .restore    (restore),
    .pwr_en     (pwr_en),
    .core_rst_n (core_rst_n),
    .state_o    (pmu_state)
  );

  core u_core (
    .clk     (clk),
    .rst_n   (core_rst_n),
    .en      (en),
    .d       (d),
    .rf_addr (rf_addr),
    .rf_we   (rf_we),
    .acc     (acc),
    .rf_rd   (rf_rd),
    .busy    (busy),
    .beats   (core_beats)
  );

  // Always-on consumers of the core's outputs.
  assign total = acc;
  assign led   = busy;
  assign rd    = rf_rd;
  assign beats = core_beats;
  // A status register: keeps the last accumulator value seen while the core was busy.
  always_ff @(posedge clk or negedge rst_n)
    if (!rst_n) status <= '0;
    else if (busy) status <= acc;
endmodule
pmu.sv
// pmu_soc: the always-on power controller. Power-unaware RTL: it only drives control signals.
// Sleep: isolate, save, switch off. Wake: switch on, reset, restore, release isolation.
module pmu (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       sleep_req,
  input  logic       wake_req,
  output logic       iso_en,
  output logic       save,
  output logic       restore,
  output logic       pwr_en,
  output logic       core_rst_n,
  output logic [2:0] state_o
);
  typedef enum logic [2:0] { RUN, ISOLATE, SAVE, OFF, PWRUP, RESET, RESTORE, RELEASE } st_e;
  st_e st;
  always_ff @(posedge clk or negedge rst_n)
    if (!rst_n) st <= RUN;
    else case (st)
      RUN:     if (sleep_req) st <= ISOLATE;
      ISOLATE: st <= SAVE;
      SAVE:    st <= OFF;
      OFF:     if (wake_req) st <= PWRUP;
      PWRUP:   st <= RESET;
      RESET:   st <= RESTORE;
      RESTORE: st <= RELEASE;
      RELEASE: st <= RUN;
      default: st <= RUN;
    endcase
  assign iso_en     = (st != RUN);
  assign save       = (st == SAVE);
  assign restore    = (st == RESTORE);
  assign pwr_en     = !(st == OFF);
  assign core_rst_n = rst_n && (st != RESET);
  assign state_o    = st;
endmodule
core.sv
// pmu_soc: the switchable core. An accumulator, a beat counter and a 4-word register file.
// Power-unaware RTL: nothing here knows about supplies.
module core (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       en,
  input  logic [7:0] d,
  input  logic [1:0] rf_addr,
  input  logic       rf_we,
  output logic [7:0] acc,
  output logic [7:0] rf_rd,
  output logic       busy,
  output logic [3:0] beats
);
  logic [7:0] rf [0:3];
  always_ff @(posedge clk or negedge rst_n)
    if (!rst_n) begin
      acc   <= '0;
      beats <= '0;
    end else if (en) begin
      acc   <= acc + d;
      beats <= beats + 4'd1;
    end
  always_ff @(posedge clk)
    if (rf_we) rf[rf_addr] <= acc;
  assign rf_rd = rf[rf_addr];
  assign busy  = en;
endmodule

Given UPF Files

Your file may load these with load_upf. The grader uses the same text.

pmu_rails.upf
# pmu_rails.upf: the rails of pmu_soc and their supply sets, from the SoC power team (given).
create_supply_port VDD -direction in
create_supply_port VSS -direction in
create_supply_net VDD_N
create_supply_net VSS_N
create_supply_net VDD_CORE
connect_supply_net VDD_N -ports {VDD}
connect_supply_net VSS_N -ports {VSS}
create_power_switch SW_CORE \
    -input_supply_port {vin VDD_N} -output_supply_port {vout VDD_CORE} \
    -control_port {ctrl u_pmu/pwr_en} -on_state {on vin {ctrl}} -off_state {off {!ctrl}}
create_supply_set SS_AON -function {power VDD_N} -function {ground VSS_N}
# The core's set: its ground is still to be added
create_supply_set SS_CORE -function {power VDD_CORE}

The Public Scenario

Three beats, sleep, wake: the accumulator comes back. Run checks its output and shows the expected lines and any failure.

tb.sv (public scenario)
`timescale 1ns/1ps
module tb;
  import UPF::*;
  logic clk = 0, rst_n = 0, sleep_req = 0, wake_req = 0, en = 0, rf_we = 0;
  logic [7:0] d = 0; logic [1:0] rf_addr = 0;
  wire [7:0] total, rd, status; wire led; wire [3:0] beats; wire [2:0] pmu_state;
  pmu_soc dut (.*);
  always #5 clk = ~clk;
  task show(string what);
    $display("%-12s acc=%0h total=%0h led=%0b iso=%0b pwr=%0b", what, dut.u_core.acc, total, led, dut.iso_en, dut.pwr_en);
  endtask
  task beats_of(input logic [7:0] x, input int n);
    en = 1; d = x; repeat (n) @(posedge clk); #1 en = 0;
  endtask
  task sleep(); sleep_req = 1; @(posedge clk); #1 sleep_req = 0; wait (pmu_state == 3'd3); #1; endtask
  task wake();  wake_req = 1;  @(posedge clk); #1 wake_req = 0;  wait (pmu_state == 3'd0); #1; endtask
  initial begin
    void'(supply_on("VDD", 1.0));
    void'(supply_on("VSS", 0.0));
    repeat (2) @(posedge clk);
    #1 rst_n = 1;
    beats_of(8'h11, 3); show("ran");
    sleep(); show("asleep");
    wake(); show("woken");
    #20 $finish;
  end
endmodule

Examples

Example 1

The Starter
Input
The starter, with the given pmu_rails.upf
OpenPA says (recorded)
Refused: answer.upf:1: instance "pmu_soc" is in no power domain; add -include_scope to a domain at the design top, or list it in -elements

The rails load, but no instance is in a power domain yet.

Example 2

The Intent of the Old File
Input
pmu_soc_10.upf, read by OpenPA on its own (its strategies)
OpenPA reports (recorded)
Strategies
  set_isolation ISO_CORE (answer.upf:24): clamp 0, enable u_pmu.iso_en active high, supply {VDD_N VSS_N}, location parent
  set_retention RET_CORE (answer.upf:30): u_core.acc; save u_pmu.save posedge, restore u_pmu.restore posedge; supply {VDD_N VSS_N}

Your file must build the same two strategies, with the same controls and the same always-on supply.

Example 3

The Sample Run: Three Beats, Sleep, Wake: The Accumulator Comes Back
Input
The reference file, run on the public scenario
The bench prints (recorded)
ran          acc=33 total=33 led=1 iso=0 pwr=1
asleep       acc=xx total=0 led=0 iso=1 pwr=0
woken        acc=33 total=33 led=0 iso=0 pwr=1

The core runs three beats of 0x11, sleeps and wakes. While it is off, its accumulator is X and total reads the clamp value 0. After wake-up the retained 0x33 is back: the same lines as the old file prints.

Constraints and Contract

  • Preserve the given supply wiring and isolation placement. Add no extra supply nets or ports. No supply net may lack a source.
  • Submit the whole UPF file for pmu_soc. Keep the domain and strategy names of the old file.
  • Do not change pmu_rails.upf: load it as it is. A set that exists can be changed only with create_supply_set -update.
  • The bench drives the supply ports VDD and VSS by name.

Hints

Hint 1

set_domain_supply_net becomes a supply set on the domain's primary handle.

Hint 2

Each strategy's net pair becomes one supply-set option, and each control command folds back into its strategy command.

Hint 3

Run the starter after each step: OpenPA names the first thing it cannot find.

What the grader checks: OpenPA reads your file and pmu_rails.upf. The grader checks the edition and the forms of the commands you used, after Tcl substitution, excluding comments and unused text. It compares the intent with the old file's. Then it runs the old file's public scenario and two hidden ones.

Run checks the public scenario only and never accepts. Submit runs every row. OpenPA is our open power-aware tool: it reads the UPF, writes a power-aware copy of the RTL, and Icarus runs that copy.

See all 2 problems on this path
Your UPF file UPFSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs
Not run yet

Run checks the public scenario. Submit checks every row in the description.

OpenPA + Icarus · server