# Porting out a list of 8 bools as an 8-bit vector

**URL:** <https://discourse.myhdl.org/t/porting-out-a-list-of-8-bools-as-an-8-bit-vector/270>\
**Category:** Support\
**Created:** [April 10, 2018, 9:35pm UTC](https://discourse.myhdl.org/t/porting-out-a-list-of-8-bools-as-an-8-bit-vector/270 "2018-04-10T21:35:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kc64](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/kc64/32/83_2.png) [@kc64](https://discourse.myhdl.org/u/kc64)\
**Post date:** [April 10, 2018, 9:35pm UTC](https://discourse.myhdl.org/t/porting-out-a-list-of-8-bools-as-an-8-bit-vector/270/1 "2018-04-10T21:35:07Z")

</div>

I have a port on my design that I wish to output as an 8-bit vector called trigger\_outputs. My outputs list is an 8-element entity.

How do I define a connection between the port and the list?

---

<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:** [April 11, 2018, 5:59pm UTC](https://discourse.myhdl.org/t/porting-out-a-list-of-8-bools-as-an-8-bit-vector/270/2 "2018-04-11T17:59:34Z")

</div>

Something like:

```python
def somemodule( ..., portout, ...)
   listofbools = [Signal(bool(0)) for _ in range(8)]

   . . . 

    @always_comb
    def assign():
        for i in range(8):
           portout.next[i] = listofbools[i]

    . . . 

   return ..., assign, ...

```

---

<div class="post-metadata">

**Author:** ![kc64](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/kc64/32/83_2.png) [@kc64](https://discourse.myhdl.org/u/kc64)\
**Post date:** [April 11, 2018, 6:58pm UTC](https://discourse.myhdl.org/t/porting-out-a-list-of-8-bools-as-an-8-bit-vector/270/3 "2018-04-11T18:58:54Z")

</div>

@josyb, thanks so much for the reply. It was very helpful. This should be in the manual with all the ellipses. It helps a newer user to see how it all ties into the structure of the code.

You may want to edit this for the next user:

```
portout[i].next = listofbools[i]
```

---

<div class="post-metadata">

**Author:** ![kc64](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/kc64/32/83_2.png) [@kc64](https://discourse.myhdl.org/u/kc64)\
**Post date:** [April 11, 2018, 7:11pm UTC](https://discourse.myhdl.org/t/porting-out-a-list-of-8-bools-as-an-8-bit-vector/270/4 "2018-04-11T19:11:55Z")

</div>

One thing I noticed is that, in the test bed, I can specify the port as

```
portout = [Signal(False) for _ in range(8)]

```

and it works.

In the convertor, I can specify

```
portout = Signal(intbv(0)[8:])

```

and it works.

If I use the other form in either place, a fault occurs.

---

<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:** [April 12, 2018, 8:24am UTC](https://discourse.myhdl.org/t/porting-out-a-list-of-8-bools-as-an-8-bit-vector/270/5 "2018-04-12T08:24:58Z")

</div>

> [@kc64](#):
>
> You may want to edit this for the next user:
> 
> portout[i].next = listofbools[i]

? Can you explain? Perhaps add a bit more of you code, so I can also answer the question/issue in your next post.

---

<div class="post-metadata">

**Author:** ![kc64](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/kc64/32/83_2.png) [@kc64](https://discourse.myhdl.org/u/kc64)\
**Post date:** [April 12, 2018, 3:50pm UTC](https://discourse.myhdl.org/t/porting-out-a-list-of-8-bools-as-an-8-bit-vector/270/6 "2018-04-12T15:50:18Z")

</div>

@josyb, once again, you have steered me clear of my own inexperience and technical difficulties.

This line

```
portout.next[i] = listofbools[i]

```

totally threw me off and I still don’t understand it. When I tried it after your first presentation of it, I got errors. That’s because I had several and changing it to the form I thought was correct was compatible with the other error I had.

Having fixed all of my known errors, things are working as I intended. Again, many thanks.

---

<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:** [April 13, 2018, 9:15am UTC](https://discourse.myhdl.org/t/porting-out-a-list-of-8-bools-as-an-8-bit-vector/270/7 "2018-04-13T09:15:30Z")

</div>

if `portout`is Signal(intbv()) then only the following works for simulation

```python
portout.next[i] = listofbools[i]

```

```python
portout[i].next = listofbools[i]

```

will throw an exception in simulation, but not in conversion, so you might end up getting confused 🙂

```auto
  File "C:\Users\josy\myhdlsupport\issues\kc64\sr.py", line 31, in assign
    portout[i].next = listofbools[i]
AttributeError: 'bool' object has no attribute 'next'

```
