Skip to content

Commit 1b537f2

Browse files
committed
csr.action: add an access strobe to the interface of R and W actions.
1 parent 30ad1e0 commit 1b537f2

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

amaranth_soc/csr/action.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,22 @@ class R(FieldAction):
2020
port : :class:`FieldPort`
2121
Field port.
2222
r_data : Signal(shape)
23-
Read data. Drives the :attr:`~FieldPort.r_data` signal of ``port``.
23+
Read data. Drives ``port.r_data``. See :class:`FieldPort`.
24+
r_stb : Signal()
25+
Read strobe. Driven by ``port.r_stb``. See :class:`FieldPort`.
2426
"""
2527
def __init__(self, shape):
2628
super().__init__(shape, access="r", members={
2729
"r_data": In(shape),
30+
"r_stb": Out(1)
2831
})
2932

3033
def elaborate(self, platform):
3134
m = Module()
32-
m.d.comb += self.port.r_data.eq(self.r_data)
35+
m.d.comb += [
36+
self.port.r_data.eq(self.r_data),
37+
self.r_stb.eq(self.port.r_stb),
38+
]
3339
return m
3440

3541

@@ -46,16 +52,22 @@ class W(FieldAction):
4652
port : :class:`FieldPort`
4753
Field port.
4854
w_data : Signal(shape)
49-
Write data. Driven by the :attr:`~FieldPort.w_data` signal of ``port``.
55+
Write data. Driven by ``port.w_data``. See :class:`FieldPort`.
56+
w_stb : Signal()
57+
Write strobe. Driven by ``port.w_stb``. See :class:`FieldPort`.
5058
"""
5159
def __init__(self, shape):
5260
super().__init__(shape, access="w", members={
5361
"w_data": Out(shape),
62+
"w_stb": Out(1),
5463
})
5564

5665
def elaborate(self, platform):
5766
m = Module()
58-
m.d.comb += self.w_data.eq(self.port.w_data)
67+
m.d.comb += [
68+
self.w_data.eq(self.port.w_data),
69+
self.w_stb.eq(self.port.w_stb),
70+
]
5971
return m
6072

6173

tests/test_csr_action.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ def test_sim(self):
1919

2020
def process():
2121
yield dut.r_data.eq(0xa)
22+
yield dut.port.r_stb.eq(1)
2223
yield Settle()
2324
self.assertEqual((yield dut.port.r_data), 0xa)
25+
self.assertEqual((yield dut.r_stb), 1)
2426

2527
sim = Simulator(dut)
2628
sim.add_process(process)
@@ -40,8 +42,10 @@ def test_sim(self):
4042

4143
def process():
4244
yield dut.port.w_data.eq(0xa)
45+
yield dut.port.w_stb.eq(1)
4346
yield Settle()
4447
self.assertEqual((yield dut.w_data), 0xa)
48+
self.assertEqual((yield dut.w_stb), 1)
4549

4650
sim = Simulator(dut)
4751
sim.add_process(process)

0 commit comments

Comments
 (0)