[Libre-soc-bugs] [Bug 762] Peripheral Pin Muxing Development

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Sun Jan 16 11:29:36 GMT 2022


https://bugs.libre-soc.org/show_bug.cgi?id=762

--- Comment #4 from Andrey Miroshnikov <andrey at technepisteme.xyz> ---
(In reply to Luke Kenneth Casson Leighton from comment #3)
>  107        comb += wb_rd_data.eq((gpio_oe_list[gpio_addr] << OESHIFT)
>  108                           + (gpio_ie_list[gpio_addr] << IESHIFT)
>  109                          + (puen_list[gpio_addr] << PUSHIFT)
>  110                          + (pden_list[gpio_addr] << PDSHIFT)
>  111                          + (gpio_i_list[gpio_addr] << IOSHIFT)
>  112                          + (bank_sel[gpio_addr] << BANKSHIFT))
> 
> this is what Record is for.  one line.

Sure. I looked at Robert's tutorial for Records
(https://github.com/RobertBaruch/nmigen-tutorial/blob/master/6_combining.md),
and created a Layout and Record:

class CSRLayout(Layout):
    def __init__(self):
        super().__init__([
            ("oe", unsigned(1)),
            ("ie", unsigned(1)),
            ("puen", unsigned(1)),
            ("pden", unsigned(1)),
            ("io", unsigned(1)),
            ("bank_sel", unsigned(NUMBANKBITS))
        ])

class CSRBus(Record):
    def __init__(self):
        super().__init__(CSRLayout)


In the SimpleGPIO module's __init__() method, I added:
self.csrbus = CSRBus()

During the object creation however, I'm getting a TypeError:
Traceback (most recent call last):
  File "simple_gpio.py", line 276, in <module>
    test_gpio()
  File "simple_gpio.py", line 258, in test_gpio
    dut = SimpleGPIO()
  File "simple_gpio.py", line 68, in __init__
    self.csrbus = CSRBus()
  File "simple_gpio.py", line 49, in __init__
    super().__init__(CSRLayout)
  File "/home/rohdo/src/nmigen/nmigen/hdl/rec.py", line 127, in __init__
    self.layout = Layout.cast(layout, src_loc_at=1 + src_loc_at)
  File "/home/rohdo/src/nmigen/nmigen/hdl/rec.py", line 25, in cast
    return Layout(obj, src_loc_at=1 + src_loc_at)
  File "/home/rohdo/src/nmigen/nmigen/hdl/rec.py", line 29, in __init__
    for field in fields:
TypeError: 'type' object is not iterable

Can you clarify what I'm missing here?

My current commit:
https://git.libre-soc.org/?p=pinmux.git;a=blob;f=src/spec/simple_gpio.py;hb=946fbf1fd881418a4061d9dab14dbe0110760f83#l36

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list