Skip to content

A simple 8 bit CPU experiment, with a very small BASIC like language compiler for the CPU.

Notifications You must be signed in to change notification settings

AnilBK/Simple-CPU

Repository files navigation

A Small CPU design experiment.

The CPU circuit is itself designed in Digital. https://github.com/hneemann/Digital

The compiler is written in Python,which exports the final binary in hexes. The writing of hexes is done by IntelHex python library.

Python Formatting:black

Files: Description
code_generator.py The original compiler.
code_generator_v2.py The original compiler modified with some OOP approach.It introduces the following two files.
register.py Software implementation of hardware register.
constants.py Constants required for the new compiler.
custom_code.txt This is where our programs are written.
code.hex This is the final file generated by compiler,which contains the instructions for CPU to execute.
data.hex This is another final file used by the CPU.This contains additional operands required for the main instructions.
CPU_With_Registers.dig The main CPU circuit.This file is opened with Digital.

Intermediate Files.

Files: Description
simplified_code.txt The first pass of compiler output.
generated_code.txt The final pass of compiler output.This file is then written as hexes.

However both compilers above produce same binary. V2 compiler(code_generator_v2) introduces two files(register and constants),while V1 compiler is a single file implementation.

About

A simple 8 bit CPU experiment, with a very small BASIC like language compiler for the CPU.

Resources

Stars

Watchers

Forks

Languages