Skip to content

Commit 1fb7c10

Browse files
committed
deps: Update to Amaranth 0.5.4 and LUNA 0.2.0.
1 parent 1d50265 commit 1fb7c10

9 files changed

Lines changed: 206 additions & 231 deletions

File tree

orbtrace/amaranth_glue/luna.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@ def __init__(self, pads, wrapper, *args, **kwargs):
3838
[
3939
('data', [('i', 8, DIR_FANIN), ('o', 8, DIR_FANOUT), ('oe', 1, DIR_FANOUT)]),
4040
('clk', [('i', 1, DIR_FANIN)] if hasattr(pads, 'clk') else [('o', 1, DIR_FANOUT)]),
41-
('stp', 1, DIR_FANOUT),
41+
('stp', [('o', 1, DIR_FANOUT)]),
4242
('nxt', [('i', 1, DIR_FANIN)]),
4343
('dir', [('i', 1, DIR_FANIN)]),
44-
('rst', 1, DIR_FANOUT),
44+
('rst', [('o', 1, DIR_FANOUT)]),
4545
],
4646
)
4747

4848
wrapper.connect(ulpi_data.i, ulpi.data.i)
4949
wrapper.connect(ulpi_data.o, ulpi.data.o)
5050
wrapper.connect(ulpi_data.oe, ulpi.data.oe)
5151

52-
wrapper.connect(pads.stp, ulpi.stp)
52+
wrapper.connect(pads.stp, ulpi.stp.o)
5353
wrapper.connect(pads.nxt, ulpi.nxt.i)
5454
wrapper.connect(pads.dir, ulpi.dir.i)
55-
wrapper.connect(ulpi_rst, ulpi.rst)
55+
wrapper.connect(ulpi_rst, ulpi.rst.o)
5656

5757
if hasattr(pads, 'clk'):
5858
wrapper.connect(pads.clk, ulpi.clk.i)

orbtrace/amaranth_glue/wrapper.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import amaranth
2-
from amaranth.hdl import ir
2+
from amaranth.hdl import _ast, _ir
33
from amaranth.back import verilog
44

55
import migen
@@ -45,8 +45,7 @@ def get_instance(self):
4545
connections = {}
4646

4747
for m, n in self.connections:
48-
module, name, *_ = self.amaranth_name_map[n]
49-
direction = self.amaranth_dir_map[n]
48+
name, direction = self.amaranth_name_map[n]
5049
s = f'{direction}_{name}'
5150

5251
assert s not in connections, f'Signal {s} connected multiple times.'
@@ -58,22 +57,18 @@ def get_instance(self):
5857
def generate_verilog(self):
5958
ports = [n for m, n in self.connections]
6059

61-
fragment = ir.Fragment.get(self.m, None).prepare(ports = ports)
60+
fragment = _ir.Fragment.get(self.m, None).prepare(ports = ports, hierarchy = (self.name,))
6261

63-
v, m = verilog.convert_fragment(fragment, name = self.name)
62+
v, _name_map = verilog.convert_fragment(fragment, name = self.name)
63+
netlist = _ir.build_netlist(fragment, name = self.name)
6464

65-
self.amaranth_dir_map = fragment.ports
66-
self.amaranth_name_map = m
65+
self.amaranth_name_map = _ast.SignalDict((sig, (name, 'o' if name in netlist.top.ports_o else 'i')) for name, sig, _ in fragment.ports)
6766

68-
for name, domain in fragment.domains.items():
67+
for name, domain in fragment.fragment.domains.items():
6968
if domain.clk in self.amaranth_name_map:
7069
self.amaranth_name_map[amaranth.ClockSignal(name)] = self.amaranth_name_map[domain.clk]
71-
if domain.clk in self.amaranth_dir_map:
72-
self.amaranth_dir_map[amaranth.ClockSignal(name)] = self.amaranth_dir_map[domain.clk]
7370
if domain.rst in self.amaranth_name_map:
7471
self.amaranth_name_map[amaranth.ResetSignal(name)] = self.amaranth_name_map[domain.rst]
75-
if domain.rst in self.amaranth_dir_map:
76-
self.amaranth_dir_map[amaranth.ResetSignal(name)] = self.amaranth_dir_map[domain.rst]
7772

7873
return v
7974

orbtrace/dfu.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def elaborate(self, platform):
136136
interface = self.interface
137137
setup = self.interface.setup
138138

139+
m.d.comb += interface.claim.eq((setup.recipient == USBRequestRecipient.INTERFACE) & (setup.index == self.if_num))
139140
m.d.usb += self.new_request.eq(0)
140141

141142
with m.FSM(domain = 'usb'):

orbtrace/power/usb_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ def elaborate(self, platform):
9999

100100
setup = self.interface.setup
101101

102+
m.d.comb += self.interface.claim.eq((setup.recipient == USBRequestRecipient.INTERFACE) & (setup.index[:8] == self.if_num))
103+
102104
with m.FSM(domain = 'usb'):
103105
with m.State('IDLE'):
104106
self.transition(m)

orbtrace/trace/usb_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ def elaborate(self, platform):
8282

8383
setup = self.interface.setup
8484

85+
m.d.comb += self.interface.claim.eq((setup.recipient == USBRequestRecipient.INTERFACE) & ((setup.index[:8] == self.if_num) | (setup.index[:8] == self.proxy_if_num)))
86+
8587
with m.FSM(domain = 'usb'):
8688
with m.State('IDLE'):
8789
self.transition(m)

orbtrace/usb_mem_bridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def elaborate(self, platform):
108108
setup = self.interface.setup
109109

110110
with m.If((setup.type == USBRequestType.VENDOR) & (setup.recipient == 3) & (setup.request == 0)):
111-
111+
m.d.comb += interface.claim.eq(1)
112112
address = Cat(setup.value, setup.index)
113113

114114

orbtrace/usb_serialnumber.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,16 @@ def elaborate(self, platform):
7575

7676
setup = self.interface.setup
7777

78+
get_descriptor = \
79+
(setup.type == USBRequestType.STANDARD) & \
80+
(setup.recipient == USBRequestRecipient.DEVICE) & \
81+
(setup.request == USBStandardRequests.GET_DESCRIPTOR) & \
82+
(setup.value == (DescriptorTypes.STRING << 8) | self.idx)
83+
84+
m.d.comb += self.interface.claim.eq(get_descriptor)
85+
7886
with m.FSM(domain = 'usb'):
7987
with m.State('IDLE'):
80-
get_descriptor = \
81-
(setup.type == USBRequestType.STANDARD) & \
82-
(setup.recipient == USBRequestRecipient.DEVICE) & \
83-
(setup.request == USBStandardRequests.GET_DESCRIPTOR) & \
84-
(setup.value == (DescriptorTypes.STRING << 8) | self.idx)
85-
8688
with m.If(setup.received & get_descriptor):
8789
m.next = 'GET_DESCRIPTOR'
8890

0 commit comments

Comments
 (0)