Repair a module instance whose wires are listed by position in the wrong order, so that each signal reaches its port.
Hardware context: A room thermostat that places a heater control block, and the testbench of a three-input voter. Repair an instance that lists its wires by position in the wrong order.
A room thermostat places one ready-made heater control block. On the test bench the heater runs with the window open, and it ignores the boost button. The control block was tested long ago and is correct.
This is a Fix problem. The bug is in the one line of thermostat that places the block. It lists four wires by position, and the order does not match the port list of the block.
Repair the instance so that each wire reaches the port it belongs to. Keep the instance name u_heater. The check also confirms that the heater block still drives the output.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
row | 3 | input of each check |
Full specification
// heater.sv: the heater control block (read-only).
module heater (
input logic cold, // 1: the room is below the set temperature
input logic window_open, // 1: a window is open, so heating would be wasted
input logic boost, // 1: the boost button is held; it overrides everything
output logic heat // 1: the heater is on
);
assign heat = (cold & ~window_open) | boost;
initial tb.heaters++; // the bench counts the copies of this block
endmodule
module thermostat (
input logic cold_sense, // from the temperature sensor
input logic window_sw, // from the window switch
input logic boost_btn, // from the boost button
output logic heat_on // to the heater relay
);
// one instance of heater, named u_heater
endmodule
| Wire of thermostat | Belongs to the port |
|---|---|
| cold_sense | cold |
| window_sw | window_open |
| boost_btn | boost |
| heat_on | heat |
The heater must be on when the room is cold and the window is closed. The boost button turns it on in every case.
Examples
Example 1
Cold Room, Window Closed- Input
cold_sense window_sw boost_btn = 100
- Output
heat_on = 1
The room is cold and no window is open, so the heater must run.
Example 2
Cold Room, Window Open- Input
cold_sense window_sw boost_btn = 110
- Output
heat_on = 0
An open window blocks the heater, even in a cold room. Nobody holds the boost button.
Example 3
The Boost Button Alone- Input
cold_sense window_sw boost_btn = 001
- Output
heat_on = 1
The boost button turns the heater on, whatever the sensor and the window switch say.
Constraints and Contract
- Keep the module name thermostat, its four ports and the instance name u_heater.
- Place exactly one heater block. Do not copy its logic into thermostat.
Hints
Hint 1
Write the port list of heater on paper, in order. Under it, write the four wires of the instance line in their order. Compare the two rows.
Hint 2
By position, the first wire goes to the first port, whatever the names say.
Hint 3
A connection by name cannot be out of order: .cold(cold_sense) ties one wire to one port.
What the grader checks: The check applies all eight input rows, and eight more in another order. It reads heat_on one nanosecond after each change and compares it with the rule of the specification. One more case confirms that a single heater block named u_heater drives the output. It does not check whether you connected by name or by position.
20 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 steps and the final capstone