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

chore: add logging to schematic viewer #627

Merged
merged 2 commits into from
Jun 19, 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 packages/teroshdl/src/features/comander/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// You should have received a copy of the GNU General Public License
// along with TerosHDL. If not, see <https://www.gnu.org/licenses/>.

import * as opn from 'open';
import * as vscode from 'vscode';
import * as shelljs from 'shelljs';
import { Base_webview } from './web';
Expand All @@ -26,7 +25,7 @@ import { OS } from "teroshdl2/out/process/common";
import { get_os } from "teroshdl2/out/process/utils";
import * as path_lib from 'path';
import { globalLogger } from '../../logger';
import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager';
import * as utils from '../../utils/utils';

export class Comander {

Expand All @@ -52,6 +51,7 @@ export class Comander {
}

private open_waveform(args: vscode.Uri) {
const config = utils.getConfig(this.manager);
const file_path = args.fsPath;
globalLogger.info(`Opening the waveform: ${file_path}`);

Expand All @@ -62,14 +62,14 @@ export class Comander {
}

let gtkwave_path = "";
let base_path = GlobalConfigManager.getInstance().get_config().tools.general.gtkwave_installation_path;
let base_path = config.tools.general.gtkwave_installation_path;
if (base_path !== "") {
gtkwave_path = path_lib.join(base_path, gtkwave_binary);
}
else {
gtkwave_path = gtkwave_binary;
}
const extra_arguments = GlobalConfigManager.getInstance().get_config().tools.general.gtkwave_extra_arguments;
const extra_arguments = config.tools.general.gtkwave_extra_arguments;

let command = `${gtkwave_path} ${file_path} ${extra_arguments}`;
shelljs.exec(command, { async: true });
Expand Down
5 changes: 3 additions & 2 deletions packages/teroshdl/src/features/dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import * as fs from 'fs';
import { t_Multi_project_manager } from '../type_declaration';
import * as nunjucks from 'nunjucks';
import { globalLogger } from '../logger';
import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager';
import * as utils from '../utils/utils';

const base_path = "dependencies_viewer";

Expand Down Expand Up @@ -135,7 +135,8 @@ export class Dependency_manager {
}
try {
const selected_project = this.manager.get_selected_project();
const python_path = GlobalConfigManager.getInstance().get_config().general.general.pypath;
const config = utils.getConfig(this.manager);
const python_path = config.general.general.pypath;
const result = await selected_project.get_dependency_graph(python_path);
if (result.successful === false) {
globalLogger.error("Error while getting dependency graph.", true);
Expand Down
4 changes: 1 addition & 3 deletions packages/teroshdl/src/features/documenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import * as fs from 'fs';
import { t_Multi_project_manager } from '../type_declaration';
import { Base_webview } from './base_webview';
import { globalLogger } from '../logger';
import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager';


export class Documenter_manager extends Base_webview {

Expand Down Expand Up @@ -134,7 +132,7 @@ export class Documenter_manager extends Base_webview {
}

private get_config(): teroshdl2.config.auxiliar_config.t_documenter_options {
const config = GlobalConfigManager.getInstance().get_config();
const config = utils.getConfig(this.manager);
return <teroshdl2.config.auxiliar_config.t_documenter_options>{
generic_visibility: config.documentation.general.generics,
port_visibility: config.documentation.general.ports,
Expand Down
31 changes: 14 additions & 17 deletions packages/teroshdl/src/features/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import * as teroshdl2 from 'teroshdl2';
import { t_Multi_project_manager } from '../type_declaration';
import * as utils from '../utils/utils';
import { e_formatter_general_formatter_verilog, e_formatter_general_formatter_vhdl } from 'teroshdl2/out/config/config_declaration';
import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager';
import { globalLogger } from '../logger';

let formatter_vhdl: Formatter | undefined = undefined;
Expand All @@ -45,52 +44,50 @@ class Formatter {
// Configuration
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private get_formatter_name() {
const config = utils.getConfig(this.manager);
if (this.lang === teroshdl2.common.general.LANGUAGE.VHDL) {
return GlobalConfigManager.getInstance().get_config().formatter.general.formatter_vhdl;
return config.formatter.general.formatter_vhdl;
}
else {
return GlobalConfigManager.getInstance().get_config().formatter.general.formatter_verilog;
return config.formatter.general.formatter_verilog;
}
}

private get_formatter_config() {
const configCurrent = utils.getConfig(this.manager);
if (this.lang === teroshdl2.common.general.LANGUAGE.VHDL) {
const formatter_name = GlobalConfigManager.getInstance().get_config().formatter.general.formatter_vhdl;
const formatter_name = configCurrent.formatter.general.formatter_vhdl;
if (formatter_name === e_formatter_general_formatter_vhdl.standalone) {
return GlobalConfigManager.getInstance().get_config().formatter.standalone;
return configCurrent.formatter.standalone;
}
else if (formatter_name === e_formatter_general_formatter_vhdl.vsg) {
return GlobalConfigManager.getInstance().get_config().formatter.svg;
return configCurrent.formatter.svg;
}
else {
return GlobalConfigManager.getInstance().get_config().formatter.standalone;
return configCurrent.formatter.standalone;
}
}
else {
const formatter_name = GlobalConfigManager.getInstance().get_config().formatter.general.formatter_verilog;
const formatter_name = configCurrent.formatter.general.formatter_verilog;
if (formatter_name === e_formatter_general_formatter_verilog.istyle) {
return GlobalConfigManager.getInstance().get_config().formatter.istyle;
return configCurrent.formatter.istyle;
}
else if (formatter_name === e_formatter_general_formatter_verilog.s3sv) {
return GlobalConfigManager.getInstance().get_config().formatter.s3sv;
return configCurrent.formatter.s3sv;
}
else if (formatter_name === e_formatter_general_formatter_verilog.verible) {
const config = {
format_args : GlobalConfigManager.getInstance().get_config().formatter.verible.format_args,
path: GlobalConfigManager.getInstance().get_config().tools.verible.installation_path
format_args : configCurrent.formatter.verible.format_args,
path: configCurrent.tools.verible.installation_path
};
return config;
}
else {
return GlobalConfigManager.getInstance().get_config().formatter.istyle;
return configCurrent.formatter.istyle;
}
}
}

private get_pytyon_path() {
return GlobalConfigManager.getInstance().get_config().general.general.pypath;
}

public async format(code) {
const formatter_name = this.get_formatter_name();
const formater_config = this.get_formatter_config();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Logger } from "./ctags/Logger";
import * as vscode from 'vscode';
import { t_Multi_project_manager } from '../../type_declaration';
import * as rusthdl_lib from './lsp/rust_hdl';
import { GlobalConfigManager } from "teroshdl2/out/config/config_manager";
import * as utils from '../../utils/utils';

export type e_provider = {
'completion': any,
Expand Down Expand Up @@ -107,7 +107,9 @@ export class LanguageProviderManager {
let is_alive = false;
let rusthdl;

const enable_vhdl_provider = GlobalConfigManager.getInstance().get_config().general.general.go_to_definition_vhdl;
const config = utils.getConfig(this.manager);

const enable_vhdl_provider = config.general.general.go_to_definition_vhdl;
if (enable_vhdl_provider === true) {
rusthdl = new rusthdl_lib.Rusthdl_lsp(this.context, this.manager);
is_alive = await rusthdl.run_rusthdl();
Expand Down Expand Up @@ -140,7 +142,8 @@ export class LanguageProviderManager {
this.context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(verilogSelector,
this.provider_list.doc));

const enable_verilog_provider = GlobalConfigManager.getInstance().get_config().general.general.go_to_definition_verilog;
const config = utils.getConfig(this.manager);
const enable_verilog_provider = config.general.general.go_to_definition_verilog;
if (enable_verilog_provider === true) {
this.context.subscriptions.push(vscode.languages.registerHoverProvider(verilogSelector,
this.provider_list.hover));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ExtensionContext } from 'vscode';
import util = require('util');
import * as teroshdl2 from 'teroshdl2';
import { t_Multi_project_manager } from '../../../type_declaration';
import * as utils from '../../../utils/utils';

const exec = util.promisify(require('child_process').exec);

Expand All @@ -21,7 +22,6 @@ import {
ServerOptions,
RevealOutputChannelOn
} from 'vscode-languageclient/node';
import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager';


const isWindows = process.platform === 'win32';
Expand Down Expand Up @@ -149,7 +149,8 @@ export class Rusthdl_lsp {
}

getServerOptionsEmbedded(context: ExtensionContext) {
const linter_name = GlobalConfigManager.getInstance().get_config().linter.general.linter_vhdl;
const config = utils.getConfig(this.manager);
const linter_name = config.linter.general.linter_vhdl;
let args: string[] = [];
if (linter_name !== teroshdl2.config.config_declaration.e_linter_general_linter_vhdl.none) {
args = ['--no-lint'];
Expand Down
45 changes: 23 additions & 22 deletions packages/teroshdl/src/features/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import * as vscode from 'vscode';
import * as teroshdl2 from 'teroshdl2';
import { t_Multi_project_manager } from '../type_declaration';
import * as utils from '../utils/utils';
import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager';

enum LINTER_MODE {
STYLE = "style",
Expand Down Expand Up @@ -50,65 +49,67 @@ class Linter {
// Configuration
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private get_linter_name() {
const config = utils.getConfig(this.manager);
if (this.lang === teroshdl2.common.general.LANGUAGE.VHDL && this.mode === LINTER_MODE.ERRORS) {
return GlobalConfigManager.getInstance().get_config().linter.general.linter_vhdl;
return config.linter.general.linter_vhdl;
}
else if ((this.lang === teroshdl2.common.general.LANGUAGE.VERILOG
|| this.lang === teroshdl2.common.general.LANGUAGE.SYSTEMVERILOG)
&& this.mode === LINTER_MODE.ERRORS) {
return GlobalConfigManager.getInstance().get_config().linter.general.linter_verilog;
return config.linter.general.linter_verilog;
}
else if (this.lang === teroshdl2.common.general.LANGUAGE.VHDL && this.mode === LINTER_MODE.STYLE) {
return GlobalConfigManager.getInstance().get_config().linter.general.lstyle_vhdl;
return config.linter.general.lstyle_vhdl;
}
else {
return GlobalConfigManager.getInstance().get_config().linter.general.lstyle_verilog;
return config.linter.general.lstyle_verilog;
}
}

private get_options(lang: teroshdl2.common.general.LANGUAGE): teroshdl2.linter.common.l_options {
let path = "";
let argument = "";
const linter_name = this.get_linter_name();
const config = utils.getConfig(this.manager);

if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_vhdl.ghdl){
path = GlobalConfigManager.getInstance().get_config().tools.ghdl.installation_path;
argument = GlobalConfigManager.getInstance().get_config().linter.ghdl.arguments;
path = config.tools.ghdl.installation_path;
argument = config.linter.ghdl.arguments;
}
else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_vhdl.modelsim &&
lang === teroshdl2.common.general.LANGUAGE.VHDL){
path = GlobalConfigManager.getInstance().get_config().tools.modelsim.installation_path;
argument = GlobalConfigManager.getInstance().get_config().linter.modelsim.vhdl_arguments;
path = config.tools.modelsim.installation_path;
argument = config.linter.modelsim.vhdl_arguments;
}
else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_vhdl.vivado &&
lang === teroshdl2.common.general.LANGUAGE.VHDL){
path = GlobalConfigManager.getInstance().get_config().tools.vivado.installation_path;
argument = GlobalConfigManager.getInstance().get_config().linter.vivado.vhdl_arguments;
path = config.tools.vivado.installation_path;
argument = config.linter.vivado.vhdl_arguments;
}
else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_verilog.icarus){
path = GlobalConfigManager.getInstance().get_config().tools.icarus.installation_path;
argument = GlobalConfigManager.getInstance().get_config().linter.icarus.arguments;
path = config.tools.icarus.installation_path;
argument = config.linter.icarus.arguments;
}
else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_verilog.modelsim &&
lang !== teroshdl2.common.general.LANGUAGE.VHDL){
path = GlobalConfigManager.getInstance().get_config().tools.modelsim.installation_path;
argument = GlobalConfigManager.getInstance().get_config().linter.modelsim.verilog_arguments;
path = config.tools.modelsim.installation_path;
argument = config.linter.modelsim.verilog_arguments;
}
else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_verilog.verilator){
path = GlobalConfigManager.getInstance().get_config().tools.verilator.installation_path;
argument = GlobalConfigManager.getInstance().get_config().linter.verilator.arguments;
path = config.tools.verilator.installation_path;
argument = config.linter.verilator.arguments;
}
else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_linter_verilog.vivado &&
lang !== teroshdl2.common.general.LANGUAGE.VHDL){
path = GlobalConfigManager.getInstance().get_config().tools.vivado.installation_path;
argument = GlobalConfigManager.getInstance().get_config().linter.vivado.verilog_arguments;
path = config.tools.vivado.installation_path;
argument = config.linter.vivado.verilog_arguments;
}
else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_lstyle_vhdl.vsg){
argument = GlobalConfigManager.getInstance().get_config().linter.vsg.arguments;
argument = config.linter.vsg.arguments;
}
else if (linter_name === teroshdl2.config.config_declaration.e_linter_general_lstyle_verilog.verible){
path = GlobalConfigManager.getInstance().get_config().tools.verible.installation_path;
argument = GlobalConfigManager.getInstance().get_config().linter.verible.arguments;
path = config.tools.verible.installation_path;
argument = config.linter.verible.arguments;
}

const options: teroshdl2.linter.common.l_options = {
Expand Down
5 changes: 4 additions & 1 deletion packages/teroshdl/src/features/schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class Schematic_manager extends Base_webview {
'empty': false
};

let config = teroshdl2.config.configManager.GlobalConfigManager.getInstance().get_config();
let config = utils.getConfig(this.manager);
try {
const selectedProject = this.manager.get_selected_project();
config = selectedProject.get_config();
Expand Down Expand Up @@ -296,6 +296,9 @@ export class Schematic_manager extends Base_webview {
// Run Yosys
const exec_i = await teroshdl2.yosys.yosys.getSchematic(config, topLevel, sources, handleStream);

const cmd = `Executing: ${exec_i.spawnfile} ${exec_i.spawnargs.join(" ")}`;
globalLogger.info(cmd);

exec_i.stdout.on('data', function (data) {
globalLogger.info(data);
});
Expand Down
3 changes: 1 addition & 2 deletions packages/teroshdl/src/features/state_machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import * as utils from '../utils/utils';
import * as nunjucks from 'nunjucks';
import { Base_webview } from './base_webview';
import { globalLogger } from '../logger';
import { GlobalConfigManager } from 'teroshdl2/out/config/config_manager';

export class State_machine_manager extends Base_webview {

Expand Down Expand Up @@ -153,7 +152,7 @@ export class State_machine_manager extends Base_webview {
// Utils
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private get_config(): teroshdl2.config.auxiliar_config.t_documenter_options {
const config = GlobalConfigManager.getInstance().get_config();
const config = utils.getConfig(this.manager);
return <teroshdl2.config.auxiliar_config.t_documenter_options>{
generic_visibility: config.documentation.general.generics,
port_visibility: config.documentation.general.ports,
Expand Down
Loading
Loading