Skip to content

Commit fc9c6cf

Browse files
committed
docs: add reference-level documentation.
1 parent 45ff663 commit fc9c6cf

File tree

20 files changed

+1252
-633
lines changed

20 files changed

+1252
-633
lines changed

amaranth_soc/csr/action.py

Lines changed: 73 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88

99

1010
class R(FieldAction):
11-
"""A read-only field action.
11+
"""A read-only :class:`~.csr.reg.FieldAction`.
1212
13-
Parameters
14-
----------
13+
Arguments
14+
---------
1515
shape : :ref:`shape-like object <lang-shapelike>`
1616
Shape of the field.
1717
18-
Interface attributes
19-
--------------------
20-
port : :class:`FieldPort`
18+
Members
19+
-------
20+
port : :py:`In(csr.reg.FieldPort.Signature(shape, "r"))`
2121
Field port.
22-
r_data : Signal(shape)
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`.
22+
r_data : :py:`In(shape)`
23+
Read data. Drives ``port.r_data``.
24+
r_stb : :py:`Out(1)`
25+
Read strobe. Driven by ``port.r_stb``.
2626
"""
2727
def __init__(self, shape):
2828
super().__init__(shape, access="r", members={
@@ -40,21 +40,21 @@ def elaborate(self, platform):
4040

4141

4242
class W(FieldAction):
43-
"""A write-only field action.
43+
"""A write-only :class:`~.csr.reg.FieldAction`.
4444
45-
Parameters
46-
----------
45+
Arguments
46+
---------
4747
shape : :ref:`shape-like object <lang-shapelike>`
4848
Shape of the field.
4949
50-
Interface attributes
51-
--------------------
52-
port : :class:`FieldPort`
50+
Members
51+
-------
52+
port : :py:`In(csr.reg.FieldPort.Signature(shape, "w"))`
5353
Field port.
54-
w_data : Signal(shape)
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`.
54+
w_data : :py:`Out(shape)`
55+
Write data. Driven by ``port.w_data``.
56+
w_stb : :py:`Out(1)`
57+
Write strobe. Driven by ``port.w_stb``.
5858
"""
5959
def __init__(self, shape):
6060
super().__init__(shape, access="w", members={
@@ -72,23 +72,23 @@ def elaborate(self, platform):
7272

7373

7474
class RW(FieldAction):
75-
"""A read/write field action, with built-in storage.
75+
"""A read/write :class:`~.csr.reg.FieldAction`, with built-in storage.
7676
7777
Storage is updated with the value of ``port.w_data`` one clock cycle after ``port.w_stb`` is
7878
asserted.
7979
80-
Parameters
81-
----------
80+
Arguments
81+
---------
8282
shape : :ref:`shape-like object <lang-shapelike>`
8383
Shape of the field.
8484
init : :class:`int`
8585
Storage initial value.
8686
87-
Interface attributes
88-
--------------------
89-
port : :class:`FieldPort`
87+
Members
88+
-------
89+
port : :py:`In(csr.reg.FieldPort.Signature(shape, "rw"))`
9090
Field port.
91-
data : Signal(shape)
91+
data : :py:`Out(shape)`
9292
Storage output.
9393
"""
9494
def __init__(self, shape, *, init=0):
@@ -100,6 +100,12 @@ def __init__(self, shape, *, init=0):
100100

101101
@property
102102
def init(self):
103+
"""Storage initial value.
104+
105+
Returns
106+
-------
107+
:class:`int`
108+
"""
103109
return self._init
104110

105111
def elaborate(self, platform):
@@ -117,28 +123,29 @@ def elaborate(self, platform):
117123

118124

