Skip to content

Commit 9f46553

Browse files
wanda-phijfng
authored andcommitted
csr: update for RFC 43, rename reset= to init=.
1 parent 1e1490e commit 9f46553

File tree

4 files changed

+46
-46
lines changed

4 files changed

+46
-46
lines changed

amaranth_soc/csr/action.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class RW(FieldAction):
8181
----------
8282
shape : :ref:`shape-castable <lang-shapecasting>`
8383
Shape of the field.
84-
reset : :class:`int`
85-
Storage reset value.
84+
init : :class:`int`
85+
Storage initial value.
8686
8787
Interface attributes
8888
--------------------
@@ -91,16 +91,16 @@ class RW(FieldAction):
9191
data : Signal(shape)
9292
Storage output.
9393
"""
94-
def __init__(self, shape, *, reset=0):
94+
def __init__(self, shape, *, init=0):
9595
super().__init__(shape, access="rw", members={
9696
"data": Out(shape),
9797
})
98-
self._storage = Signal(shape, reset=reset)
99-
self._reset = reset
98+
self._storage = Signal(shape, init=init)
99+
self._init = init
100100

101101
@property
102-
def reset(self):
103-
return self._reset
102+
def init(self):
103+
return self._init
104104

105105
def elaborate(self, platform):
106106
m = Module()
@@ -129,8 +129,8 @@ class RW1C(FieldAction):
129129
----------
130130
shape : :ref:`shape-castable <lang-shapecasting>`
131131
Shape of the field.
132-
reset : :class:`int`
133-
Storage reset value.
132+
init : :class:`int`
133+
Storage initial value.
134134
135135
Interface attributes
136136
--------------------
@@ -141,17 +141,17 @@ class RW1C(FieldAction):
141141
set : Signal(shape)
142142
Mask to set storage bits.
143143
"""
144-
def __init__(self, shape, *, reset=0):
144+
def __init__(self, shape, *, init=0):
145145
super().__init__(shape, access="rw", members={
146146
"data": Out(shape),
147147
"set": In(shape),
148148
})
149-
self._storage = Signal(shape, reset=reset)
150-
self._reset = reset
149+
self._storage = Signal(shape, init=init)
150+
self._init = init
151151

152152
@property
153-
def reset(self):
154-
return self._reset
153+
def init(self):
154+
return self._init
155155

