EEE120 8-BIT STUDY HUB_

Course Overview

Welcome to your EEE120 command center. This guide covers the core concepts from the first modules to help you build, debug, and design digital logic.

Course Modules

Lab Experiments

The labs guide you through building a 4-bit CPU in the 'Digital' simulator.

Module 1: Command Line Interface (CLI)

This section covers the essential commands for Bash (Mac/Linux) and PowerShell (Windows).

Bash (Mac/Linux) Commands

Navigation & Info

CommandDescription
pwdPrint Working Directory (shows your current location).
lsList files and directories.
ls -lLong list (shows permissions, owner, size, date).
ls -aList all files (including hidden . files).
cd [dir]Change directory. cd .. goes up one level. cd ~ or cd goes home.
whoamiShows your account name.
historyShows last-used commands.
man [cmd]Show the manual page for a command (e.g., man ls).

File & Directory Manipulation

CommandDescription
mkdir [name]Make a new directory.
touch [file]Create a new, empty file.
cp [src] [dest]Copy a file or directory. Use cp -r for recursive copy (folders).
mv [src] [dest]Move a file. Also used to rename a file.
rm [file]Remove a file.
rmdir [dir]Remove an *empty* directory.
rm -r [dir]Recursively remove a directory and all its contents (DANGEROUS!).
ln [src] [link]Create a link.

Viewing & Searching

CommandDescription
cat [file]Concatenate and print the entire file to the screen.
more [file]View a file, one page at a time (scroll down only).
less [file]View a file (scroll up and down).
head [file]Show the first 10 lines of a file.
find . -name "*.txt"Find files with a .txt extension in the current directory.
grep "text" [file]Search for "text" inside a file.
which [cmd]Shows the location of a command (e.g., which ls).

Pipes, Redirects, & Wildcards

SymbolDescription
>Redirect output to a file (overwrites). ls > files.txt
<Redirect input from a file. ./program < input.txt
|Pipe. Use the output of one command as the input for another. sort file.txt | grep "e"
*Wildcard: matches 0 or more characters. ls *.txt
?Wildcard: matches exactly 1 character. ls ?.txt

PowerShell (Windows) Commands

Note: PowerShell often has aliases to make commands look like Bash (e.g., ls, pwd, cat).

Navigation & Info

CommandDescription
pwd (alias)Get-Location. Shows your current directory.
ls (alias)Get-ChildItem. Lists files and directories.
ls -hiddenLists hidden files.
cd [dir]Set-Location. Changes directory.
historyGet-History. Shows last-used commands.
tracert [ip]Trace the network route to an address.

File & Directory Manipulation

CommandDescription
New-Item -ItemType directory -Path "name"Make a new directory.
New-Item -ItemType file -Path "file.txt"Create a new, empty file.
cp [src] [dest]Copy-Item. Use cp -r for recursive.
mv [src] [dest]Move-Item. Also renames files.
rm [file]Remove-Item. Use rm -r for recursive.

Viewing & Searching

CommandDescription
cat [file] (alias)Get-Content. Prints the whole file.
cat -head 10 [file]Shows the first 10 lines.
Get-Content [file] | Select-String "text"Searches for "text" in a file (like grep).
Get-Content [file] | sortSorts the contents of a file.
where.exe [cmd]Finds the location of a command.

Pipes & Redirects

SymbolDescription
>Redirect output to a file (overwrites). ls > files.txt
|Pipe. Use the output of one command as the input for another.

Module 1: Digital Logic Gates

Digital logic is described by truth tables, Boolean equations, and gate symbols.

AND Gate

Output is 1 only if all inputs are 1.

Expression: Y = A · B (or AB)

 A | B | Y
---|---|---
 0 | 0 | 0
 0 | 1 | 0
 1 | 0 | 0
 1 | 1 | 1

OR Gate

Output is 1 if any input is 1.

Expression: Y = A + B

 A | B | Y
---|---|---
 0 | 0 | 0
 0 | 1 | 1
 1 | 0 | 1
 1 | 1 | 1

NOT Gate (Inverter)

Output is the opposite of the input.

Expression: Y = A' (or ¬A)

 A | Y
---|---
 0 | 1
 1 | 0

XOR Gate (Exclusive OR)

Output is 1 if inputs are different. (Or, an odd number of inputs is 1).

Expression: Y = A ⊕ B

 A | B | Y
---|---|---
 0 | 0 | 0
 0 | 1 | 1
 1 | 0 | 1
 1 | 1 | 0

NAND Gate (NOT-AND)

The opposite of an AND gate. A "Universal Gate."

Expression: Y = (A · B)'

 A | B | Y
---|---|---
 0 | 0 | 1
 0 | 1 | 1
 1 | 0 | 1
 1 | 1 | 0

NOR Gate (NOT-OR)

The opposite of an OR gate. A "Universal Gate."

Expression: Y = (A + B)'

 A | B | Y
---|---|---
 0 | 0 | 1
 0 | 1 | 0
 1 | 0 | 0
 1 | 1 | 0

XNOR Gate (Exclusive NOR)

