3 pinmux documented here https://libre-soc.org/docs/pinmux/
5 from nmigen
.build
.dsl
import Resource
, Subsignal
, Pins
6 from nmigen
.build
.plat
import TemplatedPlatform
7 from nmigen
.build
.res
import ResourceManager
, ResourceError
8 from nmigen
.hdl
.rec
import Layout
9 from nmigen
import Elaboratable
, Signal
, Module
, Instance
10 from collections
import OrderedDict
11 from jtag
import JTAG
, resiotypes
, iotypes
, scanlens
12 from copy
import deepcopy
13 from nmigen
.cli
import rtlil
16 # extra dependencies for jtag testing (?)
17 #from soc.bus.sram import SRAM
19 #from nmigen import Memory
20 from nmigen
.sim
import Simulator
, Delay
, Settle
, Tick
, Passive
22 from nmutil
.util
import wrap
24 from nmutil
.gtkw
import write_gtkw
26 # from soc.debug.jtagutils import (jtag_read_write_reg,
27 # jtag_srv, jtag_set_reset,
28 # jtag_set_ir, jtag_set_get_dr)
30 from soc
.debug
.test
.test_jtag_tap
import (jtag_read_write_reg
,
39 # sigh this needs to come from pinmux.
42 gpios
.append("%d*0" % i
) # gpios to mux 0
43 return {'uart': ['tx+1', 'rx-1'],
45 # 'jtag': ['tms-', 'tdi-', 'tdo+', 'tck+'],
46 'i2c': ['sda*2', 'scl+2']}
50 a function is needed which turns the results of dummy_pinset()
53 [UARTResource("uart", 0, tx=..., rx=..),
54 I2CResource("i2c", 0, scl=..., sda=...),
55 Resource("gpio", 0, Subsignal("i"...), Subsignal("o"...)
56 Resource("gpio", 1, Subsignal("i"...), Subsignal("o"...)
60 # TODO: move to suitable location
62 """declare a list of pins, including name and direction. grouped by fn
63 the pin dictionary needs to be in a reliable order so that the JTAG
64 Boundary Scan is also in a reliable order
66 def __init__(self
, pindict
=None):
69 self
.io_names
= OrderedDict()
70 if isinstance(pindict
, OrderedDict
):
71 self
.io_names
.update(pindict
)
73 keys
= list(pindict
.keys())
76 self
.io_names
[k
] = pindict
[k
]
79 # start parsing io_names and enumerate them to return pin specs
81 for fn
, pins
in self
.io_names
.items():
83 # decode the pin name and determine the c4m jtag io type
84 name
, pin_type
, bank
= pin
[:-2], pin
[-2], pin
[-1]
85 iotype
= iotypes
[pin_type
]
86 pin_name
= "%s_%s" % (fn
, name
)
87 yield (fn
, name
, iotype
, pin_name
, scan_idx
, bank
)
88 scan_idx
+= scanlens
[iotype
] # inc boundary reg scan offset
91 if __name__
== '__main__':
93 pinset
= dummy_pinset()
95 #pin_test = Pins(Pins(pname+"_oe", dir="o", assert_width=1))
96 pin_test
= Pins(pinset
)
98 print(pin_test
.io_names
)
99 for fn
, name
, iotype
, pin_name
, scan_idx
, bank
in pin_test
:
100 print(fn
, name
, iotype
, pin_name
, scan_idx
, "Bank %s" % bank
)