Turn the levels of logic from Synthesize into a minimum clock period, a setup slack and a hold verdict. The design has two pipeline stages.
Hardware context: The timing arithmetic of a multiply-accumulate block measured on this flow in one stage (33 levels) and in two (30 and 31). Write the block that turns levels and cell times into a period, a slack and a hold verdict.
A team sizes a multiply-accumulate block before any layout exists. All they have is this flow's report and a few numbers from the cell library. The inputs a and b are 8 bits, c is 16 bits and y is 17. Built in one stage, y = a * b + c measures 33 levels of logic and 435 cells. Cut into two stages, it measures 462 cells: 30 levels in the multiplier stage and 31 in the adder stage.
Their spreadsheet gave three different answers for the same block. This is an Implement problem: write the arithmetic once, as a small combinational module, so that it can be checked. The tests sweep every input.
Brief: all times are in picoseconds. Model the delay of a path as its levels times t_gate. t_min is the smallest period at which the slower of the two stages meets setup. slack is t_clk minus t_min, signed. hold_ok is 1 when the shortest flop-to-flop path meets the hold time. Use each input only where it belongs: some of them belong in no formula for t_min. Synthesis check: the design must build on the site's synthesis flow with no latch.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
lv_a | 7 | input of each check |
lv_b | 7 | input of each check |
t_gate | 8 | input of each check |
t_clk | 16 | input of each check |
Full specification
module clock_calc (
input logic [6:0] lv_a, // levels of logic on the longest path of stage A
input logic [6:0] lv_b, // the same for stage B (equal to lv_a in a one-stage design)
input logic [6:0] lv_short, // levels on the shortest flop-to-flop path
input logic [9:0] cells, // cells in the whole design
input logic [7:0] t_gate, // delay of one level, ps
input logic [9:0] t_cq, // clock-to-Q delay of a flop, ps
input logic [9:0] t_su, // setup time of a flop, ps
input logic [9:0] t_hold, // hold time of a flop, ps
input logic [15:0] t_clk, // the clock period the system asks for, ps
output logic [15:0] t_min, // the smallest period that meets setup, ps
output logic signed [16:0] slack, // setup slack at t_clk, ps: negative means too fast a clock
output logic hold_ok // 1: the shortest path meets hold
);
// your arithmetic
endmodule
| Output | Meaning | Width |
|---|---|---|
| t_min | the smallest clock period, in ps, at which every flop-to-flop path meets setup | 16 bits; it never passes 34 431 here |
| slack | t_clk - t_min: positive or zero when the asked period is long enough | 17 bits, signed |
| hold_ok | 1 when the data on the shortest path arrives no earlier than the hold time after the edge | 1 bit |
| Design on this flow | Cells | Levels |
|---|---|---|
| mac, one stage: y <= a * b + c | 435 | 33 |
| mac, two stages: p_q <= a * b, then y <= p_q + c_q | 462 | 30 and 31 (each stage synthesized alone) |
The model is the simple one of lesson R4.1. Every level has the same delay and wires have none. Both flops see the clock edge at the same instant. A real timing tool uses a cell library and the placed wires.
Examples
Example 1
The One-Stage MAC at 250 MHz- Input
levels A=33 B=33 shortest=1; cells=435; t_gate=110 ps, t_cq=180 ps, t_su=90 ps, t_hold=60 ps; t_clk=4000 ps
- Output
t_min_ps = 3900, slack_ps = 100, hold_ok = yes
33 levels at 110 ps are 3630 ps. With clock-to-Q and setup the period is 3900 ps, so a 4000 ps clock leaves 100 ps.
Example 2
The Two-Stage MAC at 250 MHz- Input
levels A=30 B=31 shortest=1; cells=462; t_gate=110 ps, t_cq=180 ps, t_su=90 ps, t_hold=60 ps; t_clk=4000 ps
- Output
t_min_ps = 3680, slack_ps = 320, hold_ok = yes
The adder stage has 31 levels, the multiplier stage 30. The slower one gives 3680 ps. The cut bought only 220 ps, because the multiplier was not the long part alone.
Example 3
A Hold Time Longer Than the Shortest Path- Input
levels A=30 B=31 shortest=1; cells=462; t_gate=20 ps, t_cq=40 ps, t_su=90 ps, t_hold=75 ps; t_clk=4000 ps
- Output
t_min_ps = 750, slack_ps = 3250, hold_ok = no
The shortest path has 1 level of 20 ps after a 40 ps clock-to-Q. That is 60 ps, less than the 75 ps hold time. The period does not enter.
Constraints and Contract
- Inputs are known 0/1 values. Levels are 0 to 127, t_gate 0 to 255 ps, the flop times 0 to 1023 ps.
- Keep the module name and the ports. The design is combinational.
Hints
Hint 1
Follow one value: it leaves a flop, crosses the logic, and must be stable some time before the next edge. Add the three delays on that route.
Hint 2
A pipeline register ends one path and starts another. Which of the two stages decides the period?
Hint 3
Hold is a race after one edge, on the fastest route. Ask which inputs can change the result of that race, and whether the clock period is one of them.
What the grader checks: Thirteen directed and fourteen seeded sets of numbers are applied one at a time. t_min, slack and hold_ok are compared with an independent model. Two sets use levels measured on this flow for the multiply-accumulate block of the brief. The model has one delay per level and no wires, so it ranks designs and does not predict silicon.
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.
27 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 1 steps and the final capstone