W4.6.1 Describe the Switch

MediumImplementOpenPA + Icarus · serverReview the topic

Write the two power switches of duo: their ports, their states, and an acknowledge for the always-on logic.

Hardware context: A tile with a soft-start switch that acknowledges, and a switch that picks a 1.0 V or a 0.8 V rail. Describe each switch state, flag illegal controls, and time the acknowledge the power controller waits for.

The design duo has an always-on top, a CPU and a GPU. The domains, supplies and supply sets are given in duo_rails.upf, and the isolation is in duo_iso.upf.

Each unit's rail comes through a power switch from the always-on net. The switches are missing: you write them.

The power controller waits for each switch to report that it is on. In the RTL, the wires ack_cpu and ack_gpu have no driver. The switches' acknowledge ports drive them.

Full specification
SwitchInputOutputControl signalClosed (on) whenAcknowledge wire
SW_CPUVDD_NVDD_CPUsleep_cpu_nthe CPU is awake: sleep_cpu_n is 1ack_cpu
SW_GPUVDD_NVDD_GPUpwr_gpupwr_gpu is 1ack_gpu
RuleWhat the grader checks
PortsEach switch takes the always-on net in and drives its unit's rail.
ControlEach switch is controlled by the signal in the table.
StatesEach switch is on exactly when the table says, and off otherwise. An off state that also holds while an on state holds is an error.
AcknowledgeEach switch drives its own wire: 1 once it has turned on, 0 once it has turned off, with no delay.
Acknowledge supplyThe acknowledge logic runs on SS_AON, so the acknowledge is valid while the unit is off.
The scenarios passA public run and two hidden control sequences print the expected rail states and acknowledges, with the expected check counts.

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
Both units run, then the CPU goes to sleeppublic scenario: Run shows it
The GPU is switched off and on againhidden scenario
A control goes unknown for a whilehidden 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; supply ports, nets and their connections; switch names, acknowledge wires, supplies and delays
Static reportno forbidden finding

The Design

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

