增加对 IP 的支持

This commit is contained in:
锦恢 2024-11-07 22:10:19 +08:00
parent 6841795c2a
commit 0c820c7e55
17 changed files with 197 additions and 110 deletions

View File

@ -24,5 +24,6 @@
"error.vcd-viewer.bad-view-file": "Ansichtsdatei ist beschädigt", "error.vcd-viewer.bad-view-file": "Ansichtsdatei ist beschädigt",
"error.vcd-viewer.unexist-direct-vcd-file": "Die von der Ansichtsdatei referenzierte vcd-Datei existiert nicht", "error.vcd-viewer.unexist-direct-vcd-file": "Die von der Ansichtsdatei referenzierte vcd-Datei existiert nicht",
"info.welcome.join-qq-group": "Klicken Sie auf den Link, um der QQ-Gruppe beizutreten", "info.welcome.join-qq-group": "Klicken Sie auf den Link, um der QQ-Gruppe beizutreten",
"info.level.test": "Dies ist ein einfaches Beispiel" "info.level.test": "Dies ist ein einfaches Beispiel",
"info.progress.build-ip-module-tree": "构建 IP 模块树"
} }

View File

@ -24,5 +24,6 @@
"error.vcd-viewer.bad-view-file": "View file is corrupted", "error.vcd-viewer.bad-view-file": "View file is corrupted",
"error.vcd-viewer.unexist-direct-vcd-file": "The vcd file pointed to by the view file does not exist", "error.vcd-viewer.unexist-direct-vcd-file": "The vcd file pointed to by the view file does not exist",
"info.welcome.join-qq-group": "Click the link to join the QQ group", "info.welcome.join-qq-group": "Click the link to join the QQ group",
"info.level.test": "This is a simple example" "info.level.test": "This is a simple example",
"info.progress.build-ip-module-tree": "构建 IP 模块树"
} }

View File

@ -24,5 +24,6 @@
"error.vcd-viewer.bad-view-file": "ビューファイルが破損しています", "error.vcd-viewer.bad-view-file": "ビューファイルが破損しています",
"error.vcd-viewer.unexist-direct-vcd-file": "ビューファイルが指す vcd ファイルは存在しません", "error.vcd-viewer.unexist-direct-vcd-file": "ビューファイルが指す vcd ファイルは存在しません",
"info.welcome.join-qq-group": "リンクをクリックして QQ グループに参加", "info.welcome.join-qq-group": "リンクをクリックして QQ グループに参加",
"info.level.test": "これは簡単な例です" "info.level.test": "これは簡単な例です",
"info.progress.build-ip-module-tree": "构建 IP 模块树"
} }

View File

@ -24,5 +24,6 @@
"error.vcd-viewer.bad-view-file": "视图文件已损坏", "error.vcd-viewer.bad-view-file": "视图文件已损坏",
"error.vcd-viewer.unexist-direct-vcd-file": "视图文件指向的 vcd 文件不存在", "error.vcd-viewer.unexist-direct-vcd-file": "视图文件指向的 vcd 文件不存在",
"info.welcome.join-qq-group": "点击链接加入 QQ 群", "info.welcome.join-qq-group": "点击链接加入 QQ 群",
"info.level.test": "这是一个简单的样例" "info.level.test": "这是一个简单的样例",
"info.progress.build-ip-module-tree": "构建 IP 模块树"
} }

View File

@ -24,5 +24,6 @@
"error.vcd-viewer.bad-view-file": "視圖文件已損壞", "error.vcd-viewer.bad-view-file": "視圖文件已損壞",
"error.vcd-viewer.unexist-direct-vcd-file": "視圖文件指向的 vcd 文件不存在", "error.vcd-viewer.unexist-direct-vcd-file": "視圖文件指向的 vcd 文件不存在",
"info.welcome.join-qq-group": "點擊鏈接加入 QQ 群", "info.welcome.join-qq-group": "點擊鏈接加入 QQ 群",
"info.level.test": "這是一個簡單的樣例" "info.level.test": "這是一個簡單的樣例",
"info.progress.build-ip-module-tree": "构建 IP 模块树"
} }

View File

