W4.2.1 Scope It Right

EasyFixOpenPA + Icarus · serverReview the topic

The cluster team wrote its power intent for its own module. Load it at the right place in the hierarchy and wire its supplies from the top.

Hardware context: A cluster of two CPUs inside an always-on top. Apply a block's own UPF file at the right instance and wire its supplies from the top.

The top soc holds one instance, u_cluster, of module cluster. The cluster holds two CPUs, u_cpu0 and u_cpu1.

The cluster team gave you cluster.upf. Every name in it is written from inside a cluster: u_cpu0, VDD, iso0. It creates the domains PD_CL, PD_CPU0 and PD_CPU1 and the cluster's own supply ports VDD and VSS.

The starter top file loads it in the wrong place, and its last two lines name the wrong ports. Fix the top file. Do not change cluster.upf.

Full specification
InstanceDomain after your fix
soc (the top)PD_TOP
u_clusterPD_CL
u_cluster/u_cpu0PD_CPU0
u_cluster/u_cpu1PD_CPU1
RuleWhat the grader checks
The file loadsOpenPA reads your top file and cluster.upf with no refusal.
Every instance in its domainThe domain of each instance equals the table above.
The cluster is poweredThe cluster's ports VDD and VSS are fed from the top's nets VDD_N and VSS_N, so the always-on cluster logic runs.
The scenarios passA public run, and two hidden runs that switch CPUs off.

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
Switch u_cpu0 off while u_cpu1 runspublic scenario: Run shows it
Switch u_cpu1 off, then back onhidden scenario
Both CPUs off: the always-on sum registerhidden scenario
Intent equals the referencethe domain of every instance

The Design

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

soc.sv
// soc: an always-on top around a cluster of two CPUs. Power-unaware RTL.
module soc (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       en,
  input  logic [7:0] d,
  input  logic       pwr0,
  input  logic       pwr1,
  input  logic       iso0,
  input  logic       iso1,
  output logic [7:0] q0,
  output logic [7:0] q1,
  output logic [7:0] sum
);
  cluster u_cluster (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .pwr0(pwr0), .pwr1(pwr1),
                     .iso0(iso0), .iso1(iso1), .q0(q0), .q1(q1), .sum(sum));
endmodule
cluster.sv
// cluster: two identical CPUs and an always-on sum register. The power controls pass through.
module cluster (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       en,
  input  logic [7:0] d,
  input  logic       pwr0,
  input  logic       pwr1,
  input  logic       iso0,
  input  logic       iso1,
  output logic [7:0] q0,
  output logic [7:0] q1,
  output logic [7:0] sum
);
  cpu u_cpu0 (.clk(clk), .rst_n(rst_n), .en(en), .d(d),        .q(q0));
  cpu u_cpu1 (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd1), .q(q1));
  always_ff @(posedge clk or negedge rst_n)
    if (!rst_n) sum <= '0;
    else        sum <= q0 + q1;
endmodule
cpu.sv
// cpu: an 8-bit accumulator. Power-unaware RTL.
module cpu (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       en,
  input  logic [7:0] d,
  output logic [7:0] q
);
  logic [7:0] acc;
  always_ff @(posedge clk or negedge rst_n)
    if (!rst_n)  acc <= '0;
    else if (en) acc <= acc + d;
  assign q = acc;
endmodule

Given UPF Files

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

cluster.upf
# Power intent of module cluster, written by the cluster's team.
# Every name here is relative to a cluster instance.
create_power_domain PD_CL -include_scope
create_supply_port VDD -direction in
create_supply_port VSS -direction in
create_supply_net VDD_N
create_supply_net VSS_N
connect_supply_net VDD_N -ports {VDD}
connect_supply_net VSS_N -ports {VSS}
set_domain_supply_net PD_CL -primary_power_net VDD_N -primary_ground_net VSS_N

create_power_domain PD_CPU0 -elements {u_cpu0}
create_supply_net VDD_C0
create_power_switch SW0 -domain PD_CPU0 -input_supply_port {i VDD_N} -output_supply_port {o VDD_C0} \
    -control_port {c pwr0} -on_state {on i {c}} -off_state {off {!c}}
