diff --git a/configurator/package.json b/configurator/package.json old mode 100644 new mode 100755 index d74ad31..9768f02 --- a/configurator/package.json +++ b/configurator/package.json @@ -26,8 +26,8 @@ "web-vitals": "^0.2.2" }, "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", + "start": "react-scripts --openssl-legacy-provider start", + "build": "react-scripts --openssl-legacy-provider build", "test": "react-scripts test", "eject": "react-scripts eject", "publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files" diff --git a/configurator/src/components/pages/ConfigureCpuComponent.js b/configurator/src/components/pages/ConfigureCpuComponent.js index b0af641..d2afc09 100644 --- a/configurator/src/components/pages/ConfigureCpuComponent.js +++ b/configurator/src/components/pages/ConfigureCpuComponent.js @@ -1,29 +1,59 @@ -import {Alert, AlertIcon, Box, Heading, Tab, TabList, TabPanel, TabPanels, Tabs, Text} from "@chakra-ui/react"; -import {GeneralSettingsForm} from "../forms/GeneralSettingsForm"; -import {GenericSettingsFormComponent} from "../forms/GenericSettingsFormComponent"; -import {VerilogSettingsForm} from "./VerilogSettingsForm"; -import {EnterProgramForm} from "./EnterProgramForm"; -import React from "react"; -import {hazardsParams, pipelineParams} from "./HomePage"; +import React, { useState } from "react"; +import { Alert, AlertIcon, Box, Heading, Tab, TabList, TabPanel, TabPanels, Tabs, Text } from "@chakra-ui/react"; +import { GeneralSettingsForm } from "../forms/GeneralSettingsForm"; +import { GenericSettingsFormComponent } from "../forms/GenericSettingsFormComponent"; +import { VerilogSettingsForm } from "./VerilogSettingsForm"; +import { EnterProgramForm } from "./EnterProgramForm"; +import { hazardsParams, pipelineParams } from "./HomePage"; export function ConfigureCpuComponent({ - configuratorGlobalSettings, - setConfiguratorGlobalSettings, - formErrors, - generalSettings, - onFormattingChange, - onVersionChange, - programText, - setProgramText, - settings, - userChangedStages, - userChangedStages1 - }) { - return + configuratorGlobalSettings, + setConfiguratorGlobalSettings, + formErrors, + generalSettings, + onFormattingChange, + onVersionChange, + programText, + setProgramText, + settings, + userChangedStages, + userChangedStages1, +}) { + const [receivedAsmCode, setReceivedAsmCode] = useState(""); - Configure your CPU now - - + const receiveAsmCode = (event) => { + // Check the origin of the event + // Add your origin check here if needed + + // Access the asm code array from the compiler + var asmCodeArray = event.data.asmCode; + + // Check if asmCodeArray is defined and is an array + if (asmCodeArray && Array.isArray(asmCodeArray)) { + // Convert the array of objects into a string + var asmCodeString = asmCodeArray.map(instruction => instruction.text).join('\n'); + + // Use the asm code string as needed, e.g., display in the code editor + console.log("ASM code sent from parent window to warp-v"); + + // Update the state with the received ASM code (if you're using React state) + setReceivedAsmCode(asmCodeString); + } else { + console.warn("Invalid asmCodeArray:", asmCodeArray); + } +}; + +// Listen for messages +window.addEventListener("message", receiveAsmCode); + + + return ( + + + Configure your CPU now + + + General Multi-Core Pipeline @@ -83,12 +113,16 @@ export function ConfigureCpuComponent({ /> - - - - - ; + + + + + + ); } \ No newline at end of file diff --git a/configurator/src/components/pages/EnterProgramForm.js b/configurator/src/components/pages/EnterProgramForm.js index c351635..f5cf498 100644 --- a/configurator/src/components/pages/EnterProgramForm.js +++ b/configurator/src/components/pages/EnterProgramForm.js @@ -1,15 +1,22 @@ -import React from "react"; -import {Box, Checkbox, Text, Textarea, Stack} from "@chakra-ui/react"; +import React, { useEffect } from "react"; +import { Box, Checkbox, Text, Textarea, Stack } from "@chakra-ui/react"; export function EnterProgramForm({ - configuratorGlobalSettings, - setConfiguratorGlobalSettings, - programText, - setProgramText - }) { - return <> - - + configuratorGlobalSettings, + setConfiguratorGlobalSettings, + programText, + setProgramText, + receivedAsmCode, +}) { + useEffect(() => { + // Use receivedAsmCode as needed, e.g., set it to the programText state + setProgramText(receivedAsmCode); + }, [receivedAsmCode, setProgramText]); + + return ( + <> + + setConfiguratorGlobalSettings({ @@ -28,21 +35,20 @@ export function EnterProgramForm({ customInstructionsEnabled: e.target.checked } })}>Include template for custom instructions - - + - - Here, you can provide your own assembly program that will be hardcoded into the instruction memory - of - your core. - The syntax roughly mimics that defined by the RISC-V ISA, but not exactly. - -