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


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?


Something like:

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

   . . . 

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

    . . . 

   return ..., assign, ...


@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]


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.


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


@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.


if portoutis Signal(intbv()) then only the following works for simulation

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

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

  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'