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

Add arguments to reset() #9

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
frontend box and add reset args
  • Loading branch information
alanzyt311 committed Mar 25, 2023
commit 070cae1d776c17c49f494f3643ff42eba161d3bc
17 changes: 17 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -34,6 +34,21 @@

<nav class="navbar navbar-light bg-light" id="toolbar">
<div class="form-inline">
<div>Program&nbsp</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="context-enabler0" onchange="initModule()" checked>
<label class="form-check-label" for="enabled-ctx0">
1
</label>
</div>
<div>&nbsp</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="context-enabler1" onchange="initModule()" checked>
<label class="form-check-label" for="enabled-ctx1">
2
</label>
</div>
<div>&nbsp</div>
<div>
<select id="context-selector" onchange="changeContext(this.value)" class="form-control form-control"></select>
</div>
@@ -225,6 +240,8 @@ <h5 class="card-header">Log</h5>
output: document.getElementById('output-content'),
log: document.getElementById('log-content'),
contextSelector: document.getElementById('context-selector'),
contextEnabler0: document.getElementById('context-enabler0'),
contextEnabler1: document.getElementById('context-enabler1'),
fileSelector0: document.getElementById('file-selector0'),
fileSelector1: document.getElementById('file-selector1'),
playButton: document.getElementById('play-button'),
8 changes: 7 additions & 1 deletion js/execution.js
Original file line number Diff line number Diff line change
@@ -20,7 +20,13 @@ class Execution {
Elements.output.innerHTML = '';
Elements.log.innerHTML = '';

Module.reset(); // 2, [0, 1]);
// Module.reset(); // 2, [0, 1]);
Module.reset(2, [0, 1]);
// Module.reset(2, [0]);
// Module.reset(2, [1]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented code (not limited to this one instance)




while (!Module.lockSimulator(100));
RegisterUtils.init(ctx);
MemoryUtils.init(ctx);
37 changes: 37 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -94,7 +94,44 @@ async function loadData(fileInput) {
}
}


async function initModule() {

let enable_ctx0 = document.getElementById("context-enabler0").checked;
let enable_ctx1 = document.getElementById("context-enabler1").checked;
console.log("program 0 enabled: ", enable_ctx0);
console.log("program 1 enabled: ", enable_ctx1);



}

async function changeContext(ctx) {


// if (ctx !== "0") {
// // Output
// Elements.output.innerHTML = "";
// Elements.log.innerHTML = "";

// // Reg
// Elements.generalReg.innerHTML = "";
// Elements.specialReg.innerHTML = "";
// Elements.floatReg.innerHTML = "";
// Elements.doubleReg.innerHTML = "";

// // Insn
// Elements.userTextContent.innerHTML = "";
// Elements.kernelTextContent.innerHTML = "";
// Elements.kernelTextContainer.innerHTML = "";

// // Mem
// Elements.userData.innerHTML = "";
// Elements.kernelData.innerHTML = "";
// Elements.kernelDataContainer.innerHTML = "";
// Elements.stack.innerHTML = "";
// }

console.log("change ctx from ", Execution.ctx, " to ", ctx);
Execution.ctx = ctx;
console.log("current ctx: ", Execution.ctx);
21 changes: 19 additions & 2 deletions spim/spim.cpp
Original file line number Diff line number Diff line change
@@ -259,13 +259,30 @@ val getSpecialRegVals(int ctx) {
return val(typed_memory_view(9, specialRegs));
}

void reset_sim() { // unsigned int max_contexts, val active_contexts) {
// void reset_sim() { // unsigned int max_contexts, val active_contexts) {
// /* std::vector<unsigned int> arr = emscripten::vecFromJSArray<unsigned int>(active_contexts); */
// /* std::set<unsigned int> s(arr.begin(), arr.end()); */
// /* std::set<unsigned int> s({0, 1}); */

// /* reset(2, s); */
// start_simulator(2, std::set<unsigned int>{0, 1});
// }


void reset_sim(unsigned int max_contexts, const emscripten::val& arr) { // unsigned int max_contexts, val active_contexts) {
/* std::vector<unsigned int> arr = emscripten::vecFromJSArray<unsigned int>(active_contexts); */
/* std::set<unsigned int> s(arr.begin(), arr.end()); */
/* std::set<unsigned int> s({0, 1}); */
std::set<unsigned int> ctx_set;

for (size_t i = 0; i < arr["length"].as<size_t>(); i++) {
ctx_set.insert(arr[i].as<unsigned int>());
}

/* reset(2, s); */
start_simulator(2, std::set<unsigned int>{0, 1});
// start_simulator(max_contexts, std::set<unsigned int>{0, 1});
start_simulator(max_contexts, ctx_set);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up any unused code

}

EMSCRIPTEN_BINDINGS(simulationSettings) { function("setDelay", &setDelay); }