set_domain_supply_net PD_CPU0 -primary_power_net VDD_C0 -primary_ground_net VSS_N
set_isolation ISO0 -domain PD_CPU0 -applies_to outputs -clamp_value 0 \
    -isolation_power_net VDD_N -isolation_ground_net VSS_N \
    -isolation_signal iso0 -isolation_sense high -location parent

create_power_domain PD_CPU1 -elements {u_cpu1}
create_supply_net VDD_C1
create_power_switch SW1 -domain PD_CPU1 -input_supply_port {i VDD_N} -output_supply_port {o VDD_C1} \
    -control_port {c pwr1} -on_state {on i {c}} -off_state {off {!c}}
set_domain_supply_net PD_CPU1 -primary_power_net VDD_C1 -primary_ground_net VSS_N
set_isolation ISO1 -domain PD_CPU1 -applies_to outputs -clamp_value 0 \
    -isolation_power_net VDD_N -isolation_ground_net VSS_N \
    -isolation_signal iso1 -isolation_sense high -location parent

The Public Scenario

Switch u_cpu0 off while u_cpu1 runs. 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, en = 0, pwr0 = 1, pwr1 = 1, iso0 = 0, iso1 = 0;
  logic [7:0] d = 0;
  wire [7:0] q0, q1, sum;
  soc dut (.*);
  always #5 clk = ~clk;
  task show(string what);
    $display("%-10s q0=%0h q1=%0h sum=%0h", what, q0, q1, sum);
  endtask
  task beat(input logic [7:0] x); en = 1; d = x; @(posedge clk); #1 en = 0; endtask
  initial begin
    void'(supply_on("VDD", 1.0));
    void'(supply_on("VSS", 0.0));
    @(posedge clk); #1 rst_n = 1;
    beat(8'h10); beat(8'h10); show("run");
    iso0 = 1; #1 pwr0 = 0; #1;
    beat(8'h01); show("cpu0 off");
    #20 $finish;
  end
endmodule

Examples

Example 1

The Starter Top File
Input
The starter, with the given cluster.upf
OpenPA says (recorded)
Refused: cluster.upf:4: create_supply_port VDD: already created at line 5

The message names the line of cluster.upf that runs and the line of the top file that first made the same name.

Example 2

The Domain Map You Are Aiming For
Input
The reference top file, read by OpenPA (its domains)
OpenPA reports (recorded)
Power domains
  PD_TOP (answer.upf:4): soc
    primary supply PD_TOP.primary: power VDD_N, ground VSS_N
    0 register(s); 0 memory(ies)
  PD_CL (cluster.upf:3): u_cluster
    primary supply PD_CL.primary: power VDD_N, ground VSS_N
    1 register(s): u_cluster.sum; 0 memory(ies)
  PD_CPU0 (cluster.upf:12): u_cluster/u_cpu0
    primary supply PD_CPU0.primary: power u_cluster/VDD_C0, ground VSS_N  [switchable]
    1 register(s): u_cluster.u_cpu0.acc; 0 memory(ies)
  PD_CPU1 (cluster.upf:21): u_cluster/u_cpu1
    primary supply PD_CPU1.primary: power u_cluster/VDD_C1, ground VSS_N  [switchable]
    1 register(s): u_cluster.u_cpu1.acc; 0 memory(ies)

Every domain the cluster file makes lands on an instance inside u_cluster. Line numbers point into cluster.upf.

Example 3

The Sample Run: Switch u_cpu0 off While u_cpu1 Runs
Input
The reference file, run on the public scenario
The bench prints (recorded)
run        q0=20 q1=22 sum=21
cpu0 off   q0=0 q1=24 sum=22

u_cpu0 is switched off with iso0 raised first. q0 reads the clamp value 0, and the always-on sum register keeps adding q1.

Constraints and Contract

  • Submit the top file only. The grader gives OpenPA the same cluster.upf you see.
  • Keep the top's own supplies: ports VDD and VSS, nets VDD_N and VSS_N, domain PD_TOP.
  • Lines after the cluster's file must run at the top again.

Hints

Hint 1

Read the first message. It says which line runs a second time, and which line first created that name.

Hint 2

load_upf can run a file inside an instance, so that the file's names start from there.

Hint 3

From the top, a port created inside u_cluster has a hierarchical name.

What the grader checks: OpenPA reads your top file and the given cluster.upf. The grader compares the domain of every instance with the table. Then it runs a public and two hidden power scenarios.

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 1 problem 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