Skip to content

Commit

Permalink
Merge pull request #61 from EDAcation:feat/yosys-luts
Browse files Browse the repository at this point in the history
yosys: output LUTs file during synthesis
  • Loading branch information
malmeloo authored May 1, 2024
2 parents 6e828f9 + 667255b commit 9cfccd1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
"@yowasp/nextpnr-ice40": "^0.7.187-dev.514",
"@yowasp/yosys": "^0.38.21-dev.654",
"digitaljs": "github:EDAcation/digitaljs#next",
"edacation": "^0.3.4",
"edacation": "^0.3.5",
"nextpnr": "^0.4.15",
"nextpnr-viewer": "^0.6.1",
"os-browserify": "^0.3.0",
Expand Down
19 changes: 14 additions & 5 deletions src/extension/tasks/yosys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,20 @@ class YosysSynthTerminalTask extends BaseYosysTerminalTask {
async handleEnd(project: Project, outputFiles: TaskOutputFile[]) {
await super.handleEnd(project, outputFiles);

// Open LUT file in DigitalJS editor
// Find LUT file
const lutFile = outputFiles.find((file) => file.path.endsWith('luts.yosys.json'));
if (lutFile) {
const uri = vscode.Uri.joinPath(project.getRoot(), lutFile.path);
await vscode.commands.executeCommand('vscode.open', uri);
}
if (!lutFile) return;
const uri = vscode.Uri.joinPath(project.getRoot(), lutFile.path);

// Update LUT file
const oldContent = await vscode.workspace.fs.readFile(uri);
const newContent = encodeJSON({
type: 'luts',
data: decodeJSON(oldContent)
});
await vscode.workspace.fs.writeFile(uri, newContent);

// Open LUT file
await vscode.commands.executeCommand('vscode.open', uri);
}
}
2 changes: 1 addition & 1 deletion src/views/digitaljs/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class View {
throw new Error('File is missing type or data keys.');
}

if (fileData['type'] === 'rtl') {
if (fileData['type'] === 'rtl' || fileData['type'] === 'luts') {
return new DiagramViewer(this, fileData['data']);
} else if (fileData['type'] === 'stats') {
return new StatsViewer(this, fileData['data']);
Expand Down
21 changes: 13 additions & 8 deletions src/views/digitaljs/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import type {yosys2digitaljs} from 'yosys2digitaljs';

export type YosysRTL = Parameters<typeof yosys2digitaljs>[0];

interface YosysFileRTL {
type: 'rtl';
data: YosysRTL;
}

export interface YosysModuleStats {
num_wires: number;
num_wire_bits: number;
Expand All @@ -19,6 +12,13 @@ export interface YosysModuleStats {
num_cells_by_type: Record<string, number>;
}

export type YosysRTL = Parameters<typeof yosys2digitaljs>[0];

interface YosysFileRTL {
type: 'rtl';
data: YosysRTL;
}

export interface YosysStats {
creator: string;
invocation: string;
Expand All @@ -30,4 +30,9 @@ interface YosysFileStats {
data: YosysStats;
}

export type YosysFile = YosysFileRTL | YosysFileStats;
interface YosysFileLuts {
type: 'luts';
data: YosysRTL;
}

export type YosysFile = YosysFileRTL | YosysFileStats | YosysFileLuts;

0 comments on commit 9cfccd1

Please sign in to comment.