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.
@@ -0,0 +1,174 @@
1
+ declare namespace Digitaljs {
2
+ type FilePosition = {
3
+ line: number;
4
+ column: number;
5
+ };
6
+ type SourcePosition = {
7
+ name: string;
8
+ from: FilePosition;
9
+ to: FilePosition;
10
+ };
11
+ type MemReadPort = {
12
+ clock_polarity?: boolean;
13
+ enable_polarity?: boolean;
14
+ arst_polarity?: boolean;
15
+ srst_polarity?: boolean;
16
+ enable_srst?: boolean;
17
+ transparent?: boolean | boolean[];
18
+ collision?: boolean | boolean[];
19
+ init_value?: string;
20
+ arst_value?: string;
21
+ srst_value?: string;
22
+ };
23
+ type MemWritePort = {
24
+ clock_polarity?: boolean;
25
+ enable_polarity?: boolean;
26
+ no_bit_enable?: boolean;
27
+ };
28
+ type Device = {
29
+ type: string;
30
+ source_positions?: SourcePosition[];
31
+ [key: string]: any;
32
+ };
33
+ type Port = {
34
+ id: string;
35
+ port: string;
36
+ };
37
+ type Connector = {
38
+ from: Port;
39
+ to: Port;
40
+ name?: string;
41
+ source_positions?: SourcePosition[];
42
+ };
43
+ type Module = {
44
+ devices: {
45
+ [key: string]: Device;
46
+ };
47
+ connectors: Connector[];
48
+ };
49
+ type TopModule = Module & {
50
+ subcircuits: {
51
+ [key: string]: Module;
52
+ };
53
+ };
54
+ }
55
+ declare namespace Yosys {
56
+ const ConstChars: readonly ["0", "1", "x", "z"];
57
+ type BitChar = (typeof ConstChars)[number];
58
+ type Bit = number | BitChar;
59
+ type BitVector = Bit[];
60
+ type Port = {
61
+ direction: 'input' | 'output' | 'inout';
62
+ bits: any;
63
+ };
64
+ type Parameters = {
65
+ WIDTH?: JsonConstant;
66
+ A_WIDTH?: JsonConstant;
67
+ B_WIDTH?: JsonConstant;
68
+ S_WIDTH?: JsonConstant;
69
+ Y_WIDTH?: JsonConstant;
70
+ A_SIGNED?: JsonConstant;
71
+ B_SIGNED?: JsonConstant;
72
+ CLK_POLARITY?: JsonConstant;
73
+ EN_POLARITY?: JsonConstant;
74
+ ARST_POLARITY?: JsonConstant;
75
+ ARST_VALUE: JsonConstant;
76
+ CTRL_IN_WIDTH?: JsonConstant;
77
+ CTRL_OUT_WIDTH?: JsonConstant;
78
+ TRANS_NUM?: JsonConstant;
79
+ STATE_NUM?: JsonConstant;
80
+ STATE_NUM_LOG2?: JsonConstant;
81
+ STATE_RST?: JsonConstant;
82
+ RD_PORTS?: JsonConstant;
83
+ WR_PORTS?: JsonConstant;
84
+ RD_CLK_POLARITY?: JsonConstant;
85
+ RD_CLK_ENABLE?: JsonConstant;
86
+ RD_CLK_TRANSPARENT?: JsonConstant;
87
+ WR_CLK_POLARITY?: JsonConstant;
88
+ WR_CLK_ENABLE?: JsonConstant;
89
+ [key: string]: any;
90
+ };
91
+ type JsonConstant = number | string;
92
+ type Attributes = {
93
+ init: JsonConstant;
94
+ [key: string]: any;
95
+ };
96
+ type Cell = {
97
+ hide_name: 0 | 1;
98
+ type: string;
99
+ parameters: Parameters;
100
+ attributes: Attributes;
101
+ port_directions: {
102
+ [key: string]: 'input' | 'output';
103
+ };
104
+ connections: {
105
+ [key: string]: BitVector;
106
+ };
107
+ };
108
+ type Net = {
109
+ hide_name: 0 | 1;
110
+ bits: BitVector;
111
+ attributes: {
112
+ [key: string]: string;
113
+ };
114
+ };
115
+ type Module = {
116
+ ports: {
117
+ [key: string]: Port;
118
+ };
119
+ cells: {
120
+ [key: string]: Cell;
121
+ };
122
+ netnames: {
123
+ [key: string]: Net;
124
+ };
125
+ };
126
+ type Output = {
127
+ modules: {
128
+ [key: string]: Module;
129
+ };
130
+ };
131
+ }
132
+ type ConvertOptions = {
133
+ propagation?: number;
134
+ };
135
+ type Options = ConvertOptions & {
136
+ optimize?: boolean;
137
+ fsmexpand?: boolean;
138
+ fsm?: boolean | "nomap";
139
+ timeout?: number;
140
+ lint?: boolean;
141
+ };
142
+ type Output = {
143
+ output?: Digitaljs.TopModule;
144
+ yosys_output?: any;
145
+ yosys_stdout: string;
146
+ yosys_stderr: string;
147
+ lint?: LintMessage[];
148
+ };
149
+ type Portmap = {
150
+ [key: string]: string;
151
+ };
152
+ type Portmaps = {
153
+ [key: string]: Portmap;
154
+ };
155
+ type Bit = Yosys.Bit | `bit${number}`;
156
+ type Net = Bit[];
157
+ type NetInfo = {
158
+ source: undefined | Digitaljs.Port;
159
+ targets: Digitaljs.Port[];
160
+ name: undefined | string;
161
+ source_positions: Digitaljs.SourcePosition[];
162
+ };
163
+ type BitInfo = {
164
+ id: string;
165
+ port: string;
166
+ num: number;
167
+ };
168
+ type LintMessage = {
169
+ type: string;
170
+ file: string;
171
+ line: number;
172
+ column: number;
173
+ message: string;
174
+ };
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ ;
2
+ var Yosys;
3
+ (function (Yosys) {
4
+ Yosys.ConstChars = ["0", "1", "x", "z"];
5
+ })(Yosys || (Yosys = {}));
6
+ ;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "yosys2digitaljs",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Export Yosys netlists to a logic simulator",
5
- "main": "dist/index",
5
+ "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "prepare": "npm run build",
@@ -10,15 +10,28 @@
10
10
  "build": "npm run cjs",
