From 32641851b735b2c3e1d6117a8691c8cc8238fbd7 Mon Sep 17 00:00:00 2001
From: Donald Sebastian Leung
Date: Tue, 27 Oct 2020 12:14:47 +0800
Subject: [PATCH] Restructure rtio.cri to follow nMigen convention
---
README.md | 4 ++--
rtio/cri.py | 15 ++++++++++-----
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index b7c31ed..0fee243 100644
--- a/README.md
+++ b/README.md
@@ -31,8 +31,8 @@ $ python -m rtio.test.sed.output_network
- - [ ] `rtio.rtlink`
- - [x] `rtio.sed.output_network` - Sorting network (high priority)
- - [ ] `rtio.sed.output_driver`
-- [ ] Restructure to code to follow nMigen convention and re-validate existing assertions
-- - [ ] `rtio.cri` (`Interface` and `CRIDecoder` only)
+- [ ] Restructure to code to follow nMigen convention and re-validate existing assertions (if any)
+- - [x] `rtio.cri` (`Interface` and `CRIDecoder` only)
- - [ ] `rtio.rtlink`
- - [x] `rtio.sed.output_network`
- - [ ] `rtio.sed.output_driver`
diff --git a/rtio/cri.py b/rtio/cri.py
index 2dcbdef..5969795 100644
--- a/rtio/cri.py
+++ b/rtio/cri.py
@@ -59,16 +59,22 @@ class Interface(Record):
class CRIDecoder(Elaboratable):
def __init__(self, slaves=2, master=None, mode="async", enable_routing=False):
- m = Module()
- self.m = m
if isinstance(slaves, int):
slaves = [Interface() for _ in range(slaves)]
if master is None:
master = Interface()
self.slaves = slaves
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
if enable_routing:
@@ -114,8 +120,7 @@ class CRIDecoder(Elaboratable):
if direction == DIR_FANIN:
m.d.comb += getattr(master, name).eq(getattr(slave, name))
- def elaborate(self, platform):
- return self.m
+ return m
# Skip CRISwitch for now (depends on AutoCSR)