156156
def elaborate(self, platform):
157157
m = Module()
@@ -183,8 +183,8 @@ class RW1S(FieldAction):
183183
----------
184184
shape : :ref:`shape-castable <lang-shapecasting>`
185185
Shape of the field.
186-
reset : :class:`int`
187-
Storage reset value.
186+
init : :class:`int`
187+
Storage initial value.
188188
189189
Interface attributes
190190
--------------------
@@ -195,17 +195,17 @@ class RW1S(FieldAction):
195195
clear : Signal(shape)
196196
Mask to clear storage bits.
197197
"""
198-
def __init__(self, shape, *, reset=0):
198+
def __init__(self, shape, *, init=0):
199199
super().__init__(shape, access="rw", members={
200200
"clear": In(shape),
201201
"data": Out(shape),
202202
})
203-
self._storage = Signal(shape, reset=reset)
204-
self._reset = reset
203+
self._storage = Signal(shape, init=init)
204+
self._init = init
205205

206206
@property
207-
def reset(self):
208-
return self._reset
207+
def init(self):
208+
return self._init
209209

210210
def elaborate(self, platform):
211211
m = Module()

amaranth_soc/wishbone/bus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def elaborate(self, platform):
501501
for i, intr_bus in enumerate(self._intrs):
502502
m.d.comb += intr_bus.dat_r.eq(self.bus.dat_r)
503503
if hasattr(intr_bus, "stall"):
504-
intr_bus_stall = Signal(reset=1)
504+
intr_bus_stall = Signal(init=1)
505505
m.d.comb += intr_bus.stall.eq(intr_bus_stall)
506506

507507
with m.Case(i):

tests/test_csr_action.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,20 @@ def process():
5555

5656
class RWTestCase(unittest.TestCase):
5757
def test_simple(self):
58-
f4 = action.RW(unsigned(4), reset=0x5)
58+
f4 = action.RW(unsigned(4), init=0x5)
5959
self.assertEqual(f4.data.shape(), unsigned(4))
60-
self.assertEqual(f4.reset, 0x5)
60+
self.assertEqual(f4.init, 0x5)
6161
self.assertTrue(f4.port.access.readable())
6262
self.assertTrue(f4.port.access.writable())
6363

6464
f8 = action.RW(signed(8))
6565
self.assertEqual(f8.data.shape(), signed(8))
66-
self.assertEqual(f8.reset, 0)
66+
self.assertEqual(f8.init, 0)
6767
self.assertTrue(f8.port.access.readable())
6868
self.assertTrue(f8.port.access.writable())
6969

7070
def test_sim(self):
71-
dut = action.RW(unsigned(4), reset=0x5)
71+
dut = action.RW(unsigned(4), init=0x5)
7272

7373
def process():
7474
self.assertEqual((yield dut.port.r_data), 0x5)
@@ -88,22 +88,22 @@ def process():
8888

8989
class RW1CTestCase(unittest.TestCase):
9090
def test_simple(self):
91-
f4 = action.RW1C(unsigned(4), reset=0x5)
91+
f4 = action.RW1C(unsigned(4), init=0x5)
9292
self.assertEqual(f4.data.shape(), unsigned(4))
9393
self.assertEqual(f4.set .shape(), unsigned(4))
94-
self.assertEqual(f4.reset, 0x5)
94+
self.assertEqual(f4.init, 0x5)
9595
self.assertTrue(f4.port.access.readable())
9696
self.assertTrue(f4.port.access.writable())
9797

9898
f8 = action.RW1C(signed(8))
9999
self.assertEqual(f8.data.shape(), signed(8))
100100
self.assertEqual(f8.set .shape(), signed(8))
101-
self.assertEqual(f8.reset, 0)
101+
self.assertEqual(f8.init, 0)
102102
self.assertTrue(f8.port.access.readable())
103103
self.assertTrue(f8.port.access.writable())
104104

105105
def test_sim(self):
106-
dut = action.RW1C(unsigned(4), reset=0xf)
106+
dut = action.RW1C(unsigned(4), init=0xf)
107107

108108
def process():
109109
self.assertEqual((yield dut.port.r_data), 0xf)
@@ -129,22 +129,22 @@ def process():
129129

130130
class RW1STestCase(unittest.TestCase):
131131
def test_simple(self):
132-
f4 = action.RW1S(unsigned(4), reset=0x5)
132+
f4 = action.RW1S(unsigned(4), init=0x5)
133133
self.assertEqual(f4.data .shape(), unsigned(4))
134134
self.assertEqual(f4.clear.shape(), unsigned(4))
135-
self.assertEqual(f4.reset, 0x5)
135+
self.assertEqual(f4.init, 0x5)
136136
self.assertTrue(f4.port.access.readable())
137137
self.assertTrue(f4.port.access.writable())
138138

139139
f8 = action.RW1S(signed(8))
140140
self.assertEqual(f8.data .shape(), signed(8))
141141
self.assertEqual(f8.clear.shape(), signed(8))
142-
self.assertEqual(f8.reset, 0)
142+
self.assertEqual(f8.init, 0)
143143
self.assertTrue(f8.port.access.readable())
144144
self.assertTrue(f8.port.access.writable())
145145

146146
def test_sim(self):
147-
dut = action.RW1S(unsigned(4), reset=0x5)
147+
dut = action.RW1S(unsigned(4), init=0x5)
148148

149149
def process():
150150
self.assertEqual((yield dut.port.r_data), 0x5)

tests/test_csr_reg.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,18 @@ class Foo:
141141

142142
def test_create(self):
143143
class MockAction(FieldAction):
144-
def __init__(self, shape, *, reset):
144+
def __init__(self, shape, *, init):
145145
super().__init__(shape, access="rw", members={
146146
"data": Out(shape)
147147
})
148-
self.reset = reset
148+
self.init = init
149149

150150
def elaborate(self, platform):
151151
return Module()
152152

153-
field_u8 = Field(MockAction, unsigned(8), reset=1).create()
153+
field_u8 = Field(MockAction, unsigned(8), init=1).create()
154154
self.assertEqual(field_u8.port.shape, unsigned(8))
155-
self.assertEqual(field_u8.reset, 1)
155+
self.assertEqual(field_u8.init, 1)
156156

157157
def test_create_multiple(self):
158158
class MockAction(FieldAction):
@@ -500,15 +500,15 @@ class FooRegister(Register, access="rw"):
500500
def test_sim(self):
501501
class FooRegister(Register, access="rw"):
502502
a: Field(action.R, unsigned(1))
503-
b: Field(action.RW1C, unsigned(3), reset=0b111)
504-
c: {"d": Field(action.RW, signed(2), reset=-1)}
503+
b: Field(action.RW1C, unsigned(3), init=0b111)
504+
c: {"d": Field(action.RW, signed(2), init=-1)}
505505
e: [Field(action.W, unsigned(1)) for _ in range(2)]
506506
f: Field(action.RW1S, unsigned(3))
507507

508508
dut = FooRegister()
509509

510510
def process():
511-
# Check reset values:
511+
# Check init values:
512512

513513
self.assertEqual((yield dut.f.b .data), 0b111)
514514
self.assertEqual((yield dut.f.c.d.data), -1)
@@ -888,8 +888,8 @@ def test_memory_map_name_conflicts(self):
888888

889889
class BridgeTestCase(unittest.TestCase):
890890
class _RWRegister(Register, access="rw"):
891-
def __init__(self, width, reset=0):
892-
super().__init__({"a": Field(action.RW, width, reset=reset)})
891+
def __init__(self, width, init=0):
892+
super().__init__({"a": Field(action.RW, width, init=init)})
893893

894894
def test_wrong_memory_map(self):
895895
with self.assertRaisesRegex(TypeError,
@@ -917,10 +917,10 @@ def __repr__(self):
917917
def test_sim(self):
918918
regs = Builder(addr_width=16, data_width=8)
919919

920-
reg_rw_4 = regs.add("reg_rw_4", self._RWRegister(4, reset=0x0))
921-
reg_rw_8 = regs.add("reg_rw_8", self._RWRegister(8, reset=0x11))
920+
reg_rw_4 = regs.add("reg_rw_4", self._RWRegister(4, init=0x0))
921+
reg_rw_8 = regs.add("reg_rw_8", self._RWRegister(8, init=0x11))
922922
with regs.Cluster("cluster_0"):
923-
reg_rw_16 = regs.add("reg_rw_16", self._RWRegister(16, reset=0x3322))
923+
reg_rw_16 = regs.add("reg_rw_16", self._RWRegister(16, init=0x3322))
924924

925925
dut = Bridge(regs.as_memory_map())
926926

0 commit comments

Comments
 (0)