MyHDL Discourse

Intbv single bit modification


#1

Using a signal declared like this :

data = Signal(intbv(0)[4:]

I want to change only one bit of this signal in a process. For example :

    @always_seq(posedge(i_Clk), reset=None)
    def regs_manager():
        if ... :
            data[0].next = 0
        else :
            data[1].next = 1

In simulation, I get the following error :
AttributeError: ‘bool’ object has no attribute ‘next’

Conversion to VHDL seems to give correct result.

Looks like this is a bug a bug. Right ?

Note : I use last github version of myhdl with @block decorator syntax


#2

It is not a bug;. The indexing of the Signal is forwarded to the underlying intbv object and this returns a 'bool’
Use data.next[0] = 0 instead.


#3

Damn it ! I should have tried it :blush:
However, this is not very intuitive.

Thanks for your help.


#4

You can read it as follows: we are going to assign data a .next value but only for bit [0].


#5

This is a way of thinking.
Once you know the syntax, there’s no problem.