Two register addresses reach one byte of storage, one of them rotated, and the model's mirrors drift apart. Fix the post_predict callbacks that are meant to keep them in step.
Hardware context: APB register slice with an aliased register pair and a scrambled memory. Keep the mirrors of a rotated alias in step.
CFG at 08 and CFG_A at 0C are the same byte in the design. CFG_A shows it rotated left by one bit. The register model has two registers, so an access through one leaves the other's mirror stale. A colleague copied a post_predict alias callback from an equal pair, and mirror checks still fail.
Fix the callback code so both mirrors match the design after every access through either register. CFG's mirror must equal the byte, and CFG_A's the byte rotated left. That includes reads after the design changed the byte.
Full specification
// CFG (08) and CFG_A (0C) are one byte in the design; CFG_A shows it rotated left by one bit.
// Keeps the two mirrors in step.
class alias_cb extends uvm_reg_cbs;
`uvm_object_utils(alias_cb)
uvm_reg other;
function new(string name = "alias_cb"); super.new(name); endfunction
function void post_predict(input uvm_reg_field fld, input uvm_reg_data_t previous,
inout uvm_reg_data_t value, input uvm_predict_e kind,
input uvm_door_e path, input uvm_reg_map map);
void'(other.predict(value));
endfunction
endclass
// Called once per model in connect_phase.
function automatic void link(slice_regs regs);
alias_cb to_a = new("cfg_to_cfg_a");
to_a.other = regs.cfg_a;
uvm_reg_field_cb::add(regs.cfg.val, to_a);
endfunction
| Access | In the design |
|---|---|
| cfg.write(v) | byte = v |
| cfg_a.write(v) | byte = v rotated right by one: {v[0], v[7:1]} |
| cfg.read | returns byte |
| cfg_a.read | returns byte rotated left by one: {byte[6:0], byte[7]} |
| post_predict argument | Meaning |
|---|---|
| previous | The field's mirror before this prediction |
| value | The value about to become the mirror; the callback may change it |
| kind | UVM_PREDICT_WRITE after a write, UVM_PREDICT_READ after a read |
Auto prediction is on. The checks look at both mirrors after every access. They ignore the moments after the design changes the byte, before anything reads it.
Examples
Example 1
Write CFG, Read CFG_A- Input
cfg.write(3c); cfg_a.read
- Output
cfg_mirror = 0x3c, cfg_a_mirror = 0x78, cfg_in_design = 0x3c, accesses_that_left_a_stale_mirror = 0
CFG's prediction 3c becomes 78 for CFG_A (rotated left), and the read through CFG_A agrees. No access left a stale mirror.
Example 2
Write CFG_A, Read CFG- Input
cfg_a.write(5b); cfg.read
- Output
cfg_mirror = 0xad, cfg_a_mirror = 0x5b, cfg_in_design = 0xad, accesses_that_left_a_stale_mirror = 0
Writing 5b through CFG_A stores ad. The other direction needs its own callback, on CFG_A's field, turning 5b back to ad for CFG.
Example 3
The Design Changes CFG- Input
cfg.write(11); design sets CFG to a2; cfg_a.read
- Output
cfg_mirror = 0xa2, cfg_a_mirror = 0x45, cfg_in_design = 0xa2, accesses_that_left_a_stale_mirror = 0
The read through CFG_A predicts 45 for CFG_A, and its callback predicts a2 for CFG.
Constraints and Contract
- Keep the class name and link's signature; link is called once per model.
- Change the mirrors only through prediction.
Hints
Hint 1
Which accesses never reach the callback the colleague installed?
Hint 2
A value in CFG's view is not a value in CFG_A's view. Which way does each callback have to turn it?
Hint 3
previous is the old mirror; set changes the desired value only.
What the grader checks: Your callbacks run on six real register models and designs. Hidden cases mix writes, reads and changes the design makes by itself. After every access the checks compare both mirrors with the design.
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 2 problems on this path