📄 mips lab environment reference.mht
字号:
</FONT></TD></TR></TBODY></TABLE></TD></TR>
<TR><BR></TR>
<TR>
<TD noWrap><FONT face=3DArial size=3D-1><I>Return =
value:</I></FONT></TD>
<TD></TD></TR>
<TR>
<TD></TD>
<TD>
<TABLE cellPadding=3D0 border=3D0>
<TBODY>
<TR>
<TD><FONT size=3D-1>v0 </FONT></TD>
<TD><FONT size=3D-1>- msb of double precision =
</FONT></TD></TR>
<TR>
<TD><FONT size=3D-1>v1 </FONT></TD>
<TD><FONT size=3D-1>- lsb of double precision=20
</FONT></TD></TR></TBODY></TABLE></TD></TR>
<TR><BR></TR>
<TR>
<TD><FONT face=3DArial size=3D-1><I>Example:</I></FONT></TD>
<TD></TD></TR>
<TR>
<TD></TD>
<TD><FONT size=3D-1><PRE>string1:
.asciiz "Number %f"
...
li.s a0, 3.5
jal fptodp
la a0, string1
move a1, v0
move a2, v1
jal printf
Will print the string "Number 3.5" to the standard output.
</PRE></FONT></TD></TR></TBODY></TABLE>
<H2 style=3D"PAGE-BREAK-BEFORE: always">The Simulator</H2>The simulator =
(MIPS.EXE)=20
provides you with the possibility to run programs without the MIPS =
board. It=20
basically includes the same facilities as the monitor (breakpoints, =
stepping=20
etc.) except with a graphical user interface and not by entering =
commands in a=20
console.<BR><BR>
<TABLE cellPadding=3D0 width=3D553 align=3Dcenter border=3D0><A=20
href=3D"http://www.it.lth.se/dtlab/manual/sim.gif"><IMG height=3D415=20
src=3D"http://www.it.lth.se/dtlab/manual/simthumb.gif" width=3D553 =
border=3D0></A>=20
<FONT size=3D-1><B>Figure 1-2.</B><BR><I>The simulator.</I> </FONT>
<TBODY></TBODY></TABLE><BR>The main view (Figure 1-2) consists of 6 =
units, CPU,=20
RAM, Console, I/O, D-Cache and I-Cache. When you click on a unit a =
window will=20
appear (or disappear if it is already open). There is also an interrupt =
unit=20
available from the View menu. Here follows a brief description of each =
unit=A1=AFs=20
window:<BR><BR><I><U>CPU</U></I><BR>View/modify the CPU=20
registers.<BR><BR><I><U>RAM</U></I><BR>View/modify memory, also referred =
to as=20
the MemView. This unit has most functions of all, for a more detailed=20
description see below.<BR><BR><I><U>Console</U></I><BR>Standard =
input/output for=20
programs that use it.<BR><BR><I><U>I/O</U></I><BR>Simulates the 8-bit =
I/O unit,=20
with 8 switches and 8 =
LEDs.<BR><BR><I><U>D-Cache/I-Cache</U></I><BR>Views of the=20
data and instruction caches.<BR><BR><I><U>Interrupt</U></I><BR>Simulates =
the=20
interrupt unit, with buttons K1, K2 and the timer.<BR><BR>
<TABLE cellPadding=3D0 width=3D515 align=3Dcenter border=3D0><IMG =
height=3D505=20
src=3D"http://www.it.lth.se/dtlab/manual/memview.gif" width=3D515> =
<FONT=20
size=3D-1><B>Figure 1-3.</B><BR><I>The MemView.</I> </FONT>
<TBODY></TBODY></TABLE><BR>The MemView is a list over the complete =
32-bit=20
address space (4GB). Each line is one word-aligned address, 0, 4, 8 and =
so on.=20
The content of each line is displayed as four bytes in hexadecimal and =
some form=20
of "translation" of the content (by default assembler). Since, of =
course, there=20
is not 4GB of memory available and there is no point in allocating =
memory that=20
is not used, most of the memory will be non-allocated. The non-allocated =
memory=20
is displayed with a gray color and its content will be filled with =
question=20
marks (<CODE>?? ?? ?? ??</CODE>). This is not anything you have to worry =
about,=20
it is just to explain why most of the memory contains question marks. =
Addresses=20
can be displayed in two modes, virtual and physical mode. Usually only =
virtual=20
mode is of interest. Physical mode has restrictions in the MemView and =
is not=20
normally useful.<BR><BR>Most of the functions of the MemView can be =
accessed via=20
the pop-up (Figure 1-4). To view the pop-up, click the right button in =
the=20
MemView. In the first section you can select the address mode. The =
second=20
section allows you to choose the translation of the content. The third =
section=20
is related to the current position of the MemView. You can toggle =
<I>Track=20
PC</I>. If <I>Track PC</I> is enabled the view will always keep the =
address=20
pointed to by the PC in the center. At bottom right of the status bar =
you can=20
see if tracking is enabled or not (see Figure 1-3). You can also only =
<I>Jump to=20
PC</I>, this will center the current address of the PC but it will not =
track it.=20
<I>Jump to SP</I> does the same as <I>Jump to PC</I> but it jumps to the =
address=20
pointed to by the stack pointer (register 29). If any symbols are loaded =
you can=20
also jump to a symbol. When you do this a list of symbols will be =
displayed for=20
you to choose from. In the fourth and last section of the pop-up you can =
<I>Set=20
Next Statement</I> and <I>Set</I>/<I>Clear Breakpoint</I>. <I>Set Next=20
Statement</I> will set the value of the PC to the address you clicked on =
when=20
opening the pop-up. The address will have a focus-rectangle around it. =
<I>Set=20
Breakpoint</I>/<I>Clear Breakpoint</I> will set or remove a breakpoint =
at the=20
focused address.<BR><BR>
<TABLE cellPadding=3D0 width=3D209 align=3Dcenter border=3D0><IMG =
height=3D253=20
src=3D"http://www.it.lth.se/dtlab/manual/mvpopup.gif" width=3D209> =
<FONT=20
size=3D-1><B>Figure 1-4.</B><BR><I>The MemView pop-up.</I> </FONT>
<TBODY></TBODY></TABLE><BR>You can also toggle breakpoints by double =
clicking on=20
an address in the MemView. Breakpoints are displayed as dots in the left =
column=20
(see Figure 1-3). The left column may also contain vertical blue or red =
lines=20
with smaller dots on them. These line indicates if an address is cached. =
Red=20
lines if it is in the instruction cache, blue lines if it is in the data =
cache.=20
This is purely for informational purposes and can be ignored.<BR><BR>To =
jump to=20
a certain address just click in the Address column of the view. Using =
the=20
scrollbar will be fairly difficult considering that it covers the whole =
address=20
space. After entering the address press <CODE><ENTER></CODE>, or=20
<CODE><ESC></CODE> if you wish to return to the old address. To =
edit the=20
contents of an address click the Content column and enter the data. =
Press=20
<CODE><ENTER></CODE> to accept the new value or =
<CODE><ESC></CODE>=20
to keep the old value.<BR><BR>To load a program into the simulator it is =
recommended to use the "Upload To Simulator" function in MipsIt. It is =
possible=20
to load programs from the simulator. To do this, choose Open from the =
File menu.=20
There are two different file types that can be loaded, .SREC and .OUT =
files.=20
Note that SREC files contain no symbolic information. After a program is =
loaded=20
you run it or step through it instruction by instruction. To run it at =
"full=20
speed" choose Run from the Cpu menu. To step one instruction choose Step =
from=20
the Cpu menu.=20
<H4 style=3D"PAGE-BREAK-BEFORE: always">Cache</H4>The cache views show =
the=20
contents of the caches as well as some statistics. There is one view for =
each=20
cache, data and instruction. Figure 1-5 below shows the data =
cache.<BR><BR>
<TABLE cellPadding=3D0 width=3D400 align=3Dcenter border=3D0><IMG =
height=3D524=20
src=3D"http://www.it.lth.se/dtlab/manual/simdcache.gif" width=3D400 =
border=3D0>=20
<FONT size=3D-1><B>Figure 1-5.</B><BR><I>Data Cache view.</I> </FONT>
<TBODY></TBODY></TABLE><BR>The view contains four parts, current =
address, the=20
cache, an optional write buffer and cache statistics. If the write =
buffer size=20
is 0 no write buffer will be display. The address displayed is =
conveniently=20
divided into tag, index and word fields. Depending on the cache =
configuration=20
the field sizes will vary. The active row, selected by the index field, =
is=20
marked gray. The active word, selected by the word field, is marked with =
blue=20
text. The V column is the valid flag for a block. For a write back cache =
there=20
will also be a dirty flag (D) column.<BR><BR>
<TABLE cellPadding=3D0 width=3D344 align=3Dcenter border=3D0><IMG =
height=3D344=20
src=3D"http://www.it.lth.se/dtlab/manual/simdcachecfg.gif" width=3D344 =
border=3D0>=20
<FONT size=3D-1><B>Figure 1-6.</B><BR><I>Data Cache config.</I> =
</FONT>
<TBODY></TBODY></TABLE><BR>To configure the caches go to the Edit menu =
and=20
select Cache/Mem Config. The configuration dialog has three tabs, =
<I>Inst.=20
Cache</I>, <I>Data Cache</I> and <I>Memory</I>. Inst. and Data are =
almost=20
identical, the only difference is that the instruction cache has no =
write=20
policy. Figure 1-6 shows the Data Cache config. In order to completely =
disable=20
one of the caches check the Disable box. To just disable the penalty for =
a cache=20
miss check the Disable penalty box. Sizes have to be of the magnitude=20
2<SUP><I>n</I></SUP>.<BR><BR>
<TABLE cellPadding=3D0 width=3D344 align=3Dcenter border=3D0><IMG =
height=3D344=20
src=3D"http://www.it.lth.se/dtlab/manual/simmemcfg.gif" width=3D344 =
border=3D0>=20
<FONT size=3D-1><B>Figure 1-7.</B><BR><I>Memory config.</I> </FONT>
<TBODY></TBODY></TABLE><BR>If penalty is not disabled the penalty for =
memory=20
reads and writes (in clock cycles) can be set in the Memory config =
(Figure 1-7).=20
Here you can also change the size of the write buffer. The size is the =
number of=20
rows in the buffer.<BR><BR>
<TABLE cellPadding=3D0 width=3D324 align=3Dcenter border=3D0><IMG =
height=3D165=20
src=3D"http://www.it.lth.se/dtlab/manual/simdcachestats.gif" =
width=3D324 border=3D0>=20
<FONT size=3D-1><B>Figure 1-8.</B><BR><I>Data Cache statistics.</I> =
</FONT>
<TBODY></TBODY></TABLE><BR>Since the cache views give a performance =
hit in=20
execution speed there is another option to view cache statistics while =
running=20
long programs. The data and instruction caches each have a statistics =
window=20
(Figure 1-8) that can be accessed from the View menu, I-Cache Stats and =
D-Cache=20
Stats. It shows the current hit ratio, the overall hit ratio and the =
number of=20
cycles executed.=20
<H4 style=3D"PAGE-BREAK-BEFORE: always">Pipeline</H4>The pipeline =
simulator=20
consists of a shell program named Mipspipe2000.exe that loads java =
scripts with=20
structural information of the pipeline. There are two different scripts =
that=20
contains different pipeline views of the CPU. One has a simpler pipeline =
model=20
and is called <B>\S-script\s.dit</B>. The other one has a more complex =
pipeline,=20
<B>\Xl-script\xl.dit</B>. The small pipeline has no forwarding or hazard =
detection. The XL version has those features and controller units that =
can be=20
modified by the user. The controllers are programmed with a java script. =
<BR><BR>There are a number of predefined variables that correspond to =
in/out=20
signals to/from the controller. <BR><BR>Expression syntax:<BR><BR>
<TABLE cellPadding=3D0 align=3Dcenter border=3D0>
<TBODY>
<TR>
<TD colSpan=3D2><I>var</I> <B>=3D</B> <I>x</I> ;</TD>
<TD> </TD>
<TD>Assigns <I>x</I> to variable <I>var</I></TD></TR>
<TR>
<TD><I>x ::=3D</I></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD></TD>
<TD><I>x</I> <B>&</B> <I>x</I></TD>
<TD></TD>
<TD>Bitwise AND</TD></TR>
<TR>
<TD></TD>
<TD><I>x</I> <B>|</B> <I>x</I></TD>
<TD></TD>
<TD>Bitwise OR</TD></TR>
<TR>
<TD></TD>
<TD><I>x</I> <B>^</B> <I>x</I></TD>
<TD></TD>
<TD>Bitwise XOR</TD></TR>
<TR>
<TD></TD>
<TD><B>~</B><I>x</I></TD>
<TD></TD>
<TD>Bitwise complement</TD></TR>
<TR>
<TD></TD>
<TD><I>x</I> <B><<</B> <I>x</I></TD>
<TD></TD>
<TD>Logical shift left</TD></TR>
<TR>
<TD></TD>
<TD><I>x</I> <B>>></B> <I>x</I></TD>
<TD></TD>
<TD>Logical shift right</TD></TR>
<TR>
<TD></TD>
<TD><I>x</I> <B>=3D=3D</B> <I>x</I></TD>
<TD></TD>
<TD>Boolean equal</TD></TR>
<TR>
<TD></TD>
<TD><I>x</I> <B>!=3D</B> <I>x</I></TD>
<TD></TD>
<TD>Boolean not equal</TD></TR>
<TR>
<TD></TD>
<TD><B>!</B><I>x</I></TD>
<TD></TD>
<TD>Boolean NOT</TD></TR>
<TR>
<TD></TD>
<TD vAlign=3Dtop><B>(</B><I>x</I><B>)</B></TD>
<TD></TD>
<TD>Encloses a sub-expression. Operator priorities might not be as=20
expected, <B>use this often.</B></TD></TR>
<TR>
<TD></TD>
<TD><I>var</I><B>[</B><I>x</I><B>]</B></TD>
<TD></TD>
<TD>Bit extraction, returns bit <I>x</I> from variable =
<I>var</I></TD></TR>
<TR>
<TD></TD>
<TD><I>constant</I></TD>
<TD></TD>
<TD>Numeric constant, for hex use=20
<B>0x</B>-prefix</TD></TR></TBODY></TABLE><BR>An example to demonstrate =
the=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -