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

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Tue May 10 16:30:15 BST 2022


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

--- Comment #18 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
here is the pseudocode for reading the GPIO
data structs:

    read_bytes = []
    for i in range(len(sel)):
        GPIO_num = adr*len(sel)+i
        if sel[i]:
            read_bytes.append(GPIO[GPIO_num])
        else:
            read_bytes.append(Const(0, 8))
    if not wen:
        dat_r.eq(Cat(read_bytes))

and for writing, slightly different style:

    if wen:
        write_bytes = []
        for i in range(len(sel)):
            GPIO_num = adr*len(sel)+i
            write_byte = dat_w.bit_select(i*8, 8)
            if sel[i]:
                GPIO[GPIO_num].eq(write_byte)

that's it. that's all there is to it.

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


More information about the libre-soc-bugs mailing list