# Conversion of list of objects

**URL:** <https://discourse.myhdl.org/t/conversion-of-list-of-objects/275>\
**Category:** Support\
**Created:** [June 1, 2018, 2:50pm UTC](https://discourse.myhdl.org/t/conversion-of-list-of-objects/275 "2018-06-01T14:50:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aurang](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@aurang](https://discourse.myhdl.org/u/aurang)\
**Post date:** [June 1, 2018, 2:50pm UTC](https://discourse.myhdl.org/t/conversion-of-list-of-objects/275/1 "2018-06-01T14:50:20Z")

</div>

I have following class.

> class framegrabber\_roi():  
> def **init** (self, nb\_bits\_roi=16):  
> if not 16 == nb\_bits\_roi:  
> raise ValueError(“Number of bits to represent ROI must be 16”)  
> self.roi\_width = Signal(intbv(0)[nb\_bits\_roi:])  
> self.roi\_height = Signal(intbv(0)[nb\_bits\_roi:])  
> self.roi\_width\_offset = Signal(intbv(0)[nb\_bits\_roi:])  
> self.roi\_height\_offset = Signal(intbv(0)[nb\_bits\_roi:])

I have created a list of objects from the above class.

> roi\_list =   
> for i in range(2):  
> roi\_list.append(framegrabber\_roi(16))

When i try to access the list like following

> roi\_list[0].roi\_width.next = avs\_mm.writedata\_i[16:]

The conversion does not work, it throws following error  
**Object type is not supported in this context: roi\_list, \<type ‘list’\>**

When i use only a single object, the conversion work perfectly fine.  
I just wanted to be sure if this is the limitation by the conversion in myhdl because in python i can access the list of objects with their individual elements.  
Please let me know if somebody has tried a better approach to handle it.  
Thanks for your response.

---

<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:** [June 1, 2018, 3:55pm UTC](https://discourse.myhdl.org/t/conversion-of-list-of-objects/275/2 "2018-06-01T15:55:27Z")

</div>

Yes, MyHDL does not handle a list of classes.  
I pass all Signals to each instantiation like:

```python

class _correctionelement(object):
    ''' the element performing the actual work '''

    def __init__ (self, Clk, DoFpn, DoPrnu, PrnuFpn, D, Enables, Q=None, PRNU_SCALING=9, ROUNDING=False):
     ....

class ColumnCorrection(object):
    ''' column correction of image streaam '''

    def __init__ (self, WIDTH_FPN, WIDTH_PRNU, NBR_COLUMNS, NBR_LINES,
                 NBR_PARALLEL_PIXELS, ClkMM, ResetMM, Clk, Reset,
                 NbrLines, RowSequence, Enable, Sink,
                 Avalon=None, Source=None,
                 MAX_PRNU_GAIN=2.0, WIDTH_SCALING=9, ROUNDING=False,
                 ):

   ....

    def rtl(self):
        ''' the logic '''

    ...
        for i in range(self.NBR_PARALLEL_PIXELS):
            cces.append(_correctionelement(self.Clk, self.csr.Control.FpnOn, self.csr.Control.PrnuOn, coefficients[i],
                                           self.Sink.PayLoad.Data[i], pl.Enables, Q=self.Source.PayLoad.Data[i],
                                           PRNU_SCALING=self.WIDTH_SCALING, ROUNDING=self.ROUNDING))
            ccesrtl.append(cces[i].rtl())

```
