11from amaranth import *
2- from amaranth .lib import wiring
32from amaranth .lib .wiring import In , Out
43
5- from .reg import FieldPort
4+ from .reg import FieldAction
65
76
87__all__ = ["R" , "W" , "RW" , "RW1C" , "RW1S" , "ResRAW0" , "ResRAWL" , "ResR0WA" , "ResR0W0" ]
98
109
11- class R (wiring . Component ):
10+ class R (FieldAction ):
1211 """A read-only field action.
1312
1413 Parameters
@@ -24,8 +23,7 @@ class R(wiring.Component):
2423 Read data. Drives the :attr:`~FieldPort.r_data` signal of ``port``.
2524 """
2625 def __init__ (self , shape ):
27- super ().__init__ ({
28- "port" : In (FieldPort .Signature (shape , access = "r" )),
26+ super ().__init__ (shape , access = "r" , members = {
2927 "r_data" : In (shape ),
3028 })
3129
@@ -35,7 +33,7 @@ def elaborate(self, platform):
3533 return m
3634
3735
38- class W (wiring . Component ):
36+ class W (FieldAction ):
3937 """A write-only field action.
4038
4139 Parameters
@@ -51,8 +49,7 @@ class W(wiring.Component):
5149 Write data. Driven by the :attr:`~FieldPort.w_data` signal of ``port``.
5250 """
5351 def __init__ (self , shape ):
54- super ().__init__ ({
55- "port" : In (FieldPort .Signature (shape , access = "w" )),
52+ super ().__init__ (shape , access = "w" , members = {
5653 "w_data" : Out (shape ),
5754 })
5855
@@ -62,7 +59,7 @@ def elaborate(self, platform):
6259 return m
6360
6461
65- class RW (wiring . Component ):
62+ class RW (FieldAction ):
6663 """A read/write field action, with built-in storage.
6764
6865 Storage is updated with the value of ``port.w_data`` one clock cycle after ``port.w_stb`` is
@@ -83,8 +80,7 @@ class RW(wiring.Component):
8380 Storage output.
8481 """
8582 def __init__ (self , shape , * , reset = 0 ):
86- super ().__init__ ({
87- "port" : In (FieldPort .Signature (shape , access = "rw" )),
83+ super ().__init__ (shape , access = "rw" , members = {
8884 "data" : Out (shape ),
8985 })
9086 self ._storage = Signal (shape , reset = reset )
@@ -108,7 +104,7 @@ def elaborate(self, platform):
108104 return m
109105
110106
111- class RW1C (wiring . Component ):
107+ class RW1C (FieldAction ):
112108 """A read/write-one-to-clear field action, with built-in storage.
113109
114110 Storage bits are:
@@ -134,8 +130,7 @@ class RW1C(wiring.Component):
134130 Mask to set storage bits.
135131 """
136132 def __init__ (self , shape , * , reset = 0 ):
137- super ().__init__ ({
138- "port" : In (FieldPort .Signature (shape , access = "rw" )),
133+ super ().__init__ (shape , access = "rw" , members = {
139134 "data" : Out (shape ),
140135 "set" : In (shape ),
141136 })
@@ -163,7 +158,7 @@ def elaborate(self, platform):
163158 return m
164159
165160
166- class RW1S (wiring . Component ):
161+ class RW1S (FieldAction ):
167162 """A read/write-one-to-set field action, with built-in storage.
168163
169164 Storage bits are:
@@ -189,8 +184,7 @@ class RW1S(wiring.Component):
189184 Mask to clear storage bits.
190185 """
191186 def __init__ (self , shape , * , reset = 0 ):
192- super ().__init__ ({
193- "port" : In (FieldPort .Signature (shape , access = "rw" )),
187+ super ().__init__ (shape , access = "rw" , members = {
194188 "clear" : In (shape ),
195189 "data" : Out (shape ),
196190 })
@@ -218,7 +212,7 @@ def elaborate(self, platform):
218212 return m
219213
220214
221- class _Reserved (wiring . Component ):
215+ class _Reserved (FieldAction ):
222216 _doc_template = """
223217 {description}
224218
@@ -233,7 +227,7 @@ class _Reserved(wiring.Component):
233227 Field port.
234228 """
235229 def __init__ (self , shape ):
236- super ().__init__ ({ "port" : In ( FieldPort . Signature ( shape , access = "nc" ))} )
230+ super ().__init__ (shape , access = "nc" )
237231
238232 def elaborate (self , platform ):
239233 return Module ()
0 commit comments