Skip to content

Commit 511cf1c

Browse files
committed
RFC #30: use strings to represent reset values.
1 parent b92fe39 commit 511cf1c

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

text/0000-component-metadata.md

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,7 @@ class AsyncSerialSignature(Signature):
6363

6464
class AsyncSerial(Component):
6565
def __init__(self, *, divisor_reset, divisor_bits, data_bits=8, parity="none"):
66-
self.divisor_reset = divisor_reset
67-
self.divisor_bits = divisor_bits
68-
self.data_bits = data_bits
69-
self.parity = parity
70-
71-
@property
72-
def signature(self):
73-
return AsyncSerialSignature(self.divisor_reset, self.divisor_bits, self.data_bits, self.parity)
66+
super().__init__(AsyncSerialSignature(divisor_reset, divisor_bits, data_bits, parity))
7467

7568

7669
if __name__ == "__main__":
@@ -95,79 +88,79 @@ The `.metadata` property of a `Component` returns a `ComponentMetadata` instance
9588
"dir": "in",
9689
"width": 10,
9790
"signed": false,
98-
"reset": 868
91+
"reset": "868"
9992
},
10093
"rx_ack": {
10194
"type": "port",
10295
"name": "rx_ack",
10396
"dir": "in",
10497
"width": 1,
10598
"signed": false,
106-
"reset": 0
99+
"reset": "0"
107100
},
108101
"rx_data": {
109102
"type": "port",
110103
"name": "rx_data",
111104
"dir": "out",
112105
"width": 8,
113106
"signed": false,
114-
"reset": 0
107+
"reset": "0"
115108
},
116109
"rx_err": {
117110
"type": "port",
118111
"name": "rx_err",
119112
"dir": "out",
120113
"width": 3,
121114
"signed": false,
122-
"reset": 0
115+
"reset": "0"
123116
},
124117
"rx_i": {
125118
"type": "port",
126119
"name": "rx_i",
127120
"dir": "in",
128121
"width": 1,
129122
"signed": false,
130-
"reset": 0
123+
"reset": "0"
131124
},
132125
"rx_rdy": {
133126
"type": "port",
134127
"name": "rx_rdy",
135128
"dir": "out",
136129
"width": 1,
137130
"signed": false,
138-
"reset": 0
131+
"reset": "0"
139132
},
140133
"tx_ack": {
141134
"type": "port",
142135
"name": "tx_ack",
143136
"dir": "in",
144137
"width": 1,
145138
"signed": false,
146-
"reset": 0
139+
"reset": "0"
147140
},
148141
"tx_data": {
149142
"type": "port",
150143
"name": "tx_data",
151144
"dir": "in",
152145
"width": 8,
153146
"signed": false,
154-
"reset": 0
147+
"reset": "0"
155148
},
156149
"tx_o": {
157150
"type": "port",
158151
"name": "tx_o",
159152
"dir": "out",
160153
"width": 1,
161154
"signed": false,
162-
"reset": 0
155+
"reset": "0"
163156
},
164157
"tx_rdy": {
165158
"type": "port",
166159
"name": "tx_rdy",
167160
"dir": "out",
168161
"width": 1,
169162
"signed": false,
170-
"reset": 0
163+
"reset": "0"
171164
}
172165
},
173166
"annotations": {}
@@ -242,71 +235,71 @@ The JSON object returned by ``serial.metadata.as_json()`` will now use this anno
242235
"dir": "in",
243236
"width": 10,
244237
"signed": false,
245-
"reset": 868
238+
"reset": "868"
246239
},
247240
"rx_ack": {
248241
"type": "port",
249242
"name": "rx_ack",
250243
"dir": "in",
251244
"width": 1,
252245
"signed": false,
253-
"reset": 0
246+
"reset": "0"
254247
},
255248
"rx_data": {
256249
"type": "port",
257250
"name": "rx_data",
258251
"dir": "out",
259252
"width": 8,
260253
"signed": false,
261-
"reset": 0
254+
"reset": "0"
262255
},
263256
"rx_err": {
264257
"type": "port",
265258
"name": "rx_err",
266259
"dir": "out",
267260
"width": 3,
268261
"signed": false,
269-
"reset": 0
262+
"reset": "0"
270263
},
271264
"rx_i": {
272265
"type": "port",
273266
"name": "rx_i",
274267
"dir": "in",
275268
"width": 1,
276269
"signed": false,
277-
"reset": 0
270+
"reset": "0"
278271
},
279272
"rx_rdy": {
280273
"type": "port",
281274
"name": "rx_rdy",
282275
"dir": "out",
283276
"width": 1,
284277
"signed": false,
285-
"reset": 0
278+
"reset": "0"
286279
},
287280
"tx_ack": {
288281
"type": "port",
289282
"name": "tx_ack",
290283
"dir": "in",
291284
"width": 1,
292285
"signed": false,
293-
"reset": 0
286+
"reset": "0"
294287
},
295288
"tx_data": {
296289
"type": "port",
297290
"name": "tx_data",
298291
"dir": "in",
299292
"width": 8,
300293
"signed": false,
301-
"reset": 0
294+
"reset": "0"
302295
},
303296
"tx_o": {
304297
"type": "port",
305298
"name": "tx_o",
306299
"dir": "out",
307300
"width": 1,
308301
"signed": false,
309-
"reset": 0
302+
"reset": "0"
310303
},
311304
"tx_rdy": {
312305
"type": "port",
@@ -405,8 +398,8 @@ class ComponentMetadata(Annotation):
405398
"type": "boolean",
406399
},
407400
"reset": {
408-
"type": "integer",
409-
"minimum": 0,
401+
"type": "string",
402+
"pattern": "^[+-]?[0-9]+$",
410403
},
411404
},
412405
"additionalProperties": False,
@@ -464,7 +457,7 @@ class ComponentMetadata(Annotation):
464457
# ...
465458
```
466459

467-
Reset values are represented by their two's complement. For example, the reset value of `Member(Out, signed(2), reset=-1)` would be given as `3`.
460+
Reset values are serialized to strings (e.g. "-1"), because JSON can only represent integers up to 2^53.
468461

469462
## Drawbacks
470463
[drawbacks]: #drawbacks

0 commit comments

Comments
 (0)