-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken abc9 support for synth_ecp5
#29
Comments
That aside, I'm still very much enjoying this package! As a new years present, here's a simple Deno program that can just synthesize an entire directory of Verilog code, assuming a import { parse } from "https://deno.land/[email protected]/flags/mod.ts";
import { walk } from "https://deno.land/[email protected]/fs/walk.ts";
import { Tree } from "npm:@yowasp/runtime";
import { runYosys } from "npm:@yowasp/yosys";
import { runEcppack, runNextpnrEcp5 } from "npm:@yowasp/nextpnr-ecp5";
async function walkToTree(path: string): Promise<Tree> {
const files: Tree = {};
const dirpath = path + (path.endsWith("/") ? "" : "/");
// first, walk all the normal files and add them to the tree
for await (const entry of walk(path, { maxDepth: 1 })) {
if (entry.path === path) {
continue;
}
const relpath = entry.path.slice(dirpath.length);
if (entry.isDirectory) {
files[relpath] = await walkToTree(entry.path);
} else {
files[relpath] = await Deno.readFile(entry.path);
}
}
return files;
}
const flags = parse(Deno.args, {
boolean: ["help"],
});
if (flags.help) {
console.log("FIXME");
Deno.exit(1);
}
console.log("Performing RTL synthesis...");
const rtlTree = await walkToTree(String(flags._[0]));
const synthTree = await runYosys(
[
"top.v",
"-p",
"hierarchy -libdir . -auto-top",
"-p",
"synth_ecp5 -noabc9 -json top.json",
],
rtlTree,
{
printLine: (line: string) => {
console.log(line);
return;
},
},
);
console.log("Performing place and route...");
const pnrTree = await runNextpnrEcp5(
[
"--json",
"top.json",
"--textcfg",
"top.config",
"--lpf",
"pinout.lpf",
"--85k",
"--package",
"CABGA381",
"--placer",
"static",
],
synthTree,
{
printLine: (line: string) => {
console.log(line);
return;
},
},
);
console.log("Packing bitstream...");
const packTree = await runEcppack(
[
"--idcode",
"0x41113043",
"top.config",
"top.bit",
],
pnrTree,
{
printLine: (line: string) => {
console.log(line);
return;
},
},
);
await Deno.writeFile("top.bit", packTree["top.bit"] as Uint8Array);
console.log("Wrote bitstream to top.bit"); Nothing more than a single file needed to automate the whole flow. I find this remarkable and I have a bunch of ideas that can build off of this. I'm really looking forward to future improvements (e.g. hostcalls for |
The log up to this point is perfectly normal. How does it fail? |
I think that's the default behavior. Isn't it? |
Yep! How do you feel about the "tree" data structure, by the way? It's a bit stringly typed but it seems simple and TypeScript can handle it. The idea there is to make each executable a normal, pure JavaScript function.
Nice!
This is in scope in principle but I haven't thought about how to do this. Certainly I would not object to having callbacks that e.g. spawn a subprocess and communicate, or open a socket. The primitives for this operation need to be well thought out. I do not currently run Asyncify on normal YoWASP binaries (except for openFPGALoader, where this is a part of the ABI contract, essentially) so stdin or socket reads can only be synchronous. This is why right now the only thing you get is I think running Asyncify would complicate the build process substantially: it will no longer be possible to use the same .wasm file for both Python and JavaScript deployment. Because of this, I am very hesitant to use Asyncify. I do not think I have the bandwidth to maintain, debug, and support two divergent copies of the build pipeline for Yosys and nextpnr. It looks like the only way to synchronously obtain data from another web worker is by using There is no support for Unix domain sockets in WASI so that's out. It seems that our API then must be based around calling subprocesses, where stdin, stdout, and stderr are connected via pipes, and each pipe is implemented using something like a bipartite buffer based on SAB. (We should probably make the stdio interface more principled at this point, separating stdin/stdout/stderr into their own individual options.) The main remaining problem is the filesystem. It seems completely impractical, and nightmarish in any case, to have any notion of shared filesystem. We could make a copy of the filesystem at the time of spawning but that's it. We could maybe add an option to return not a full tree but a diff of the tree, which will save space too, though you can already do this in the caller. This will never be remotely POSIX-compliant in terms of shared semantics. I hope this braindump helps. |
I think this is maybe some kind of bug in Yosys, rather than the build. The code is just a copy of the example in https://github.com/YosysHQ/prjtrellis/tree/master/examples/ulx3s, and I think that script above can basically reproduce it (if you rename However, I found that if I changed the Yosys invocation from this:
To this:
With this
Then it works!
Yeah, it was just leftover debugging cruft that I hadn't cleaned up before copying out of my editor. |
Here's a log of the two different runs with those arguments; Also I think the asyncify point makes sense, yeah. For this Deno experiment I was just going to do web workers with SharedArrayBuffer to communicate results and run multiple design sweeps. My actual goal in the long run is to have a portable command line tool I can integrate with monorepo build systems (Buck2), so the loss of EDIT: I also quite like the |
sigh So. I know that
Happy to integrate that upstream if we can work out a nice and lightweight solution for the pipe and popen API. (I am pretty sure we can).
Yes! When I started using Yosys within Amaranth and ran into the need to deploy it, I found it conceptually intolerable that I have to build a pure function for a huge matrix of platforms and OSes just because it happens to be written in C. So I fixed it o:3 |
I've now uploaded all of the tools with |
|
When using
synth_ecp5
, it seems-abc9
has been turned on by default at some point. However, it looks like something got miscompiled, or abc support is missing somehow, meaningsynth_ecp5
just immediately fails unless you specify-noabc9
:I haven't taken the time to diagnose if this is an obviously known issue or not. I thought abc would be compiled into yosys in this case, but I can't remember all the details OTTOMH...
Version: @yowasp/yosys/0.37.58-dev.635
The text was updated successfully, but these errors were encountered: