-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswim.tex
More file actions
5538 lines (4887 loc) · 315 KB
/
swim.tex
File metadata and controls
5538 lines (4887 loc) · 315 KB
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[
paper=letter,
parskip=half,
fontsize=12pt,
titlepage=firstiscover,
toc=bibliography,
numbers=endperiod
]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amssymb} % Additional symbols
\usepackage{csquotes} % Context-sensitive quotes
\usepackage[backend=biber,style=ieee]{biblatex}
\usepackage{booktabs} % Convenience shortcuts for tables
\usepackage{etoolbox} % Adds additional hooks like \AtBeginEnvironment
\usepackage{fancyvrb} % Fancy verbatim environments
\usepackage{float} % Enables exact-placement of figures
\usepackage{geometry} % Sets page margins
\usepackage{graphicx} % Set additional properties (like dimensions) to graphics
\usepackage[hidelinks]{hyperref} % Enables linking
\usepackage[none]{hyphenat} % Disable hyphenation
\usepackage{newtxtext} % Adds Times New Roman
\usepackage{setspace} % Sets line spacing
\usepackage{soul} % Better handling of certain text styles
\usepackage{tabularx} % Adds automatically-sized tables
\usepackage{ltablex} % Extension of tabularx for extending over pages
\usepackage{url} % Better display of URLs in references
\usepackage{xpatch} % Extension of etoolbox
\addbibresource{references.bib}
\graphicspath{ {./images/} }
% Add the command \tightlist
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
% Define a blockquote
\AtBeginEnvironment{quote}{\par\singlespacing\small}
% Add resizable centered and left-aligned table columns
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
% From setspace package
\setstretch{1.2}
% 1 inch margins
\AfterCalculatingTypearea{\geometry{margin=1in}}
\recalctypearea
% New page after sections
\let\oldsection\section
\renewcommand{\section}{\newpage\oldsection}
% Center all images
\makeatletter
\g@addto@macro\@floatboxreset\centering
\makeatother
% Show 4 levels of depth in TOC
\setcounter{secnumdepth}{\paragraphtocdepth}
\setcounter{tocdepth}{\paragraphtocdepth}
% Use Times New Roman
\addtokomafont{disposition}{\rmfamily}
\title{SWIM}
\subtitle{Simple Web Interface for MIPS}
\author{
Kevin Cahalan
\and
Jerrett Longworth
\and
Huy Nguyen
\and
Evan Raiford
\and
Jimmie Smith
}
\begin{document}
\sloppy
\maketitle
\pagenumbering{arabic}
\setcounter{page}{1}
\tableofcontents
\section{Executive Summary}
SWIM (Simple Web Interface for MIPS) is a web interface to view and
interact with a MIPS64 emulator, designed by Kevin Cahalan, Jerrett
Longworth, Huy Nguyen, Evan Raiford, and Jimmie Smith. This project was
initially pitched by Kevin Cahalan and was designed in Senior Design at
the University of Central Florida in Fall 2022.
SWIM is intended to contain a self-contained package of everything
needed to write programs in assembly, assemble them to binary
instructions for MIPS64, execute the instructions in a simulated
processor of the same architecture, and to visualize the execution of
this processor. The purpose of this project is intended to supplement
computer architecture courses, with a specific focus on the instruction
set architecture used in the curricula at the University of Central
Florida, MIPS. Regardless of the skill level and knowledge of students
who use this software, SWIM ultimately serves to assist students in
furthering their understanding of computer architecture.
SWIM's design offers additional flexibility compared to other emulators,
being designed in a way that could easily allow for future development
and features, as well as having open support for alternative instruction
set architectures. This serves the dual purpose of SWIM to not only be
an educational tool for students in an isolated environment, but to last
as a solution that can continue to be used in the future, regardless of
what instruction set architectures later become prominent.
SWIM is available to use by anyone at no cost. SWIM is licensed under
GNU GPL 3.0 and allows anyone to freely view the project's code and
modify it as seen fit for the free distribution to others.
Subsequent sections of this document outline and organize the design
process for SWIM, including research into the MIPS64 instruction set
architecture, project requirements and specifications, and project code
management. The following section describes in more detail the
motivations and outline of the project, and later sections describe its
successes, challenges, and auxiliary information surrounding its design.
\section{Overview}
\subsection{Project Description}
\label{subsec:project-description}
When studying Computer Science or a related field, students must learn
about computer architecture and design, which includes assembly
languages and instruction set architectures. In many universities,
including the University of Central Florida, the chosen instruction set
architecture is MIPS32. If students proceed to take more advanced
courses centered on computer architecture, they inevitably encounter
MIPS64 in that process, as well.
While there are already a number of emulators and tools available for
students and instructors to learn and teach MIPS, there can be a number
of issues that make them difficult or even impossible to use in some
cases. Current options for MIPS emulation software are overly-complex or
use out-of-date frameworks. Our project aims to be a new, alternative
MIPS emulation tool that is easier to digest compared to existing
options. The current go-to option for educational MIPS simulation is
SPIM \cite{spim}. While it has a rich feature-set, SPIM is no longer
actively maintained, is aging since its original release in 1990, and is
not user-friendly by modern standards.
Additionally, most other MIPS emulation options \cite{wepsim, jsspim,
wemips, mips-interpreter, mini-mips, mips-assembler-field-guide,
mips-assembler-hogan, cpulator}, including SPIM, only support MIPS32,
meaning the 64-bit extension of MIPS, MIPS64, is unsupported. Many
students do not attempt to use SPIM unless required by their courses due
to these limitations. Due to this, learning low-level programming
concepts, a task that is already difficult in and of itself, is even
more difficult for most students than it needs to be.
Our solution to this issue is SWIM, a simple web interface for MIPS32
and MIPS64. SWIM is a MIPS emulator that supports a subset of both
MIPS32 and MIPS64, and completely runs within a web browser. In SWIM,
people can write and run MIPS32 and MIPS64 programs in browsers with an
enhanced text editor with line-by-line execution, view register and
memory contents, and recognize MIPS pseudo-instructions in a modern,
easy-to-use interface. Making an emulator that supports both major
versions of MIPS means that students will be able to use SWIM throughout
an extended part of their low-level programming education, especially
considering alternative options for MIPS emulation. Being browser-based,
the barrier for entry is much lower than downloaded software, is
agnostic to any one platform or operating system, and accessible from
anywhere with an internet connection. Having modern features like
step-through debugging and register viewing will make the development
experience more similar to modern languages and easier to work with.
The goal of SWIM is to help students be interested and want to use the
emulator to study for classes and self-taught individuals to use it to
satisfy curiosity. Both groups of people should experience a minimal
learning curve when it comes to interacting with the MIPS pipeline. SWIM
aims to become the standard for MIPS education as a standard emulator
for both MIPS32 and MIPS64.
The code for this project is written primarily in Rust \cite{rust-book}
to utilize its secure memory management systems, type checking, and
borrow-checking. Where necessary, JavaScript and TypeScript is used to
supplement this for web-based development. The text editing interface
uses the Monaco library \cite{monaco} due to its existing familiarity
with programmers. The server-side component of SWIM merely serves to
deliver content and application files. SWIM implements a strong subset
of the instructions supported by MIPS32 and MIPS64.
\subsubsection{The Tech Stack}
SWIM's tech stack is unique in the fact that a lot of the tools and
frameworks used in its development are still in their preliminary
stages, unlike conventional tools such as JavaScript, React, Emscripten,
and MongoDB. This project's tech stack uses the Rust programming
language for developing all parts of the application: emulation core,
parser, and interface. This helps with having a cohesive understanding
of how the codebase is structured, as all code from all components use
the same programming language.
Moving up to abstraction in Rust, the Yew framework \cite{yew} and Gloo
toolkit \cite{gloo} facilitates how the front end interacts with
Javascript APIs and aids in converting Rust code into the appropriate
WebAssembly binaries and JavaScript files without direct intervention or
understanding from a development perspective. WebAssembly
\cite{webassembly} is still in its infancy, but it allows our Rust code
to be run on browsers like Google Chrome, Mozilla Firefox, Apple Safari,
and Microsoft Edge. Due to the recency of WebAssembly, users must run
the latest version of those browsers – or their respective FOSS forks
(i.e. Chromium, Waterfox, etc.) – in order for WebAssembly to function
properly. While the majority of code running for this project is in
WebAssembly, JavaScript is still essential for the application to
initially load on the web browser. Trunk \cite{trunk} is the tool for
packaging and finalizing the software; Trunk has configurations that
allows us to automatically re-compile the software as we edit it.
GitHub Pages is used to host SWIM, additionally allowing users access to
the project's source code on the same site. For the user interface,
Microsoft's Monaco Editor is used, given its support for assembly
syntax, Intellisense, themes, and its extensible API.
\begin{figure}[H]
\includegraphics[height=10cm]{tech-stack}
\caption{Visualization of the Tech Stack}
\end{figure}
\subsection{Project Motivation}
The motivation behind SWIM, at its root, is at the major flaws in the
currently-available resources in the educational MIPS emulation scene.
As mentioned in Section \ref{subsec:project-description}, there are no
real options for those who want to learn MIPS64. In addition, most if
not all existing options for MIPS32 emulation arguably have an
unnecessary learning curve to being used. Many students in computer
architecture courses dread learning and using MIPS, as there is simply
not the same level of assistance available that many students have
become accustomed to expect. For example, if a student wants to learn
Python, there is a plenitude of resources to help them along the way.
There are countless Python IDEs, online resources for running Python,
and so forth. For learning MIPS, most of the information found will be
from a textbook or course lectures, and many members of the project team
have been directly affected by this environment.
In addition, a major motivation of any software development project is
to accomplish something amazing; something that we felt was realistic
and useful. Much of the team is comprised of low-level programming
enthusiasts, making the mission of the project even more plausible and
usable in real-world scenarios than the perspective of a traditional
programmer. Along the way, we want to improve our own understanding of
computation and computer architecture by building a core component of a
computer processor. Writing a MIPS emulator an interesting project, and
best of all, has clear direction. From the initial project pitch, it is
understood how the project will generally work and what it can do.
Many of the initial project proposals in Senior Design seemed to have no
real-world use or clear direction, coming from individuals with little
technical experience. The time and difficulty for some projects were
underestimated from a technical perspective, and some only generically
indicate what problem it solves or what purpose it has. Artificial
intelligence and virtual/augmented reality have been cited as catch-all
solutions to many problems, which is contrary to the beliefs of the
project team. While it can be very hard to gauge the difficulty and time
needed for a project without clear direction, we do not have the time or
luxury to gamble on a project to get lost on. This MIPS emulation
project felt like a great balance between direction and difficulty.
To become a professional emulator developer, small steps of learning are
required. By writing this emulator, our team is taking a small step in
this direction and we provide a better understanding of emulator
development. The ability to understand all parts of a computing system
-- RAM, flash memory, register states, and so on -- are crucial to
working with emulation. Additionally, physical hardware can be limited
based its interfaces, may be costly to develop on, or in some cases
inaccessible altogether. Security researchers want to be able to create
as many virtual environments as possible with minimal cost to understand
everything a system does.
\subsection{Individual Motivations}
\subsubsection{Kevin Cahalan}
\begin{figure}[H]
\includegraphics[height=7cm]{profile-kevin}
\end{figure}
For a while I have been wanting to write an awesome emulator. Things
kept getting in the way, I never got to it. Ever since I first started
learning Python, I have had an urge to get the ultimate understanding of
computers. Python sucked, it did not feel like programming. Writing
Python felt like telling a program what to do, not a computer. There was
clearly magic underneath. I hated having these magical devices out there
that I could simply not fathom or imagine. Computers seemed to be true
magic. To go further down my journey of getting a true understanding of
computers, I started learning C. C was a breath of free air. The more I
programmed in C, the more computers made sense. Writing my first
emulator, some emulator for a computer from the 70s, I took a big step
in learning the magic behind computing. Emulation development turns out
to be a great way for clearing away the magic property of computers.
When writing an emulator, you are effectively writing your own computer
in software. By working on SWIM I will be continuing my journey to get
the ultimate understanding of computation. I will further fight the
mysterious magic of computation.
Another big individual motivation for this are the job prospects. There
is solid money out there for emulation development. Emulators have all
sorts of uses, hacking, training, testing, legacy hardware replacement,
and so on. In the world of professional hacking, the need for automation
fits hand in hand with emulator development. Automated bug finders need
a surface to play with. Preferably a scalable surface. Using real
hardware can get super expensive very fast. It can be millions or
billions of dollars, sometimes impossible to get. With training it is
not best to trust a new person with expensive equipment. Issues of money
and safety come into play. It would not be the best idea to just drop
someone into an f-35, you start them with an accurate flight simulator.
So accurate that you emulate the computers within the aircraft for the
simulation. When testing new software for an f-35, initially using a
real aircraft would be unsafe. You test your software in emulation. In
the world of banking there are old legacy computers that need to be
replaced. Re-writing the software for these ancient computers can be
very risky and costly. The solution is to write an emulation layer to
port so that the old software could run on modern computers. With many
more examples out there, emulation happens to be very important for this
world. And the best part of all this, there's big money in the industry.
\subsubsection{Jerrett Longworth}
\begin{figure}[H]
\includegraphics[height=7cm]{profile-jerrett}
\end{figure}
From first being introduced to computer architecture and processor logic
and design at UCF, I was immediately interested in the subject area and
wanted to learn more. This topic, along with similar low-level topics
such as assembly languages, became a focus of mine throughout my
Computer Science studies. In the popular open-world sandbox game
Minecraft, I designed logic and built circuitry from scratch for a
system that takes a binary number and displays it on an in-game
seven-segment display. While studying Computer Logic and Organization
(CDA 3103) with Sarah Angell, I had already begun to think about the
utility and overall interest factor of having a live graphical
representation of a CPU performing instructions in its pipeline, not
only for an Instruction Set Architecture like MIPS, but for x86 and ARM
as well. SWIM offers this first step into creating a visualization such
as this.
I have thought about various forms, both in hardware and software, that
could achieve this effect. Inspired by an engineering sample of an
Nvidia 30-series graphics card, a hardware approach could have a
dedicated pin on the processor that reports some basic information like
the current instruction opcode or instruction pointer. A software
approach could be a graphical overlay over a high-definition image of
the internals of a CPU. A user could be given a live view of the bits
changing as a virtual CPU executes instructions, and you could pan and
zoom around the parts of the processor to see values located in
registers, memory, and other components.
Based on these ideas, I feel SWIM is an incredibly valuable project,
both for the educational factor for classes like CDA 3103, but also for
the personal enjoyment and satisfaction of watching this piece of
technology run at its most exposed state.
Another reason why this project is important to me is due to my
affiliation with Wiki Knights, which is a student organization dedicated
to reducing or eliminating the costs of textbooks and homework access
codes by encouraging the adoption of Open Educational Resources (OER) in
courses across the university. This group has already been developing a
free Introduction to C Programming (COP 3223) textbook with examples and
practice problems, which is currently deployed in classes as of the time
of writing. Further development is active within the group to re-open
the Adaptive Learning Engine project authored by the ALOSI Labs as a
collaboration between Harvard University's Office of the Vice Provost
for Advances in Learning and Microsoft. Along these efforts, an
open-source project such as SWIM offers another free resource for
students, course instructors, and researchers in areas related to
computer architecture.
\subsubsection{Jimmie Smith}
\begin{figure}[H]
\includegraphics[height=7cm]{profile-jimmie}
\end{figure}
While I pitched a project for this class with a similar topic, I figured
this was a more noble project to do. As someone who enjoyed CDA3103 and
EEL4768, SWIM could be the first step to educating people who are
interested in Assembly in a friendlier environment. Funnily enough, my
pitch has the same underlying goal as SWIM of modernizing the “old”
workflow with enhancements and visual feedback that makes it easier for
the user to understand the concept and have fun with it, too. Recently,
I have been learning about the Motorola 68000 since it was a CPU that
was used extensively back then, so I have a general feel for CISC and
RISC assembly with their concepts. I also have an affinity for emulation
since it is fun to explore older systems, and you can preserve, study,
and make new tools for them.
This is my first time being relegated to front-end development solely so
it is a huge responsibility to make sure the whole suite is presented in
an appropriate manner. Even though I have been assigned to work on the
front end with Rust, I am excited to understand Rust since I heard
people giving praise for its design compared to C. I have a few ideas of
my own on how I want the program to look since user experience is key.
Learning Assembly is hard to sell compared to high-level languages,
there are not that many good online tutorials for assembly, it is much
more verbose, and it has a steeper learning curve so interactivity is my
top-priority. This is a nice challenge for me since I have to constantly
ask myself how to make SWIM fun to use while the back end focuses on
creating a good emulation core.
My experience with MIPS in the past was easy-going at first, but by the
time I took Computer Architecture it became overwhelming especially when
it came to the different datapaths. By the end of the course, I was
having a difficult time understanding the concepts and how significant
they are. I had a harder time finding any tools that would help me
understand MIPS64 compared to MIPS32, so SWIM would fill in that gap.
With SWIM, it would not only remedy any confusions with MIPS64's
concepts but it can also be the basis for studying different types of
architecture and their feature set.
\subsubsection{Evan Raiford}
\begin{figure}[H]
\includegraphics[height=7cm]{profile-evan}
\end{figure}
My motivation for this project stems from multiple different places. The
first reason is that I see a need for the existence of a tool such as
this. One of the restricted electives I chose to take was EEL4768,
Computer Architecture, and a large part of that class was understanding
the changes necessary to implement a 64-bit system as opposed to a
32-bit system and the language used to detail these changes was MIPS64.
Examples drawn out on the board and thorough explanations are great
tools to assist in learning but for many people, myself included, the
best way to get a grasp on things is to try them out themselves. Having
a version of MIPS64 readily accessible would be a great tool to help
students learn.
A second, albeit related, reason I am motivated for this project is that
I am hopeful that we can build a tool that makes MIPS more approachable
for students. One of my absolute favorite things about my experience
earning my computer science degree has been building a solid
understanding of how a computer works from the bottom up. Assembly
languages, such as MIPS, are one of the foundational aspects of this.
However, assembly languages can often come across as intimidating and
hard to approach for new learners so students frequently only learn
enough to get through their class. I think a solid understanding of
basic instruction set architectures is vital to being a well-rounded
software developer. My hope is that the SWIM project will help make MIPS
and low-level programming concepts more approachable for the average
student.
The idea of making SWIM browser based is another reason I am motivated
for this project. Making it browser-based makes the software more
approachable for students since they would not need to download anything
onto their devices to use it. It also means it is more readily
accessible for instructors. If an instructor wants to use software that
has to be downloaded in a lecture hall, they often do not have the
option to download the software onto whatever device is used in the
lecture hall so they, instead, have to bring their own device with them
and hook that up to the projector in order to use the software in a
lecture. Having SWIM online circumvents that issue entirely. If somebody
wanted to use SWIM in a lecture, the software is accessible through the
browser so all they would need to do is navigate to the website.
Another reason that I am motivated for this project is the lack of a
sponsor. Having a sponsor on a project does give a lot of benefits like
financial backing, industry experience and advice, and a guiding hand.
However, they often also come with their own motivations for the
project, often hoping to use the tool to help bolster their business.
Doing a project without a bespoke sponsor ensures that whatever we make
is not beholden to somebody else's vision of what it can or should be.
Doing it without a sponsor also ensures that our end product is one made
wholly by us. Any issues we have along the way, we ourselves are the
ones that overcome them. The project that we make is one that we are
able to make solely on the experience that we have gained ourselves
either on our own or at UCF.
\subsubsection{Huy Nguyen}
\begin{figure}[H]
\includegraphics[height=7cm]{profile-huy}
\end{figure}
My motivation for the project stems from my experience with some of the
materials needed for this project, about the MIPS pipeline. The idea of
an accessible web-based MIPS emulation would have helped me and my peers
a lot back when I was studying Computer Architecture and System
Softwares. It would also make these subjects a lot easier on students
who need to take those, as well as being interested to learn more about
MIPS, which in turn would help with easier and more understandable
teaching than what me and my peers went through during those classes in
the past.
I am also attracted to this project by the prospect of not needing a
sponsor. Not having a sponsor means a few things. One of those things is
that we as a group are not constrained by the sponsors' demands, which
means we can be more comfortable in giving project ideas so that it
looks like what the group thinks it is, not what anyone outside thinks
it is. This would also mean anything we need to spend on for the project
we have to spend ourselves, and we also have to set deadlines ourselves,
which may be hard or distracting. However, I believe this will get me
more familiar with these kinds of projects where the idea is from a
single person and it is up to me and my group to expand on, not just a
pre-laid road by a company. Although I may lose the experience of
working with a sponsor, I currently have an opportunity to make a
project that I may be able to talk about in the future, which is this
project. This project would also hopefully improve my skills working
with my teammates, as it will undoubtedly help with further group
projects and careers in general in the future.
This project also seems like an opportunity to come in contact with more
variety in coding, as the project currently aims to run mostly on the
front end in Rust, a language I have never touched before. After having
a look at it, it seems solid, so it made me look forward to using it on
a project and adding one more language to my arsenal. That will also
mean I get to learn more about web development, specifically running an
emulator online, and what it entails.
\subsection{Group Member Ideas}
At the project's initial inception and gathering of group members, all
group members contributed ideas to brainstorm the features and
capabilities that would be supported by the project. Some of these ideas
have been implemented into the project or its stretch goals, and others
are left as possible suggestions for future revisions of the project.
The following are the ideas provided by each group member.
\subsubsection{Kevin Calahan}
\begin{itemize}
\item The project itself.
\item The use of Rust for programming both the back end and front end.
\item Test driven development. All instructions should have test cases to
prove that they work correctly.
\item Naming the project “OurSPIM.” This name was based on an assignment named
“MySPIM.”
\item The possible project name “MipAndNayNay64.” This project name is based
off the song “Watch Me.”
\item That way at which our instruction decode code would be written.
\item How instructions are going to be handled in our codebase.
\end{itemize}
\subsubsection{Jerrett Longworth}
\begin{itemize}
\item Interactive live view of the emulator pipeline with access to memory and
register contents. A user could hover over various components or traces
with their mouse to see their current contents.
\item Alternative live view of the pipeline, which is overlaid onto a
real-world image of a CPU die. This could be zoomed or panned to see
individual bits in any of the components.
\item Ability to view and change memory and register contents during
execution.
\item Communication to and from the user with a virtual display and input,
communicated through an emulated bus.
\item A “tutorial/educator mode,” which would allow an educator to create
overlays and control the interface automatically to guide students to
learn about a specific concept.
\item A “quiz mode,” which would allow an educator to create overlays similar
to the “tutorial mode,” but with interactive questions and problems that
can report results to an LMS such as Instructure Canvas.
\end{itemize}
\subsubsection{Jimmie Smith}
\begin{itemize}
\item As a design goal, SWIM should not only support MIPS64 but it should be
designed openly to load in different emulators of CPUs and their
respective datapaths (if available). This would require some careful
planning, but should be feasible since this is being built from scratch.
\item Having a live debugger for SWIM would be a simple feature to implement,
but could streamline the debugging process even more.
\item Since this is a web application, I think having customizable options
would elevate the user experience like dark mode, color-coding for
instructions, registers, etc.
\end{itemize}
\subsubsection{Evan Raiford}
\begin{itemize}
\item An account system so that users are able to store something that they
have been working on and then come back and continue working on it
later. This would also allow lecturers the opportunity to store work
that they can then access in a lecture.
\item A tool that explains the function of instructions.
\item Prefabricated programs that users can take a look at and mess around
with to get a feel for how things are done in MIPS. A brief overview and
explanation of what is being done and why could accompany it.
\item The name that we ended up going with: SWIM. A Simple Web Interface for
MIPS.
\end{itemize}
\subsubsection{Huy Nguyen}
\begin{itemize}
\item We can make the front end look more accessible by giving the MIPS
pipeline map more space as well as making the UI fit viewing mode, or
hide them.
\item Testing on Eustis3. Although I do think that this may not work or take
forever to load the front end since our project is front end heavy.
\item Admin accounts for testing front ends and account creations if
necessary.
\end{itemize}
\subsection {Individual Roles}
Due to the highly technical nature of this project, it would have been
difficult for everybody on the team to work equally in each of the
different types of work required for making SWIM. Because of this, we
had each member of the team focus on a specific discipline and only help
out on other parts of the project when necessary. Listed below are the
individual roles that each team member had on our project:
\begin{itemize}
\item Evan Raiford - Project Manager, Parser \& Assembler
Evan was the project manager on on SWIM, running meetings, building
schedules, and handling any communication that had to come from the
team. On the development end, his focus was on the parser \& assembler,
building the systems to recognize MIPS64 syntax, expand
pseudo-instructions, and then translate it into the appropriate binary,
and providing syntax error information back to the front end.
Additionally, he worked on certain parts of the front end that dealt
directly with information coming from the parser. Specifically, this was
the information for mouse hover on instructions, syntax error messages,
and the formatting of the memory view.
\item Jerrett Longworth - Emulation Core, Visual Datapath
Jerrett worked primarily on the emulation core, building the overall
framework for the five-stage datapath and doing the entirety of
development on the floating-point processor. Additionally, he built the
bulk of the visual datapath, mirroring the emulation core. On the front
end, he helped with general issues with CSS, Yew, and Rust-Monaco.
Within Rust-Monaco, he implemented the error underlining and the error
mouse hovering. He also created the majority of our integration tests.
\item Kevin Cahalan - Emulation Core, Visual Datapath
Kevin worked on the emulation core, working specifically on the
general-purpose processor and extending it to handle extra instructions.
He also worked on the visual datapath, adding extra lines to have it
accurately mirror the emulation core and creating the simplified visual
datapath that more closely mirrors the design within the Hennessy \&
Patterson textbook. He also worked on ensuring that as many of the
MIPS64 instructions GCC utilizes work accurately on the emulation core.
\item Jimmie Smith - Front End (Monaco)
Jimmie's work was on hooking up the SWIM to Rust-Monaco to take
advantage of the features that it offers. This involved creating a
custom language for syntax highlighting based on the subset of MIPS64
instructions SWIM supports, getting the last executed instruction
highlighted, displaying the corresponding information about an
instruction on a line with mouse hovering, and replacing the text within
Monaco with version with translated pseudo-instructions after assembly
among multiple others. Additionally, he added in the ability to load
files into SWIM and the ability to copy the text from Monaco onto a
user's clipboard.
\item Huy Nguyen - Front End (Graphical Interface)
Huy primarily focused on the visual interface that the users interact
with in SWIM. This included creating GP and FP register views, a memory
view, and a console and hooking them up to the contents of the emulation
core. He also worked to add alternative views for the registers,
allowing views for the values in decimal, hexadecimal, and binary.
Additionally, he created the visual design for the project, working on
color choice, project layout, and adding in smaller UI details like
button icons.
\end{itemize}
\subsection{Goals}
\begin{itemize}
\item Students should be able to run simple assembly programs written for
MIPS64.
\item Improperly formatted instructions should be recognized as such and be
made apparent to the user.
\item Compiled programs should run functionally the same as a true MIPS64
processor.
\item SWIM should be accessible in all major web browsers.
\end{itemize}
\subsection{Broader Impacts}
The end goal of this project is to help make it easier for people to
learn about the MIPS instruction set architecture and to create an
intuitive and visually pleasing system with which people can interact
with MIPS32 and MIPS64. This project aims to lower some of the barriers
that are common when studying computer architecture and low-level
programming. In this way, SWIM could help redefine how MIPS emulation is
used in education, making MIPS more accessible. Since the project is
designed entirely to run in a web browser, it is not only more
accessible for students at UCF, but for learners all over the world.
Additionally, with the project being available online, and thus
immediately accessible by any computer with a modern web browser, SWIM
is a great option for professors and course instructors to use during
lectures, as they do not have to spend time or effort to install
additional software to use in classroom computers. In this way, SWIM
could become the de facto way of teaching MIPS. By making MIPS easier to
teach within lectures and easier for students to use on their own, we
aim to make low-level programming concepts overall easier for students
to learn.
\subsection{Legal, Ethical, and Privacy Issues}
The most notable issue that arises from this project is the simulation
of an instruction set architecture that was created not in the public
domain, but as a commercial product by MIPS Technologies. After
research, it is clear that the creation of a MIPS emulator is legal, and
is supported anecdotally by other existing emulators. ``Clean room
design,'' also known as the ``Chinese wall technique,'' is the concept
of reverse engineering and using publicly available specifications from
an original creator, then creating an original piece of work without
infringing on copyright. The term ``clean'' is used to describe this
process since there is no knowledge of copyrighted or private
techniques. Creating SWIM, as well as any other emulator, is considered
legal due to this argument. This is especially true for the case of
MIPS, as all specifications for instruction set architecture are
intentionally published by MIPS Technologies to be implemented by
vendors.
The same clean room concept is true for basing the software off of other
options available publicly for emulating MIPS. Since this project is
completely original with no code influence from these other projects, no
legal issues are foreseen with basing features or aspects of the
interface with software that already exists.
We do not foresee any ethical issues from our design of SWIM. Generally
speaking, ethical issues stem from one of three different places:
malicious monetization of a product, misuse of user data, or
insufficient security systems. Since we are not collecting or storing
any personal data on our users, we do not believe we will have any
ethical issues in this regard. Additionally, SWIM is intended purely as
an educational tool and will be entirely free-to-use for anyone. There
will not be any financial costs incurred by the end users when using our
project. Due to this, SWIM should not have any ethical issues in regards
to monetization. For the aforementioned reasons, as there is no
communication with outside servers with the exception of loading the
application, this similarly should be reason for no ethical issues.
Similar to ethical issues, no privacy issues were foreseen based on our
needs. SWIM runs entirely in a user's local web browser client and does
not make use of accounts for users, meaning no sensitive data, such as
email address or passwords, is stored on the servers used to host SWIM.
Further, the project does not communicate with outside servers outside
the initial loading of the application.
We have put the SWIM project under the GNU General Public License. Our
hope has been to make SWIM available freely for anybody to use and for
them to be able to take what we have built and then modify it to fit
their needs, as well. The GPL aligns with that exactly. Putting the SWIM
project under the GNU General Public License helps to ensure that no
issues surrounding copyright of the software that we have built can
arise. Plainly, no issues should arise from copyright because SWIM is
licensed in a way that allows for its free distribution.
\subsection{Financing}
SWIM is a project that was pitched by a student, and thus funding
support from a sponsor is not available for our group. With the scope of
this project, major funding was not necessary. The project runs entirely
client-side in a web browser, and needed no paid components to be
developed.
After considerable research, hosting and deployment is free through the
use of GitHub Pages and GitHub Actions. See Section
\ref{subsec:deployment} for more details. Other initially considered
free hosting solutions included Heroku and UCF's Linux server (Eustis).
Heroku previously offered free dynamic hosting for projects up to 1,000
hours, however this option was discarded as inviable, since Heroku
removed support for their free hosting tier in November 2022. This would
not only be infeasible for long-term use, but would have interrupted
development plans, as SWIM was designed and created from September 2022
to April 2023.
UCF's own Linux server, Eustis, was another considered free option, but
was similarly not viable for its limited availability. SWIM is intended
to continue to be used long after the project is completed and the
graduation of the initial developers. Part of Eustis's policy is to
delete data from students that are no longer active at the university,
which would remove any deployment of SWIM. Due to this, Eustis was
eventually discarded as a hosting option.
\section{Project Requirements and Specifications}
\subsection{Overall}
\subsubsection{Requirements}
\begin{itemize}
\item This project should be logically organized in three primary sections:
the emulation core, the interface, and the parser.
\item The emulation core should be able to emulate the execution of a
processor using the MIPS64 ISA.
\item The interface should be able to give users the ability to interact with
the emulation core and the parser.
\item The parser should be able to take assembly code as input and produce
binary data.
\item The emulation core should be able to operate standalone to the interface
and parser.
\item The parser should be able to operate standalone to the emulation core
and the interface.
\item The interface, by its design, should depend on an emulation core and
parser.
\end{itemize}
\subsubsection{Business Requirements}
\begin{itemize}
\item The project should be hosted publicly on a server with minimal
restrictions of access, with the restriction of using secure protocols
and standards for modification of the server.
\item A version control system should be used to track changes in code.
\item Unit tests should be created in tandem during development.
\item Any tests should be enforced as passing prior to additional changes
being made to the project code repository.
\end{itemize}
\subsection{Emulation Core}
The emulation core acts as the project component performing simulation
of a processor.
\subsubsection{Requirements}
\begin{itemize}
\item MIPS32 support
All basic and necessary MIPS32 instructions are supported. This includes
basic arithmetic operations such as addition, subtraction,
multiplication, and division, as well as other common operations
performed by the ALU such as bit shifting, bitwise AND and OR. Basic
memory operations, branching, and jumping are also a requirement. For
full details on support for these instructions, see Section
\ref{subsec:supported-instructions}. A general outline of the MIPS ISA
can be found in Section \ref{sec:mips64}.
\item MIPS64 support
In addition to the support for a subset of MIPS32 instructions, one of
the features required as part of the motivations for this project is
support for a subset of MIPS64 instructions. In some regard, support for
these instructions mostly mirror that of the support for their 32-bit
counterparts. Details on which instructions are supported can similarly
be found in Section \ref{subsec:supported-instructions}. Scope and
details of the MIPS64 ISA can be found in Section \ref{sec:mips64}.
\end{itemize}
\subsubsection{Business Requirements}
\begin{itemize}
\item The core should be accessed using an API for the graphical interface.
(Specific implementation details are as defined in Section
\ref{subsec:emulation-core-api}.)
\item The core should be simple to use and offer little difficulty for
front-end development.
\item The core and its API should be built and implemented in a way that
allows it to be replaced with other drop-in replacement architectures,
including those with other paradigm structures such as pipelining,
branch prediction, or out-of-order execution.
\item The core should be able to execute by one instruction at a time, or by
one segment of the datapath at a time.
\item The core should not handle errors, but instead either attempt to
brute-force the error or pass the error to the interface using it.
\item The core should incorporate tests of all parts and edge cases of the
datapath.
\item The core should be able to execute each instruction in a negligible
amount of time.
\end{itemize}
\subsection{Interface}
\subsubsection{Requirements}
\begin{itemize}
\item Users should be able to create and edit MIPS64 assembly code within an
integrated editor.
\item Instruction-by-instruction execution / step-through debugging
The interface should be able to execute instructions one at a time.
Users should be able to know which line is being executed. The function
of our step-through debugging should be very similar to that of Visual
Studio Code. We will be using the same front-end code editor library
that Visual Studio Code uses, Monaco.
\begin{figure}[H]
\includegraphics[height=7cm]{step-through-debugging}
\caption{Step through Debugging with Visual Studio Code.}
\end{figure}
\item Register view
Users should be able to view register values. Visual Studio Code acts as
a preferred reference of a layout to follow:
\begin{figure}[H]
\includegraphics[height=7cm]{vs-code-registers}
\caption{Visual Studio Code Register View.}
\end{figure}
\item Users should be given the option to change the number format for showing
the contents of the registers between binary, integer, and hexadecimal.
\item Memory view: Users should be able to view the entire contents of the
instruction and data memory.
\item Interactive live view of datapath
Interactive live view of the emulator datapath with access to inner
trace contents. A user could hover over various components or traces
with their mouse to see their current contents. The live view will
provide the user with how the information is processed and passed
through each stage. Users should be able to see which stage is active
with some visual indication.
\item Mouse hover instruction assistance
With other IDEs, users can get assistance and documentation by hovering
their cursor over code they want to understand. For example, if they
want to know what the C printf() function does, they could hover their
mouse over the printf() function in their code. In Visual Studio Code,
and similarly for other IDEs, the functionality may look like Figure
\ref{fig:vs-code-hover-variable}.
\begin{figure}[H]
\includegraphics[height=2cm]{vs-code-hover-variable}
\caption{Mouse hover function and variables assistance.}
\label{fig:vs-code-hover-variable}
\end{figure}
\item The information provided in the hover dialog should include the effect
of the instruction in pseudocode and any possible limitations to this
instruction.
\end{itemize}
\subsubsection{Business Requirements}
\begin{itemize}
\item The interface should be easy to use and familiar for users already
familiar with Visual Studio Code, Replit, or Godbolt.
\item The interface should act performant and responsive, where there are no
frame drops nor stuttering, and selected options give feedback within
0.1 seconds of interacting.
\item The interface should act as a logical bridge between the emulation core
and the parser.
\end{itemize}
\subsection{Parser}
\subsubsection{Requirements}
\begin{itemize}
\item The parser should be able to properly interpret and tokenize all
supported instructions, as described in Section
\ref{subsec:supported-instructions}.
\item The parser should be able to assemble all supported assembly
instructions into binary instructions as per the official MIPS64
instruction set specifications.
\item Error reporting and detection of invalid assembly code
The user should be able to see if there are any parts of their assembly
code that are improperly formatted. This may include using the incorrect
syntax for a given instruction, using invalid immediate values, or using
instructions that do not exist in either the project's supported subset
of instructions or the MIPS64 instruction set as a whole.
\item Error detection for labels: The parser will return an error if there is
a J-type instruction that uses a label as an operand that does not match
any of the labels found throughout the program.
\item In reporting errors and invalid assembly code to the graphical
interface, a description of the error and the location in the code
causing the error should be provided.
\item When the parser expects an instruction name but receives a string that
does match any of the instructions that it recognizes, it should be
considered an error.
\item If the parser is reading an instruction and expects a label name as one
of the operands but receives one that has not been defined, it should be
considered an error.
\item Suggestions for correct instruction or label when an invalid one is
recognized
This falls as an extension to the existing functionality of reporting
errors. In the event that there are invalid instructions or labels used
in inputted assembly code, the parser should also be able to give
suggestions on which instructions or labels to use in replacement. If
there are instructions or labels with similar names to the invalid ones,
these will be suggested first before others. The existing error
recognition for instruction names and label names should still operate
at a similar level of quality and speed, with or without this feature.
\end{itemize}
\subsubsection{Business Requirements}
\begin{itemize}
\item Messages and suggestions from the parser should be easy to understand
for the user by using simple language.
\item The parser should be able to communicate errors with processing user
input to the interface for displaying errors at its discretion.
\item The parser should be able to properly parse and assemble valid input
code containing less than 50 lines within 4 seconds of being initiated.
\item The parser should create an API to be used with the graphical interface.
\item The API used by the parser should be structured in a way that makes
front-end development as simple as possible.
\end{itemize}
\section{Project Challenges}
One of the challenges that this project faces is being unfamiliar with
the technology. Each team member had to study Rust and Yew on their own,
not without the additional background knowledge in HTML, CSS, and
JavaScript necessary for front-end development. Furthermore, as SWIM
focuses on the implementation of MIPS64, some members needed to review
and understand granular implementation details of the instruction set
architecture. As such, time was dedicated towards researching these
concepts and finding currently-available options for MIPS simulators, to
understand the scope of functionality and features that would eventually
be added into SWIM.
Another prominent challenge of this project was less on a technical
level, but it was found that group members could not meet consistently
due to their schedules each week during the semester of taking Senior
Design I. The proposed solution was to asynchronously communicate
through Discord, and meeting in any available synchronous times at least
once a week. This has offered increased and consistent communication
between group members outside of weekly meetings. Sharing of materials
and sources between group members became easier as a result, but a
problem remained for keeping track of progress. The discord bot DailyBot