yosys2digitaljs 0.8.0 → 0.9.1

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/test.sv DELETED
@@ -1,31 +0,0 @@
1
-
2
- // Full adder
3
- module fulladder(
4
- input a,
5
- input b,
6
- input d,
7
- output o,
8
- output c
9
- );
10
-
11
- logic t, c1, c2;
12
-
13
- halfadder ha1(a, b, t, c1);
14
- halfadder ha2(t, d, o, c2);
15
-
16
- assign c = c1 | c2;
17
-
18
- endmodule
19
- // Half adder
20
- module halfadder(
21
- input a,
22
- input b,
23
- output o,
24
- output c
25
- );
26
-
27
- assign o = a ^ b;
28
- assign c = a & b;
29
-
30
- endmodule
31
-
package/test1.sv DELETED
@@ -1,19 +0,0 @@
1
-
2
- module m(
3
- input a,
4
- output b
5
- );
6
-
7
- n x(a, b);
8
-
9
- endmodule
10
-
11
- module n(
12
- input a,
13
- output b
14
- );
15
-
16
- assign b = !a;
17
-
18
- endmodule
19
-
package/test1.v DELETED
@@ -1,19 +0,0 @@
1
-
2
- module m(
3
- input a,
4
- output b
5
- );
6
-
7
- n x(a, b);
8
-
9
- endmodule
10
-
11
- module n(
12
- input a,
13
- output b
14
- );
15
-
16
- assign b = !a;
17
-
18
- endmodule
19
-
package/test2.v DELETED
@@ -1,19 +0,0 @@
1
-
2
- module n(
3
- input a,
4
- output b
5
- );
6
-
7
- assign b = !a;
8
-
9
- endmodule
10
-
11
- module m(
12
- input a,
13
- output b
14
- );
15
-
16
- n x(a, b);
17
-
18
- endmodule
19
-
package/test3.sv DELETED
@@ -1,63 +0,0 @@
1
- // Half adder
2
- module halfadder(
3
- input a,
4
- input b,
5
- output o,
6
- output c
7
- );
8
-
9
- assign o = a ^ b;
10
- assign c = a & b;
11
-
12
- endmodule
13
-
14
- // Full adder
15
- module fulladder(
16
- input a,
17
- input b,
18
- input d,
19
- output o,
20
- output c
21
- );
22
-
23
- logic t, c1, c2;
24
-
25
- halfadder ha1(a, b, t, c1);
26
- halfadder ha2(t, d, o, c2);
27
-
28
- assign c = c1 | c2;
29
-
30
- endmodule
31
-
32
- // Multibit serial adder
33
- module serialadder
34
- #(parameter WIDTH = 4)(
35
- input [WIDTH-1:0] a,
36
- input [WIDTH-1:0] b,
37
- output [WIDTH:0] o
38
- );
39
-
40
- logic [WIDTH:0] c;
41
- logic [WIDTH-1:0] s;
42
-
43
- assign c[0] = 1'b0;
44
-
45
- genvar ii;
46
- generate
47
- for (ii=0; ii<WIDTH; ii=ii+1)
48
- begin
49
- fulladder fa(a[ii],b[ii],c[ii],s[ii],c[ii+1]);
50
- end
51
- endgenerate
52
-
53
- assign o = {c[WIDTH], s};
54
-
55
- endmodule
56
-
57
- module zzz(
58
- input [3:0] a,
59
- input [3:0] b,
60
- output [4:0] o
61
- );
62
- serialadder z(a,b,o);
63
- endmodule
package/test3.v DELETED
@@ -1,19 +0,0 @@
1
-
2
- module m(
3
- input a,
4
- output b
5
- );
6
-
7
- assign b = !a;
8
-
9
- endmodule
10
-
11
- module n(
12
- input a,
13
- output b
14
- );
15
-
16
- m x(a, b);
17
-
18
- endmodule
19
-
package/test4.sv DELETED
@@ -1,62 +0,0 @@
1
- // Half adder
2
- module halfadder(
3
- input a,
4
- input b,
5
- output o,
6
- output c
7
- );
8
-
9
- assign o = a ^ b;
10
- assign c = a & b;
11
-
12
- endmodule
13
-
14
- // Full adder
15
- module fulladder(
16
- input a,
17
- input b,
18
- input d,
19
- output o,
20
- output c
21
- );
22
-
23
- logic t, c1, c2;
24
-
25
- halfadder ha1(a, b, t, c1);
26
- halfadder ha2(t, d, o, c2);
27
-
28
- assign c = c1 | c2;
29
-
30
- endmodule
31
-
32
- // Multibit serial adder
33
- module serialadder(
34
- input [4-1:0] a,
35
- input [4-1:0] b,
36
- output [4:0] o
37
- );
38
-
39
- logic [4:0] c;
40
- logic [4-1:0] s;
41
-
42
- assign c[0] = 1'b0;
43
-
44
- genvar ii;
45
- generate
46
- for (ii=0; ii<4; ii=ii+1)
47
- begin
48
- fulladder fa(a[ii],b[ii],c[ii],s[ii],c[ii+1]);
49
- end
50
- endgenerate
51
-
52
- assign o = {c[4], s};
53
-
54
- endmodule
55
-
56
- module zzz(
57
- input [3:0] a,
58
- input [3:0] b,
59
- output [4:0] o
60
- );
61
- serialadder z(a,b,o);
62
- endmodule
package/yosyss DELETED
@@ -1,4 +0,0 @@
1
- #!/bin/bash
2
-
3
- kill -9 $$
4
-