Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
Change yosys.js from ccall to callMain, fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Jun 20, 2022
1 parent e4728da commit 4e3217a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/workers/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export const INDEX_WORKER_LOCK = 1;
export const INDEX_WORKER_NOTIFY = 2;
export const INDEX_DATA = 3;

export const SHARED_BUFFER_LENGTH = INDEX_DATA * 4 + BLOCK_SIZE;
// Shared buffer consists of three int32 lock fields and the data field.
// The data field consists of a uint8 status code and the data itself.
// The largest data transfered is the buffer for the read operation, which has a maxiumum length equal to the block size.
// The shared buffer is used by both uint8 and int32 typed arrays, so the length has to be a multiple of 4 (for int32).
export const SHARED_BUFFER_LENGTH = (INDEX_DATA + 1) * 4 + BLOCK_SIZE;

export type Operation = 'readdir'| 'rmdir' | 'unlink' | 'stat' | 'read' | 'write';
10 changes: 2 additions & 8 deletions src/workers/yosys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ export class WorkerYosys extends WorkerTool<Yosys> {

async execute(file: StorageFile<unknown, unknown>): Promise<ToolResult[]> {
const path = `/storages/${file.getFullPath()}`;
// const extension = file.getExtension();
// const content = await file.readText();

// this.tool.getFS().writeFile(`design.${extension}`, content);

console.debug('YOSYS', path);

this.tool.getFS().writeFile(`design.ys`, `
design -reset;
Expand All @@ -39,8 +33,8 @@ export class WorkerYosys extends WorkerTool<Yosys> {
synth_ice40 -json luts.json;
`);

// @ts-expect-error: ccall does not exist on type
this.tool.getModule().ccall('run', '', ['string'], ['script design.ys']);
// @ts-expect-error callMain does not exist on type
this.tool.getModule().callMain(['-T', 'design.ys']);

// TODO: consider writing back to FS here instead of in main thread

Expand Down

0 comments on commit 4e3217a

Please sign in to comment.