Skip to content

Commit 7d76126

Browse files
committed
csr.bus.{Multiplexer↔Decoder}
This reverses the rename done in commit 5520e0d. Commit 2a634b3 introduced a Multiplexer that doesn't actually do multiplexing, so revert that to make everything less confusing.
1 parent 2a634b3 commit 7d76126

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

nmigen_soc/csr/bus.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def __init__(self, *, addr_width, data_width, alignment=0, name=None):
153153
], name=name, src_loc_at=1)
154154

155155

156-
class Decoder(Elaboratable):
157-
"""CSR bus decoder.
156+
class Multiplexer(Elaboratable):
157+
"""CSR register multiplexer.
158158
159159
An address-based multiplexer for CSR registers implementing atomic updates.
160160
@@ -275,22 +275,22 @@ def elaborate(self, platform):
275275
return m
276276

277277

278-
class Multiplexer(Elaboratable):
279-
"""CSR bus multiplexer.
278+
class Decoder(Elaboratable):
279+
"""CSR bus decoder.
280280
281-
An address-based multiplexer for subordinate CSR buses.
281+
An address decoder for subordinate CSR buses.
282282
283283
Usage
284284
-----
285285
286286
Although there is no functional difference between adding a set of registers directly to
287-
a :class:`Decoder` and adding a set of reigsters to multiple :class:`Decoder`s that are
288-
aggregated with a :class:`Multiplexer`, hierarchical CSR buses are useful for organizing
289-
a hierarchical design. If many peripherals are directly served by a single :class:`Decoder`,
290-
a very large amount of ports will connect the peripheral registers with the decoder, and
291-
the cost of decoding logic would not be attributed to specific peripherals. With a multiplexer,
292-
only five signals per peripheral will be used, and the logic could be kept together with
293-
the peripheral.
287+
a :class:`Multiplexer` and adding a set of registers to multiple :class:`Multiplexer`s that are
288+
aggregated with a :class:`Decoder`, hierarchical CSR buses are useful for organizing
289+
a hierarchical design. If many peripherals are directly served by a single
290+
:class:`Multiplexer`, a very large amount of ports will connect the peripheral registers with
291+
the decoder, and the cost of decoding logic would not be attributed to specific peripherals.
292+
With a decoder, only five signals per peripheral will be used, and the logic could be kept
293+
together with the peripheral.
294294
295295
Parameters
296296
----------
@@ -342,7 +342,7 @@ def add(self, sub_bus, *, addr=None):
342342
def elaborate(self, platform):
343343
m = Module()
344344

345-
# See Decoder.elaborate above.
345+
# See Multiplexer.elaborate above.
346346
r_data_fanin = 0
347347

348348
with m.Switch(self.bus.addr):

nmigen_soc/test/test_csr_bus.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def test_data_width_wrong(self):
8282
Interface(addr_width=16, data_width=-1)
8383

8484

85-
class DecoderTestCase(unittest.TestCase):
85+
class MultiplexerTestCase(unittest.TestCase):
8686
def setUp(self):
87-
self.dut = Decoder(addr_width=16, data_width=8)
87+
self.dut = Multiplexer(addr_width=16, data_width=8)
8888
Fragment.get(self.dut, platform=None) # silence UnusedElaboratable
8989

9090
def test_add_4b(self):
@@ -195,9 +195,9 @@ def sim_test():
195195
sim.run()
196196

197197

198-
class DecoderAlignedTestCase(unittest.TestCase):
198+
class MultiplexerAlignedTestCase(unittest.TestCase):
199199
def setUp(self):
200-
self.dut = Decoder(addr_width=16, data_width=8, alignment=2)
200+
self.dut = Multiplexer(addr_width=16, data_width=8, alignment=2)
201201
Fragment.get(self.dut, platform=None) # silence UnusedElaboratable
202202

203203
def test_add_two(self):
@@ -255,9 +255,9 @@ def sim_test():
255255
sim.run()
256256

257257

258-
class MultiplexerTestCase(unittest.TestCase):
258+
class DecoderTestCase(unittest.TestCase):
259259
def setUp(self):
260-
self.dut = Multiplexer(addr_width=16, data_width=8)
260+
self.dut = Decoder(addr_width=16, data_width=8)
261261
Fragment.get(self.dut, platform=None) # silence UnusedElaboratable
262262

263263
def test_add_wrong_sub_bus(self):
@@ -266,24 +266,24 @@ def test_add_wrong_sub_bus(self):
266266
self.dut.add(1)
267267

268268
def test_add_wrong_data_width(self):
269-
decoder = Decoder(addr_width=10, data_width=16)
270-
Fragment.get(decoder, platform=None) # silence UnusedElaboratable
269+
mux = Multiplexer(addr_width=10, data_width=16)
270+
Fragment.get(mux, platform=None) # silence UnusedElaboratable
271271

272272
with self.assertRaisesRegex(ValueError,
273273
r"Subordinate bus has data width 16, which is not the same as "
274274
r"multiplexer data width 8"):
275-
self.dut.add(decoder.bus)
275+
self.dut.add(mux.bus)
276276

277277
def test_sim(self):
278-
dec_1 = Decoder(addr_width=10, data_width=8)
279-
self.dut.add(dec_1.bus)
278+
mux_1 = Multiplexer(addr_width=10, data_width=8)
279+
self.dut.add(mux_1.bus)
280280
elem_1 = Element(8, "rw")
281-
dec_1.add(elem_1)
281+
mux_1.add(elem_1)
282282

283-
dec_2 = Decoder(addr_width=10, data_width=8)
284-
self.dut.add(dec_2.bus)
283+
mux_2 = Multiplexer(addr_width=10, data_width=8)
284+
self.dut.add(mux_2.bus)
285285
elem_2 = Element(8, "rw")
286-
dec_2.add(elem_2, addr=2)
286+
mux_2.add(elem_2, addr=2)
287287

288288
elem_1_addr, _, _ = self.dut.bus.memory_map.find_resource(elem_1)
289289
elem_2_addr, _, _ = self.dut.bus.memory_map.find_resource(elem_2)
@@ -322,7 +322,7 @@ def sim_test():
322322
self.assertEqual((yield bus.r_data), 0xaa)
323323

324324
m = Module()
325-
m.submodules += self.dut, dec_1, dec_2
325+
m.submodules += self.dut, mux_1, mux_2
326326
with Simulator(m, vcd_file=open("test.vcd", "w")) as sim:
327327
sim.add_clock(1e-6)
328328
sim.add_sync_process(sim_test())

0 commit comments

Comments
 (0)