Skip to content

Commit

Permalink
Add first part of the SM83 simple model
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekkio committed Feb 12, 2024
1 parent 62e4238 commit 265a953
Show file tree
Hide file tree
Showing 4 changed files with 1,384 additions and 0 deletions.
5 changes: 5 additions & 0 deletions chapter/cpu/intro.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import "../../common.typ": *

== Introduction

Game Boy SoCs contain a Sharp SM83 CPU core, which is an 8-bit CPU core closely resembling Zilog Z80 and Intel 8080 but is neither.
27 changes: 27 additions & 0 deletions chapter/cpu/simple.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#import "../../common.typ": *

== Simple model

#figure(
image(width: 70%, "../../images/SM83-simple.svg"),
caption: "Simple model of the SM83 CPU core"
) <sm83-simple>

@sm83-simple shows a simplified model of the SM83 CPU core. The core interacts with the rest of the SoC using interrupt signals, an 8-bit bidirectional data bus, and a 16-bit address bus controlled by the CPU core.

The main subsystems of the CPU core are as follows:

#grid(columns: 2, gutter: 12pt,
[*Control unit*], [
The control unit decodes the executed instructions and generates control signals for the rest of the CPU core. It is also responsible for checking and dispatching interrupts.
],
[*Register file*], [
The register file holds most of the state of the CPU inside registers. It contains the 16-bit Program Counter (PC), the 16-bit Stack Pointer (SP), the 8-bit Accumulator (A), the Flags register (F), general-purpose register pairs consisting of two 8-bit halves such as BC, DE, HL, and the special-purpose 8-bit registers Instruction Register (IR) and Interrupt Enable (IE).
],
[*ALU*], [
An 8-bit Arithmetic Logic Unit (ALU) has two 8-bit input ports and is capable of performing various calculations. The ALU outputs its result either to the register file or the CPU data bus.
],
[*IDU*], [
A dedicated 16-bit Increment/Decrement Unit (IDU) is capable of performing only simple increment/decrement operations on the 16-bit address bus value, but they can be performed independently of the ALU, improving maximum performance of the CPU core. The IDU always outputs its result back to the register file, where it can be written to a register pair or a 16-bit register.
]
)
3 changes: 3 additions & 0 deletions gbctr.typ
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
]

= Sharp SM83 CPU core

#include "chapter/cpu/intro.typ"
#include "chapter/cpu/simple.typ"
#include "chapter/cpu/timing.typ"
#include "chapter/cpu/instruction-set.typ"

Expand Down
Loading

0 comments on commit 265a953

Please sign in to comment.