Intbv and the .next attribute

I was doing a testbench and had a “signal” I defined as opcode = intbv('000'). Then I did something like this:

opcode.next = 1

but opcode never changed during the simulation and I never got any warnings or errors.

Of course, the simulation started working correctly once I defined the signal as opcode = Signal(intbv('000')). Without the Signal(), my code was just creating a new attribute called next in the opcode object and this is perfectly legal so I wasn’t getting any indication of a problem.

My question: should the intbv and modbv classes have a predefined next property that will issue an error or warning if an assignment is made to them?

David,

That’s indeed a useful enhancement. The same has happened to me too :slight_smile: Not often, but it takes a fair amount of time peering into the waveform before this ‘inattention’ is found.

Regards,
Josy

I also agree this would be a useful enhancement. Since the intbv is not intended to have dynamic attributes (especially for conversion) the __getattr__ can be implemented so no dynamic attributes can created (e.g. if not hasattr(self, attr): raise Exception). If dynamic attrs are desired for modeling a subclass can be created.

The Signal object already does something similar.