Output is 1 if inputs are the same.

Expression: Y = (A ⊕ B)'

 A | B | Y
---|---|---
 0 | 0 | 1
 0 | 1 | 0
 1 | 0 | 0
 1 | 1 | 1

Key Logic Concepts (from Quiz 1)

Module 2: Number Systems

Computers use binary (Base-2), but humans often use decimal (Base-10), octal (Base-8), or hexadecimal (Base-16) for convenience.

Number Base Chart

Decimal (Base-10)Binary (Base-2)Hex (Base-16)Octal (Base-8)
0000000
1000111
............
7011177
81000810
91001911
101010A12
111011B13
121100C14
131101D15
141110E16
151111F17
16100001020

Conversions

Decimal to Binary (e.g., 88)

Find the largest power of 2 that fits and subtract. Repeat.

88
- 64 (2^6) -> 1
Remaining: 24
- 32 (2^5) -> 0
- 16 (2^4) -> 1
Remaining: 8
-  8 (2^3) -> 1
Remaining: 0
-  4 (2^2) -> 0
-  2 (2^1) -> 0
-  1 (2^0) -> 0

Result: 1011000. As 8-bit: 01011000

Binary to Hexadecimal (e.g., 10101011)

Group bits into sets of 4 (nibbles) from right to left.

Binary: 1010 1011
Group 1: 1010 = 8 + 2 = 10 = A (Hex)
Group 2: 1011 = 8 + 2 + 1 = 11 = B (Hex)

Result: AB

Decimal to Hexadecimal (e.g., 1302)

Repeatedly divide by 16 and read the remainders from bottom up.

1302 / 16 = 81 remainder 6
  81 / 16 =  5 remainder 1
   5 / 16 =  0 remainder 5

Read remainders up: 516
Result: 516

Signed Binary: Two's Complement

This is the standard way to represent negative numbers in binary.

To find a negative number (e.g., -22 in 6 bits):

  1. Get positive binary: 22 = 16 + 4 + 2 = 10110
  2. Pad to N bits: (6 bits) -> 010110
  3. Invert all bits (One's Complement): 101001
  4. Add 1: 101001 + 1 = 101010
-22 (decimal) = 101010 (6-bit signed)

Range & Overflow

Number Ranges (N bits)

Signed Overflow

An overflow occurs when the result of an addition is too large (or too small) to fit in the given bits. It can only happen when adding two numbers of the *same sign*.

Rule: Overflow occurs if the carry **into** the Most Significant Bit (MSB) is NOT EQUAL to the carry **out of** the MSB.

C_in (to MSB) ≠ C_out (from MSB)  => OVERFLOW!

Example (Q10): 110100 + 110100

  ¹ ¹   (Carries)
  110100  (-12)
+ 110100  (-12)
----------
  101000  (-24)
  
C_in to MSB = 1
C_out of MSB = 1
Since C_in == C_out, there is NO overflow.

Module 2: Adders & Circuits

These are the circuits that perform binary addition.

Half Adder

Adds two 1-bit numbers (A and B). It has two outputs: Sum and Carry.

ABSumCarry
0000
0110
1010
1101

This is the circuit from Quiz Q18, Option A.

Full Adder

Adds three 1-bit numbers (A, B, and a Carry In, $C_{in}$). This allows adders to be "cascaded" or "chained" together.

AB$C_{in}$Sum$C_{out}$
00000
00110
01010
01101
10010
10101
11001
11111

Multi-bit Adders

Lab FAQs & Troubleshooting

Common issues and solutions from the EEE120 Lab FAQ.

What do I turn in?

TWO items are required:

  1. The filled-out lab template (doc or pdf).
  2. A .zip file of your *entire* lab folder.

Double-check you submitted the correct files!

GTKWave: Why are my waveforms all red (unknown 'x' state)?

This is the most common error. It means your circuit's input/output names do NOT EXACTLY match the names specified in the lab manual.

Check for:

  • Spelling errors (e.g., Cout vs cout)
  • Capitalization errors
  • Extra spaces
Digital Error: "A name is missing. Have e.g. all pins a label set?"

You have an input or output pin in your circuit that you forgot to label. Find the pin and set its "Label" property.

Digital Error: "Several outputs are connected to each other"

You have connected two outputs (e.g., the outputs of two different gates) to the same wire. This is NOT allowed.

This can also happen from an accidental "extra" wire. You may need to move components around to find where the short circuit is.

Digital Error: "Bit count of splitter is not matching"

You used a splitter/merger component, but the bits don't add up. This is common when you forget to set the "Bit count" property of a main input or output pin.

For example, if you connect a 4-bit wire to a splitter, but the input pin it's coming from is still set to the default of 1 bit.

iverilog Error: "...syntax error I give up"

This is almost always caused by a space in a name (e.g., a wire labeled "my wire"). Verilog does not allow spaces in names. Go back into Digital and remove the space.

I changed my .v file, but the simulation didn't change.

You must rerun iverilog (recompile) every time you change a .v file. The simulation only runs on the last compiled version.