This folder teaches the foundations behind GPU_Mastery_Guide.md and gpu_project/, from zero, one idea at a time. Every lesson has:
- Plain-language explanations, with the "why" before the "how"
- The math, with worked examples you can check by hand
- Runnable code (Verilog and Python), every example tested, with its real output shown
- Exercises with answers (hidden in collapsible sections: try first!)
- "How this connects to the GPU", so nothing is learned in isolation
| # | Lesson | You'll understand | Runnable code |
|---|---|---|---|
| 1 | Electricity, Transistors and Why Hardware Has Limits | Voltage, current, transistors as switches, CMOS gates, why gates have delay, power = αCV²f, clocks | — |
| 2 | Numbers and Binary Math | Binary, hex, bit widths, two's complement, overflow, fixed point, floating point | numbers_lab.py |
| 3 | Logic Gates and Boolean Algebra | Truth tables, Boolean laws, De Morgan, deriving the full adder, NAND universality | full adder + exhaustive test |
| 4 | Combinational Circuits | Mux, decoder, comparator, adder, shifter, the latch trap, width rules | 5 blocks + exhaustive tests |
| 5 | Sequential Logic and Clocks | Feedback, latches, flip-flops, registers, counters, reset, setup/hold, f_max math | register, counter, shift register |
| 6 | Thinking in Clock Cycles | = vs <=, latency vs throughput, pipelining, state machines, valid/ready |
blocking demo, traffic-light FSM, handshake |
| 7 | Memory | RAM, read latency, ports, banking, FIFOs, $readmemh, bandwidth math |
synchronous RAM, FIFO vs model |
| 8 | Computer Arithmetic | Multiplication, product widths, fixed-point Verilog, lerp, how FP add/multiply work, signed pitfalls | Q8.8 multiplier, lerp |
| 9 | How a Processor Works | Fetch/decode/execute, ISA, encoding, assemblers, decoding your GPU's instructions | a complete tiny CPU + assembler |
| 10 | From CPU to GPU | Threads, lanes, SIMD, warps, masks, divergence, latency hiding, a tour of gpu_core.sv |
SIMT lane tracer, latency-hiding timeline |
| 11 | Graphics Math | Vectors, dot product, matrices, homogeneous coordinates, perspective, edge functions, barycentrics, Z-buffer | transform walkthrough, software rasterizer (makes a PNG) |
| 12 | Tools and Workflow | Simulation vs synthesis, testbenches, GTKWave, debugging method, linting | — |
| 13 | Glossary and Final Quiz | 60+ terms, 25 quiz questions with answers, where to go next | — |
Time: roughly 1–2 evenings per lesson. Don't rush Lessons 5, 6 and 10: they contain the ideas everything else rests on.
- Read the explanation once.
- Predict what the example will print, then run it and compare. Surprises are where learning happens.
- Change something (an input, a width, a parameter) and predict again.
- Do the exercises on paper before opening the answers.
- Can you explain the "How this connects to the GPU" section to someone else? Then move on.
The tools were installed to D:\Downloads\Hardware\tools\oss-cad-suite:
. D:\Downloads\Hardware\tools\oss-cad-suite\environment.ps1
$env:VERILATOR_ROOT = "$env:YOSYSHQ_ROOT\share\verilator"
cd D:\Downloads\Hardware\GPU\hardware_basics
.\run_all.ps1 # runs every example in every lesson and reports PASS/FAILTo run a single example, follow the commands shown in its lesson (e.g. in Lesson 5: cd code\05_sequential, then iverilog ... and vvp ...).
hardware_basics/
README.md (this file)
01_ ... 13_*.md (the lessons)
run_all.ps1 (runs every example)
code/
02_numbers/ numbers_lab.py
03_logic_gates/ full_adder.v, tb_logic.v
04_combinational/ comb_blocks.v, tb_comb.v
05_sequential/ seq_basics.v, tb_seq.v
06_cycles_fsm/ blocking_demo.v, traffic_light.v, tb_traffic.v, tb_handshake.v
07_memory/ memories.v, tb_memories.v
08_arithmetic/ fixed_point.v, tb_fixed.v
09_tiny_cpu/ tiny_cpu.v, tb_cpu.v, tiny_asm.py, sum.s, sum.hex
10_cpu_to_gpu/ simt_trace.py, latency_hiding.py
11_graphics_math/ transform_demo.py, mini_raster.py