-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
118 changed files
with
22,336 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#################################################### | ||
# Students' Makefile for the CS:APP Architecture Lab | ||
#################################################### | ||
|
||
# IMPORTANT: Change the USER variable to your unique UserID | ||
USER = changeMe | ||
|
||
sim: | ||
(cd sim; make) | ||
|
||
# Use this rule to build the handin file for Part A ("make handin-parta") | ||
handin-parta: | ||
cp sim/misc/sum.ys $(USER)-sum.ys | ||
cp sim/misc/rsum.ys $(USER)-rsum.ys | ||
cp sim/misc/copy.ys $(USER)-copy.ys | ||
tar cf - $(USER)-sum.ys $(USER)-rsum.ys $(USER)-copy.ys > $(USER)-parta.tar | ||
rm -f $(USER)-sum.ys $(USER)-rsum.ys $(USER)-copy.ys | ||
|
||
# Use this rule to build the handin file for Part B ("make handin-partb") | ||
handin-partb: | ||
cp sim/seq/seq-full.hcl $(USER)-seq-full.hcl | ||
tar cf - $(USER)-seq-full.hcl > $(USER)-partb.tar | ||
rm -f $(USER)-seq-full.hcl | ||
|
||
# Use this rule to build the handin file for Part C ("make handin-partc") | ||
handin-partc: | ||
cp sim/pipe/ncopy.ys $(USER)-ncopy.ys | ||
cp sim/pipe/pipe-full.hcl $(USER)-pipe-full.hcl | ||
tar cf - $(USER)-ncopy.ys $(USER)-pipe-full.hcl > $(USER)-partc.tar | ||
rm -f $(USER)-ncopy.ys $(USER)-pipe-full.hcl | ||
|
||
clean: | ||
rm -f *~ *.o | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
##################################################################### | ||
# CS:APP Architecture Lab | ||
# Handout files for students | ||
# | ||
# Copyright (c) 2002, 2010 R. Bryant and D. O'Hallaron, | ||
###################################################################### | ||
|
||
This directory contains the files that you need for the CS:APP | ||
architecture lab. | ||
|
||
****** | ||
Files: | ||
****** | ||
Makefile Use this to handin your solutions | ||
README This file | ||
sim.tar Archive of the Y86 tools in tar format | ||
simguide.pdf CS:APP Guide to Simulators document |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Comment this out if you don't have Tcl/Tk on your system | ||
|
||
#GUIMODE=-DHAS_GUI | ||
|
||
# Modify the following line so that gcc can find the libtcl.so and | ||
# libtk.so libraries on your system. You may need to use the -L option | ||
# to tell gcc which directory to look in. Comment this out if you | ||
# don't have Tcl/Tk. | ||
|
||
#TKLIBS=-L/usr/lib -ltk -ltcl | ||
|
||
# Modify the following line so that gcc can find the tcl.h and tk.h | ||
# header files on your system. Comment this out if you don't have | ||
# Tcl/Tk. | ||
|
||
#TKINC=-isystem /usr/include/tcl8.5 | ||
|
||
################################################## | ||
# You shouldn't need to modify anything below here | ||
################################################## | ||
|
||
# Use this rule (make all) to build the Y86 tools. The variables you've | ||
# assigned to GUIMODE, TKLIBS, and TKINC will override the values that | ||
# are currently assigned in seq/Makefile and pipe/Makefile. | ||
all: | ||
(cd misc; make all) | ||
(cd pipe; make all GUIMODE=$(GUIMODE) TKLIBS="$(TKLIBS)" TKINC="$(TKINC)") | ||
(cd seq; make all GUIMODE=$(GUIMODE) TKLIBS="$(TKLIBS)" TKINC="$(TKINC)") | ||
(cd y86-code; make all) | ||
|
||
clean: | ||
rm -f *~ core | ||
(cd misc; make clean) | ||
(cd pipe; make clean) | ||
(cd seq; make clean) | ||
(cd y86-code; make clean) | ||
(cd ptest; make clean) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/*********************************************************************** | ||
* Y86 Tools (Student Distribution) | ||
* | ||
* Copyright (c) 2002, 2010 R. Bryant and D. O'Hallaron, | ||
***********************************************************************/ | ||
|
||
This directory contains the student distribution of the Y86 tools. It | ||
is a proper subset of the master distribution, minus the solution | ||
files found in the master distribution. | ||
|
||
yas Y86 assembler | ||
yis Y86 instruction (ISA) simulator | ||
hcl2c HCL to C translator | ||
hcl2v HCL to Verilog translator | ||
ssim SEQ simulator | ||
ssim+ SEQ+ simulator | ||
psim PIPE simulator | ||
|
||
************************* | ||
1. Building the Y86 tools | ||
************************* | ||
|
||
The Y86 simulators can be configured to support TTY and GUI | ||
interfaces. A simulator running in TTY mode prints all information | ||
about its run-time behavior on the terminal. It's harder to understand what's | ||
going on, but useful for automated testing, and doesn't require any | ||
special installation features. A simulator running in GUI mode uses a | ||
fancy graphical user interface. Nice for visualizing and debugging, | ||
but requires installation of Tcl/Tk on your system. | ||
|
||
To build the Y86 tools, perform the following steps: | ||
|
||
NOTE: If your instructor prepared this distribution for you, then you | ||
can skip Step 1 and proceed directly to Step 2. The Makefile will | ||
already have the proper values for GUIMODE, TKLIBS, and TKINC for your | ||
system. | ||
|
||
Step 1. Decide whether you want the TTY or GUI form of the simulators, | ||
and then modify ./Makefile in this directory accordingly. (The changes | ||
you make to the variables in this Makefile will override the values | ||
already assigned in the Makefiles in the seq and pipe directories.) | ||
|
||
Building the GUI simulators: If you have Tcl/Tk installed on your | ||
system, then you can build the GUI form by initializing the GUIMODE, | ||
TKLIBS, and TKINC variables, as appropriate for your system. (The | ||
default values work for Linux systems.) | ||
|
||
Assigning GUIMODE=-DHAS_GUI causes the necessary GUI support code in | ||
the simulator sources to be included. The TKLIBS variable tells gcc | ||
where to look for the libtcl.so and libtk.so libraries. And the TKINC | ||
variable tells gcc where to find the tcl.h and tk.h header files. | ||
|
||
Building the TTY simulators: If you don't have Tcl/Tk installed on | ||
your system, then build the TTY form by commenting out all three of | ||
these variables (GUIMODE, TKLIBS, and TKINC) in the Makefile. | ||
|
||
Step 2: Once you've modified the Makefile to build either the GUI or | ||
TTY form, then you can construct the entire set of Y86 tools by typing | ||
|
||
unix> make clean; make | ||
|
||
******** | ||
2. Files | ||
******** | ||
|
||
Makefile | ||
Builds the Y86 tools | ||
|
||
README | ||
This file | ||
|
||
misc/ | ||
Source files for the Y86 assembler yas, the Y86 instruction | ||
simulator yis, and the isa.c file that is used by the -t option | ||
of the processor simulators to check the results against the | ||
ISA simulation. Also contains files for the programs | ||
hcl2c and hcl2v | ||
|
||
seq/ | ||
Code for the SEQ and SEQ+ simulators. Contains HCL files for | ||
labs and homework problems that involve modifying SEQ. | ||
|
||
pipe/ | ||
Code for the PIPE simulator. Contains HCL files for labs and | ||
homework problems that involve modifying PIPE. | ||
|
||
y86-code/ | ||
Example .ys files from CS:APP and scripts for conducting | ||
automated benchmark teseting of the new processor designs. | ||
|
||
ptest/ | ||
Automated regression testing scripts for testing processor designs. | ||
|
||
verilog/ | ||
System for producing Verilog designs from HCL code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
CC=gcc | ||
CFLAGS=-Wall -O2 | ||
LCFLAGS=-O2 | ||
LEX = flex | ||
YACC=bison | ||
LEXLIB = -lfl | ||
YAS=./yas | ||
|
||
all: yis yas hcl2c | ||
|
||
# These are implicit rules for making .yo files from .ys files. | ||
# E.g., make sum.yo | ||
.SUFFIXES: .ys .yo | ||
.ys.yo: | ||
$(YAS) $*.ys | ||
|
||
# These are the explicit rules for making yis yas and hcl2c and hcl2v | ||
yas-grammar.o: yas-grammar.c | ||
$(CC) $(LCFLAGS) -c yas-grammar.c | ||
|
||
yas-grammar.c: yas-grammar.lex | ||
$(LEX) yas-grammar.lex | ||
mv lex.yy.c yas-grammar.c | ||
|
||
isa.o: isa.c isa.h | ||
$(CC) $(CFLAGS) -c isa.c | ||
|
||
yas.o: yas.c yas.h isa.h | ||
$(CC) $(CFLAGS) -c yas.c | ||
|
||
yas: yas.o yas-grammar.o isa.o | ||
$(CC) $(CFLAGS) yas-grammar.o yas.o isa.o ${LEXLIB} -o yas | ||
|
||
yis.o: yis.c isa.h | ||
$(CC) $(CFLAGS) -c yis.c | ||
|
||
yis: yis.o isa.o | ||
$(CC) $(CFLAGS) yis.o isa.o -o yis | ||
|
||
hcl2c: hcl.tab.c lex.yy.c node.c outgen.c | ||
$(CC) $(LCFLAGS) node.c lex.yy.c hcl.tab.c outgen.c -o hcl2c | ||
|
||
hcl2v: hcl.tab.c lex.yy.c node.c outgen.c | ||
$(CC) $(LCFLAGS) -DVLOG node.c lex.yy.c hcl.tab.c outgen.c -o hcl2v | ||
|
||
hcl2u: hcl.tab.c lex.yy.c node.c outgen.c | ||
$(CC) $(LCFLAGS) -DUCLID node.c lex.yy.c hcl.tab.c outgen.c -o hcl2u | ||
|
||
lex.yy.c: hcl.lex | ||
$(LEX) hcl.lex | ||
|
||
hcl.tab.c: hcl.y | ||
$(YACC) -d hcl.y | ||
|
||
clean: | ||
rm -f *.o *.yo *.exe yis yas hcl2c mux4 *~ core.* | ||
rm -f hcl.tab.c hcl.tab.h lex.yy.c | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/*********************************************************************** | ||
* Y86 Assembler, Instruction Simulator, and HCL translator | ||
* | ||
* Copyright (c) 2002, R. Bryant and D. O'Hallaron, All rights reserved. | ||
* May not be used, modified, or copied without permission. | ||
***********************************************************************/ | ||
|
||
This directory contains all of the source files for the following: | ||
|
||
YAS Y86 assembler | ||
YIS Y86 instruction level simulator | ||
HCL2C HCL to C translator | ||
HCL2V HCL to Verilog translator | ||
|
||
********************* | ||
1. Building the tools | ||
********************* | ||
|
||
unix> make clean | ||
unix> make | ||
|
||
******** | ||
2. Files | ||
******** | ||
|
||
Makefile Builds yas, yis, hcl2c, hcl2v | ||
README This file | ||
|
||
* Versions of Makefile in the student's distribution | ||
* (Instructor distribution only) | ||
Makefile-sim | ||
|
||
* Example programs for Part A of the CS:APP Architecture Lab | ||
examples.c C versions of three Y86 functions | ||
ans-copy.ys Solution copy function (instructor distribution only) | ||
ans-sum.ys Solution sum function (instructor distribution only) | ||
ans-rsum.ys Solution rsum function (instructor distribution only) | ||
|
||
|
||
* Instruction simulator code shared by yas, yis, ssim, ssim+, and psim | ||
isa.c | ||
isa.h | ||
|
||
* Files used to build the yas assembler | ||
yas The YAS binary | ||
yas.c yas source file and header file | ||
yas.h | ||
yas-grammar.lex Y86 lexical scanner spec | ||
yas-grammar.c Lexical scanner generated from yas-grammar.lex | ||
|
||
* Files used to build the yis instruction simulator | ||
yis The YIS binary | ||
yis.c yis source file | ||
|
||
* Files used to build the hcl2c translator | ||
hcl2c The HCL2C binary | ||
node.c auxiliary routines and header file | ||
node.h | ||
hcl.lex HCL lexical scanner spec | ||
lex.yy.c HCL lexical scanner generated from hcl.lex | ||
hcl.y HCL grammar | ||
hcl.tab.c HCL parser generated from hcl.y | ||
hcl.tab.h Token definitions | ||
|
||
* Example HCL programs used during the writing of the CS:APP book | ||
* (Instructor distribution only) | ||
frag.{hcl,c} | ||
mux4.{hcl,c} | ||
reg-file.{hcl,c} | ||
test.hcl | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Name: Tiankui Guo | ||
# ID: [email protected] | ||
|
||
.pos 0 | ||
init: | ||
irmovl Stack, %esp | ||
irmovl Stack, %ebp | ||
irmovl $12, %eax | ||
subl %eax, %esp | ||
irmovl src, %eax | ||
rmmovl %eax, (%esp) | ||
irmovl dest, %eax | ||
rmmovl %eax, 4(%esp) | ||
irmovl $3, %eax | ||
rmmovl %eax, 8(%esp) | ||
call copy_block | ||
halt | ||
|
||
copy_block: | ||
pushl %esi | ||
pushl %ebx | ||
mrmovl 12(%esp), %ecx | ||
mrmovl 16(%esp), %ebx | ||
mrmovl 20(%esp), %edx | ||
irmovl $0, %eax | ||
andl %edx, %edx | ||
jle End | ||
Loop: | ||
irmovl $4, %edi | ||
addl %edi, %ecx | ||
mrmovl -4(%ecx), %esi | ||
addl %edi, %ebx | ||
rmmovl %esi, -4(%ebx) | ||
xorl %esi, %eax | ||
irmovl $1, %edi | ||
subl %edi, %edx | ||
jne Loop | ||
End: | ||
popl %ebx | ||
popl %esi | ||
ret | ||
|
||
.align 4 | ||
# Source block | ||
src: | ||
.long 0x00a | ||
.long 0x0b0 | ||
.long 0xc00 | ||
# Destination block | ||
dest: | ||
.long 0x111 | ||
.long 0x222 | ||
.long 0x333 | ||
|
||
.pos 0x100 | ||
Stack: |
Oops, something went wrong.