CS120 Fall 2018

Course web page: http://www.cs.binghamton.edu/~pmadden/courses/cs120
Instructor: Prof. Patrick H. Madden email pmadden@acm.org
Lectures: A0 12-1 in UU108, B1 9:40-10:40 in UU215
Office Hours: MWF from 11 to 12 in ENGB Q4. I'm usually available Tuesday and Thursday mornings. You can also send and email, and we can set up a time to meet.
TAs: Fatemeh Tahmasbi (ftahmas1 at binghamton dot edu) and Mohammad Khasawneh (mkhasaw1 at binghamton dot edu)
2018 Course Syllabus

There are multiple lab sections; check with BUSI for times.  You must attend the lab session you are assigned to.  There are too many students to deal with anyone switching sections.  If you do not attend your s ection, you won't get credit for the lab.

Text: Harris & Harris, which you can find in the Binghamton on-line bookstore, or you can find Harris & Harris, Digital Design and Computer Architecture ARM EDITION  on Amazon

Note: we are using the ARM version of the textbook this year, not the MIPS version as in prior years.

C Programming appendix from the textbook.
Textbook resources
Tutoring is available through UPE -- If you're lost, there are people who would be happy to help you.
You might also want to join the ACM student chapter; lots of helpful people there too.

We will use Arduino UNOs for some labs. We will have some for use in lab, but you might want to buy one of your own to play with outside of class. They really are pretty cool, and cheap. You can find them for anywhere from about $5 to about $20 on-line.  You may be able to pick up an Arduino from someone who took the class in a prior semester (there are a couple of earlier models; the Duemilanove should be fine). Amazon is a good place to get them.  You can also look at Sparkfun, Adafruit, and NKC. You can also get them at Unicorn Electronics.  The people at Unicorn Electronics are really nice; if you want to have a successful career in computer science, you should get used to the idea of tinkering with stuff and trying things out, in your spare time -- and Unicorn has lots of fun stuff to tinker with.  Unicorn is good.

Unicorn Electronics -- A local store to buy parts at
Recommended: check out TopCoder algorithms competitions, to get an idea of the sort of folks you'll be up against in the job market.
Highly recommended: join the ACM Student chapter, and try the local programming contests. The ACM Code of Ethics is a worthwhile read, to know what will be expected of you as a computing professional.

Don't underestimate the value of taking notes.


  • Three exams (25% each). Two during the semester, plus a final.
  • Lab attendance and participation. 15%
  • In-class quizzes: 10% total
There will be about 11 lab sessions; you can miss one of these. After that, the 15% will be reduced by the portion of labs missed (for example: suppose there are in fact 11 labs, and you miss two -- the first one does not impact you, but the second reduces the grade by 1.5%). If you are physically present in the lab, but your mind is not there, you will not get credit -- the TAs are the final authority on if you've put in the effort or not.

In-class quizzes are similar; you can miss two, and then they start knocking down your grade. Quiz sheets will be handed out at the start of class, and then if you're paying attention, you might notice some of the quiz questions are going to get worked on the board. Fill in the quiz, and hand it in at the end of class. The quizzes will be "graded" simply for a name check, and to see if you were paying a bit of attention. There's a good chance that questions on quizzes will also show up on the exams.

Useful stuff:

Don't worry about the letter grade too much -- the objective is to learn some useful material, and build the skills you'll need for a career in computer science. At some point, you may want to get a job, which will almost certainly involve an interview. If you don't know the material thoroughly, your GPA won't help you at all. A high GPA won't help you on the job either. The only thing that really matters is what you can do, and how you do it.  If the grade is all you're worried about, I'd suggest pursuing a degree at Thunderwood College.
All exams are closed book/closed notes.  No calculators, cell phones, pagers, CB radios, and so on.  Bring a pen or pencil.  There will be scratch paper available.

The in-class quizzes will happen roughly once a week, but won't be announced in advance. There are morning and afternoon sessions; they may not have quizzes on the same day. So, make your life easy: show up to class, and be paying attention. Part of the training for a career in computer science is learning how to show up on time and get work done.  Being in class with your brain turned on is part of this training. The course grade is based on showing up and doing the work; having a good excuse does not remove this requirement.  If there is a disaster of some sort which prevents you from attending class, you can withdraw; the University has policies in place to handle this.
Lab Attendance is Required.  Show up on time to lab, ready to work.  The TAs are under strict orders to not give credit to anyone who shows up late.  Do not use your cell phones or surf the web during lab; the TAs are also under orders to not give credit to those not focused on the work.  You may miss or fail to complete one lab for any reason; after this, your final grade starts to drop..  You will not get credit for attending another lab, and there are no make-ups.  Be in the right place, at the right time, and get the work done.  There will be some homework problems; you will bring these to lab to have them checked, and you will be able to have the TA help you if needed.
If you have a laptop or tablet, use it for taking notes, not playing games.  Bring paper and pencil/pen.  Take notes during class, and pay attention.  The lecture format of instruction has been going on for thousands of years, for good reason -- if you listen, pay attention, and take notes, you'll learn something.  If you don't, you won't.  Office hours are available if you're having trouble keeping up in class, but if you don't have any notes, you won't get much sympathy during office hours.
The point of the class is to learn the material, and to develop the skills you will need for a successful career in computer science. If you're not interested in the material, please find another profession, and go do that.
Grade ranges are typically [90-100%] = [A- to A], [80-90%]=[B- to B+], [70-80%]=[C- to C+], and so on.  You don't want to be in the D to F range (the F range may start at 65%).  Depending on the actual scores, the percentage range may change slightly.  Don't worry about grades; focus on the actual material.  A letter on a piece of paper has no particular value, and won't get you very far in your career.

