Write rules for a VHDL-style entity on its ports only, bound into the entity.
Hardware context: A UART transmitter delivered as a VHDL entity, with only its ports visible. Write and bind datasheet rules on the ports of a block whose inside is hidden.
A UART transmitter arrives as a VHDL entity: SystemVerilog sees its ports and nothing inside. Two rules come from its datasheet. A start while busy is illegal, and a start makes the block busy at the next edge.
Write uart_rules, and fix the bind into vhdl_uart, the entity, so it connects the right ports. The entity's body here is a Verilog stand-in; do not use anything inside it. A wrapper, uart_wrap, has ports with the same names but other meanings.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
go | 1 | stimulus, the same for every design |
tx_busy | 1 | stimulus, the same for every design |
Full specification
// A stand-in for a VHDL entity. Treat its body as unknown: only the ports are part of the contract.
module vhdl_uart (input logic clk, tx_start, output logic tx_busy);
logic [1:0] n = 0;
logic busy_q = 0; // internal: a delayed copy, not part of the contract
always @(posedge clk) begin
if (tx_start || n != 0) n <= n + 2'd1;
busy_q <= (n != 0);
end
assign tx_busy = (n != 0);
endmodule
// A wrapper that also has ports named tx_start and tx_busy, with other meanings.
module uart_wrap (input logic clk, go, output logic tx_busy, output logic tx_start);
vhdl_uart core (.clk(clk), .tx_start(go), .tx_busy(tx_busy));
assign tx_start = go && !tx_busy; // a filtered request, not the raw one
endmodule
module uart_rules (
input logic clk, tx_start, tx_busy,
output int restart, // tx_start while busy
output int no_busy // tx_start not followed by busy at the next edge
);
// two rules
endmodule
// and one bind statement
| Edge | What the program shown here does | Expected |
|---|---|---|
| 15 | a start: busy from 25 | nothing |
| 35 | a second start while busy | restart fails once |
The full check also runs a second program, which this page does not show. Counts are read from the bound instance: u_wrap.core.rules.
Examples
Example 1
One Restart- Input
Program: a start at 15, another at 35
- Output
restart = 1
The start at 35 comes while the block is busy.
Example 2
Every Start Makes It Busy- Input
Program: a start at 15, another at 35
- Output
no_busy = 0
Busy follows each start at the next edge.
Example 3
None by 30- Input
Program: only the first start
- Output
restart = 0
The only start before 30 comes while the block is idle.
Constraints and Contract
- Write uart_rules with two concurrent assertions on its ports only.
- Keep the bind into vhdl_uart (the entity), instance name rules, on the entity's ports.
- Do not change the ports of uart_rules.
Hints
Hint 1
A VHDL entity exposes only its ports to a bind.
Hint 2
The wrapper also has a tx_start port, but it is a filtered copy. Bind to the entity itself.
Hint 3
The counters are outputs; a bind may leave them unconnected with .restart().
What the grader checks: Your module and bind are compiled with a fixed bench of two programs: the one shown here and a hidden one. Graded: both failure counts of the bound instance in each.
5 checks on Verilator · 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 4 steps and the final capstone