duo.sv
// duo: an always-on top with a CPU and a GPU. Power-unaware RTL.
module duo (
  input  logic       clk,
  input  logic       rst_n,
  input  logic       en,
  input  logic [7:0] d,
  input  logic       sleep_cpu_n,
  input  logic       pwr_gpu,
  input  logic       iso_cpu,
  input  logic       iso_gpu,
  output logic [7:0] q_cpu,
  output logic [7:0] q_gpu,
  output logic [1:0] acks
);
  wire ack_cpu, ack_gpu;   // no RTL drives these wires: the UPF switches' -ack_port do
  acc u_cpu (.clk(clk), .rst_n(rst_n), .en(en), .d(d),        .q(q_cpu));
  acc u_gpu (.clk(clk), .rst_n(rst_n), .en(en), .d(d + 8'd1), .q(q_gpu));
  assign acks = {ack_gpu, ack_cpu};
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.

duo_rails.upf
# duo_rails.upf: the domains, supplies and supply sets of duo (given).
create_power_domain PD_TOP -elements {.}
create_power_domain PD_CPU -elements {u_cpu}
create_power_domain PD_GPU -elements {u_gpu}

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_CPU
create_supply_net VDD_GPU
connect_supply_net VDD_N -ports {VDD}
connect_supply_net VSS_N -ports {VSS}

create_supply_set SS_AON -function {power VDD_N} -function {ground VSS_N}
create_supply_set SS_CPU -function {power VDD_CPU} -function {ground VSS_N}
create_supply_set SS_GPU -function {power VDD_GPU} -function {ground VSS_N}
associate_supply_set SS_AON -handle PD_TOP.primary
associate_supply_set SS_CPU -handle PD_CPU.primary
associate_supply_set SS_GPU -handle PD_GPU.primary
duo_iso.upf
# duo_iso.upf: isolation of the two units (given).
set_isolation ISO_CPU -domain PD_CPU -applies_to outputs -clamp_value 0 \
    -isolation_supply SS_AON -isolation_signal iso_cpu -isolation_sense high -location parent
set_isolation ISO_GPU -domain PD_GPU -applies_to outputs -clamp_value 0 \
    -isolation_supply SS_AON -isolation_signal iso_gpu -isolation_sense high -location parent

The Public Scenario

Both units run, then the CPU goes to sleep. 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, sleep_cpu_n = 1, pwr_gpu = 1, iso_cpu = 0, iso_gpu = 0;
  logic [7:0] d = 0;
  wire [7:0] q_cpu, q_gpu; wire [1:0] acks;
  duo dut (.*);
  always #5 clk = ~clk;
  function automatic string rail(string net);
    upfSupplyTypeT v; upfSupplyStateE s;
    v = get_supply_value(net); s = get_supply_state(v);
    return $sformatf("%s %0d mV", s.name(), $rtoi(get_supply_voltage(v) * 1000.0));
  endfunction
  task show(string what);
    $display("%-10s cpu=%-17s gpu=%-17s acks=%b q_cpu=%0h q_gpu=%0h", what, rail("VDD_CPU"), rail("VDD_GPU"), acks, q_cpu, q_gpu);
  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); show("both on");
    iso_cpu = 1; #1 sleep_cpu_n = 0; #1 show("cpu asleep");
    beat(8'h01); show("gpu runs");
    #20 $finish;
  end
endmodule

Examples

Example 1

The Starter's Supply Network
Input
The starter, read by OpenPA (its supply network)
OpenPA reports (recorded)
Supply network
  VDD_N: port VDD  {port:VDD net:VDD_N fn:SS_AON.power fn:PD_TOP.primary.power}
  VSS_N: port VSS  {port:VSS net:VSS_N fn:SS_AON.ground fn:SS_CPU.ground fn:SS_GPU.ground fn:PD_TOP.primary.ground fn:PD_CPU.primary.ground fn:PD_GPU.primary.ground}
  VDD_CPU: root VDD_CPU  {net:VDD_CPU fn:SS_CPU.power fn:PD_CPU.primary.power}
  VDD_GPU: root VDD_GPU  {net:VDD_GPU fn:SS_GPU.power fn:PD_GPU.primary.power}

VDD_CPU and VDD_GPU feed the units' sets, but nothing drives them. The switches are their missing sources.

Example 2

The Domains of the Given File
Input
The starter, read by OpenPA (its domains)
OpenPA reports (recorded)
Power domains
  PD_TOP (duo_rails.upf:2): duo
    primary supply SS_AON: power VDD_N, ground VSS_N
  PD_CPU (duo_rails.upf:3): u_cpu
    primary supply SS_CPU: power VDD_CPU, ground VSS_N
  PD_GPU (duo_rails.upf:4): u_gpu
    primary supply SS_GPU: power VDD_GPU, ground VSS_N

Each unit already has its supply set. Neither set is switchable yet: nothing drives VDD_CPU or VDD_GPU.

Example 3

The Sample Run: Both Units Run, Then the CPU Goes to Sleep
Input
The reference file, run on the public scenario
The bench prints (recorded)
both on    cpu=FULL_ON 1000 mV   gpu=FULL_ON 1000 mV   acks=11 q_cpu=10 q_gpu=11
cpu asleep cpu=OFF 0 mV          gpu=FULL_ON 1000 mV   acks=10 q_cpu=0 q_gpu=11
gpu runs   cpu=OFF 0 mV          gpu=FULL_ON 1000 mV   acks=10 q_cpu=0 q_gpu=13

Both units run with both acknowledges at 1. The CPU goes to sleep with iso_cpu raised first: its rail reads OFF, its acknowledge falls, and the GPU keeps adding.

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 duo. Keep the two load_upf lines: duo_rails.upf first, duo_iso.upf last.
  • Name the switches SW_CPU and SW_GPU. Port and state names are your choice.
  • The bench drives the ports VDD and VSS, sleep_cpu_n, pwr_gpu and the isolation enables. It reads VDD_CPU, VDD_GPU and the output acks = {ack_gpu, ack_cpu}.

Hints

Hint 1

Read the control name carefully: a signal that ends in _n is active low. When is the CPU awake?

Hint 2

A switch with an acknowledge port needs -supply_set. Which supply stays on when the unit is off?

Hint 3

With no expression, an acknowledge port drives 1 after the switch turns on and 0 after it turns off.

What the grader checks: OpenPA reads your file and the two given files. The grader compares the domains, supply sets, switches (input, output and control nets) and isolation with the reference. Then it runs a public and two hidden control sequences, reading the rails, the acknowledges and the check counts.

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