A read bus with three drivers gives a wrong value when two sources talk at once. Give the bus one driver, and keep the tri-state only where the pin needs it.
Hardware context: The read path of a register block with a status register, a data register, an ID constant and a bidirectional pad; and a PWM core inside a top module that renames its ports. Rebuild the three-driver read bus as one driver and keep the tri-state at the pad.
A register block has three things to read: a status register, a data register and an ID constant. Each drives a shared internal read bus through its own tri-state driver. The bus leaves the chip on a bidirectional pad.
An address decode bug upstream sometimes raises two selects in the same cycle. The read data then showed X in simulation, and the synthesis flow refused the block for conflicting drivers. The shipped lines are in the specification.
A first repair changed the bus to a wired-OR net, which is the starter. The X is gone and the block builds. Now two selects in one cycle OR two registers together, and software reads a value that neither register holds.
This is a Fix problem. Rebuild the internal bus so that it has a stated priority and a known value in every case. One driver is the clean way to get both. The pad is different: another device shares that pin, so the chip must still let go of it.
Brief: status wins over data, and data wins over the ID. With no select the bus reads 8'h00. rdata never shows X or Z for known inputs. The pad carries rdata when pad_oe is 1 and is released when pad_oe is 0. pad_in follows the pad. Synthesis check: the design must build on the site's synthesis flow with no latch. The cell and level counts come from an open-source flow and are a proxy for area and depth, not a foundry result.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
script | 116 | input of each check |
Full specification
module read_port (
input logic sel_stat, // read the status register
input logic sel_data, // read the data register
input logic sel_id, // read the ID constant, 8'hA5
input logic [7:0] stat,
input logic [7:0] data,
input logic pad_oe, // 1: this chip drives the pad with rdata
output logic [7:0] rdata, // the internal read bus
output logic [7:0] pad_in, // what the pad carries
inout wire [7:0] pad // the bidirectional pin
);
// ...
endmodule
wire [7:0] bus;
assign bus = sel_stat ? stat : 8'bz; // each source drives the bus when it is selected
assign bus = sel_data ? data : 8'bz;
assign bus = sel_id ? ID : 8'bz;
| sel_stat | sel_data | sel_id | rdata |
|---|---|---|---|
| 1 | any | any | stat |
| 0 | 1 | any | data |
| 0 | 0 | 1 | 8'hA5 |
| 0 | 0 | 0 | 8'h00 |
| pad_oe | The other device | pad | pad_in |
|---|---|---|---|
| 1 | off | rdata | rdata |
| 0 | drives a value | that value | that value |
| 0 | off | floats (all z) | not checked |
Each test applies 4 steps of one nanosecond. After each step the result holds rdata, what the pad carried (pad_seen, 0 when it floats) and whether the pad floated (pad_floats).
Examples
Example 1
One Source at a Time- Input
sel=stat stat=3c data=81 pad:chip drives sel=data stat=3c data=81 pad:chip drives sel=id stat=3c data=81 pad:chip drives sel=none stat=3c data=81 pad:nobody drives
- Output
rdata_step0 = 0x3c, pad_seen_step0 = 0x3c, pad_floats_step0 = no, rdata_step1 = 0x81, pad_seen_step1 = 0x81, pad_floats_step1 = no, rdata_step2 = 0xa5, pad_seen_step2 = 0xa5, pad_floats_step2 = no, rdata_step3 = 0x0, pad_seen_step3 = 0x0, pad_floats_step3 = yes
Status, data and the ID are read in turn and leave on the pad. In the last step nothing is selected and the pad is released: rdata is 0 and the pad floats.
Example 2
Two Selects Overlap- Input
sel=stat+data stat=0f data=f0 pad:nobody drives sel=data+id stat=0f data=5a pad:nobody drives sel=stat+id stat=12 data=5a pad:nobody drives sel=stat+data+id stat=ff data=00 pad:nobody drives
- Output
rdata_step0 = 0xf, pad_seen_step0 = 0x0, pad_floats_step0 = yes, rdata_step1 = 0x5a, pad_seen_step1 = 0x0, pad_floats_step1 = yes, rdata_step2 = 0x12, pad_seen_step2 = 0x0, pad_floats_step2 = yes, rdata_step3 = 0xff, pad_seen_step3 = 0x0, pad_floats_step3 = yes
Status wins over data, data wins over the ID, and status wins over both. The tri-state bus showed X here, and the wired-OR bus mixes the two values.
Example 3
Nothing Selected- Input
sel=none stat=ff data=ff pad:nobody drives sel=data stat=00 data=77 pad:nobody drives sel=none stat=11 data=22 pad:chip drives sel=id stat=00 data=00 pad:nobody drives
- Output
rdata_step0 = 0x0, pad_seen_step0 = 0x0, pad_floats_step0 = yes, rdata_step1 = 0x77, pad_seen_step1 = 0x0, pad_floats_step1 = yes, rdata_step2 = 0x0, pad_seen_step2 = 0x0, pad_floats_step2 = no, rdata_step3 = 0xa5, pad_seen_step3 = 0x0, pad_floats_step3 = yes
The bus reads 0 with no select, whatever the registers hold. With pad_oe at 1 that 0 goes out on the pad.
Constraints and Contract
- Inputs are known 0/1 values. pad_oe and the other device are never on in the same step.
- Keep the module name and the ports. The block is combinational.
Hints
Hint 1
Count the drivers of the internal bus. Each assign to it is one, and a wired-OR net only changes how they combine.
Hint 2
A bus with one driver needs two decisions the tri-states never made. Who wins when two selects are on? What does the bus read when none is?
Hint 3
Write the internal bus as one always_comb chain that ends in an else. Leave the pad as it is: pad_oe ? value : 8'bz is how a chip shares a pin.
What the grader checks: Six directed and twelve seeded scripts of four steps each set the selects, the registers and both sides of the pad. rdata, the pad value and whether the pad floats are compared with an independent model after every step. Passing shows one known value on the bus for these inputs. The synthesis check adds that the flow accepts the drivers and finds no latch, so a second tri-state driver on the internal bus fails. The number of drivers is not graded. A wired-OR net whose drivers are gated into the priority order passes, because it builds the same logic. Lint is silent on wor and tri buses, so a Lint check would not catch it either.
The submitted design must synthesize with 0 latches and no combinational loop. Counts come from the pinned open-source synthesis flow. They are proxies for logic size and depth, not physical area or timing.
18 checks on Icarus Verilog + Yosys · server. 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