11
11
  "test": "./run_tests.sh"
12
12
  },
13
+ "exports": {
14
+ "./core": {
15
+ "types": "./dist/core.d.ts",
16
+ "import": "./dist/core.js",
17
+ "require": "./dist/core.js"
18
+ },
19
+ "./node": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js",
22
+ "require": "./dist/index.js"
23
+ }
24
+ },
13
25
  "author": "Marek Materzok",
14
26
  "license": "BSD-2-Clause",
15
27
  "dependencies": {
16
28
  "3vl": "^1.0.1",
17
- "big-integer": "^1.6.49",
29
+ "assert": "^2.1.0",
30
+ "big-integer": "^1.6.52",
18
31
  "hashmap": "^2.4.0",
19
- "minimist": "^1.2.5",
32
+ "minimist": "^1.2.8",
20
33
  "sanitize-filename": "^1.6.3",
21
- "tmp-promise": "^1.1.0",
34
+ "tmp-promise": "^3.0.3",
22
35
  "topsort": "^0.0.2"
23
36
  },
24
37
  "engines": {
@@ -30,7 +43,7 @@
30
43
  "url": "https://github.com/tilk/yosys2digitaljs.git"
31
44
  },
32
45
  "devDependencies": {
33
- "@types/node": "^16.10.3",
34
- "typescript": "^4.4.3"
46
+ "@types/node": "^24.10.1",
47
+ "typescript": "^5.9.3"
35
48
  }
36
49
  }
package/process.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  const fs = require('fs');
5
5
  const argv = require('minimist')(
6
- process.argv.slice(2),
6
+ process.argv.slice(2),
7
7
  {boolean: ["optimize", "yosys_out", "yosys_output", "html", "no_io_ui", "tmpdir", "noindent", "fsmexpand"],
8
8
  string: ["fsm"],
9
9
  default: {fsm: true}}
@@ -31,6 +31,7 @@ if (argv._.length === 0) {
31
31
  console.error('No Verilog files passed!');
32
32
  process.exit(1);
33
33
  }
34
+ const yosys2digitaljs_core = require('./dist/core.js');
34
35
  const yosys2digitaljs = require('./dist/index.js');
35
36
  const opts = {};
36
37
  if (argv.optimize) opts.optimize = true;
@@ -62,7 +63,7 @@ result.then(res => {
62
63
  console.log('*/');
63
64
  }
64
65
  const output = res.output;
65
- if (!argv.no_io_ui) yosys2digitaljs.io_ui(output);
66
+ if (!argv.no_io_ui) yosys2digitaljs_core.io_ui(output);
66
67
  console.log(JSON.stringify(output, null, argv.noindent ? 0 : 2));
67
68
  if (argv.html) {
68
69
  console.log(');const paper = circuit.displayOn($(\'#paper\'));circuit.start();</script></body></html>');