Opaque error and stacktrace when unable to compile
wordandahalf opened this issue · 6 comments
An absolutely wonderful project you have here! I was poking around to see if it could work with one of my Verilog projects (https://github.com/wordandahalf/XDN/), but it fails without an easily diagnosable error:
$ npm start ./XDN/rtl/XDN.v
> @ start /home/ryan/Documents/Workspace/Factorio/verilog2factorio
> node --no-warnings --loader ts-node/esm ./src/main.ts "./XDN/rtl/XDN.v"
Generating netlist
Error: ENOENT: no such file or directory, open './temp.json'
at Object.openSync (fs.js:476:3)
at Module.readFileSync (fs.js:377:35)
at ChildProcess.<anonymous> (file:///home/ryan/Documents/Workspace/Factorio/verilog2factorio/src/main.ts:16:40)
at ChildProcess.emit (events.js:315:20)
at ChildProcess.EventEmitter.emit (domain.js:467:12)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `node --no-warnings --loader ts-node/esm ./src/main.ts "./XDN/rtl/XDN.v"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ryan/.npm/_logs/2021-04-26T20_35_53_644Z-debug.log
$ cat /home/ryan/.npm/_logs/2021-04-26T20_35_53_644Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start', './XDN/rtl/XDN.v' ]
2 info using npm@6.14.12
3 info using node@v14.16.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @~prestart: @
6 info lifecycle @~start: @
7 verbose lifecycle @~start: unsafe-perm in lifecycle true
8 verbose lifecycle @~start: PATH: /usr/lib64/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ryan/Documents/Workspace/Factorio/verilog2factorio/node_modules/.bin:/home/ryan/.sdkman/candidates/java/current/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/share/avr/bin:/snap/bin
9 verbose lifecycle @~start: CWD: /home/ryan/Documents/Workspace/Factorio/verilog2factorio
10 silly lifecycle @~start: Args: [
10 silly lifecycle '-c',
10 silly lifecycle 'node --no-warnings --loader ts-node/esm ./src/main.ts "./XDN/rtl/XDN.v"'
10 silly lifecycle ]
11 silly lifecycle @~start: Returned: code: 1 signal: null
12 info lifecycle @~start: Failed to exec start script
13 verbose stack Error: @ start: `node --no-warnings --loader ts-node/esm ./src/main.ts "./XDN/rtl/XDN.v"`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/lib64/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib64/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1048:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid @
15 verbose cwd /home/ryan/Documents/Workspace/Factorio/verilog2factorio
16 verbose Linux 5.11.12-177.current
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start" "./XDN/rtl/XDN.v"
18 verbose node v14.16.1
19 verbose npm v6.14.12
20 error code ELIFECYCLE
21 error errno 1
22 error @ start: `node --no-warnings --loader ts-node/esm ./src/main.ts "./XDN/rtl/XDN.v"`
22 error Exit status 1
23 error Failed at the @ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Without diving too much into the code, I have a feeling that yosys fails to synthesize the XDN code and its errors aren't forwarded to stderr/stdout.
Running the yosys
command directly (yosys -p "proc; flatten; wreduce; opt; fsm; opt; memory; opt; peepopt; async2sync; wreduce; opt" -o temp.json ./XDN/rtl/XDN.v
) confirms my suspicion, it throws an error due to paths in the includes.
Fixing that issue by moving the XDN/rtl/
folder up a directory solves that problem, but now the program throws different errors:
$ npm start rtl/XDN.v
> @ start /home/ryan/Documents/Workspace/Factorio/verilog2factorio
> node --no-warnings --loader ts-node/esm ./src/main.ts "rtl/XDN.v"
Generating netlist
Building graph for XDN
Unknown node type Register
Unknown node type ALU
Unknown node type Register
Unknown node type Clock
Unknown node type ControlUnit
Unknown node type Register
Unknown node type Register
Unknown node type Output
Unknown node type ProgramCounter
Unknown node type RAM
Thinking about it for more than a half-second, it's probably because I needed to run the command with the other files:
$ npm start rtl/ALU.v rtl/ControlUnit.v rtl/Divider.v rtl/Clock.v rtl/Output.v rtl/ProgramCounter.v rtl/RAM.v rtl/Register.v rtl/XDN.v
> @ start /home/ryan/Documents/Workspace/Factorio/verilog2factorio
> node --no-warnings --loader ts-node/esm ./src/main.ts "rtl/ALU.v" "rtl/ControlUnit.v" "rtl/Divider.v" "rtl/Clock.v" "rtl/Output.v" "rtl/ProgramCounter.v" "rtl/RAM.v" "rtl/Register.v" "rtl/XDN.v"
Generating netlist
Building graph for ALU
Unknown node type $sub
which looks more like an error that can be addressed.
Alright so there are two issues here.
One is that you currently need to have all used modules in the same file. Passing all files on the command line still tries to compile them separately.
And the second one being a missing node type. Which i can fix fairly easily.
The mentioned issues should be fixed with 2ef2b9d. You can now pass multiple files on the command line and i added the sub node.
Definitely fixed the main issue! I'll go ahead and close this--thanks for the help.
I am still getting a few nodes missing ($gt, $sdff); I'd love to throw together a PR if you have any resources that explain what they are! I found $gt in the Yosys Manual, but not $sdff.
The docs on the yosys website are quite old. You will find up to date descriptions of all nodes in the manual folder of your yosys build.