Skip to content

Commit

Permalink
resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatDeparted2061 committed Feb 4, 2025
1 parent 4962f5d commit fe96bfb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/simulator/src/Verilog2CV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import 'codemirror/theme/monokai.css';
import 'codemirror/theme/midnight.css';

import 'codemirror/addon/hint/show-hint.css';
import 'codemirror/addon/hint/show-hint.js';
import 'codemirror/addon/hint/anyword-hint.js';
import 'codemirror/mode/verilog/verilog.js';
import 'codemirror/addon/edit/closebrackets.js';
import 'codemirror/addon/hint/anyword-hint.js';
Expand Down Expand Up @@ -69,7 +71,15 @@ export async function createVerilogCircuit(): Promise<void> {
}

export function saveVerilogCode(): void {
if (!editor) {
showError('Editor not initialized');
return;
}
const code: string = editor.getValue();
if (!globalScope?.verilogMetadata) {
showError('Circuit scope not initialized');
return;
}
globalScope.verilogMetadata.code = code;
generateVerilogCircuit(code);
}
Expand Down Expand Up @@ -200,6 +210,12 @@ function processDevices(json: YosysJSON, circuitDevices: { [key: string]: Verilo
}

function processDevice(device: string, deviceData: any, circuitDevices: { [key: string]: VerilogSubCircuit | unknown }, subCircuitScope: { [key: string]: string }): void {
function processDevice(
device: string,
deviceData: YosysDevice,
circuitDevices: Record<string, VerilogSubCircuit | unknown>,
subCircuitScope: Record<string, string>
): void {
const deviceType = deviceData.type;
if (deviceType === 'Subcircuit') {
processSubCircuitDevice(device, deviceData, circuitDevices, subCircuitScope);
Expand Down Expand Up @@ -294,6 +310,10 @@ export default function generateVerilogCircuit(

export function setupCodeMirrorEnvironment(): void {
const myTextarea = document.getElementById('codeTextArea') as HTMLTextAreaElement;
if (!myTextarea) {
showError('Code editor textarea not found');
return;
}

CodeMirror.commands.autocomplete = function (cm: CodeMirror.Editor) {
cm.showHint({ hint: CodeMirror.hint.anyword });
Expand Down
2 changes: 1 addition & 1 deletion src/simulator/src/types/verilog.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface SimulatorMobileStore {
export interface Node {
verilogLabel?: string;
parent: {
verilogLabel: string;
verilogLabel?: string;
};
label?: string;
connect(node: Node): void;
Expand Down

0 comments on commit fe96bfb

Please sign in to comment.