-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
436 lines (408 loc) · 14.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="style.css" />
<title>Mips Datapath Simulator</title>
</head>
<body>
<!-- GitHub Logo Start -->
<a
href="https://github.com/saliherdemk/Mips-Datapath-Simulator"
target="blank"
>
<img
src="media/githubLogo.png"
alt=""
id="github"
class="absolute right-0"
/>
</a>
<!-- GitHub Logo End -->
<!-- Lejant Start -->
<button class="fixed bottom-2 right-3 z-40" onclick="toggleLejant()">
<div class="shadow-lg rounded hidden" id="lejant">
<img src="media/lejant.png" alt="" />
</div>
<img
src="media/tip.png"
width="50"
height="50"
alt=""
class="float-right"
/>
</button>
<!-- Lejant End -->
<div class="flex flex-col justify-center items-center py-5 px-[15%]">
<!-- Instruction Inputs Start -->
<div
class="w-full text-center p-5 h-25 flex justify-center items-center relative"
>
<form action="" id="inst-form" onsubmit="setMachineCode(event)">
<div class="flex">
<div class="px-4 block">
<label
for="instruction"
class="block mb-2 text-sm font-medium text-gray-900"
>Instruction</label
>
<select
id="instruction"
class="border border-gray-300 text-gray-900 text-sm rounded-lg w-32 p-2.5 mx-2.5 inst-form-input"
name="inst-inp"
onchange="setInstruction(event)"
>
<option value="Add">Add</option>
<option value="Sub">Sub</option>
<option value="And">And</option>
<option value="Or">Or</option>
<option value="Jr">Jr</option>
<option value="Addi">Addi</option>
<option value="Lw">Lw</option>
<option value="Sw">Sw</option>
<option value="Beq">Beq</option>
<option value="J">J</option>
<option value="Jal">Jal</option>
</select>
</div>
<div id="reg-inputs" class="flex">
<div id="reg-inp1">
<div class="reg-input reg-input-1 block">
<label
for="reg-input1"
class="block mb-2 text-sm font-medium text-gray-900"
>Register</label
>
<select
id="reg-input1"
class="border border-gray-300 text-gray-900 text-sm rounded-lg w-32 p-2.5 mx-2.5 reg-select inst-form-input"
name="reg-input-1-1"
></select>
</div>
<div class="reg-input reg-input-2 hidden">
<label
for="text-inp1"
class="block mb-2 text-sm font-medium text-gray-900"
>Address</label
>
<input
id="text-inp1"
type="text"
class="border border-gray-300 text-gray-900 text-sm rounded-lg w-32 p-2.5 mx-2.5 reg-select inst-form-input"
name="reg-input-1-2"
maxlength="4"
value="0"
required
/>
</div>
</div>
<div id="reg-inp2">
<div class="reg-input reg-input-1 block">
<label
for="reg-input2"
class="block mb-2 text-sm font-medium text-gray-900"
>Register</label
>
<select
id="reg-input2"
class="border border-gray-300 text-gray-900 text-sm rounded-lg w-32 p-2.5 mx-2.5 reg-select inst-form-input"
name="reg-input-2-1"
></select>
</div>
<div class="reg-input reg-input-2 hidden">
<label
for="text-inp2"
class="block mb-2 text-sm font-medium text-gray-900"
>Offset</label
>
<input
id="text-inp2"
type="text"
class="border border-gray-300 text-gray-900 text-sm rounded-lg w-32 p-2.5 mx-2.5 reg-select inst-form-input"
value="0"
maxlength="4"
required
name="reg-input-2-2"
/>
</div>
</div>
<div id="reg-inp3">
<div class="reg-input reg-input-1 block">
<label
for="reg-input3"
class="block mb-2 text-sm font-medium text-gray-900"
>Register</label
>
<select
id="reg-input3"
class="border border-gray-300 text-gray-900 text-sm rounded-lg w-32 p-2.5 mx-2.5 reg-select inst-form-input"
name="reg-input-3-1"
></select>
</div>
<div class="reg-input reg-input-2 hidden">
<label
for="text-input3"
id="input3-label"
class="block mb-2 text-sm font-medium text-gray-900"
>Immediate</label
>
<input
id="text-input3"
type="text"
class="border border-gray-300 text-gray-900 text-sm rounded-lg w-32 p-2.5 mx-2.5 reg-select inst-form-input"
value="0"
maxlength="4"
name="reg-input-3-2"
required
/>
</div>
</div>
</div>
<button
class="h-10 w-2/3 w-full bg-green-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded place-self-end"
type="submit"
>
Add
</button>
</div>
<div class="flex justify-center items-center pt-3 gap-2">
Selected Address:
<div id="selected-address">None</div>
</div>
</form>
<button class="right-0 absolute" onclick="toggleRegisters()">
<i class="arrow down"></i>
</button>
</div>
<!-- Instruction Inputs End -->
<div
class="w-full max-h-[500px] relative overflow-hidden transition-all"
id="container"
isExpanded="true"
>
<!-- Registers Start -->
<form class="text-right" id="reg-form" onsubmit="setRegisters(event)">
<p class="text-lg text-center h-10">Registers</p>
<div class="grid grid-cols-8 gap-4" id="reg-input-container">
<div class="border-2">
<p class="text-center">$0</p>
<div class="text-center">
<input
type="text"
class="text-center border-2 rounded mb-1"
disabled
placeholder="..."
value="0"
size="2"
maxlength="2"
name="reg0"
/>
</div>
</div>
</div>
<button
type="submit"
class="bg-green-500 hover:bg-blue-700 text-white font-bold py-2 px-4 my-2 rounded"
>
Assign
</button>
</form>
<!-- Registers End -->
<!-- Memory Start -->
<p class="text-lg text-center h-10 flex flex-col mb-3">
Memory
<span class="text-xs text-center text-gray-500">
(All values are zero at the beggining)
</span>
</p>
<div
class="relative overflow-x-auto w-full flex gap-4 pb-2"
id="mem-container"
></div>
<!-- Memory End -->
</div>
</div>
<!-- Popup Buttons Start -->
<div class="grid grid-cols-3 items-center mx-[15%]">
<div class="flex justify-center items-center">
Speed:
<input
class="ml-2"
id="speed-input"
type="range"
step="50"
min="100"
max="3000"
value="1000"
onchange="changeSpeed(event)"
oninput="changeSpeed(event)"
/>
<span class="w-12 pl-2" id="speed-value-container">1000ms</span>
</div>
<span class="col-start-2 flex justify-center gap-2">
<button
onclick="goOneCycle()"
class="bg-gray-200 w-12 h-12 rounded-full flex justify-center items-center"
>
<img src="media/goOnce.png" width="36" alt="" />
</button>
<button
onclick="toggleAutomation()"
class="bg-gray-200 w-12 h-12 rounded-full flex justify-center items-center"
>
<i class="play"></i>
<i class="pause hidden"></i>
</button>
</span>
<div class="ml-auto">
<button
onclick="openPopups()"
class="bg-green-500 hover:bg-blue-700 text-white font-bold py-2 px-4 my-2 rounded"
>
Open Popups
</button>
<button
onclick="closePopups()"
class="bg-rose-500 hover:bg-blue-700 text-white font-bold py-2 px-4 my-2 rounded"
>
Close Popups
</button>
</div>
</div>
<!-- Popup Buttons End -->
<!-- Binary Sidebar Start -->
<div
id="valuesContainer"
class="fixed h-full text-center w-[410px] top-[95px] left-0 z-40 transition-all -translate-x-[calc(100%_-_40px)]"
>
<div class="relative">
<div
class="h-[50px] w-full text-lg bg-white flex flex-col items-center justify-center sticky top-0 shadow"
>
Binary Equivalent of Hex Values
<span class="text-xs text-gray-500"
>(Hover to highlight the node on datapath)</span
>
</div>
<button
type="button"
class="absolute top-0 right-3 h-[50px]"
onclick="toggleValuesContainer()"
>
<svg
class="w-6 h-6"
aria-hidden="true"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
width="50"
height="50"
>
<path
clip-rule="evenodd"
fill-rule="evenodd"
d="M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zm0 10.5a.75.75 0 01.75-.75h7.5a.75.75 0 010 1.5h-7.5a.75.75 0 01-.75-.75zM2 10a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 10z"
></path>
</svg>
</button>
</div>
<aside
class="bg-[#f6f6f6] h-[calc(90%_-_50px)] overflow-y-scroll w-[calc(100%_-_40px)]"
></aside>
<!-- Binary Sidebar End -->
</div>
<!-- Address Book Start -->
<div
id="address-book"
class="fixed w-[330px] h-96 top-28 left-24 rounded shadow bg-white z-40"
>
<!-- Draggable -->
<div
class="w-full bg-gray-500 cursor-move text-center text-white py-2 rounded-t"
id="draggable-book"
>
Address Book
<button id="shrink-book" class="absolute right-2 top-2.5">
<img src="media/close.png" alt="" width="20" height="20" />
</button>
</div>
<!-- Addresses-->
<div id="addresses" class="h-[calc(100%_-_40px)] w-full overflow-auto">
<table class="w-full">
<thead>
<tr>
<th class="sticky left-0 p-3 bg-white min-w-[60px]">Address</th>
<th class="min-w-[388px]">Machine Code</th>
<th class="min-w-[160px]">Meaning</th>
<th class="sticky right-0 bg-white min-w-[128px]">Controls</th>
</tr>
</thead>
<tbody id="address-body"></tbody>
</table>
<div class="sticky bottom-0 left-0 flex justify-center items-center">
<button
class="bg-[#dee0ee] px-3 h-9 hover:bg-[#575b71] rounded-t"
onclick="decrementPageNumber()"
>
<img src="media/minus.png" alt="" width="12" height="12" />
</button>
<span class="bg-white px-3 h-9 flex items-center" id="page-counter"
>0</span
>
<button
class="bg-[#dee0ee] px-3 h-9 hover:bg-[#575b71] rounded-t"
onclick="incrementPageNumber()"
>
<img src="media/plus.png" alt="" width="12" height="12" />
</button>
</div>
</div>
<!-- Resizer -->
<div
class="absolute right-2 bottom-2 h-4 w-4 cursor-se-resize text-xs flex justify-center items-center"
id="resizer"
>
<i class="icon icon-link"></i>
</div>
</div>
<!-- Address Book End -->
<!-- Datapath Canvas -->
<div id="canvas-container" class="flex justify-center py-5"></div>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.min.js"
integrity="sha512-NxocnqsXP3zm0Xb42zqVMvjQIktKEpTIbCXXyhBPxqGZHqhcOXHs4pXI/GoZ8lE+2NJONRifuBpi9DxC58L0Lw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script src="js/data/data.js"></script>
<script src="js/utilities/managers/InstructionManager.js"></script>
<script src="js/utilities/managers/RegisterManager.js"></script>
<script src="js/utilities/managers/MemoryManager.js"></script>
<script src="js/utilities/managers/BookManager.js"></script>
<script src="js/utilities/helpers.js"></script>
<script src="js/utilities/initilizer.js"></script>
<script src="js/utilities/organizers/organizer.js"></script>
<script src="js/utilities/organizers/pathOrganizer.js"></script>
<script src="js/utilities/organizers/addressOrganizer.js"></script>
<script src="js/utilities/variables.js"></script>
<script src="js/utilities/script.js"></script>
<script src="js/utilities/cycle.js"></script>
<script src="js/utilities/initDatapath.js"></script>
<script src="js/utilities/canvas.js"></script>
<script src="js/components/node.js"></script>
<script src="js/components/point.js"></script>
<script src="js/components/wire.js"></script>
<script src="js/components/component.js"></script>
<script src="js/components/pc.js"></script>
<script src="js/components/alu.js"></script>
<script src="js/components/instructionMemory.js"></script>
<script src="js/components/register.js"></script>
<script src="js/components/dataMemory.js"></script>
<script src="js/components/mux.js"></script>
<script src="js/components/ellipse.js"></script>
<script src="js/components/control.js"></script>
<script src="js/components/and.js"></script>
</body>
</html>