yosys2digitaljs 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts ADDED
@@ -0,0 +1,182 @@
1
+ namespace Digitaljs {
2
+ export type FilePosition = {
3
+ line: number,
4
+ column: number
5
+ };
6
+
7
+ export type SourcePosition = {
8
+ name: string,
9
+ from: FilePosition,
10
+ to: FilePosition
11
+ };
12
+
13
+ export type MemReadPort = {
14
+ clock_polarity?: boolean,
15
+ enable_polarity?: boolean,
16
+ arst_polarity?: boolean,
17
+ srst_polarity?: boolean,
18
+ enable_srst?: boolean,
19
+ transparent?: boolean | boolean[],
20
+ collision?: boolean | boolean[],
21
+ init_value?: string,
22
+ arst_value?: string,
23
+ srst_value?: string
24
+ };
25
+
26
+ export type MemWritePort = {
27
+ clock_polarity?: boolean,
28
+ enable_polarity?: boolean,
29
+ no_bit_enable?: boolean
30
+ };
31
+
32
+ export type Device = {
33
+ type: string,
34
+ source_positions?: SourcePosition[],
35
+ [key: string]: any
36
+ };
37
+
38
+ export type Port = {
39
+ id: string,
40
+ port: string
41
+ };
42
+
43
+ export type Connector = {
44
+ from: Port,
45
+ to: Port,
46
+ name?: string,
47
+ source_positions?: SourcePosition[]
48
+ };
49
+
50
+ export type Module = {
51
+ devices: { [key: string]: Device },
52
+ connectors: Connector[]
53
+ };
54
+
55
+ export type TopModule = Module & {
56
+ subcircuits: { [key: string]: Module }
57
+ };
58
+ };
59
+
60
+ namespace Yosys {
61
+
62
+ export const ConstChars = ["0", "1", "x", "z"] as const;
63
+
64
+ export type BitChar = (typeof ConstChars)[number];
65
+
66
+ export type Bit = number | BitChar;
67
+
68
+ export type BitVector = Bit[];
69
+
70
+ export type Port = {
71
+ direction: 'input' | 'output' | 'inout',
72
+ bits: any
73
+ };
74
+
75
+ export type Parameters = {
76
+ WIDTH?: JsonConstant,
77
+ A_WIDTH?: JsonConstant,
78
+ B_WIDTH?: JsonConstant,
79
+ S_WIDTH?: JsonConstant,
80
+ Y_WIDTH?: JsonConstant,
81
+ A_SIGNED?: JsonConstant,
82
+ B_SIGNED?: JsonConstant,
83
+ CLK_POLARITY?: JsonConstant,
84
+ EN_POLARITY?: JsonConstant,
85
+ ARST_POLARITY?: JsonConstant,
86
+ ARST_VALUE: JsonConstant,
87
+ CTRL_IN_WIDTH?: JsonConstant,
88
+ CTRL_OUT_WIDTH?: JsonConstant,
89
+ TRANS_NUM?: JsonConstant,
90
+ STATE_NUM?: JsonConstant,
91
+ STATE_NUM_LOG2?: JsonConstant,
92
+ STATE_RST?: JsonConstant,
93
+ RD_PORTS?: JsonConstant,
94
+ WR_PORTS?: JsonConstant,
95
+ RD_CLK_POLARITY?: JsonConstant,
96
+ RD_CLK_ENABLE?: JsonConstant,
97
+ RD_CLK_TRANSPARENT?: JsonConstant,
98
+ WR_CLK_POLARITY?: JsonConstant,
99
+ WR_CLK_ENABLE?: JsonConstant,
100
+ [key: string]: any
101
+ };
102
+
103
+ export type JsonConstant = number | string;
104
+
105
+ export type Attributes = {
106
+ init: JsonConstant,
107
+ [key: string]: any
108
+ };
109
+ export type Cell = {
110
+ hide_name: 0 | 1,
111
+ type: string,
112
+ parameters: Parameters,
113
+ attributes: Attributes,
114
+ port_directions: { [key: string]: 'input' | 'output' },
115
+ connections: { [key: string]: BitVector }
116
+ };
117
+
118
+ export type Net = {
119
+ hide_name: 0 | 1,
120
+ bits: BitVector,
121
+ attributes: { [key: string]: string }
122
+ };
123
+
124
+ export type Module = {
125
+ ports: { [key: string]: Port },
126
+ cells: { [key: string]: Cell },
127
+ netnames: { [key: string]: Net }
128
+ };
129
+
130
+ export type Output = {
131
+ modules: { [key: string]: Module }
132
+ };
133
+
134
+ };
135
+
136
+ type ConvertOptions = {
137
+ propagation?: number,
138
+ };
139
+
140
+ type Options = ConvertOptions & {
141
+ optimize?: boolean,
142
+ fsmexpand?: boolean,
143
+ fsm?: boolean | "nomap",
144
+ timeout?: number,
145
+ lint?: boolean
146
+ };
147
+
148
+ type Output = {
149
+ output?: Digitaljs.TopModule,
150
+ yosys_output?: any,
151
+ yosys_stdout: string,
152
+ yosys_stderr: string,
153
+ lint?: LintMessage[]
154
+ };
155
+
156
+ type Portmap = { [key: string]: string };
157
+ type Portmaps = { [key: string]: Portmap };
158
+
159
+ type Bit = Yosys.Bit | `bit${number}`;
160
+
161
+ type Net = Bit[];
162
+
163
+ type NetInfo = {
164
+ source: undefined | Digitaljs.Port,
165
+ targets: Digitaljs.Port[],
166
+ name: undefined | string,
167
+ source_positions: Digitaljs.SourcePosition[]
168
+ };
169
+
170
+ type BitInfo = {
171
+ id: string,
172
+ port: string,
173
+ num: number
174
+ };
175
+
176
+ type LintMessage = {
177
+ type: string,
178
+ file: string,
179
+ line: number,
180
+ column: number,
181
+ message: string
182
+ };
package/tests/z.sv ADDED
@@ -0,0 +1,7 @@
1
+ // high impedance state
2
+ module sourceZ(
3
+ output out
4
+ );
5
+ assign out = 1'bZ;
6
+
7
+ endmodule
package/result.json DELETED
@@ -1,420 +0,0 @@
1
- {
2
- "creator": "Yosys 0.8 (git sha1 5706e90)",
3
- "modules": {
4
- "fsm": {
5
- "attributes": {
6
- "src": "tests/fsm.sv:1"
7
- },
8
- "ports": {
9
- "clk": {
10
- "direction": "input",
11
- "bits": [ 2 ]
12
- },
13
- "rst": {
14
- "direction": "input",
15
- "bits": [ 3 ]
16
- },
17
- "a": {
18
- "direction": "input",
19
- "bits": [ 4 ]
20
- },
21
- "b": {
22
- "direction": "output",
23
- "bits": [ 5 ]
24
- }
25
- },
26
- "cells": {
27
- "$auto$simplemap.cc:136:simplemap_reduce$41": {
28
- "hide_name": 1,
29
- "type": "$_OR_",
30
- "parameters": {
31
- },
32
- "attributes": {
33
- },
34
- "port_directions": {
35
- "A": "input",
36
- "B": "input",
37
- "Y": "output"
38
- },
39
- "connections": {
40
- "A": [ 6 ],
41
- "B": [ 7 ],
42
- "Y": [ 8 ]
43
- }
44
- },
45
- "$auto$simplemap.cc:136:simplemap_reduce$61": {
46
- "hide_name": 1,
47
- "type": "$_OR_",
48
- "parameters": {
49
- },
50
- "attributes": {
51
- "src": "tests/fsm.sv:16"
52
- },
53
- "port_directions": {
54
- "A": "input",
55
- "B": "input",
56
- "Y": "output"
57
- },
58
- "connections": {
59
- "A": [ 7 ],
60
- "B": [ 9 ],
61
- "Y": [ 10 ]
62
- }
63
- },
64
- "$auto$simplemap.cc:136:simplemap_reduce$63": {
65
- "hide_name": 1,
66
- "type": "$_OR_",
67
- "parameters": {
68
- },
69
- "attributes": {
70
- "src": "tests/fsm.sv:16"
71
- },
72
- "port_directions": {
73
- "A": "input",
74
- "B": "input",
75
- "Y": "output"
76
- },
77
- "connections": {
78
- "A": [ 6 ],
79
- "B": [ 11 ],
80
- "Y": [ 12 ]
81
- }
82
- },
83
- "$auto$simplemap.cc:206:simplemap_lognot$52": {
84
- "hide_name": 1,
85
- "type": "$_NOT_",
86
- "parameters": {
87
- },
88
- "attributes": {
89
- },
90
- "port_directions": {
91
- "A": "input",
92
- "Y": "output"
93
- },
94
- "connections": {
95
- "A": [ 13 ],
96
- "Y": [ 14 ]
97
- }
98
- },
99
- "$auto$simplemap.cc:206:simplemap_lognot$59": {
100
- "hide_name": 1,
101
- "type": "$_NOT_",
102
- "parameters": {
103
- },
104
- "attributes": {
105
- },
106
- "port_directions": {
107
- "A": "input",
108
- "Y": "output"
109
- },
110
- "connections": {
111
- "A": [ 15 ],
112
- "Y": [ 16 ]
113
- }
114
- },
115
- "$auto$simplemap.cc:496:simplemap_adff$42": {
116
- "hide_name": 1,
117
- "type": "$_DFF_PP1_",
118
- "parameters": {
119
- },
120
- "attributes": {
121
- },
122
- "port_directions": {
123
- "C": "input",
124
- "D": "input",
125
- "Q": "output",
126
- "R": "input"
127
- },
128
- "connections": {
129
- "C": [ 2 ],
130
- "D": [ 11 ],
131
- "Q": [ 6 ],
132
- "R": [ 3 ]
133
- }
134
- },
135
- "$auto$simplemap.cc:496:simplemap_adff$43": {
136
- "hide_name": 1,
137
- "type": "$_DFF_PP0_",
138
- "parameters": {
139
- },
140
- "attributes": {
141
- },
142
- "port_directions": {
143
- "C": "input",
144
- "D": "input",
145
- "Q": "output",
146
- "R": "input"
147
- },
148
- "connections": {
149
- "C": [ 2 ],
150
- "D": [ 8 ],
151
- "Q": [ 9 ],
152
- "R": [ 3 ]
153
- }
154
- },
155
- "$auto$simplemap.cc:496:simplemap_adff$44": {
156
- "hide_name": 1,
157
- "type": "$_DFF_PP0_",
158
- "parameters": {
159
- },
160
- "attributes": {
161
- },
162
- "port_directions": {
163
- "C": "input",
164
- "D": "input",
165
- "Q": "output",
166
- "R": "input"
167
- },
168
- "connections": {
169
- "C": [ 2 ],
170
- "D": [ 17 ],
171
- "Q": [ 7 ],
172
- "R": [ 3 ]
173
- }
174
- },
175
- "$auto$simplemap.cc:496:simplemap_adff$45": {
176
- "hide_name": 1,
177
- "type": "$_DFF_PP0_",
178
- "parameters": {
179
- },
180
- "attributes": {
181
- },
182
- "port_directions": {
183
- "C": "input",
184
- "D": "input",
185
- "Q": "output",
186
- "R": "input"
187
- },
188
- "connections": {
189
- "C": [ 2 ],
190
- "D": [ 18 ],
191
- "Q": [ 11 ],
192
- "R": [ 3 ]
193
- }
194
- },
195
- "$auto$simplemap.cc:85:simplemap_bitop$38": {
196
- "hide_name": 1,
197
- "type": "$_AND_",
198
- "parameters": {
199
- },
200
- "attributes": {
201
- },
202
- "port_directions": {
203
- "A": "input",
204
- "B": "input",
205
- "Y": "output"
206
- },
207
- "connections": {
208
- "A": [ 14 ],
209
- "B": [ 9 ],
210
- "Y": [ 17 ]
211
- }
212
- },
213
- "$auto$simplemap.cc:85:simplemap_bitop$39": {
214
- "hide_name": 1,
215
- "type": "$_AND_",
216
- "parameters": {
217
- },
218
- "attributes": {
219
- },
220
- "port_directions": {
221
- "A": "input",
222
- "B": "input",
223
- "Y": "output"
224
- },
225
- "connections": {
226
- "A": [ 16 ],
227
- "B": [ 9 ],
228
- "Y": [ 18 ]
229
- }
230
- },
231
- "$auto$simplemap.cc:85:simplemap_bitop$48": {
232
- "hide_name": 1,
233
- "type": "$_XOR_",
234
- "parameters": {
235
- },
236
- "attributes": {
237
- },
238
- "port_directions": {
239
- "A": "input",
240
- "B": "input",
241
- "Y": "output"
242
- },
243
- "connections": {
244
- "A": [ 4 ],
245
- "B": [ "0" ],
246
- "Y": [ 13 ]
247
- }
248
- },
249
- "$auto$simplemap.cc:85:simplemap_bitop$55": {
250
- "hide_name": 1,
251
- "type": "$_XOR_",
252
- "parameters": {
253
- },
254
- "attributes": {
255
- },
256
- "port_directions": {
257
- "A": "input",
258
- "B": "input",
259
- "Y": "output"
260
- },
261
- "connections": {
262
- "A": [ 4 ],
263
- "B": [ "1" ],
264
- "Y": [ 15 ]
265
- }
266
- },
267
- "$procmux$3": {
268
- "hide_name": 1,
269
- "type": "$pmux",
270
- "parameters": {
271
- "S_WIDTH": 2,
272
- "WIDTH": 1
273
- },
274
- "attributes": {
275
- "src": "tests/fsm.sv:16"
276
- },
277
- "port_directions": {
278
- "A": "input",
279
- "B": "input",
280
- "S": "input",
281
- "Y": "output"
282
- },
283
- "connections": {
284
- "A": [ "x" ],
285
- "B": [ "1", "0" ],
286
- "S": [ 10, 12 ],
287
- "Y": [ 5 ]
288
- }
289
- }
290
- },
291
- "netnames": {
292
- "$auto$fsm_map.cc:118:implement_pattern_cache$31": {
293
- "hide_name": 1,
294
- "bits": [ 17 ],
295
- "attributes": {
296
- }
297
- },
298
- "$auto$fsm_map.cc:118:implement_pattern_cache$35": {
299
- "hide_name": 1,
300
- "bits": [ 18 ],
301
- "attributes": {
302
- }
303
- },
304
- "$auto$fsm_map.cc:170:map_fsm$24": {
305
- "hide_name": 1,
306
- "bits": [ 19, 8 ],
307
- "attributes": {
308
- }
309
- },
310
- "$auto$fsm_map.cc:74:implement_pattern_cache$29": {
311
- "hide_name": 1,
312
- "bits": [ 14 ],
313
- "attributes": {
314
- }
315
- },
316
- "$auto$fsm_map.cc:74:implement_pattern_cache$33": {
317
- "hide_name": 1,
318
- "bits": [ 16 ],
319
- "attributes": {
320
- }
321
- },
322
- "$auto$simplemap.cc:127:simplemap_reduce$40": {
323
- "hide_name": 1,
324
- "bits": [ 20 ],
325
- "attributes": {
326
- }
327
- },
328
- "$auto$simplemap.cc:127:simplemap_reduce$60": {
329
- "hide_name": 1,
330
- "bits": [ 21 ],
331
- "attributes": {
332
- }
333
- },
334
- "$auto$simplemap.cc:127:simplemap_reduce$62": {
335
- "hide_name": 1,
336
- "bits": [ 22 ],
337
- "attributes": {
338
- }
339
- },
340
- "$auto$simplemap.cc:250:simplemap_eqne$46": {
341
- "hide_name": 1,
342
- "bits": [ 13 ],
343
- "attributes": {
344
- }
345
- },
346
- "$auto$simplemap.cc:250:simplemap_eqne$53": {
347
- "hide_name": 1,
348
- "bits": [ 15 ],
349
- "attributes": {
350
- }
351
- },
352
- "$auto$simplemap.cc:256:simplemap_eqne$49": {
353
- "hide_name": 1,
354
- "bits": [ 13 ],
355
- "attributes": {
356
- }
357
- },
358
- "$auto$simplemap.cc:256:simplemap_eqne$56": {
359
- "hide_name": 1,
360
- "bits": [ 15 ],
361
- "attributes": {
362
- }
363
- },
364
- "$auto$wreduce.cc:347:run$37": {
365
- "hide_name": 1,
366
- "bits": [ 19, 8, 23, 24 ],
367
- "attributes": {
368
- }
369
- },
370
- "$procmux$4_CTRL": {
371
- "hide_name": 1,
372
- "bits": [ 10 ],
373
- "attributes": {
374
- }
375
- },
376
- "$procmux$5_CTRL": {
377
- "hide_name": 1,
378
- "bits": [ 12 ],
379
- "attributes": {
380
- }
381
- },
382
- "a": {
383
- "hide_name": 0,
384
- "bits": [ 4 ],
385
- "attributes": {
386
- "src": "tests/fsm.sv:1"
387
- }
388
- },
389
- "b": {
390
- "hide_name": 0,
391
- "bits": [ 5 ],
392
- "attributes": {
393
- "src": "tests/fsm.sv:1"
394
- }
395
- },
396
- "clk": {
397
- "hide_name": 0,
398
- "bits": [ 2 ],
399
- "attributes": {
400
- "src": "tests/fsm.sv:1"
401
- }
402
- },
403
- "rst": {
404
- "hide_name": 0,
405
- "bits": [ 3 ],
406
- "attributes": {
407
- "src": "tests/fsm.sv:1"
408
- }
409
- },
410
- "state": {
411
- "hide_name": 0,
412
- "bits": [ 6, 9, 7, 11 ],
413
- "attributes": {
414
- "onehot": 1
415
- }
416
- }
417
- }
418
- }
419
- }
420
- }