yosys2digitaljs 0.2.3 → 0.6.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/ChangeLog.md +33 -0
- package/README.md +4 -4
- package/dist/index.d.ts +164 -0
- package/dist/index.js +1132 -0
- package/package.json +12 -4
- package/process.js +13 -2
- package/src/index.ts +1284 -0
- package/tests/cycleadder.sv +1 -1
- package/tests/cycleadder_arst.sv +1 -1
- package/tests/dff_masterslave.sv +1 -1
- package/tests/dlatch_gate.sv +1 -1
- package/tests/fsm.sv +4 -3
- package/tsconfig.json +15 -0
- package/.travis.yml +0 -8
- package/index.js +0 -878
package/ChangeLog.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
## [0.6.0] -- 2022-02-02
|
|
5
|
+
|
|
6
|
+
### Added
|
|
7
|
+
|
|
8
|
+
- Support for Yosys 0.11 cells `$aldff`, `$aldffe`
|
|
9
|
+
- Added a function `yosys2digitaljs` for converting a Yosys JSON output obtained elsewhere, without running Yosys locally
|
|
10
|
+
|
|
11
|
+
## [0.5.0] -- 2021-10-06
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Support for Yosys 0.10 cells `$adffe`, `$sdff`, `$sdffe`, `$sdffce`, `$adlatch`, `$sr`, `$dffsr`, `$dffsre`
|
|
16
|
+
- Support for Yosys 0.10 improved memory cell `$mem_v2`
|
|
17
|
+
- Support for source code positions
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Support for JSON output generated by Yosys 0.10
|
|
22
|
+
|
|
23
|
+
## [0.4.0] -- 2021-08-20
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Linting via Verilator
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Ported to TypeScript
|
|
32
|
+
- Removed ad-hoc transformations, as they are now performed in DigitalJS
|
|
33
|
+
|
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
[](https://travis-ci.org/tilk/yosys2digitaljs)
|
|
2
1
|
# yosys2digitaljs
|
|
3
2
|
This program converts JSON netlist output generated by [Yosys](http://www.clifford.at/yosys/)
|
|
4
3
|
circuit synthesis software for use with the
|
|
@@ -25,9 +24,10 @@ The generated JSON is printed on standard output.
|
|
|
25
24
|
# API
|
|
26
25
|
Yosys2digitaljs can be used as a library. The API is promise (or async/await) based. Available functions are:
|
|
27
26
|
|
|
28
|
-
- `
|
|
29
|
-
- `
|
|
30
|
-
- `
|
|
27
|
+
- `yosys2digitaljs(json, options)` - converts the Yosys JSON output `json` (passed as an JS object) to a DigitalJS representation of the same circuit.
|
|
28
|
+
- `process_sv(sv_text, options)` - converts a single SystemVerilog source passed as a string.
|
|
29
|
+
- `process_files(texts, options)` - converts multiple Verilog/SystemVerilog sources. The `texts` parameter is an object, with keys being file names, and corresponding values containing the file contents as strings. Example: `{ 'test.sv': 'module test; ...' }`.
|
|
30
|
+
- `process(filenames, dirname, options)` - converts Verilog/SystemVerilog sources saved on the filesystem under names `filenames` in the directory `dirname`.
|
|
31
31
|
|
|
32
32
|
The functions return a promise, which fulfills with an object value with following keys:
|
|
33
33
|
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
declare namespace Digitaljs {
|
|
3
|
+
type FilePosition = {
|
|
4
|
+
line: number;
|
|
5
|
+
column: number;
|
|
6
|
+
};
|
|
7
|
+
type SourcePosition = {
|
|
8
|
+
name: string;
|
|
9
|
+
from: FilePosition;
|
|
10
|
+
to: FilePosition;
|
|
11
|
+
};
|
|
12
|
+
type MemReadPort = {
|
|
13
|
+
clock_polarity?: boolean;
|
|
14
|
+
enable_polarity?: boolean;
|
|
15
|
+
arst_polarity?: boolean;
|
|
16
|
+
srst_polarity?: boolean;
|
|
17
|
+
enable_srst?: boolean;
|
|
18
|
+
transparent?: boolean | boolean[];
|
|
19
|
+
collision?: boolean | boolean[];
|
|
20
|
+
init_value?: string;
|
|
21
|
+
arst_value?: string;
|
|
22
|
+
srst_value?: string;
|
|
23
|
+
};
|
|
24
|
+
type MemWritePort = {
|
|
25
|
+
clock_polarity?: boolean;
|
|
26
|
+
enable_polarity?: boolean;
|
|
27
|
+
no_bit_enable?: boolean;
|
|
28
|
+
};
|
|
29
|
+
type Device = {
|
|
30
|
+
type: string;
|
|
31
|
+
source_positions?: SourcePosition[];
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
};
|
|
34
|
+
type Port = {
|
|
35
|
+
id: string;
|
|
36
|
+
port: string;
|
|
37
|
+
};
|
|
38
|
+
type Connector = {
|
|
39
|
+
from: Port;
|
|
40
|
+
to: Port;
|
|
41
|
+
name?: string;
|
|
42
|
+
source_positions?: SourcePosition[];
|
|
43
|
+
};
|
|
44
|
+
type Module = {
|
|
45
|
+
devices: {
|
|
46
|
+
[key: string]: Device;
|
|
47
|
+
};
|
|
48
|
+
connectors: Connector[];
|
|
49
|
+
};
|
|
50
|
+
type TopModule = Module & {
|
|
51
|
+
subcircuits: {
|
|
52
|
+
[key: string]: Module;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
declare namespace Yosys {
|
|
57
|
+
type BitChar = '0' | '1' | 'x';
|
|
58
|
+
type Bit = number | '0' | '1' | 'x';
|
|
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
|
+
declare type ConvertOptions = {
|
|
133
|
+
propagation?: number;
|
|
134
|
+
};
|
|
135
|
+
declare type Options = ConvertOptions & {
|
|
136
|
+
optimize?: boolean;
|
|
137
|
+
fsmexpand?: boolean;
|
|
138
|
+
fsm?: boolean | "nomap";
|
|
139
|
+
timeout?: number;
|
|
140
|
+
lint?: boolean;
|
|
141
|
+
};
|
|
142
|
+
declare type Output = {
|
|
143
|
+
output?: Digitaljs.TopModule;
|
|
144
|
+
yosys_output?: any;
|
|
145
|
+
yosys_stdout: string;
|
|
146
|
+
yosys_stderr: string;
|
|
147
|
+
lint?: LintMessage[];
|
|
148
|
+
};
|
|
149
|
+
declare type LintMessage = {
|
|
150
|
+
type: string;
|
|
151
|
+
file: string;
|
|
152
|
+
line: number;
|
|
153
|
+
column: number;
|
|
154
|
+
message: string;
|
|
155
|
+
};
|
|
156
|
+
export declare function verilator_lint(filenames: string[], dirname?: string, options?: Options): Promise<LintMessage[]>;
|
|
157
|
+
export declare function yosys2digitaljs(obj: Yosys.Output, options?: ConvertOptions): Digitaljs.TopModule;
|
|
158
|
+
export declare function process(filenames: string[], dirname?: string, options?: Options): Promise<Output>;
|
|
159
|
+
export declare function io_ui(output: Digitaljs.Module): void;
|
|
160
|
+
export declare function process_files(data: {
|
|
161
|
+
[key: string]: string;
|
|
162
|
+
}, options?: Options): Promise<Output>;
|
|
163
|
+
export declare function process_sv(text: string, options?: Options): Promise<Output>;
|
|
164
|
+
export {};
|