Schedule


Below is a preview of our week-by-week plan for the entire quarter. There may be slight adjustments and rearrangements as we go. The schedule for the final project is set and will not change.

In the readings below, K&R refers to Kernighan and Ritchie's classic text The C Programming Language (accessible via Stanford's subscription to Safari Books Online). Nick Parlante's EssentialC is another great C reference. Please do the recommended readings before lecture for best effect!

Week 1
Lecture
Mon 3/30
Welcome and intro to RISC-V ( slides, code )

After a quick recap of course logistics, we dive right into the RISC-V ISA and the Mango Pi MQ-Pro SBC we'll be using this quarter. Introduce instructions for arithmetic and logical operations.

Readings:

Lab/assign Lab 0: Orientation ( writeup )

Please do the Lab 0 prelab preparation before coming to lab.

Assignment 0: Git oriented ( writeup )
Lecture
Fri 4/3
RISC-V assembly and machine code ( slides, code )

More RISC-V assembly: control flow using branch/jump, load and store instructions, instruction encoding and decoding. Tools to build and execute an assembly program. GPIO peripheral control via memory-mapped I/O.

Readings:

Week 2
Lecture
Mon 4/6
From Assembly to C ( slides, code )

Moving up from assembly to C. Implementation of C expressions and control structures.

Readings:

  • Brush up on C basics (syntax, data types, operators, control structures) via your favorite C reference; sections 1-2 of Nick Parlante's EssentialC; or chapters 1, 2, and 3 of K&R. Skip content on I/O and standard libraries (we are bare metal!)
  • Read Dennis Ritchie's account of the history of C
  • Try out the Compiler Explorer demoed in lecture
  • Read our guides on make and gcc
Lab/assign Lab 1: Getting to know your Mango Pi ( writeup )

Please do the Lab 1 prelab preparation before coming to lab.

Assignment 1: Larson Scanner ( writeup )
Lecture
Fri 4/10
C Pointers and Arrays ( slides, code )

Memory, addresses, and pointers. Address arithmetic, layout of arrays and structures. Typecast and volatile.

Readings:

  • Review EssentialC chapters 3 and 6 (postpone heap and memory management for later) or K&R 5.1-5.4.
  • C volatile can be subtle and tricky. See GeeksForGeeks advice on correct use and John Regehr's blog on what NOT to do with volatile
Week 3
Lecture
Mon 4/13
C Functions ( slides, code )

How functions are implemented. Control flow: call and return. Parameter passing, local variables, return value. Coordination on use of registers. Runtime stack management.

Readings:

  • Read up on C functions (Chapter 4 in K&R, or Section 4 in Essential C).
Lab/assign Lab 2: Below C Level ( writeup )

Prelab to prep before lab.

Assignment 2: Clock ( writeup )
Lecture
Fri 4/17
Communication and the Serial Protocol ( slides, code )

Using gpio pins to transmit bits/signals, UART hardware peripheral, Ascii character set, C-strings. Strategies for testing and debuggging.

Readings:

  • Review this excellent tutorial on serial communication from Sparkfun.
  • Use your C reference to read up characters, C-strings, and output functions (putc,puts,printf) (Sections 1.5, 1.6, 1.9, 5.5, 6, 7 in K&R; or Section 3 in EssentialC). C-strings are primitive compared to Java/C++ strings; take note of the manual effort required to use and pitfalls to avoid.
  • Helpful overview with examples: C Strings are Weird: A Practice Guide
  • Read our course guides on testing and gdb debugger.
  • Historical diversion: Poul-Henning Kamp's essay on The Most Expensive One-byte Mistake. Did Ken, Dennis, and Brian choose wrong with NUL-terminated text strings?
  • Summer reading: The Victorian Internet by Tom Standage is a faascinating account of the world shift from invention of the telegraph and early digital communication.
Week 4
Lecture
Mon 4/20
Modules, Libraries, and Linking ( slides, code )

Module design, makefiles, build process, preprocessor, linking, symbol resolution and relocation, program start sequence.

Readings:

Lab/assign Lab 3: Debugging and Testing ( writeup )

Prelab to prep before lab.

Assignment 3: String Formatting ( writeup )
Lecture
Fri 4/24
Memory Management ( slides, code )

Stack allocation: stack frames, local variables, backtrace. Dynamic allocation: implementing a heap allocator. Runtime detection of memory errors.

Readings:

  • Read our overview of stack frames
  • Review dynamic memory allocation (malloc/free in C) and the operation of the heap (K&R 5.6-5.9 or Essential C Section 6). Compare and contrast stack versus heap allocation. Why do we need both?
Week 5
Lecture
Mon 4/27
C Mastery ( slides, code )

We're around the halfway point! We will use this lecture to catch-up/expand on lecture content covered lightly on first pass, and discuss how to further your mastery of C.

Readings:

Lab/assign Lab 4: Linked and Loaded ( writeup )

Prelab to prep before lab.

Assignment 4: Stack and Heap
Lecture
Fri 5/1
Keyboards and the PS/2 Protocol ( )

Prof. Chris Gregg will lead a lecture on all things keyboard: the venerable P2S/2 protocol plus bonus excursions into Midi protocol and controlling an old-school typewriter!

Readings:

  • Read Adam Chapweske's overview of the PS/2 protocol for keyboards and mice.
  • Neat video from Ben Eater demonstrating how to read PS/2 scancode via breadboard wizardry. He does it all in hardware, thankfully easier for us in software!
Week 6
Lecture
Mon 5/4
Graphics and the framebuffer
Lab/assign Lab 5: Keyboard Surfin' Assignment 5: Keyboard and Simple Shell
Lecture
Fri 5/8
Project
Week 7
Lecture
Mon 5/11
Interrupts
Lab/assign Lab 6: Drawing into the Framebuffer Assignment 6: Graphics Library and Console
Lecture
Fri 5/15
Interrupts, cont'd
Week 8
Lecture
Mon 5/18
Sensor Input
Lab/assign Lab 7: Mango Pi, Interrupted Assignment 7: System Monitor with Interrupts
Lecture
Fri 5/22
Output
Week 9
Lecture
Mon 5/25
Memorial Day
Lab/assign Lab 8: Project Team Meeting 1 Final Project
Lecture
Fri 5/29
Week 10
Lecture
Mon 6/1
Wrap or There and Back Again
Lab/assign Lab 9: Project Team Meeting 2
Lecture
Fri 6/5
No lecture (Finals)
Week 11
Final Project
Demo session Wed 6/10 at 9:00 am
Code submission due Wed 6/10 at 11:59 pm