If I catch anyone cheating (or helping someone cheat), they will fail the course.  The Watson School Academic Honesty code is in effect, and I will not hesitate to apply it. There are lots of people who are trying to get into Watson, and we simply don't have the space; if you indicate that you're not interested in being a good computer scientist, please understand that we will swap you out for someone else.  There will not be make-up dates for labs. Get things done on time.

Lecture and exam schedule

  • August 22nd Going over the syllabus, general overview of the course. Take a look at the chapter on C programming from the textbook.
  • August 24th C programming, logging into the university machines, remote access. Lots of fun with printf, simple loops, if statements, grouping lines of code.
    • Binghamton Information Technology Services. There are many machines on campus you can log into and use. In most places, you'll use your PODS password. What services are available, and where they are, are always changing. For this class, we'll be using machines maintained by the CS department. You can also use Bingsuns.
    • To log in to a remote machine, you can use ssh on a Mac or Linux box, or a tool like putty on a PC. Get used to doing this stuff. You'll be doing a lot of it.
  • Labs, Week of August 26th In lab, you'll log into the Linux machines, and write a few simple C programs. There are lots of text editors; find one you like, and get comfortable with it. Be able to use others if you have to. Emacs is a great editor; hard to learn, but very very powerful. Vi is a popular editor as well; lots of good programmers used to use vi before they became smarter, and switched to using emacs. Gedit is probably the easiest "starter" editor.
  • August 27th More C programming. Function calls, global and local variables.
  • August 29th Wrapping up basics of C programming, and we'll jump into Chapter 1.
  • August 31st More from Chapter 1, binary-to-decimal, hex, and the start of negative numbers. Take a look at bitrange.c and bitrangeint.c
  • Labs, Week of September 2nd In lab, we'll write a little more C code, and use some integer arrays. Nothing tricky; just making sure we get people up to speed on C syntax, and using Unix editing and development tools.
  • September 3rd No class -- Labor Day!
  • September 5th More from chapter 1, binary representations of integers, hexadecimal, and the start of Boolean logic elements (AND, OR, NOT gates).
    Check out code for printing integers as binary values.
  • September 7th Boolean gates, Logisim, and building a simple adder. Chapter 1, section 1.5.
    Download Logisim, and start playing around with it. The adder circuit for Logisim is worth looking at carefully. Knowing how this works might be useful for an exam in the future.
  • Week of September 9th No labs.
  • September 12th Truth tables, sum of products, product of sums, chapter 2. There was a quiz, and the Quiz 2 key is here.
  • September 14th More truth tables, and a simple adder circuit. Yay math! Minterms, maxterms. Sum of products, product of sums, and maybe some Karnaugh maps.
  • Week of September 16th Labs: Logisim, building an adder, an adder/subtracter, and converting truth tables into Sum-of-Products circuits.
  • September 17th Chapter 2, more on Sum-of-Products
  • September 19th No class (Yom Kippur).
  • September 21st Multiple output circuits, Karnaugh Maps
  • Week of September 23rdLabs: Karnaugh map simplification.
  • September 24th Don't Care values, Karnaugh Maps
  • September 26th Multiplexers and decoders
  • September 28th Delay, glitches, and all the ugly real-world stuff.
  • Week of September 30th Labs: practice questions and review.
  • October 1st Boolean logic, gates, circuits, review for Exam 1 (practice questions). Intro to Finite State Machines (chapter 3).
  • October 3rd C language refresher/review. More Finite State Machines
  • October 4th - Review Session for Exam 1 UPE will host a review for the exam, 8 to 9pm, in Engineering Building N25.
  • October 3rd, 4th, 5th. Google recruiters on campus. Lots of events going on; it might be a little early for an internship, but it's never too early to meet people and start building connections.
  • October 5th Exam 1. You should take a look at Quiz 3, and the key for the quiz. to get an idea of what will be on the exam. Seriously, look at the key; it'll help you get a better score on the exam.
  • Week of October 7th No Labs!
  • October 8th Finite State Machines, chapter 3.
  • October 10th Finite State Machines, chapter 3.
    Some useful circuits: Traffic Light and the mux controlled adder.
    For the quiz, there's ALU + Registers. Quiz 4 is here.
  • Week of October 14th Lab 5, programming the tiny processor.
  • October 15th The tiny processor, finite state machines, more from chapter 3. Parllelism from chapter 3.
  • October 17th Chapter 5. Adders, multipliers, more complex ALUs. Memory arrays, register files.
  • October 19th Chapter 6. Assembly language. We'll be using the slides to cover MIPS assembly, and the book to cover ARM assembly.
  • Week of October 21 Labs: writing MIPS assembly code, running the SPIM simulator.
  • October 22nd Chapter 6. Assembly language.
  • October 24th Chapter 6. Assembly language. Memory accesses, labels, branches, and more. Plus, there's a secret quiz.
    A very cool site to check out is Compiler Explorer, which will show you the assembly language version of your high level code, using a bunch of different assembly languages!
  • October 26th Chapter 6. Assembly language -- pointers, accessing arrays.
    array.s and sum_array.s
  • Week of October 28th Labs: more MIPS hacking with QtSPIM. A sample solution is here. Run SPIM. Look carefully at the code. Think about what the program is doing, and why.... The variation of the code that moves the pointer is here.
  • October 29th More chapter 6, arrays, pointers, and maybe function calls. Check the PDF slides around page 75.
  • October 31st Function calls, chapter 6, the stack
  • November 2nd Chapter 6, the stack, and comparisons of ARM, MIPS, x86. Secret quiz that no one expects.
  • Week of November 4th Lab: function calls, passing arguments, and using the stack.
    We'll start with the Logisim TinyProc2 processor, and you can hack on the assembler to add support for the subtract instruction. This should be easy. Here's a little bit of TinyProc2 assembly code. Write some code, run it through the assembler, and then be amazed when you load the code into the Logisim processor at it's ability to do computations!
    After that, some fun time with Arduinos -- fire up the Arduino development environment, and write code to blink lights and make music. Whatever you do, don't Google "hot line bling Arduino."
  • November 5th. Chapter 6, local variables, the stack.
  • November 7th. Chapter 6, more on the stack. The stack is important, right? How about some little code examples, that might also make for good exam questions?
  • November 9th. Connecting the stack to C, pointers to arrays, and more. Secret quiz that no one expects.
  • Week of November 11th Lab: review for exam 2.
    Prep questions for the exam.
  • November 12th. C structures, pointers, and why base+offset is cool.
  • November 14th. More on C structs, and some review for Exam 2
  • November 16th Exam 2. Exam 2 key.
  • Week of November 18th No labs this week (Thanksgiving)
  • November 19th Chapter 7, microarchitecture.
  • Week of November 25th Lab: Arduino sounds, input and output
  • November 26th Chapter 7, microarchitecture, performance analysis
  • November 28th Chapter 7, multicycle processors. All that finite state machine stuff we did earlier? Here's where it gets interesting.
  • November 30th Chapter 7, pipelines. That NOP instruction? Here's why. SUPER SECRET QUIZ!
  • LAB: Week of December 2nd One more time with QtSPIM, and some exercises to work on the stack, and on converting from C to MIPS assembly.
    IMPORTANT: the solution is here on the web; give a real effort to do this, before looking at the solution. If you understand things better, you'll get the answers right on the final exam. Just loading in the code and hitting "run" won't help you on the exam.
    Take a look at lab10.c, and run ito on the lab machines. How it works, and what it does, should be easy to understand.
    Now the part where you do some work: convert the C code into MIPS assembly, and get it to run under QtSPIM. It should not be too hard. Use the stack to send arguments to the functions (and not registers). The goal of this assignment is to get you more familiar with the stack.
    Single step through the MIPS code, and make sure it does what you think it does.
    Here is lab10.s, a solution to the lab. If you run into trouble, take a look. If you think you've figured it out, take a look. But seriously, give a good effort into doing this on your own. That's what will help you do well on the final.
  • December 3rd Another quick look at the stack and function calls. func.s func-c.c
  • December 5th A quick look at pointers, and how things work with the stack, and why pointers are a good thing even if they hurt your brain. If we have time, very briefly some chapter 8, memory systems.
  • December 7th Review for the final exam. Very important super secret quiz.
  • December 11th Final (8:05pm, LH001)
    Key for the final prep
    Key for the A version of the first exam.
    IF YOU HAVE A SCHEDULE CONFLICT, there will be an alternate final time. It looks like we'll have December 12th, 1pm, as an alternate. SEND ME EMAIL, AND GET A CONFIRMATION IF YOU NEED AN ALTERNATE TIME. If Tuesday night works, please take the exam then.

Slides from the book

Professional Societies

Code and Logisim Examples from Class