@ -0,0 +1,7 @@
set_param general.maxThreads 8
create_project template /home/dide/project/Digital-Test/DIDEtemp/prj/xilinx -part none -force
set_property SOURCE_SET sources_1 [get_filesets sim_1]
set_property top_lib xil_defaultlib [get_filesets sim_1]
update_compile_order -fileset sim_1 -quiet
source /home/dide/project/Digital-IDE/resources/script/xilinx/refresh.tcl -quiet
file delete /home/dide/project/Digital-IDE/resources/script/xilinx/launch.tcl -force

View File

@ -0,0 +1,40 @@
remove_files -quiet [get_files]
set xip_repo_paths {}
set_property ip_repo_paths $xip_repo_paths [current_project] -quiet
update_ip_catalog -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/ip/xfft_v9/xfft_v9.xci -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/bimpy.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/bimpy.v -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/bitreverse.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/bitreverse.v -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/butterfly.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/butterfly.v -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/convround.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/convround.v -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/hwbfly.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/hwbfly.v -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/ifftmain.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/ifftmain.v -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/ifftstage.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/ifftstage.v -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/laststage.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/laststage.v -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/longbimpy.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/longbimpy.v -quiet
add_files /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/qtrstage.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/src/ifft/qtrstage.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-Test/DIDEtemp/user/sim/FFT_IFFT_tb.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Math/Advance/FFT/Flow/FFT_IFFT.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Math/Advance/FFT/Flow/stage/BF_stage.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Math/Advance/FFT/Flow/stage/fft_stage.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Math/Advance/FFT/Flow/top/fft.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Math/Advance/FFT/Flow/top/ifft.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Math/Advance/FFT/Flow/utils/ftrans.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Math/Advance/FFT/Flow/utils/ftwiddle.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Memory/SRAM/Shift/shiftTaps.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Math/Advance/Complex/cmplAdsu.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Math/Advance/Complex/cmplMult.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Memory/SRAM/SDPRAM.v -quiet
add_files -fileset sim_1 /home/dide/project/Digital-IDE/library/Basic/Math/Advance/Complex/cordic.v -quiet
add_files -fileset constrs_1 /home/dide/project/Digital-Test/DIDEtemp/user/data -quiet
file delete /home/dide/project/Digital-IDE/resources/script/xilinx/refresh.tcl -force

View File

