# Intbv single bit modification

**URL:** <https://discourse.myhdl.org/t/intbv-single-bit-modification/152>\
**Category:** Bug\
**Created:** [January 25, 2017, 2:42pm UTC](https://discourse.myhdl.org/t/intbv-single-bit-modification/152 "2017-01-25T14:42:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrPi](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/drpi/32/36_2.png) [@DrPi](https://discourse.myhdl.org/u/DrPi)\
**Post date:** [January 25, 2017, 2:42pm UTC](https://discourse.myhdl.org/t/intbv-single-bit-modification/152/1 "2017-01-25T14:42:50Z")

</div>

Using a signal declared like this :

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

```

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

```auto
    @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

---

<div class="post-metadata">

**Author:** ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)\
**Post date:** [January 25, 2017, 3:04pm UTC](https://discourse.myhdl.org/t/intbv-single-bit-modification/152/2 "2017-01-25T15:04:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DrPi](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/drpi/32/36_2.png) [@DrPi](https://discourse.myhdl.org/u/DrPi)\
**Post date:** [January 25, 2017, 3:12pm UTC](https://discourse.myhdl.org/t/intbv-single-bit-modification/152/3 "2017-01-25T15:12:38Z")

</div>

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

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)\
**Post date:** [January 25, 2017, 6:14pm UTC](https://discourse.myhdl.org/t/intbv-single-bit-modification/152/4 "2017-01-25T18:14:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DrPi](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/drpi/32/36_2.png) [@DrPi](https://discourse.myhdl.org/u/DrPi)\
**Post date:** [January 26, 2017, 7:27am UTC](https://discourse.myhdl.org/t/intbv-single-bit-modification/152/5 "2017-01-26T07:27:09Z")

</div>

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