vrleboss vrleboss - 6 months ago 64
C Question

SystemVerilog looping through hierarchy

I have registers instantiated in a Register block

as such:


All these registers have the same inner structure.
I would like to simulate the effects of bit flips in these registers.

//Here an attempt to do bit flips
bitFlipLocation = $random;
force DUT.RegBlock.Register1.reg[bitFlipLocation] = ~DUT.RegBlock.Register1.reg[bitFlipLocation];
release DUT.ABCStar1.RegBlock.Register1.reg[bitFlipLocation];

Is there a way to create a loop over all
DUT.Regblock.Register1, RegisterA, RegisterABC, ...
and create these bit flips?

Answer Source

There are ways to do this, but not within the SystemVerilog language itself. You can write VPI code in C to iterate over block names and apply the forces use the C API. Or you can use tool specific commands to iterate of block names and use commands (usually Tcl) to apply the forces.

Both of those are beyond the scope of what can be shown in this forum.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download