119125
class RW1C(FieldAction):
120-
"""A read/write-one-to-clear field action, with built-in storage.
126+
"""A read/write-one-to-clear :class:`~.csr.reg.FieldAction`, with built-in storage.
121127
122128
Storage bits are:
129+
123130
* cleared by high bits in ``port.w_data``, one clock cycle after ``port.w_stb`` is asserted;
124131
* set by high bits in ``set``, one clock cycle after they are asserted.
125132
126133
If a storage bit is set and cleared on the same clock cycle, setting it has precedence.
127134
128-
Parameters
129-
----------
135+
Arguments
136+
---------
130137
shape : :ref:`shape-like object <lang-shapelike>`
131138
Shape of the field.
132139
init : :class:`int`
133140
Storage initial value.
134141
135-
Interface attributes
136-
--------------------
137-
port : :class:`FieldPort`
142+
Members
143+
-------
144+
port : :py:`In(csr.reg.FieldPort.Signature(shape, "rw"))`
138145
Field port.
139-
data : Signal(shape)
146+
data : :py:`Out(shape)`
140147
Storage output.
141-
set : Signal(shape)
148+
set : :py:`In(shape)`
142149
Mask to set storage bits.
143150
"""
144151
def __init__(self, shape, *, init=0):
@@ -151,6 +158,12 @@ def __init__(self, shape, *, init=0):
151158

152159
@property
153160
def init(self):
161+
"""Storage initial value.
162+
163+
Returns
164+
-------
165+
:class:`int`
166+
"""
154167
return self._init
155168

156169
def elaborate(self, platform):
@@ -171,40 +184,47 @@ def elaborate(self, platform):
171184

172185

173186
class RW1S(FieldAction):
174-
"""A read/write-one-to-set field action, with built-in storage.
187+
"""A read/write-one-to-set :class:`~.csr.reg.FieldAction`, with built-in storage.
175188
176189
Storage bits are:
190+
177191
* set by high bits in ``port.w_data``, one clock cycle after ``port.w_stb`` is asserted;
178192
* cleared by high bits in ``clear``, one clock cycle after they are asserted.
179193
180194
If a storage bit is set and cleared on the same clock cycle, setting it has precedence.
181195
182-
Parameters
183-
----------
196+
Arguments
197+
---------
184198
shape : :ref:`shape-like object <lang-shapelike>`
185199
Shape of the field.
186200
init : :class:`int`
187201
Storage initial value.
188202
189-
Interface attributes
190-
--------------------
191-
port : :class:`FieldPort`
203+
Members
204+
-------
205+
port : :py:`In(csr.reg.FieldPort.Signature(shape, "rw"))`
192206
Field port.
193-
data : Signal(shape)
207+
data : :py:`Out(shape)`
194208
Storage output.
195-
clear : Signal(shape)
209+
clear : :py:`In(shape)`
196210
Mask to clear storage bits.
197211
"""
198212
def __init__(self, shape, *, init=0):
199213
super().__init__(shape, access="rw", members={
200-
"clear": In(shape),
201214
"data": Out(shape),
215+
"clear": In(shape),
202216
})
203217
self._storage = Signal(shape, init=init)
204218
self._init = init
205219

206220
@property
207221
def init(self):
222+
"""Storage initial value.
223+
224+
Returns
225+
-------
226+
:class:`int`
227+
"""
208228
return self._init
209229

210230
def elaborate(self, platform):
@@ -228,14 +248,14 @@ class _Reserved(FieldAction):
228248
_doc_template = """
229249
{description}
230250
231-
Parameters
232-
----------
251+
Arguments
252+
---------
233253
shape : :ref:`shape-like object <lang-shapelike>`
234254
Shape of the field.
235255
236-
Interface attributes
237-
--------------------
238-
port : :class:`FieldPort`
256+
Members
257+
-------
258+
port : :py:`In(csr.reg.FieldPort.Signature(shape, "nc"))`
239259
Field port.
240260
"""
241261
def __init__(self, shape):
@@ -247,23 +267,23 @@ def elaborate(self, platform):
247267

248268
class ResRAW0(_Reserved):
249269
__doc__ = _Reserved._doc_template.format(description="""
250-
A reserved read-any/write-zero field action.
270+
A reserved read-any/write-zero :class:`~.csr.reg.FieldAction`.
251271
""")
252272

253273

254274
class ResRAWL(_Reserved):
255275
__doc__ = _Reserved._doc_template.format(description="""
256-
A reserved read-any/write-last field action.
276+
A reserved read-any/write-last :class:`~.csr.reg.FieldAction`.
257277
""")
258278

259279

260280
class ResR0WA(_Reserved):
261281
__doc__ = _Reserved._doc_template.format(description="""
262-
A reserved read-zero/write-any field action.
282+
A reserved read-zero/write-any :class:`~.csr.reg.FieldAction`.
263283
""")
264284

265285

266286
class ResR0W0(_Reserved):
267287
__doc__ = _Reserved._doc_template.format(description="""
268-
A reserved read-zero/write-zero field action.
288+
A reserved read-zero/write-zero :class:`~.csr.reg.FieldAction`.
269289
""")

0 commit comments

Comments
 (0)