This is the homepage for CS 353: Architecture and Compilers, a course offered by Fritz Ruehr at the Computer Science Department of Willamette University.
Learning to program in Java or Python can be fun and empowering, but it may still leave you mystified about how computers really work: what are the components of a physical computer? How does the computer “know” what to do when it runs a program? What connects abstract ideas like objects and methods to the silicon hardware?
This hybrid course in computer architecture and high-level language processing (compilers) will provide you with the answers to these questions. The course is a “soup-to-nuts” overview of the various levels of structure embodied in a physical computer, as well as the various stages by which high-level languages are translated into a form which the computer can directly execute. In traditional curricula, these two topics are often covered in separate courses—we have combined them into a single comprehensive overview in order to expedite Willamette's pedagogical goals.
We will start our journey with basic facts about binary encodings, how they are used to represent data and how logical operations can be used to transform these data. We will then see how basic electrical components called gates can be used to realize these operations on digital signals, and how they can be combined into circuits which will implement more complex processes. Finally, we will see how these circuits are used to build higher-level components which constitute a typical computer, and how digital data stored inside the computer can be used to control its operation. In the second phase of our studies, we will start with the strings of characters which comprise a program file, and see how it can be analyzed in successive stages until the internal structure of the program is exposed. We will then see how this internal structure can be translated into the low-level codes which a computer can execute, in a way which respects the meanings of the original program. Finally, as time permits, we will survey a few important concepts which inform the design of high-level languages both like and unlike Java or Python.
As the semester progresses, new News items will be added to the top of this section, after the line below, so that the most recent ones appear first. You should thus get in the habit of coming to this page to check the top of the News for announcements, etc.
I have kept the old news items from earlier teachings of the course and the most recent one (Fall 2019) intact below, in a separate section, just in case we need them.
Note that previous versions of the course were taught for students who (mostly) knew and used only Java. This Fall 2020 version is the first to be taught to a mixed group of students, many of whom are mostly familiar with Python. I will make suitable adjustments to assignemnts and other documents as we go through the semester
Current work (study for the exam and work on all labs)
Study for the final exam (Dec 7 2020 from 2-5pm) using the new Fall 2020 Final Exam review notes.
Reading/study: review lectures on the PC-231 computer and the shunting-yard algorithm (see also the Wikipedia entry on shunting-yard).
Coding: work on Lab 3: Building circuits in a GUI or Lab 4: Hidden circuit simulator or Lab 5: Writing PC-231 Programs as listed in the Labs section below.
And, by the way, here is some
quick sample code
on how to organize your Python code for the Hidden Circuits
lab.
Here are some handy regular expression resources for Python in particular:
the official python (3.9) documentation on
the re
regular expression library;
a handy “how to” guide, also from the official python (3.9) documentation;
the w3schools.com
section on
regular expressions in Python,
complete with embedded, interactive examples.
Check out thus truth table generator generously provided by a class at Stanford, or this generator from Michael Rieppel at Syracuse University, … or this one with a purple monster and a psychic duck (!) from Christian Gottschall at the University of Vienna.
Here is the Fall 2020 syllabus (note that I am not distributing this or many other documents on paper this semester, due to issues with the Covid-19 pandemic).
Hereafter starts the old news part of the section …
Here are the new Fall 2019 final exam review notes!
An animated version of stack machine compilation, is here, but it doesn't seem to work well in FireFox (try Chrome or IE).
Here are some links relevant to the code generation part of the compiler:
Check the following links for examples of context-free grammars:
A somewhat more realistic Java grammar (and in a slightly different notational style).
sed
unix tool)
Here are the new Fall 2019 midterm review notes, all ready for the exam on Friday 25 October.
Regarding near-term scheduling:
the mid-term exam has been scheduled (by class vote)
for Fri 25 Oct
:
remember that there is no class on Fri 18 Oct
,
as it is the college-wide mid-semester break day;
a mid-term exam review outline will be posted soon—we will
spend Mon 21
and Wed 23
in lecture
reviewing for the upcoming exam.
I fixed a few things in the lab write-up itself (see link above) and in
the advice on structuring (see the next link). Specifically, I changed the
way I would recommend doing the syntax for lights in the lab write-up and
added a remark about GUI elements and their proxies. In the structuring
advice, I fixed a bug in the code where I wasn’t calling the hash
table’s
Here is the revised advice on structuring the hidden circuits lab.
And finally, here are the bonus graphics of lights; feel free to use them in your GUIs (or just use standard (e.g.) Swing components).
I’m going to recommend for Lab 3 that you use the LogicLy (free trial); circuit simulator. Some alternative simulators available for { free, trial usage, cost } include the following:
Logic Lab from Neuro Productions) [requires Flash];
Simulator.io (on-line);
the Do Circuits vitrtual lab (on-line);
the Logic Gate Simulator from Academo (only single output!).
The on-line version of the Fall 2019 syllabus is here.
Someday soon we should talk for a bit about storage costs for Java objects, as relevant to Lab 2 especially.
OK, as of the first week of class, you should be working on
Lab 1: Numerals, numbers and strings,
a basic warm-up exercise.
(If it seems to simple to you, concentrate your best efforts on issues
of code modularity, error-checking, corner cases, etc.)
But everyone should make sure that their program checks that the
digits in the input numeral are in range for the given base.
check out this graphic
to convert bases using Horner’s technique (to go the opposite
direction, produce digits from right to left using the mod operator
(%
), updating the total using division (/
)
by the base);
you can find the two’s complement “clock graphic” here;
and see the two’s complement conversion instructions in this PDF file.
Just for fun, here is
a nice little computer for counting in binary.
(Psst! There’s also a link down below to a
wood and marbles adding machine.)
Check out the new Fall 2018 final exam review notes!
Read about the Swift programming language’s approach to various Unicode woes in this blog post from Ole Begemann (an extract from a new book on Advanced Swift).
In the news today, and relevant to our current topics, here is a thread on StackOverflow about why different associations in a Java expression lead to different run-time results.
Following Turkey Day break we will be going over Dijkstra’s Shunting Yard Algorithm, using these notes.
Here are the new Fall 2018 midterm review notes, all ready for the exam on Monday 29 October.
PuTTY
,
but it’s pretty old-fashioned; for some alternatives, check out these
web pages (found via a simple Google search):
Alex Lockwood, your intrepid Lab Assistant, has kindly
supplied some sample inputs for Lab 4 here
(as a ".txt"
file), for use in your demos.
Weekend Update: since a number of people were gone for various athletic events and illness this past Friday (14 Sep), I thought I would consolidate information for them here on the homepage as to what went on in class. Specifically, we talked about the nature of low-level switches (such as transistors), and how they can be used to implement common logic gates; see this graphical explanation. In lab, we saw how truth tables can be used to determine the “logical” way to add two numerals in binary. This is also now discussed and illustrated at the end of the revised Lab 2 write-up
Also, for the latest scoop on Unicode, see this blog post on Unicode 8.0 and this one on Unicode 9.0.
As promised in lecture, I have updated the Lab 2 write-up to include more detail (and accurate binary numerals …); you can find the resulting new write-up here.
The new Archive section can be found below by clicking on this link right here. (More material will be added from these News links soon; use “find in page” for now.)
Just in time for the upcoming final exam review, here is a very detailed explanation of Horner’s technique in the context of evaluating numerals (in an arbitrary base).
Here‘s a shorter version of multiply I worked up
in class the other day year—this one is simpler than the
one we saw Friday since it ignores signs.
Alden sends this link to a 10-minute take on computer architecture from “LosT” at DEF CON 24. (Maybe we should have just watched this and then taken the rest of the semester off until the final, eh?)*
* Fritz’s near-Canadian roots are showing …
I will try really hard to remember to show you all a “gated SR-latch” on Wednesday (this is here to remind me):
gated SR-latch circuit.
(Here‘s how it looked in the older “Logg-o” tool: less room to draw, but real gate shapes.)
Stop the presses! There is a new version of the Lab 2 main picture
available
here; in particular, it corrects some errors
in the original lab 2 graphic, so check it out!
(Oh, and by the way, here’s a more convenient link to the
“two’s complement clock”;
thanks and a “hat tip” to Elizabeth for reminding me to
add this link!)
OK, just to start off the semester right, WU CS and CS 353 alumnus Nathaniel Garst sent me this page from Ken Shirriff’s blog which shows what an Intel 8008 processor looks like on the “inside” (where the “Intel” is, I suppose).
Thanks, Nathaniel!
And, continuing this trend of focus on processors, here is a little video on
How a CPU is Made.
(This one is a much higher-level, non-technical run-down wit focus
on materials and manufacturng processes.)
306 9ea c20 200 211 1e0 601 9e0 d10 91e 428 e24 000
”!
“...did you see the bottom line? I programmed my first computers in binary, using toggle switches. I always think of how my code turns into electrical signals, even when it's "written" by connecting pictures in XCode that are compiled into Obj-C that is compiled into C that is compiled into LLVM that is compiled into Assembler that is assembled into object code that is linked into binaries that becomes executable code that is dispatched through the pipelines and routed through the logical arrays of gates ... and then back out into representations that eventually have a meaning assigned by humans. ”(and here you thought I was just making this stuff up as we went along ...)
... ( inst & 0x0F0 ) >>> 4
... inst & 0x0F0 >>> 4
Visual6502.org
have written
a full 6502 chip simulator in Javascript,
runnable on the web (also available in Python). We'll have to try this out when we get
to that point in class! (They have more info, slides, a research paper, etc., on
their project homepage.)
This section of the homepage (inaugurated Spring 2017) will be a growing collection of handouts for the class, organized by topic, in chronological order. The files are, for the most part, in PDF format, which should be easily readable in a browser or with other tools if downloaded.
(Note: some, but not all, of these handouts are already linked from the course homepage, or from individual labs.)
Homework and quizzes
Numerals and numbers
Hardware
Bit manipulation
int
s and
PC-231 integers
Circuit simulator
Machine architectures
Assembly language
Expression language and trees
Scanning and parsing
Code generation
(I have added “abstract due dates” below for each of the labs. What does this mean? Well, first of all, they are stated in terms of the weeks of the semester rather than the days and months of any specific year (this mean less bother about updating for me, but requires you to be at least somewhat aware of how far into the semester we are “currently” if you wish to gague your own progress). But the due dates are also abstract in that they are a little vague and soft: you are not required to finish the lab by the expected date, but should expect to do so, or perhaps strive to do so. As stated in lecture, if you let these things go too long, you will have a Bad Time™ at the end of the semester.)
By the way, here is the revised advice on structuring the hidden circuits lab.
/opt/sfw/bin/gcc
. To make this easier, you might
want to set up an alias in your ~/.cshrc
file;
just add a line like this:
alias gcc /opt/sfw/bin/gcc
.login
file:
(that last character is a backspace key: if your backspace is currently set to erase, this is hard to enter, but in thestty erase ^H
vi
editor you
can use a Control-V Control-H sequence (the Control-V escapes the next character
to be entered in as a literal character)
ccode
directory
C:\Program Files\Windows NT\hypertrm.exe
(note: no vowel in "trm"). You can also just enter
"hypertrm" in the "Run ..." command line feature of the Start menu.
Remember to start studying for the midterm exam, scheduled for Friday 16 October; you can do so using the Fall 2020 midterm review notes, and check out this sample exam for the format and to test your software.
Reading/study: review lectures on the PC-231 computer and try the new homework assignment found here. Also, we will develop some code for a multiplier in class (see this older file for actual PC-231 code).
Coding: work on Lab 3: Building circuits in a GUI as listed in the Labs section below.
Current work (2nd week): review class notes and work on Lab 1
Reading: review your class notes on semiotics, digits and bases, and Horner’s technique (for the last, see the more detailed visual … document in the Handout archive below.
Coding: work on Lab 1: Numerals, numbers and strings as listed in the Labs section below. Don’t worry about making a GUI interface (unless you want to), but use the description’s white and grey boxes style to understand which items are inputs (white boxes) and which are outputs (grey boxes). This is not really due at any specific time—I also want to be able to gauge your coding level and style.
We won't be using a formal textbook this semester, so I will be trying to gather links to relevant on-line material. A lot of good-quality articles are available on Wikipedia, the free on-line "open source" encyclopedia (you might want to consider donating some portion of your textbook savings to their efforts).