Skip to content
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

yosys: output LUTs file during synthesis #61

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;