Skip to content

Blog

CPU part 17 - Small changes before going to hardware

With the caches done, the CPU is almost complete, and before some final steps and testing it on hardware I wanted to make several small changes after a review of the current progress. That is what this post is about, including some interesting timing and placement analysis on the register file.

Read more →

2026-11-15

CPU part 16 - L1 Cache part 3 (early restart)

In the previous post, a stage with a cache miss waited until the whole line was in the cache. However, the CPU only needs a single word from that line which allows us to do some smart optimizations.

Read more →

2026-11-14

CPU part 15 - L1 Cache part 2 (misses + controller)

In the previous post we saw that a cache hit costs nothing. This post is about the other case: a miss, where the line has to come from SDRAM first. It is also about the cache controller that does that work, about writing dirty lines back, and about the two instructions that clear the caches.

Read more →

2026-11-14

CPU part 14 - L1 Cache part 1 (design + hits)

Waiting for memory is very expensive in a pipelined CPU: every cycle spent waiting throws away what pipelining gains. The FPGC uses SDRAM as main memory, which is fast in terms of bandwidth but slow in terms of latency. Caches are the solution to reduce latency. They are small, fast memories inside the CPU that keep a copy of the parts of SDRAM that are used the most. This post explains how caches work, what the options are, and how a cache hit works in the B32P4. Since caches (L1 cache in this case) are quite complex, there will be multiple posts about them with this being the first one.

Read more →

2026-11-04

CPU part 13 - Interrupts

Programs often have to react to things that happen outside the CPU, like a key being pressed, a byte arriving at the UART or a timer running out. A program can keep checking for these itself, but the devices can also ask for the attention of the CPU when they need it. That is what interrupts are for. In this post I explain how interrupts work, what the options are, and how they ended up in the B32P4 CPU.

Read more →

2026-10-31

CPU part 12 - Multiply and divide

There are two seemingly simple arithmetic operations that are challenging to implement in hardware: multiplication and division. In contrast to addition and subtraction, they require more complex circuits and usually cannot be performed in a single clock cycle. This blog post will explain how they work and what ended up in the B32P4 CPU.

Read more →

2026-10-31

CPU part 11 - Waiting for memory

Until now, every memory the CPU talked to answered in exactly one cycle. Real memory is not that nice: the SDRAM the FPGC uses as main memory takes many cycles, and even with caches, a cache miss still causes a delay. In this post the CPU learns to wait for memory that answers whenever it is ready.

Read more →

2026-10-25

CPU part 10 - Stack and Error register

In this post the CPU gets its hardware stack for push and pop, and the CPU-internal I/O registers. One of these registers is new in B32P4: the error register, which tells you when a program did something it should not have done.

Read more →

2026-10-25

CPU part 9 - Reading and writing memory

So far, the CPU could only work with its 16 registers. In this post we will make a start on actually reading from and writing to memory regions.

Read more →

2026-10-25

CPU part 8 - The first pipeline

Until now, every part of the CPU lived on its own: the ALU, the decoder, the register file, and the forwarding, hazard and branch units. In this post they finally come together into a pipeline that runs actual programs. It can’t access memory yet, but it can already calculate, branch and jump, which is enough to run loops.

Read more →

2026-10-24