Split a camera chip into an always-on part, an image pipe and a GPU. Each instance must land in the domain the table gives.
Hardware context: A media chip with a core and a DSP, and a camera chip with an image pipe and a GPU. Draw each power domain so that every instance lands where the power plan says.
The design cam has three blocks. u_sys is always-on glue, and inside it sits a GPU, u_sys/u_gpu. u_isp is an image pipe with a scaler and a statistics unit, and it has a register of its own. u_enc is an encoder beside it.
The SoC power team gave you cam_rails.upf: the supply ports, the always-on nets and two switched rails, VDD_ISP and VDD_GPU. Write the domain lines before it loads, then the primary supplies and the isolation after it.
Every instance must land in the domain the table gives. You can omit redundant -elements entries: an instance's children follow it unless another domain claims them.
Full specification
| Instance | Domain | Primary supply |
|---|---|---|
| cam (the top) | PD_TOP | VDD_N, VSS_N |
| u_sys | PD_TOP | VDD_N, VSS_N |
| u_sys/u_gpu | PD_GPU | VDD_GPU, VSS_N |
| u_isp, u_isp/u_scale, u_isp/u_stats | PD_ISP | VDD_ISP, VSS_N |
| u_enc | PD_ISP | VDD_ISP, VSS_N |
| Isolation of | Applies to | Clamp | Enable | Supply | Location |
|---|---|---|---|---|---|
| PD_ISP | outputs | 0 | iso_isp, active high | VDD_N, VSS_N | parent |
| PD_GPU | outputs | 0 | iso_gpu, active high | VDD_N, VSS_N | parent |
| Rule | What the grader checks |
|---|---|
| The top is in a domain | The design top itself is in PD_TOP. A file that leaves it out is refused. |
| One domain per instance | No instance is claimed by two domains. A file that does so is refused. |
| Names from the current scope | Every -elements path is written from the design top, where the file runs. |
| Every instance in its domain | The domain of each instance equals the table. |
| Supplies and isolation | Each domain has the table's primary supply. The isolation equals the table. |
| The scenarios pass | A public run, and two hidden runs that switch the rails off and on. |
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.
| Row | Rule |
|---|---|
| Switch the image pipe off while the GPU runs | public scenario: Run shows it |
| Switch the GPU off for two beats | hidden scenario |
| Image pipe off, back on with a reset | hidden scenario |
| Intent equals the reference | the domain of every instance; isolation cells (clamp, enable, sense, supply); supply sets and switches; the primary supply of every domain; where each isolation cell is placed; supply ports, nets and their connections |
The Design
The power-unaware RTL your UPF describes (top cam). Open a file to read it.
cam.sv
// cam: an always-on top with a system block, an image pipe and an encoder. Power-unaware RTL.
module cam (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
input logic pwr_isp,
input logic pwr_gpu,
input logic iso_isp,
input logic iso_gpu,
output logic [7:0] q_isp,
output logic [7:0] q_enc,
output logic [7:0] q_gpu,
output logic [7:0] total
);
sys u_sys (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(q_gpu));
isp u_isp (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(q_isp));
acc u_enc (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd3), .q(q_enc));
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) total <= '0;
else total <= q_isp + q_enc + q_gpu;
endmodule
sys.sv
// sys: always-on glue around a GPU; it registers the GPU's result.
module sys (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
output logic [7:0] q
);
logic [7:0] g;
acc u_gpu (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd2), .q(g));
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) q <= '0;
else q <= g;
endmodule
isp.sv
// isp: a scaler and a statistics unit, and a register that adds their results.
module isp (
input logic clk,
input logic rst_n,
input logic en,
input logic [7:0] d,
output logic [7:0] q
);
logic [7:0] s, t;
acc u_scale (.clk(clk), .rst_n(rst_n), .en(en), .d(d), .q(s));
acc u_stats (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd1), .q(t));
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) q <= '0;
else q <= s + t;
endmodule
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
Given UPF Files
Your file may load these with load_upf. The grader uses the same text.
cam_rails.upf
# cam_rails.upf: the rails of cam, from the SoC power team.
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}
create_supply_net VDD_ISP
create_supply_net VDD_GPU
create_power_switch SW_ISP -domain PD_TOP -input_supply_port {i VDD_N} -output_supply_port {o VDD_ISP} \
-control_port {c pwr_isp} -on_state {on i {c}} -off_state {off {!c}}
create_power_switch SW_GPU -domain PD_TOP -input_supply_port {i VDD_N} -output_supply_port {o VDD_GPU} \
-control_port {c pwr_gpu} -on_state {on i {c}} -off_state {off {!c}}
The Public Scenario
Switch the image pipe off while the GPU 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, pwr_isp = 1, pwr_gpu = 1, iso_isp = 0, iso_gpu = 0;
logic [7:0] d = 0;
wire [7:0] q_isp, q_enc, q_gpu, total;
cam dut (.*);
always #5 clk = ~clk;
task show(string what);
$display("%-9s scale=%0h stats=%0h isp=%0h enc=%0h gpu=%0h sys=%0h | q_isp=%0h q_enc=%0h total=%0h", what,
dut.u_isp.u_scale.q, dut.u_isp.u_stats.q, dut.u_isp.q, dut.u_enc.q, dut.u_sys.u_gpu.q, dut.u_sys.q, q_isp, q_enc, total);
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); @(posedge clk); #1 show("all run");
iso_isp = 1; #1 pwr_isp = 0; #1;
beat(8'h01); show("isp off");
#20 $finish;
end
endmodule
Examples
Example 1
The Starter- Input
The starter, with the given cam_rails.upf
- OpenPA says (recorded)
Refused: answer.upf:1: instance "cam" is in no power domain; add -include_scope to a domain at the design top, or list it in -elements
With no domain at all, the design top is in none. OpenPA stops at the first instance that has no domain.
Example 2
One Domain for Everything- Input
create_power_domain PD_TOP -elements {.} and nothing else- OpenPA reports (recorded)
Power domains PD_TOP (answer.upf:3): cam, u_enc, u_isp, u_isp/u_scale, u_isp/u_stats, u_sys, u_sys/u_gpu
With one domain at the top, every instance follows the top into PD_TOP. Your file must move some of them out.
Example 3
The Sample Run: Switch the Image Pipe off While the GPU Runs- Input
The reference file, run on the public scenario
- The bench prints (recorded)
all run scale=10 stats=11 isp=21 enc=13 gpu=12 sys=12 | q_isp=21 q_enc=13 total=13 isp off scale=xx stats=xx isp=xx enc=xx gpu=15 sys=12 | q_isp=0 q_enc=0 total=12
The image pipe is switched off with iso_isp raised first. Its registers and the encoder's go to X, and their outputs read the clamp value 0. The GPU and the always-on registers keep working.
Constraints and Contract
- Submit the whole UPF file for cam. Keep the domain names and the line that loads cam_rails.upf; the grader gives OpenPA the same file you see.
- cam_rails.upf makes its switches in PD_TOP, so PD_TOP must exist.
- The bench drives the supply ports VDD and VSS, the switch controls and the isolation enables.
Hints
Hint 1
Which instance has no parent? It needs a domain too, and . names the current scope.
Hint 2
A child follows its parent into the parent's domain. Name a child only when it must go somewhere else.
Hint 3
Write each -elements path from the design top, through the instances above it.
What the grader checks: OpenPA reads your file and cam_rails.upf. The grader checks each instance, primary supply, supply connection and isolation cell, including its location. 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 2 problems on this path