Add two callback hooks to a burst driver: one per beat to edit the beat, one per item to hold the lane. Both must reach the pins.
Hardware context: Lane VIP whose driver offers an edit hook and a timing hook. Add and call the hook points of a lane driver.
Your team ships a lane VIP whose items are bursts of one to four beats. Users want to corrupt chosen beats or slow the lane between items, without copying your driver.
Declare the two hooks in lane_cb, register lane_cb with lane_driver, and call each hook at the right point of the run loop. Users' callbacks must change the pins through pre_beat and the timing through post_item.
Full specification
// The hooks the VIP offers. Users extend lane_cb and override the hooks they need.
class lane_cb extends uvm_callback;
`uvm_object_utils(lane_cb)
function new(string name = "lane_cb"); super.new(name); endfunction
// Declare pre_beat and post_item here.
endclass
class lane_driver extends uvm_driver #(lane_item);
`uvm_component_utils(lane_driver)
virtual lane_if vif;
function new(string name, uvm_component parent); super.new(name, parent); endfunction
// The pin protocol, for each byte of each item:
// build a lane_beat: data = the byte, par = ^data, last = 1 on the item's last byte;
// at a falling edge drive valid = 1, data, par and last;
// wait for a rising edge where ready is 1, then set valid = 0.
// Call item_done after the item's last beat.
task run_phase(uvm_phase phase);
forever begin
seq_item_port.get_next_item(req);
seq_item_port.item_done();
end
endtask
endclass
| Hook | Prototype | When the driver calls it |
|---|---|---|
| pre_beat | virtual function void pre_beat(lane_driver drv, lane_item it, int index, lane_beat beat) | For every beat, after the driver builds it and before any pin moves. index counts the item's beats from 0. Edits to beat must reach the pins. |
| post_item | virtual task post_item(lane_driver drv, lane_item it) | Once per item, after the sink took the item's last beat and before item_done. The driver waits until every callback returns. |
Users add callbacks with uvm_callbacks #(lane_driver, lane_cb)::add(drv, cb). A run must print no CBUNREG warning. With no callback, beats are taken 20 ns apart from 15 ns.
Examples
Example 1
Bad Parity on the Second Beat of Item 1- Input
items of 3, 1 beats; bad parity on item 1 beat 1; gaps none
- Output
bad_parity_beats = {1}, last_beats = {2, 3}, beat1_ns_div5 = 3, beat2_ns_div5 = 7, beat3_ns_div5 = 11, beat4_ns_div5 = 15, beats = 4, pre_beat_calls = 4, post_item_calls = 2, cbunreg_warnings = 0
The user's pre_beat flips beat.par for index 1 of item 1, so the sink takes beat 2 with bad parity. Beats 3 and 4 are the last beats of the two items.
Example 2
Two Idle Clocks After a Two-Beat Item- Input
items of 2, 2 beats; bad parity on none; gaps 2 after item 1
- Output
bad_parity_beats = {}, last_beats = {1, 3}, beat1_ns_div5 = 3, beat2_ns_div5 = 7, beat3_ns_div5 = 13, beat4_ns_div5 = 17, beats = 4, pre_beat_calls = 4, post_item_calls = 2, cbunreg_warnings = 0
post_item waits two rising edges after the sink took beat 2 at 35 ns. Beat 3 is taken at 65 ns instead of 55 ns.
Example 3
One-Beat Items with a Gap and an Edit- Input
items of 1, 1, 1 beats; bad parity on item 2 beat 0; gaps 3 after item 2
- Output
bad_parity_beats = {1}, last_beats = {0, 1, 2}, beat1_ns_div5 = 3, beat2_ns_div5 = 7, beat3_ns_div5 = 15, beat4_ns_div5 = 0, beats = 3, pre_beat_calls = 3, post_item_calls = 3, cbunreg_warnings = 0
Item 2's only beat has bad parity. Three idle clocks after it push item 3 from 55 ns to 75 ns.
Constraints and Contract
- Keep the class names, the hook names and the prototypes above: users' callbacks override them.
- Keep the pin protocol of the starter.
- Call pre_beat once per beat and post_item once per item.
Hints
Hint 1
Users' callbacks only reach the pins through the objects you pass them. Which object do you copy to the pins?
Hint 2
A task hook that runs while valid is high delays the beat in flight. Where can a callback wait without changing a beat?
Hint 3
One macro line declares that lane_driver accepts lane_cb callbacks. Without it every add prints a warning, although the callbacks still run.
What the grader checks: Your driver runs on six real lanes with hidden bursts and users' callbacks. The checks read the parity, last marker and time of each beat the sink took, and count hook calls and CBUNREG warnings.
6 checks on UVM · 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 problem on this path