Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mmhobi7/emulsiV into mmho…
Browse files Browse the repository at this point in the history
…bi7-master
  • Loading branch information
Guillaume-Savaton-ESEO committed Mar 16, 2021
2 parents e312c22 + 5537b5e commit 34bf332
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 24 deletions.
2 changes: 1 addition & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ <h3 id="registers">Registers</h3>
<p>Virgule contains the following 32-bit registers:</p>

<ul>
<li>16 general-purpose registers named <code>x0</code> to <code>x15</code>
<li>32 general-purpose registers named <code>x0</code> to <code>x31</code>
as specified in the RV32E base instruction set of the RISC-V specification.</li>
<li>The program counter <code>pc</code>. This register contains the address of the
current instruction. Its reset value is zero and it is always a multiple of 4.</li>
Expand Down
60 changes: 39 additions & 21 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,45 @@ <h1>Comparator</h1>
</div>
<div id="cell-x" class="cell">
<h1>General-purpose regs</h1>
<table id="x">
<tr> <th>x0</th> <td class="reg" id="x0"></td> </tr>
<tr> <th>x1</th> <td class="reg" id="x1"></td> </tr>
<tr> <th>x2</th> <td class="reg" id="x2"></td> </tr>
<tr> <th>x3</th> <td class="reg" id="x3"></td> </tr>
<tr> <th>x4</th> <td class="reg" id="x4"></td> </tr>
<tr id="xrs1" class="overlay"></tr>
<tr> <th>x5</th> <td class="reg" id="x5"></td> </tr>
<tr> <th>x6</th> <td class="reg" id="x6"></td> </tr>
<tr id="xrs2" class="overlay"></tr>
<tr> <th>x7</th> <td class="reg" id="x7"></td> </tr>
<tr> <th>x8</th> <td class="reg" id="x8"></td> </tr>
<tr id="xrd" class="overlay"></tr>
<tr> <th>x9</th> <td class="reg" id="x9"></td> </tr>
<tr> <th>x10</td> <td class="reg" id="x10"></td> </tr>
<tr> <th>x11</td> <td class="reg" id="x11"></td> </tr>
<tr> <th>x12</td> <td class="reg" id="x12"></td> </tr>
<tr> <th>x13</td> <td class="reg" id="x13"></td> </tr>
<tr> <th>x14</td> <td class="reg" id="x14"></td> </tr>
<tr> <th>x15</td> <td class="reg" id="x15"></td> </tr>
</table>
<div class="tbl-wrapper">
<table id="x">
<tr> <th>x0</th> <td class="reg" id="x0"></td> </tr>
<tr> <th>x1</th> <td class="reg" id="x1"></td> </tr>
<tr> <th>x2</th> <td class="reg" id="x2"></td> </tr>
<tr> <th>x3</th> <td class="reg" id="x3"></td> </tr>
<tr> <th>x4</th> <td class="reg" id="x4"></td> </tr>
<tr id="xrs1" class="overlay"></tr>
<tr> <th>x5</th> <td class="reg" id="x5"></td> </tr>
<tr> <th>x6</th> <td class="reg" id="x6"></td> </tr>
<tr id="xrs2" class="overlay"></tr>
<tr> <th>x7</th> <td class="reg" id="x7"></td> </tr>
<tr> <th>x8</th> <td class="reg" id="x8"></td> </tr>
<tr id="xrd" class="overlay"></tr>
<tr> <th>x9</th> <td class="reg" id="x9"></td> </tr>
<tr> <th>x10</td> <td class="reg" id="x10"></td> </tr>
<tr> <th>x11</td> <td class="reg" id="x11"></td> </tr>
<tr> <th>x12</td> <td class="reg" id="x12"></td> </tr>
<tr> <th>x13</td> <td class="reg" id="x13"></td> </tr>
<tr> <th>x14</td> <td class="reg" id="x14"></td> </tr>
<tr> <th>x15</td> <td class="reg" id="x15"></td> </tr>
<tr> <th>x16</td> <td class="reg" id="x16"></td> </tr>
<tr> <th>x17</td> <td class="reg" id="x17"></td> </tr>
<tr> <th>x18</td> <td class="reg" id="x18"></td> </tr>
<tr> <th>x19</td> <td class="reg" id="x19"></td> </tr>
<tr> <th>x20</td> <td class="reg" id="x20"></td> </tr>
<tr> <th>x21</td> <td class="reg" id="x21"></td> </tr>
<tr> <th>x22</td> <td class="reg" id="x22"></td> </tr>
<tr> <th>x23</td> <td class="reg" id="x23"></td> </tr>
<tr> <th>x24</td> <td class="reg" id="x24"></td> </tr>
<tr> <th>x25</td> <td class="reg" id="x25"></td> </tr>
<tr> <th>x26</td> <td class="reg" id="x26"></td> </tr>
<tr> <th>x27</td> <td class="reg" id="x27"></td> </tr>
<tr> <th>x28</td> <td class="reg" id="x28"></td> </tr>
<tr> <th>x29</td> <td class="reg" id="x29"></td> </tr>
<tr> <th>x30</td> <td class="reg" id="x30"></td> </tr>
<tr> <th>x31</td> <td class="reg" id="x31"></td> </tr>
</table>
</div>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/assembly.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export function assemble(str) {
}
const res = parseInt(m[1]);
return isNaN(res) || res < 0 ? 0 :
res > 15 ? 15 :
res > 31 ? 31 :
res;
}

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ window.addEventListener("load", async () => {
const memSize = 4096;

const bus = new Bus();
const cpu = new Processor(16, bus);
const cpu = new Processor(32, bus);
const mem = new Memory(0, memSize);
const ctrl = new Controller(cpu, bus, mem);
bus.addDevice(mem);
Expand Down
11 changes: 11 additions & 0 deletions src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export function resize() {
const tblWrapper = document.querySelector("#cell-memory .tbl-wrapper");
const tblWrapperScrollTop = tblWrapper.scrollTop;

// Preserve the scrolling in the registry table wrapper.
const tblWrapperx = document.querySelector("#cell-x .tbl-wrapper");
const tblWrapperScrollTopx = tblWrapperx.scrollTop;

// Reset the "register" cell to the top of the window.
const regH1 = document.querySelector("#cell-x h1");
regH1.style["padding-top"] = 0;
Expand All @@ -43,9 +47,16 @@ export function resize() {
const mainBottom = document.querySelector(".divider").getBoundingClientRect().top;
resizeElt(tblWrapper, mainBottom - memBottom);

// Set registry table height to its maximum in its parent grid cell.
const xBottomx = tblWrapperx.getBoundingClientRect().bottom;
resizeElt(tblWrapperx, ioTop - xBottomx);

// Restore the scrolling of the memory view.
tblWrapper.scrollTop = tblWrapperScrollTop;

// Restore the scrolling of the memory view.
tblWrapperx.scrollTop = tblWrapperScrollTopx;

// Center the contents of the "register" cell vertically.
delta = mainBottom - document.querySelector("#cell-x table").getBoundingClientRect().bottom;
regH1.style["padding-top"] = (delta / 2) + "px";
Expand Down

0 comments on commit 34bf332

Please sign in to comment.