close-circle
Close
0%
0%

smlCPU - A small CPU/Microcontroller

A small Processor which should be functional for various daily tasks.

Similar projects worth following
Please go to https://github.com/xu42am/smlCPU/ for the newest updates on this project

The ALU

You can see the ALU in the purple ring. The ALU supports 16Bit

natural numbers altough I want to implement floating point numbers. It's

return-value can be returned into the registers for further use.

The Instruction table is as following:

NOT 0000
AND 0001
OR 0010
XOR 0011
ADD/SUB 0100/1100
MOV 0101

MOV is used to move data from one register to an other.

If you want to use SUB you use 1100 instead of 0100.

The Registers

The Registers can be found in the yellow ring on the picture. There are 16 registers(r0 to r15) from which only 9 are connected to enable write in. They're each 16Bit long. The right multiplexer is used to choose the second operand for an ALU operation or to choose which register should be output to the terminal. r0 is the first operand of every ALU operation and the first operand for comparator(CMP) operations. r1 is the second operand of CMP operations. The second multiplexer is used to inspect the registers from external. If the write enable(coming from the left side) is activated on a register, the content will be updated when the clock(on the top) is active (it is set at 1High and 79Lows).

The RAM

The RAM-blocks can be seen in the green ring. It is split up in 3 parts to make it a bit easier to oversee. All RAM-blocks are activated when the RUN-pin is set to 1.

  • Data-RAM

The Data-RAM is the upper one. It holds 16Bit of Data which then can be loaded from the RAM into the Registers.

  • Instruction-RAM

The Instruction-RAM is situated in the middle. It holds 24Bit of Instructions. Here is a list of the functions of each Bit:

    • 0 to 3 activate the write enable for one register
    • 4 to 5 set the CheckRepeats option
    • 6 set write enable for r8
    • 7 reset the counter in the "Loop-Device"
    • 8 enable external input(enables the EIU)
    • 9 choose between manual Data Input from the EIU or use the return value of the last program.
    • 10 to 11 not used
    • 12 to 15 choose second operand for ALU operation or choose which register should be output to the screen
    • 16 to 19 choose ALU Instruction(see ALU part for the ALU instruction table)
    • 20 save the result of the ALU operation
    • 21 save the result of the CMP operation
    • 22 activate the "Loop-Device"
    • 23 activate CPU stepping (needed to run the CPU)

If you want the CPU to load data from the Data-RAM to a register you issue the command 800001 (the 8 is the 23rd bit and the 1 is the 0 bit). The commands are all written in HEX to have a better overview over the code(because writing 24bits in binary is a bit longer and not so good to read).

  • Address-RAM


The External-Input-Unit(EIU)

The EIU can be seen in the blue ring on the picture. The EIU is used to program the CPU from external. It is activated through a flag which is set with a SoftwareCommand. The CPU is only programmable through the EIU, making it the key to the external happening of the CPU. It is capable of programming the data-, instruction- and address-RAM. You can set a second flag to choose if you load your data from external or use a return value. When the EIU is activated the complete CPU stops and only continues if the SR-Latch is deactivated through the RES_OVRFLW-Pin.

SML-STRT-INS

More or the less the INIT-Code for the CPU. Load this File in the central RAM

sml-strt-ins - 431.00 bytes - 09/26/2016 at 19:35

download-circle
Download

SML-STRT-DAT

More or the less the INIT-Data for the CPU. Load this File in the upper RAM

sml-strt-dat - 185.00 bytes - 09/26/2016 at 19:35

download-circle
Download

SML-STRT-ADRS

More or the less the INIT-Addresses for the CPU. Load this File in the lower RAM

sml-strt-adrs - 130.00 bytes - 09/26/2016 at 19:35

download-circle
Download

Assembler.c

The Assembler for the CPU. It's not yet finished and I'll upload a more functional version later...

C Source File - 2.40 kB - 09/26/2016 at 19:34

download-circle
Download

smlRISClib.circ

Includes some stuff for the CPU

circ - 192.49 kB - 09/26/2016 at 19:32

download-circle
Download