@ -302,8 +302,6 @@ function instanceByLangID(module: HdlModule): string {
async function instantiation() { async function instantiation() {
const module = await selectModuleFromAll(); const module = await selectModuleFromAll();
if (module) { if (module) {
console.log(module);
const code = instanceByLangID(module); const code = instanceByLangID(module);
const editor = vscode.window.activeTextEditor; const editor = vscode.window.activeTextEditor;
if (editor) { if (editor) {

View File

@ -62,10 +62,10 @@ async function testbench() {
if (!hdlFile.isHDLFile(path)) { if (!hdlFile.isHDLFile(path)) {
return; return;
} }
console.log(path); // console.log(path);
const currentHdlFile = hdlParam.getHdlFile(path); const currentHdlFile = hdlParam.getHdlFile(path);
console.log(currentHdlFile); // console.log(currentHdlFile);
if (!currentHdlFile) { if (!currentHdlFile) {
vscode.window.showErrorMessage('There is no hdlFile respect to ' + path); vscode.window.showErrorMessage('There is no hdlFile respect to ' + path);

View File

@ -37,6 +37,11 @@ export interface ICommonParam {
param: string param: string
} }
export type DoFastFileType = 'common' | 'ip' | 'primitives';
export type DoFastToolChainType = 'xilinx' | 'efinity' | 'intel';
export interface IDoFastParam { export interface IDoFastParam {
path: string path: string,
fileType: DoFastFileType,
toolChain: DoFastToolChainType
} }

View File

@ -613,7 +613,6 @@ class PrjInfo implements PrjInfoMeta {
} else if (srcPath === '') { } else if (srcPath === '') {
return workspace; return workspace;
} }
console.log(hdlPath.join(workspace, srcPath));
return hdlPath.join(workspace, srcPath); return hdlPath.join(workspace, srcPath);
} }

View File

@ -3,6 +3,7 @@ import * as vscode from 'vscode';
import { AbsPath, RelPath } from '../global'; import { AbsPath, RelPath } from '../global';
import { HdlLangID } from '../global/enum'; import { HdlLangID } from '../global/enum';
import { DoFastFileType } from '../global/lsp';
interface Position { interface Position {
// row/line of the cursor, index from 0 // row/line of the cursor, index from 0
@ -37,6 +38,7 @@ enum HdlFileType {
LocalLib = 'local_lib', LocalLib = 'local_lib',
RemoteLib = 'remote_lib' RemoteLib = 'remote_lib'
}; };
enum InstModPathStatus {Current, Include, Others, Unknown}; enum InstModPathStatus {Current, Include, Others, Unknown};
// enum SymbolType { // enum SymbolType {
// Module = 'module', // Module = 'module',
@ -195,7 +197,8 @@ interface CommentResult {
interface Fast { interface Fast {
content: RawHdlModule[] content: RawHdlModule[]
languageId: string languageId: string
macro: Macro macro: Macro,
fileType: DoFastFileType
} }
interface All { interface All {

View File

@ -8,6 +8,7 @@ import { MainOutput, ReportType } from '../global/outputChannel';
import * as common from './common'; import * as common from './common';
import { hdlFile, hdlPath } from '../hdlFs'; import { hdlFile, hdlPath } from '../hdlFs';
import { HdlSymbol } from './util'; import { HdlSymbol } from './util';
import { DoFastFileType } from '../global/lsp';
class HdlParam { class HdlParam {
private readonly topModules : Set<HdlModule> = new Set<HdlModule>(); private readonly topModules : Set<HdlModule> = new Set<HdlModule>();
@ -52,7 +53,7 @@ class HdlParam {
*/ */
public async addHdlPath(path: AbsPath) { public async addHdlPath(path: AbsPath) {
path = hdlPath.toSlash(path); path = hdlPath.toSlash(path);
await this.initHdlFiles([path]); await this.doHdlFast(path, 'common');
const hdlFile = this.getHdlFile(path); const hdlFile = this.getHdlFile(path);
if (!hdlFile) { if (!hdlFile) {
MainOutput.report('error happen when we attempt to add file by path: ' + path, ReportType.Error); MainOutput.report('error happen when we attempt to add file by path: ' + path, ReportType.Error);
@ -225,15 +226,16 @@ class HdlParam {
} }
} }
private async doHdlFast(path: AbsPath) { private async doHdlFast(path: AbsPath, fileType: DoFastFileType) {
try { try {
const fast = await HdlSymbol.fast(path); const fast = await HdlSymbol.fast(path, fileType);
if (fast) { if (fast) {
const languageId = hdlFile.getLanguageId(path); const languageId = hdlFile.getLanguageId(path);
new HdlFile(path, new HdlFile(path,
languageId, languageId,
fast.macro, fast.macro,
fast.content); fast.content,
fast.fileType);
} }
} catch (error) { } catch (error) {
MainOutput.report('Error happen when parse ' + path, ReportType.Error); MainOutput.report('Error happen when parse ' + path, ReportType.Error);
@ -241,29 +243,18 @@ class HdlParam {
} }
} }
public async initHdlFiles(hdlFiles: AbsPath[], progress?: vscode.Progress<IProgress>) {
public async initializeHdlFiles(hdlFiles: AbsPath[], progress: vscode.Progress<IProgress>) {
const { t } = vscode.l10n; const { t } = vscode.l10n;
let count: number = 0; let count: number = 0;
let fileNum = hdlFiles.length; let fileNum = hdlFiles.length;
// TODO: 找出最合理的核心数
const parallelChunk = Math.min(os.cpus().length, 32); const parallelChunk = Math.min(os.cpus().length, 32);
console.log("use cpu: " + parallelChunk); console.log("use cpu: " + parallelChunk);
const pools: { id: number, promise: Promise<void>, path: string }[] = []; const pools: { id: number, promise: Promise<void>, path: string }[] = [];
const reportTitle = t('info.progress.build-module-tree'); const reportTitle = t('info.progress.build-module-tree');
progress.report({ message: reportTitle + ` ${1}/${fileNum}`, increment: 0 });
progress?.report({ message: reportTitle + ` ${1}/${fileNum}`, increment: 0 });
// for (const path of hdlFiles) {
// count ++;
// console.log('send request: ' + path);
// await this.doHdlFast(path);
// const increment = Math.floor(count / fileNum * 100);
// progress?.report({ message: reportTitle + ` ${count}/${fileNum}`, increment });
// }
async function consumePools() { async function consumePools() {
for (const p of pools) { for (const p of pools) {
@ -279,7 +270,7 @@ class HdlParam {
count ++; count ++;
console.log('send request: ' + path); console.log('send request: ' + path);
const p = this.doHdlFast(path); const p = this.doHdlFast(path, 'common');
pools.push({ id: count, promise: p, path }); pools.push({ id: count, promise: p, path });
if (pools.length % parallelChunk === 0) { if (pools.length % parallelChunk === 0) {
// 消费并发池 // 消费并发池
@ -290,12 +281,49 @@ class HdlParam {
if (pools.length > 0) { if (pools.length > 0) {
await consumePools(); await consumePools();
} }
} }
public async initialize(hdlFiles: AbsPath[], progress: vscode.Progress<IProgress>) { public async initializeIPsPath(IPsPath: string[], progress: vscode.Progress<IProgress>) {
await this.initHdlFiles(hdlFiles, progress); const { t } = vscode.l10n;
let count: number = 0;
let fileNum = IPsPath.length;
const parallelChunk = Math.min(os.cpus().length, 32);
console.log("use cpu: " + parallelChunk);
const pools: { id: number, promise: Promise<void>, path: string }[] = [];
const reportTitle = t('info.progress.build-ip-module-tree');
progress.report({ message: reportTitle + ` ${1}/${fileNum}`, increment: 0 });
async function consumePools() {
for (const p of pools) {
const increment = Math.floor(p.id / fileNum * 100);
await p.promise;
console.log("handle id " + p.id + ' increment: ' + increment);
progress?.report({ message: reportTitle + ` ${p.id}/${fileNum}`, increment });
}
pools.length = 0;
}
for (const path of IPsPath) {
count ++;
console.log('send request: ' + path);
const p = this.doHdlFast(path, 'ip');
pools.push({ id: count, promise: p, path });
if (pools.length % parallelChunk === 0) {
// 消费并发池
await consumePools();
}
}
if (pools.length > 0) {
await consumePools();
}
}
public async makeAllInstance() {
for (const hdlFile of this.getAllHdlFiles()) { for (const hdlFile of this.getAllHdlFiles()) {
hdlFile.makeInstance(); hdlFile.makeInstance();
} }
@ -352,7 +380,7 @@ class HdlParam {
public async addHdlFile(path: AbsPath) { public async addHdlFile(path: AbsPath) {
path = hdlPath.toSlash(path); path = hdlPath.toSlash(path);
await this.initHdlFiles([path]); await this.doHdlFast(path, 'common');
const moduleFile = this.getHdlFile(path); const moduleFile = this.getHdlFile(path);
if (!moduleFile) { if (!moduleFile) {
MainOutput.report('error happen when create moduleFile ' + path, ReportType.Warn); MainOutput.report('error happen when create moduleFile ' + path, ReportType.Warn);
@ -665,9 +693,7 @@ class HdlModule {
// search included file // search included file
for (const include of this.file.macro.includes) { for (const include of this.file.macro.includes) {
const absIncludePath = hdlPath.rel2abs(this.path, include.path); const absIncludePath = hdlPath.rel2abs(this.path, include.path);
console.log(absIncludePath);
const includeFile = hdlParam.getHdlFile(absIncludePath); const includeFile = hdlParam.getHdlFile(absIncludePath);
console.log(includeFile);
if (includeFile) { if (includeFile) {
excludeFile.add(includeFile); excludeFile.add(includeFile);
@ -810,18 +836,21 @@ class HdlFile {
public path: string; public path: string;
public languageId: HdlLangID; public languageId: HdlLangID;
public type: common.HdlFileType; public type: common.HdlFileType;
public doFastType: DoFastFileType;
public macro: common.Macro; public macro: common.Macro;
private readonly nameToModule: Map<string, HdlModule>; private readonly nameToModule: Map<string, HdlModule>;
constructor(path: string, constructor(path: string,
languageId: HdlLangID, languageId: HdlLangID,
macro: common.Macro, macro: common.Macro,
modules: common.RawHdlModule[]) { modules: common.RawHdlModule[],
doFastType: DoFastFileType) {
this.path = path; this.path = path;
this.languageId = languageId; this.languageId = languageId;
this.macro = macro; this.macro = macro;
this.type = hdlFile.getHdlFileType(path); this.type = hdlFile.getHdlFileType(path);
this.doFastType = doFastType;
// add to global hdlParam // add to global hdlParam
hdlParam.setHdlFile(this); hdlParam.setHdlFile(this);

View File

@ -1,34 +1,18 @@
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { hdlFile } from '../hdlFs'; import { hdlFile } from '../hdlFs';
import { HdlLangID } from '../global/enum'; import { HdlLangID } from '../global/enum';
import { AbsPath, LspClient } from '../global'; import { AbsPath, LspClient, opeParam } from '../global';
import { DoFastRequestType, ITextDocumentItem, CustomParamRequestType, UpdateFastRequestType } from '../global/lsp'; import { DoFastRequestType, ITextDocumentItem, CustomParamRequestType, UpdateFastRequestType, DoFastFileType, DoFastToolChainType } from '../global/lsp';
import { Fast, RawHdlModule } from './common'; import { Fast, RawHdlModule } from './common';
async function doFastApi(path: string, fileType: DoFastFileType): Promise<Fast | undefined> {
async function doFastApi(path: string): Promise<Fast | undefined> {
try { try {
const client = LspClient.DigitalIDE; const client = LspClient.DigitalIDE;
const langID = hdlFile.getLanguageId(path); const langID = hdlFile.getLanguageId(path);
const toolChain = opeParam.prjInfo.toolChain as DoFastToolChainType;
if (client) { if (client) {
const response = await client.sendRequest(DoFastRequestType, { path }); const response = await client.sendRequest(DoFastRequestType, { path, fileType, toolChain });
response.languageId = langID;
return response;
}
} catch (error) {
console.error("error happen when run doFastApi, " + error);
console.error("error file path: " + path);
return undefined;
}
}
async function updateFastApi(path: string): Promise<Fast | undefined> {
try {
const client = LspClient.DigitalIDE;
const langID = hdlFile.getLanguageId(path);
if (client) {
const response = await client.sendRequest(UpdateFastRequestType, { path });
response.languageId = langID; response.languageId = langID;
return response; return response;
} }
@ -46,26 +30,8 @@ namespace HdlSymbol {
* @param path * @param path
* @returns * @returns
*/ */
export function fast(path: AbsPath): Promise<Fast | undefined> { export function fast(path: AbsPath, fileType: DoFastFileType): Promise<Fast | undefined> {
const langID = hdlFile.getLanguageId(path); return doFastApi(path, fileType);
switch (langID) {
case HdlLangID.Verilog:
case HdlLangID.Vhdl:
case HdlLangID.SystemVerilog:
return doFastApi(path);
default: return new Promise(resolve => resolve(undefined));
}
}
export function updateFast(path: AbsPath): Promise<Fast | undefined> {
const langID = hdlFile.getLanguageId(path);
switch (langID) {
case HdlLangID.Verilog:
case HdlLangID.Vhdl:
case HdlLangID.SystemVerilog:
return updateFastApi(path);
default: return new Promise(resolve => resolve(undefined));
}
} }
} }

View File

@ -269,6 +269,7 @@ class XilinxOperation {
// 导入非本地的设计源文件 // 导入非本地的设计源文件
const HDLFiles = hdlParam.getAllHdlFiles(); const HDLFiles = hdlParam.getAllHdlFiles();
for (const file of HDLFiles) { for (const file of HDLFiles) {
// TODO: 新增library的add_files
if (file.type === "src") { if (file.type === "src") {
scripts.push(`add_files ${file.path} -quiet`); scripts.push(`add_files ${file.path} -quiet`);
} }

View File

@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import * as fs from 'fs'; import * as fs from 'fs';
import * as fspath from 'path';
import { AbsPath, IProgress, LspClient, MainOutput, opeParam, ReportType } from '../global'; import { AbsPath, IProgress, LspClient, MainOutput, opeParam, ReportType } from '../global';
import { PathSet } from '../global/util'; import { PathSet } from '../global/util';
@ -94,7 +95,11 @@ class PrjManage {
} }
/** /**
* get all the hdl files that to be parsed in the project * @description hdl
* - sim
* - src
* - common lib
* - custom lib
* @returns * @returns
*/ */
public async getPrjHardwareFiles(): Promise<AbsPath[]> { public async getPrjHardwareFiles(): Promise<AbsPath[]> {
@ -126,47 +131,76 @@ class PrjManage {
return hdlFiles; return hdlFiles;
} }
/**
* @description IP
*/
public async getPrjIPs() {
const toolchain = opeParam.prjInfo.toolChain;
switch (toolchain) {
case 'xilinx':
return this.getXilinxIPs();
break;
default:
break;
}
return [];
}
public getXilinxIPs() {
const srcFolder = opeParam.prjInfo.arch.hardware.src;
const ipFolder = hdlPath.resolve(srcFolder, '../ip');
const validIPs: string[] = [];
if (fs.existsSync(ipFolder) && hdlFile.isDir(ipFolder)) {
for (const folder of fs.readdirSync(ipFolder)) {
const folderPath = hdlPath.join(ipFolder, folder);
if (this.isValidXilinxIP(folderPath)) {
validIPs.push(folderPath);
}
}
}
return validIPs;
}
public isValidXilinxIP(folderPath: string): boolean {
const folderName = fspath.basename(folderPath);
const descriptionFile = folderName + '.vho';
const descriptionFilePath = hdlPath.join(folderPath, descriptionFile);
return fs.existsSync(descriptionFilePath);
}
public async initialise(context: vscode.ExtensionContext, progress: vscode.Progress<IProgress>, countTimeCost: boolean = true) { public async initialise(context: vscode.ExtensionContext, progress: vscode.Progress<IProgress>, countTimeCost: boolean = true) {
if (countTimeCost) { if (countTimeCost) {
console.time('launch'); console.time('launch');
} }
// 初始化 OpeParam
// 包含基本的插件的文件系统信息、用户配置文件和系统配置文件的合并数据结构
const refreshPrjConfig = await this.initOpeParam(context); const refreshPrjConfig = await this.initOpeParam(context);
MainOutput.report('finish initialise opeParam', ReportType.Info); MainOutput.report('finish initialise opeParam', ReportType.Info);
prjManage.refreshPrjFolder(refreshPrjConfig); prjManage.refreshPrjFolder(refreshPrjConfig);
// 解析 hdl 文件,构建 hdlParam
const hdlFiles = await this.getPrjHardwareFiles(); const hdlFiles = await this.getPrjHardwareFiles();
MainOutput.report(`finish collect ${hdlFiles.length} hdl files`, ReportType.Info); await hdlParam.initializeHdlFiles(hdlFiles, progress);
await hdlParam.initialize(hdlFiles, progress); // 根据 toolchain 解析合法的 IP构建 hdlParam
const IPsPath = await this.getPrjIPs();
await hdlParam.initializeIPsPath(IPsPath, progress);
// TODO: 解析原语并构建
// 构建 instance 解析
await hdlParam.makeAllInstance();
// 分析依赖关系错位情况
const unhandleNum = hdlParam.getUnhandleInstanceNumber(); const unhandleNum = hdlParam.getUnhandleInstanceNumber();
MainOutput.report(`finish analyse ${hdlFiles.length} hdl files, find ${unhandleNum} unsolved instances`, ReportType.Info); MainOutput.report(`finish analyse ${hdlFiles.length} hdl files, find ${unhandleNum} unsolved instances`, ReportType.Info);
// 完成后端向前端发送消息的注册
const mainClient = LspClient.DigitalIDE;
if (mainClient !== undefined) {
await mainClient.onReady();
mainClient.onNotification('update/fast', async (params: any) => {
try {
const fast = params.fast as Fast;
const path = params.path as string;
console.log("[receive notification] path: " + path);
hdlParam.updateFast(path, fast);
refreshArchTree();
} catch (error) {
console.error("error happen when update fast: " + error);
}
});
// mainClient.onNotification('update/string', async (params: any) => {
// console.log('[StringNotificationType] receive from backend');
// console.log(params);
// });
}
this.pl = new PlManage(); this.pl = new PlManage();
// TODO : finish it later // TODO : finish it later
// this.ps = new PsManage(); // this.ps = new PsManage();
MainOutput.report('create pl', ReportType.Info); MainOutput.report('create pl', ReportType.Info);

View File

@ -146,8 +146,8 @@ class HdlAction extends BaseAction {
return; return;
} }
const fast = await HdlSymbol.updateFast(path); const fast = await HdlSymbol.fast(path, 'common');
console.log('get update fast'); console.log('update fast: ' + path);
if (!fast) { if (!fast) {
// vscode.window.showErrorMessage('error happen when parse ' + path + '\nFail to update'); // vscode.window.showErrorMessage('error happen when parse ' + path + '\nFail to update');