CS 2810: Computer Organization and Architecture
Fall 2025
Week 1: Aug 18–22. Classes begin Wednesday
- Thursday, Aug 21: Introduction and the Programmer’s Model
- Course overview: What is computer architecture?
- The hardware/software interface: a contract.
- Logistics: Syllabus, website, introduction to Codegrinder.
- Big Picture: Abstraction layers in a modern computer.
- The programmer’s model: registers (
x0
-x31
). - In-class Activity: Students work in small groups with a worksheet showing a simple program’s execution trace. The goal is to collaboratively build a mental model of the registers and instruction flow by analyzing the effect of each instruction on the machine’s state.
- A first instruction:
addi
(add immediate). - Dissecting an instruction: opcode, destination, source, immediate.
Week 2: Aug 25–29.
Tuesday, Aug 26: The Single-Cycle Datapath
- Goal: Build a hardware machine that can execute RISC-V instructions.
- Start with the program counter (PC) and Instruction Memory.
- Decoding the instruction and reading from the Register File.
- The Arithmetic Logic Unit (ALU): the calculator of the CPU.
- In-class Activity: On whiteboards, student groups trace the datapath for an
sub x5, x6, x7
instruction, highlighting the active wires and control signals. - What about
addi
? The role of the immediate generator and multiplexers (MUXes). - Updating the PC to
PC + 4
.
Thursday, Aug 28: Branching and Conditionals
- Review: Datapath for R-type and I-type arithmetic.
- The need for control flow:
if
statements. - Branch instructions:
beq
(branch if equal). - How to implement
beq
in hardware? Compare registers and check for zero. - In-class Activity: Groups translate a C
if-else
statement into RISC-V assembly, then trace one of the paths on a simplified datapath diagram. - From C to Assembly: implementing a simple
if (a == b)
. - Other branches:
bne
,blt
,bge
.
Assignment Due: rv64: hello world
Week 3: Sep 1–5. Labor day holiday, no Monday classes.
Tuesday, Sep 2: Loops and Control Flow Structures
- Review:
if-else
structures using conditional branches. - From C to Assembly: implementing
while
andfor
loops. - The canonical loop structure: test condition, body, jump/branch.
- In-class Activity: Students convert a C
for
loop that calculates a sum into RISC-V assembly. Discuss different valid implementations. - Nested loops and register management.
- Introduction to pseudoinstructions (
li
,mv
,j
).
- Review:
Thursday, Sep 4: The OS Interface and Introduction to Functions
- Big Picture: How does your program run? The Operating System.
- The concept of a process and its memory layout: text, data, stack, heap.
- System Calls: How a user program requests services from the OS (
ecall
). - In-class Activity: Students write a simple program that uses
ecall
to print their name to the console. - Motivating the need for functions: abstraction and code reuse.
- The key instructions:
jal
(jump and link) andjalr
(jump and link register).
Assignment Due: rv64: conditionals
Week 4: Sep 8–12.
Tuesday, Sep 9: Leaf Functions and the ABI
- Review:
jal
andjalr
. - The Application Binary Interface (ABI) for functions: arguments in
a0-a7
, return values ina0-a1
. - A simple leaf function (a function that calls no other functions).
- In-class Activity: Write a simple leaf function
int add_three(int a, int b, int c)
and the corresponding calling code in RISC-V. - Walkthrough: A complete example of a caller and a leaf callee.
- Discussing the limitations: What happens if the callee needs to use a register the caller was also using?
- Review:
Thursday, Sep 11: Intro to the Stack Problem & Register Conventions
- Review: The
ra
register is fragile. What if a function calls another function? - The problem: A non-leaf function needs to preserve the original
ra
. - Introduction to register saving conventions.
- Temporary registers (
t0-t6
): Caller must save if needed. Callee can trash. - Saved registers (
s0-s11
): Callee must save/restore if used. Caller can trust them. - Quiz 1: rv64: simple functions with conditionals
- Review: The
Assignment Due: rv64: loops
Week 5: Sep 15–19.
Tuesday, Sep 16: The Stack
- Review: The problem of saving
ra
and thes
vst
register convention. - Solution: The stack segment of memory and the stack pointer (
sp
). - The stack frame: a private section of the stack for a single function call.
- Allocating and deallocating a stack frame by modifying
sp
. - In-class Activity: Trace a non-leaf function call. Groups draw the stack, showing the
stack frames for the caller and callee, and track the values of
ra
,sp
, and one saved register. - Storing and restoring
ra
ands
registers usingsd
andld
.
- Review: The problem of saving
Thursday, Sep 18: Memory and Arrays (Basics)
- Review: The five parts of a computer, including Data Memory.
- Load and Store instructions:
ld
(load doubleword),sd
(store doubleword). - Addressing mode: base + offset.
ld rd, offset(rs1)
. - Accessing elements in an array by calculating the offset (index × elementSize).
- A simple loop to sum the elements of an integer array.
- Quiz 2: rv64: simple functions with loops
Assignment Due: rv64: arrays
Week 6: Sep 22–26.
Tuesday, Sep 23: Advanced Memory Access
- Review: Array access in a loop.
- Global vs. local data. The
.data
and.text
segments. - Loading the address of a global variable using
la
(load address). - Structs in C: a contiguous block of memory for related variables.
- In-class Activity: Given a C struct definition, groups determine the memory layout and write assembly code to access a specific field of the 10th element in an array of those structs.
- Implementing structs in assembly: accessing fields via offsets from a base pointer.
Thursday, Sep 25: Digital Logic Fundamentals
- A shift from software to hardware.
- From transistors to logic gates (a brief overview).
- Boolean logic: AND, OR, NOT. Truth tables and logic symbols.
- Building a 1-bit adder from basic gates.
- Building a 4-bit ripple-carry adder by chaining 1-bit adders.
- Building a simple 1-bit ALU that can do AND, OR, and ADD.
- Quiz 3: rv64: memory and arrays
Week 7: Sep 29–Oct 3.
Tuesday, Sep 30: From Pipelining to Parallelism
- Review: The single-cycle datapath is simple but slow.
- A better idea: Pipelining. The 5-stage RISC-V pipeline concept.
- The challenge of pipelining: Hazards.
- Control Hazards and the role of Branch Prediction.
- In-class Activity: Groups trace a short sequence of dependent instructions through a pipeline diagram, identifying where a stall would occur and how forwarding resolves it.
- The limits of Instruction-Level Parallelism (ILP).
- Modern CPU techniques: Superscalar, Out-of-Order Execution.
- A “tourist view” of other forms of parallelism: Data Parallelism (SIMD, GPUs) and Thread-Level Parallelism (Hyperthreading, Multicore).
Thursday, Oct 2: Recursive Functions
- A capstone software topic that relies on a solid understanding of the stack.
- What is recursion? A function that calls itself. Base case and recursive step.
- Example: Factorial.
- Mapping recursive factorial to RISC-V. The stack frame is crucial.
- Tracing
factorial(3)
on the stack as it builds up and unwinds. - Quiz 4: rv64: function calls
Assignment Due: Sudoku pencil marks calculator
Week 8: Oct 6–10. Fall break, no classes Thursday or Friday.
- Tuesday, Oct 7: Midterm Exam
Week 9: Oct 13–17.
Tuesday, Oct 14: From Assembly to C
- Welcome back: Connecting the two halves of the course.
- C as a “portable assembly language.”
- Basic program structure and compilation (
clang -S
). - Variables, types, and operators and their mapping to assembly.
- In-class Activity: Groups are given a simple C program and its corresponding RISC-V assembly output. Their task is to annotate the assembly, connecting each C line to the instructions that implement it.
Thursday, Oct 16: Control Flow in C and Memory Layout
- Control Flow (
if
,while
,for
) and Functions in C. - Examining the assembly: The compiler manages the ABI and stack frame for us.
- In-class Activity: On a whiteboard, draw the memory layout of a simple
program with one global variable and a function containing two local variables.
Use
&
to find and label their hypothetical addresses. - Revisiting the process memory layout: text, data, stack, heap.
- The
&
operator: getting the memory address of a variable.
- Control Flow (
Week 10: Oct 20–24.
Tuesday, Oct 21: Introduction to Pointers
- The most important topic in C: pointers are just addresses.
- Declaring, assigning (
&
), and dereferencing (*
) pointers. - In-class Activity: Groups trace a short code snippet that declares a variable and a pointer, assigns the address, and changes the variable’s value directly and then through the pointer, tracking the values of both.
- Pointer arithmetic:
ptr + 1
increments the address bysizeof(*ptr)
.
Thursday, Oct 23: Pointers and Arrays
- The big reveal: In C, an array name is (mostly) a constant pointer to the first element.
array[i]
is syntactic sugar for*(array + i)
.- In-class Activity: Write two versions of a
strlen
function: one using array indexing[]
and one using only pointer arithmetic*
and++
. - Passing arrays to functions (you are just passing a pointer).
- String literals as character arrays.
Assignment Due: c: Getting started
Week 11: Oct 27–31.
Tuesday, Oct 28: The Memory Hierarchy and Caching
- The CPU is fast, memory is slow. This is the fundamental performance problem.
- The memory hierarchy: registers, L1/L2/L3 caches, main memory.
- The principle of locality: temporal and spatial.
- In-class Activity: Analyze two loops that access a 2D array. One iterates row-by-row, the other column-by-column. Groups discuss and predict which will be faster and why.
- How a cache works (conceptual overview) and the cost of a cache miss.
Thursday, Oct 30: Structs and Memory Layout
struct
: grouping related data together.- Memory layout: fields are stored contiguously.
- Padding and alignment: why
sizeof(struct)
might be greater than the sum of its parts. - Accessing fields with
.
(for objects) and->
(for pointers to objects). - Quiz 5: c: loops and arrays
Assignment Due: c: loops
Week 12: Nov 3–7.
Tuesday, Nov 4: Dynamic Memory and The Heap
- The limits of the stack: variables’ lifetimes are tied to function calls.
- The Heap: a large pool of memory for data with a dynamic lifetime.
malloc()
andfree()
: the programmer’s contract.- In-class Activity: Groups diagram the stack and the heap. They trace a program
that creates a local variable,
malloc
s a block of memory, and assigns its address to a pointer. They show what happens when the function returns. - Memory leaks and dangling pointers.
Thursday, Nov 6: Linked Lists vs. Vectors
- Implementing a linked list node using a
struct
. - The “vector” data structure (a dynamic array) and
realloc
. - Performance comparison: Why are vectors/arrays almost always faster on modern hardware?
- Cache locality: A linked list is a cache-miss machine.
- Quiz 6: c: using pointers
- Implementing a linked list node using a
Assignment Due: c: maze solver
Week 13: Nov 10–14.
Tuesday, Nov 11: Processes and System Calls
- Big Picture: How does the shell run your program?
- The
fork()
system call: creates a nearly identical copy of the current process. - The
exec()
family of system calls: replaces the current process image with a new one. - In-class Activity: On a whiteboard, trace the execution of a simple shell
command like
ls -l
. Diagram the shell process, thefork
, the child process callingexec
, and the parent process waiting. - File descriptors:
0
(stdin),1
(stdout),2
(stderr).
Thursday, Nov 13: Bitwise Operations in C
- A return to low-level thinking.
- Operators:
&
(AND),|
(OR),^
(XOR),~
(NOT). - Shift operators:
<<
(left shift),>>
(right shift). - Practical uses: setting, clearing, and testing individual bits in a flag variable.
- Quiz 7: c: bitwise ops
Week 14: Nov 17–21.
Tuesday, Nov 18: I/O Redirection and Pipes
- How does
ls > out.txt
work? Thedup2()
system call. - How does
ls | grep .c
work? Thepipe()
system call. - In-class Activity: Groups diagram the processes and file descriptors involved
in a pipeline command like
cat file.txt | sort | uniq
. - The shell
fork
s twice, sets up the pipe between the children, andexec
s the commands. - This is the foundation of the powerful Unix command-line philosophy.
- How does
Thursday, Nov 20: Unions and Advanced Pointers
union
: storing different data types in the same memory location.- Function pointers: storing the address of a function.
void*
: a generic pointer that can point to anything.typedef
: creating aliases for complex types.- Quiz 8: c: structs
Week 15: Nov 24–28. Thanksgiving break, no classes.
Week 16: Dec 1–5. Friday is last day of classes.
Tuesday, Dec 2: Virtual Memory
- A brief, high-level overview of the final piece of the puzzle.
- Problems: How to run multiple processes without them interfering? How to run a program bigger than physical memory?
- Solution: Virtual Memory. Give each process its own private, linear address space.
- The MMU (Memory Management Unit) translates virtual to physical addresses.
- Page tables and page faults.
Thursday, Dec 4: Course Wrap-up and Final Exam Review
- Tying it all together: The journey from logic gates to a running C program.
- The “contract”: ISA, ABI, OS system calls.
- How hardware trends (caching, parallelism) influence software development.
- Review of key topics from the entire semester.
- Open Q&A session.
Assignment Due: c: Wordle solver
Finals Week: Dec 8–12.
- Exam: Final exam
Note: Changes to this schedule are likely and will be announced in class.
Resources
- Syllabus
- Examples from class
- Command-line tutorial
- The missing semester of your CS education
- RISC-V cheat sheet
- Textbook website (with slides)
- Beej’s Guide to C Programming
- Adventure by Warren Robinett
- YT playlist: RISC-V assembly language
- YT playlist: RISC-V microarchitecture
- Khan Academy on binary and hexadecimal
Setup instructions for Windows users
Setup instructions for MacOS users
Setup instructions for Linux users
Last Updated 08/17/2025