Close
0%
0%

smlCPU - A small CPU/Microcontroller

A small study I did without a clear plan.

Similar projects worth following
I built this Processor to get an own understanding of how computers work in detail.
I'm taking this project as an inspiration for a new development and now I know what I can change.

The CPU consists mainly of:

Memory The memory contains the Program, Data and Address Information, which is decoded and processed by the ALU, Registers or Loop Device

Registers(rX) "Working Memory" of the CPU, quick load and save of data for ALU or Loop Device r0 is straight connected to the first input of the ALU, r31 is connected to the Loop Device

ALU The ALU processes arithmetical and logical instructions. The first input is straight wired to r0 the second input can be chosen(r0 to r31). The result of the ALU operation is returned to a register.

Loop Device The Loop Device controls the Program Execution and is responsible for Comparative Jumps(Alternate Address) in Memory It has a counter for counting iterations of a loop.

The Instructions of the CPU are:

LOAD Load Data from Memory to specified Register 

MOVE Move Data from Register A to Register B

EN_EXT enable external Input to Register A

LD_RES reset the counter in the Loop-Device

LD_ACT activate the counter in the Loop-Device (Loop-Device =+ 1)

LD_TGL switch between compare and count mode

CMP_GR jumps if r31 is greater than Register A

CMP_LE jumps if r31 is less than Register A

CMP_EQ jumps if r31 is equal Register A

HLT halts the CPU

EN_PRGM enables programming mode

INV inverts r0 and stores result in Register A

OR "or"s r0 and Register A and stores the result in Register B

XOR "xor"s r0 and Register A and stores the result in Register B

AND "or"s r0 and Register A and stores the result in Register B

ADD adds r0 and Register A and stores the result in Register B

SUB subtracts Register A from r0 and stores the result in Register B

0 load 0 0 5 1
1 load 1 0 3 2
2 add 1 2 0 3
3 hlt 0 0 0 4
4 hlt 0 0 0 5

this program adds 5(r0) and 3(r1) together and stores it in r3

the downloadable files are on github.com/jfassl/smlCPU

  • 1 × NTE74LS181 4 Bit ALU Slice Component
  • 10 × CD4555BE Demultiplexer
  • 10 × CD4052BE Multiplexer
  • 10 × CD4069UBE Inverter
  • 10 × CD4013BE Registers

View all 9 components

  • Building the CPU

    Justus Hausmann09/10/2017 at 11:31 0 comments

    I started building the CPU back in July. The listed components are not all I will need but for now it is what I've ordered and the next parts I'll order will be posted too.

View project log

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

Justus Hausmann wrote 09/05/2017 at 07:20 point

thank you for your help, i appreciate it.  You can look forward to an update on the project

  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 Hausmann 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

zpekic wrote 08/18/2017 at 23:27 point

I have built a similar 4-bit minimalist CPU around Am2901 in VHDL, running on the Mercury FPGA board. Code is here: https://github.com/zpekic/tinycomputer

  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