Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

XBlayz/Electron_CPU-16bit

Repository files navigation

Electron CPU (16bit)

CPU (16bit) architecture made with Logisim-evolution to learn how a CPU works on the hardware level.

A simple 16bit, 8 register, multi BUS CPU created using Logisim-evolution for testing and playing around by setting up different instruction sets and executing programs, that can be made using customs tools (simple Python programs). The CPU uses a simple Register File architecture with a direct BUS I/O interface, used to connect different peripherals. The project provides:

  • CPU logic diagram;
  • Logisim-evolution project;
  • Datasheets for all the different components:
    • CU (Control Unit);
    • IR (Instruction Register);
    • Memory;
    • PC (Program Counter);
    • RF (Register File);
  • Programming tools:
    • CU compiler v1.0 (CPU instruction set compiler);
    • Assembly compiler v0.0 (Program assembler); #TODO
  • Programs examples:
    • Old version:
      • Addition
      • Greater
    • New version:
      • ...

CPU diagram

Logisim preview (v1.0)


(How to use)

How to use the Logisim-evolution project :

Download Logisim-evolution from the GitHub page I linked here to open the Logisim-evolution project.

The project is created on version v3.8.0, but I think it wil work with all future versions.

How to load programs in the CPU :

In order to load a program in the CPU you need to compile the source code in binari using the loaded instruction set of the CPU, and then load the file in the RAM (you can load a text file like the ones in the Example - (Programs) using the Edit content/Open functionality of Logisim-evolution).

How to use the CU compiler :

If you want to change or add an instruction to the instruction set of the CPU what you need to do is:

  1. Add the RTL code (Register Transfer Language) of the instruction to this file;
  2. Add the new μ-instruction (micro instruction) to the UINS_SET dictionary (line 137 of the CU compiler) with the relative alpha signal;
  3. Recompile the CU_data.txt file by running the Python script;
  4. Put the new CU_data.txt file in the CU ROM in Logisim;

You might need to install the tqdm package, used for displaying progress bas in the terminal during the compilation process. You can use this command in your shell:

pip install tqdm

More info here.

How to compile a program :

#TODO

-Find a bug?-

If you found an issue or would like to submit an improvement to this project, please submit an issue using the issues tab above. If you would like to submit a PR with a fix, reference the issue you are referring to.

If you want any additional information about the project, post an issue and I will help you as soon as it's possible.

-Known issues- (Work in progress)

List of things to add or improve (Checked means W.I.P):

  • Machine code compiler;
  • *Fix name of misleading μ-instruction;
  • I/O functionality (+datasheet);
  • CU Compiler terminal execution;
  • CPU tool (all-in-one Python app);
  • ...

NOTE :

Take in consideration that some of the μ-instruction in the CU_Instructions-RTL (v1.0) file, relative to ALU operation that use 2 inputs, have misleading names because the order of the operation is actually reversed!

This is due to an error occurred during the naming of the μ-instruction and dose not fall back on the actual implementation.

This is only a problem for non commutative operations, like subtraction, where the actual order of operation can change the results.

The things you need to remember is that the Ri register can only be directly put in the B space of the ALU, and the Rj register can only be directly put in the A space of the ALU.

This will be solved in a future update, and when it happens this note will be removed.