netlist: 支持使用特殊字符代表路径 | 支持 ys 脚本简单 ls
This commit is contained in:
parent
2796de88f5
commit
11770385ce
30
package.json
30
package.json
@ -555,6 +555,15 @@
|
|||||||
"category": "Digital-IDE",
|
"category": "Digital-IDE",
|
||||||
"title": "%digital-ide.netlist.title%"
|
"title": "%digital-ide.netlist.title%"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "digital-ide.netlist.run-ys",
|
||||||
|
"icon": {
|
||||||
|
"light": "images/svg/light/netlist.svg",
|
||||||
|
"dark": "images/svg/dark/netlist.svg"
|
||||||
|
},
|
||||||
|
"category": "Digital-IDE",
|
||||||
|
"title": "%digital-ide.netlist.title%"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "digital-ide.fsm",
|
"command": "digital-ide.fsm",
|
||||||
"icon": {
|
"icon": {
|
||||||
@ -737,6 +746,11 @@
|
|||||||
"when": "resourceLangId == vhdl",
|
"when": "resourceLangId == vhdl",
|
||||||
"command": "digital-ide.vhdl2vlog",
|
"command": "digital-ide.vhdl2vlog",
|
||||||
"group": "navigation@6"
|
"group": "navigation@6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"when": "editorLangId == ys",
|
||||||
|
"command": "digital-ide.netlist.run-ys",
|
||||||
|
"group": "navigation@1"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"editor/context": [
|
"editor/context": [
|
||||||
@ -1020,6 +1034,17 @@
|
|||||||
},
|
},
|
||||||
"configuration": "./config/ignore.configuration.json"
|
"configuration": "./config/ignore.configuration.json"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "ys",
|
||||||
|
"extensions": [
|
||||||
|
".ys"
|
||||||
|
],
|
||||||
|
"icon": {
|
||||||
|
"dark": "./images/svg/dark/ys.svg",
|
||||||
|
"light": "./images/svg/dark/ys.svg"
|
||||||
|
},
|
||||||
|
"configuration": "./config/ys.configuration.json"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "digital-ide-output",
|
"id": "digital-ide-output",
|
||||||
"mimetypes": [
|
"mimetypes": [
|
||||||
@ -1078,6 +1103,11 @@
|
|||||||
"language": "dideignore",
|
"language": "dideignore",
|
||||||
"scopeName": "source.dideignore",
|
"scopeName": "source.dideignore",
|
||||||
"path": "./syntaxes/ignore.json"
|
"path": "./syntaxes/ignore.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": "ys",
|
||||||
|
"scopeName": "source.ys",
|
||||||
|
"path": "./syntaxes/ys.json"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"snippets": [
|
"snippets": [
|
||||||
|
@ -3,6 +3,7 @@ import * as fspath from 'path';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import { WASI } from 'wasi';
|
import { WASI } from 'wasi';
|
||||||
|
|
||||||
import { AbsPath, opeParam, ReportType, YosysOutput } from '../../global';
|
import { AbsPath, opeParam, ReportType, YosysOutput } from '../../global';
|
||||||
import { hdlParam } from '../../hdlParser';
|
import { hdlParam } from '../../hdlParser';
|
||||||
import { hdlDir, hdlFile, hdlPath } from '../../hdlFs';
|
import { hdlDir, hdlFile, hdlPath } from '../../hdlFs';
|
||||||
@ -26,8 +27,8 @@ class Netlist {
|
|||||||
|
|
||||||
constructor(context: vscode.ExtensionContext) {
|
constructor(context: vscode.ExtensionContext) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.wsName = 'dide';
|
this.wsName = '{workspace}';
|
||||||
this.libName = 'lib';
|
this.libName = '{library}';
|
||||||
}
|
}
|
||||||
|
|
||||||
public async open(uri: vscode.Uri, moduleName: string) {
|
public async open(uri: vscode.Uri, moduleName: string) {
|
||||||
@ -82,7 +83,12 @@ class Netlist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const wasm = this.wasm;
|
const wasm = this.wasm;
|
||||||
const { wasi, fd } = this.makeWasi(targetYs);
|
const wasiResult = this.makeWasi(targetYs, moduleName);
|
||||||
|
|
||||||
|
if (wasiResult === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { wasi, fd } = wasiResult;
|
||||||
|
|
||||||
const netlistPayloadFolder = hdlPath.join(opeParam.prjInfo.prjPath, 'netlist');
|
const netlistPayloadFolder = hdlPath.join(opeParam.prjInfo.prjPath, 'netlist');
|
||||||
const targetJson = hdlPath.join(netlistPayloadFolder, moduleName + '.json');
|
const targetJson = hdlPath.join(netlistPayloadFolder, moduleName + '.json');
|
||||||
@ -124,7 +130,7 @@ class Netlist {
|
|||||||
const netlistPayloadFolder = hdlPath.join(opeParam.prjInfo.prjPath, 'netlist');
|
const netlistPayloadFolder = hdlPath.join(opeParam.prjInfo.prjPath, 'netlist');
|
||||||
hdlDir.mkdir(netlistPayloadFolder);
|
hdlDir.mkdir(netlistPayloadFolder);
|
||||||
const target = hdlPath.join(netlistPayloadFolder, topModule + '.ys');
|
const target = hdlPath.join(netlistPayloadFolder, topModule + '.ys');
|
||||||
const targetJson = hdlPath.join(netlistPayloadFolder, topModule + '.json').replace(opeParam.workspacePath, '/' + this.wsName);
|
const targetJson = hdlPath.join(netlistPayloadFolder, topModule + '.json').replace(opeParam.workspacePath, this.wsName);
|
||||||
|
|
||||||
const scripts: string[] = [];
|
const scripts: string[] = [];
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
@ -135,10 +141,10 @@ class Netlist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (file.startsWith(opeParam.workspacePath)) {
|
if (file.startsWith(opeParam.workspacePath)) {
|
||||||
const constraintPath = file.replace(opeParam.workspacePath, '/' + this.wsName);
|
const constraintPath = file.replace(opeParam.workspacePath, this.wsName);
|
||||||
scripts.push(`read_verilog -sv -formal -overwrite ${constraintPath}`);
|
scripts.push(`read_verilog -sv -formal -overwrite ${constraintPath}`);
|
||||||
} else if (file.startsWith(opeParam.prjInfo.libCommonPath)) {
|
} else if (file.startsWith(opeParam.prjInfo.libCommonPath)) {
|
||||||
const constraintPath = file.replace(opeParam.prjInfo.libCommonPath, '/' + this.libName);
|
const constraintPath = file.replace(opeParam.prjInfo.libCommonPath, this.libName);
|
||||||
scripts.push(`read_verilog -sv -formal -overwrite ${constraintPath}`);
|
scripts.push(`read_verilog -sv -formal -overwrite ${constraintPath}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,16 +164,17 @@ class Netlist {
|
|||||||
scripts.push(`write_json ${targetJson}`);
|
scripts.push(`write_json ${targetJson}`);
|
||||||
const ysCode = scripts.join('\n');
|
const ysCode = scripts.join('\n');
|
||||||
hdlFile.writeFile(target, ysCode);
|
hdlFile.writeFile(target, ysCode);
|
||||||
return target.replace(opeParam.workspacePath, '/' + this.wsName);
|
return target.replace(opeParam.workspacePath, this.wsName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private makeWasi(target: string) {
|
private makeWasi(target: string, moduleName: string) {
|
||||||
// 创建日志文件路径
|
// 创建日志文件路径
|
||||||
const logFilePath = hdlPath.join(opeParam.prjInfo.prjPath, 'netlist', 'netlist.log');
|
const logFilePath = hdlPath.join(opeParam.prjInfo.prjPath, 'netlist', moduleName + '.log');
|
||||||
hdlFile.removeFile(logFilePath);
|
hdlFile.removeFile(logFilePath);
|
||||||
const logFd = fs.openSync(logFilePath, 'a');
|
const logFd = fs.openSync(logFilePath, 'a');
|
||||||
|
|
||||||
const wasi = new WASI({
|
try {
|
||||||
|
const wasiOption = {
|
||||||
version: 'preview1',
|
version: 'preview1',
|
||||||
args: [
|
args: [
|
||||||
'yosys',
|
'yosys',
|
||||||
@ -176,18 +183,21 @@ class Netlist {
|
|||||||
],
|
],
|
||||||
preopens: {
|
preopens: {
|
||||||
'/share': hdlPath.join(opeParam.extensionPath, 'resources', 'dide-netlist', 'static', 'share'),
|
'/share': hdlPath.join(opeParam.extensionPath, 'resources', 'dide-netlist', 'static', 'share'),
|
||||||
['/' + this.wsName ]: opeParam.workspacePath,
|
[this.wsName ]: opeParam.workspacePath,
|
||||||
['/' + this.libName]: opeParam.prjInfo.libCommonPath
|
[this.libName]: opeParam.prjInfo.libCommonPath
|
||||||
},
|
},
|
||||||
stdin: process.stdin.fd,
|
stdin: process.stdin.fd,
|
||||||
stdout: process.stdout.fd,
|
stdout: process.stdout.fd,
|
||||||
stderr: logFd,
|
stderr: logFd,
|
||||||
// stdout: logFd,
|
|
||||||
// stderr: logFd,
|
|
||||||
env: process.env
|
env: process.env
|
||||||
});
|
};
|
||||||
|
|
||||||
|
const wasi = new WASI(wasiOption);
|
||||||
return { wasi, fd: logFd };
|
return { wasi, fd: logFd };
|
||||||
|
} catch (error) {
|
||||||
|
fs.closeSync(logFd);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async loadWasm() {
|
private async loadWasm() {
|
||||||
@ -294,6 +304,10 @@ class Netlist {
|
|||||||
YosysOutput.report('Schematic saved in ' + savePath);
|
YosysOutput.report('Schematic saved in ' + savePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async runYs(uri: vscode.Uri) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function openNetlistViewer(context: vscode.ExtensionContext, uri: vscode.Uri, moduleName: string) {
|
export async function openNetlistViewer(context: vscode.ExtensionContext, uri: vscode.Uri, moduleName: string) {
|
||||||
@ -301,6 +315,11 @@ export async function openNetlistViewer(context: vscode.ExtensionContext, uri: v
|
|||||||
viewer.open(uri, moduleName);
|
viewer.open(uri, moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function runYsScript(context: vscode.ExtensionContext, uri: vscode.Uri) {
|
||||||
|
const viewer = new Netlist(context);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function registerMessageEvent(panel: vscode.WebviewPanel) {
|
function registerMessageEvent(panel: vscode.WebviewPanel) {
|
||||||
panel.webview.onDidReceiveMessage(message => {
|
panel.webview.onDidReceiveMessage(message => {
|
||||||
|
@ -140,6 +140,12 @@ function registerNetlist(context: vscode.ExtensionContext) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
context.subscriptions.push(
|
||||||
|
vscode.commands.registerCommand('digital-ide.netlist.run-ys', (uri) => {
|
||||||
|
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
context.subscriptions.push(
|
context.subscriptions.push(
|
||||||
vscode.commands.registerCommand('digital-ide.netlist.treeview', (view: ModuleDataItem) => {
|
vscode.commands.registerCommand('digital-ide.netlist.treeview', (view: ModuleDataItem) => {
|
||||||
if (view.path && view.name) {
|
if (view.path && view.name) {
|
||||||
|
@ -39,7 +39,7 @@ function extractTarGz(filePath: string, outputDir: string): Promise<void> {
|
|||||||
cwd: outputDir, // 解压到指定目录
|
cwd: outputDir, // 解压到指定目录
|
||||||
});
|
});
|
||||||
|
|
||||||
inputStream.pipe(gunzip).pipe(extract);
|
inputStream.pipe(gunzip).pipe(extract as NodeJS.WritableStream);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
extract.on('finish', () => {
|
extract.on('finish', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user