View all 6 files

  • Arithmetic/Logic-Unit (ALU)

    Justus Fassl09/28/2016 at 19:28 0 comments

    You can see the ALU in the purple ring. The ALU supports 16Bit natural numbers altough I want to implement floating point numbers. It's return-value can be returned into the registers for further use.

    The Instruction table is as following:

    NOT 0000
    AND 0001
    OR 0010
    XOR 0011
    ADD/SUB 0100/1100
    MOV 0101

    MOV is used to move data from one register to an other.

    If you want to use SUB you use 1100 instead of 0100.

  • External-Input-Unit (EIU)

    Justus Fassl09/28/2016 at 18:58 0 comments

    The EIU can be seen in the blue circle on the picture. The EIU is used to program the CPU from external. It is activated through a flag which is set with a SoftwareCommand. The CPU is (for now) only programmable through the EIU, making it the key to the external happening of the CPU. It is capable of programming the data-, instruction- and address-RAM. You can set a second flag to choose if you load your data from external or use a return value. When the EIU is activated the complete CPU stops and only continues if the SR-Latch is deactivated through the RES_OVRFLW-Pin.

  • Improving the smlRISC-Assembler

    Justus Fassl09/09/2016 at 19:32 0 comments

    I am currently working on a better version of the smlRISC-Assembler to make it more useful for me than just entering the hexadecimal code. I will upload as soon as it works halfway "ok"...

  • Working on floating point operations and code

    Justus Fassl08/21/2016 at 17:20 0 comments

    Because I think that, 4Bit Numbers are not big enough, I decided to implement floating point operations into the ALU.

    Also I want to implement some more features into the IPU which you will see later...

  • Working on CPU-external ROM...

    Justus Fassl08/09/2016 at 19:14 0 comments

    As I promised, I've uploaded the new schematics of the CPU... for now I'm sure that the CPU-Design is good as it is... I'll try to produce a halfway understandable Video to explain the CPU when the time has come...

  • New Start

    Justus Fassl08/05/2016 at 10:39 0 comments

    It has been a long time since I uploaded... due to problems with my architecture. Because of these problems, such as a lot of simulation oscillations and not working instructions, I decided to plan a CPU like mine only with Registerbanks, how I call them, to provide a more stable environment and to be able to make big steps forward again. I'll upload the new schematics later...

View all 6 project logs

Enjoy this project?

Share

Discussions

agp.cooper wrote 06/16/2017 at 14:18 point

If your looking to write a simple but working assembler you may want to look at Sandro Maffiodo "OI" webpage (http://www.assezeta.com/sandromaffiodo/oi/), he has a simple assembler for download. It basically does three things:

1 tokenise (and remove comments)

2 resolve address/data references

3 emit/export the result

Although it is for SUBLEQ, the assembler is not actually language specific. I used it as a base for my assembler (but with more functions).

Your instruction set is similar to the PDP-8:

000 – AND – AND the memory operand with AC. 
001 – TAD – Two's complement ADd the memory operand to 
010 – ISZ – Increment the memory operand and Skip next instruction if result is Zero. 
011 – DCA – Deposit AC into the memory operand and Clear AC. 
100 – JMS – JuMp to Subroutine 
101 – JMP – JuMP. 
110 – IOT – Input/Output Transfer 
111 – OPR – microcoded OPeRations

If you want an assembler for the PDP-8 look here: 

http://homepage.divms.uiowa.edu/~jones/pdp8/index.html

Regards AlanX

  Are you sure? yes | no

Kyle N. wrote 08/21/2016 at 18:29 point

The word "compiler" in the name of your cpp file is misleading.  If it translates C/C++/Python/Etc. into either object or machine code, it's a compiler.  What you wrote is a very simplistic assembler.

  Are you sure? yes | no

Justus Fassl wrote 04/19/2016 at 14:39 point

thanks for your advice. i looked at the pdp11 for some "inspiration" and will checkout the datasheet ( I've already downloaded it).

  Are you sure? yes | no

Peabody1929 wrote 04/09/2016 at 17:28 point

It might be interesting to look at the architecture of the AMD Am2901 4-bit slice component.  It provides all the pieces to create a functional processor.  Checkout the datasheet.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates