Restructure rtio.cri to follow nMigen convention

pull/1/head
Donald Sebastian Leung 2020-10-27 12:14:47 +08:00
parent 05f37c0c13
commit 32641851b7
2 changed files with 12 additions and 7 deletions

View File

@ -31,8 +31,8 @@ $ python -m rtio.test.sed.output_network
- - [ ] `rtio.rtlink` - - [ ] `rtio.rtlink`
- - [x] `rtio.sed.output_network` - Sorting network (high priority) - - [x] `rtio.sed.output_network` - Sorting network (high priority)
- - [ ] `rtio.sed.output_driver` - - [ ] `rtio.sed.output_driver`
- [ ] Restructure to code to follow nMigen convention and re-validate existing assertions - [ ] Restructure to code to follow nMigen convention and re-validate existing assertions (if any)
- - [ ] `rtio.cri` (`Interface` and `CRIDecoder` only) - - [x] `rtio.cri` (`Interface` and `CRIDecoder` only)
- - [ ] `rtio.rtlink` - - [ ] `rtio.rtlink`
- - [x] `rtio.sed.output_network` - - [x] `rtio.sed.output_network`
- - [ ] `rtio.sed.output_driver` - - [ ] `rtio.sed.output_driver`

View File

@ -59,16 +59,22 @@ class Interface(Record):
class CRIDecoder(Elaboratable): class CRIDecoder(Elaboratable):
def __init__(self, slaves=2, master=None, mode="async", enable_routing=False): def __init__(self, slaves=2, master=None, mode="async", enable_routing=False):
m = Module()
self.m = m
if isinstance(slaves, int): if isinstance(slaves, int):
slaves = [Interface() for _ in range(slaves)] slaves = [Interface() for _ in range(slaves)]
if master is None: if master is None:
master = Interface() master = Interface()
self.slaves = slaves self.slaves = slaves
self.master = master self.master = master
self.mode = mode
self.enable_routing = enable_routing
# # # def elaborate(self, platform):
m = Module()
slaves = self.slaves
master = self.master
mode = self.mode
enable_routing = self.enable_routing
# routing # routing
if enable_routing: if enable_routing:
@ -114,8 +120,7 @@ class CRIDecoder(Elaboratable):
if direction == DIR_FANIN: if direction == DIR_FANIN:
m.d.comb += getattr(master, name).eq(getattr(slave, name)) m.d.comb += getattr(master, name).eq(getattr(slave, name))
def elaborate(self, platform): return m
return self.m
# Skip CRISwitch for now (depends on AutoCSR) # Skip CRISwitch for now (depends on AutoCSR)