706e50c813d75f8c20575ad2f0abb2fb002c7b65
1 from nmigen
.build
import *
4 __all__
= ["UARTResource", "IrDAResource"]
7 def UARTResource(*args
, rx
, tx
, rts
=None, cts
=None, dtr
=None, dsr
=None, dcd
=None, ri
=None,
10 io
.append(Subsignal("rx", Pins(rx
, dir="i", assert_width
=1)))
11 io
.append(Subsignal("tx", Pins(tx
, dir="o", assert_width
=1)))
13 io
.append(Subsignal("rts", Pins(rts
, dir="o", assert_width
=1)))
15 io
.append(Subsignal("cts", Pins(cts
, dir="i", assert_width
=1)))
17 io
.append(Subsignal("dtr", Pins(dtr
, dir="o", assert_width
=1)))
19 io
.append(Subsignal("dsr", Pins(dsr
, dir="i", assert_width
=1)))
21 io
.append(Subsignal("dcd", Pins(dcd
, dir="i", assert_width
=1)))
23 io
.append(Subsignal("ri", Pins(ri
, dir="i", assert_width
=1)))
26 return Resource
.family(*args
, default_name
="uart", ios
=io
)
29 def IrDAResource(number
, *, rx
, tx
, en
=None, sd
=None, attrs
=None):
30 # Exactly one of en (active-high enable) or sd (shutdown, active-low enable) should
31 # be specified, and it is mapped to a logic level en subsignal.
32 assert (en
is not None) ^
(sd
is not None)
34 io
.append(Subsignal("rx", Pins(rx
, dir="i", assert_width
=1)))
35 io
.append(Subsignal("tx", Pins(tx
, dir="o", assert_width
=1)))
37 io
.append(Subsignal("en", Pins(en
, dir="o", assert_width
=1)))
39 io
.append(Subsignal("en", PinsN(sd
, dir="o", assert_width
=1)))
42 return Resource("irda", number
, *io
)