Close
0%
0%

MikroLeo

MikroLeo is a 4-bit microcomputer developed mainly for educational purposes and distributed for free under open-source licenses.

Similar projects worth following
4-bit Didactic Microcomputer

This project was developed mainly for educational purposes.
I hope it will be a good learning platform for those who likes electronics, computers and programming.

Since my first attempts, many efforts have been made to make this project real.

It is aimed at students, enthusiasts, hackers, professors and anyone who wants to understand or improve their knowledge of electronics and learn how a simple computer works. In addition, it is also an attempt to rescue the story about the beginning of the development of integrated circuits and computers on a single chip, to demonstrate the capabilities that these machines had at that time.

It is a fully open-source hardware and software project that can be built at home. Only the printed circuit board (PCB) needs to be produced by some company.

For the next steps, an important thing is to make good documentation for MikroLeo!

Support this project!
Help to promote and disseminate the knowledge.

For now, updates are only being made to the github repository.

https://github.com/edson-acordi/4bit-microcomputer

Main Features:

  • Implements a 4 bit CPU
  • 2k x 16 Program Memory (up to 4k)
  • 2k x 4 RAM (up to 4k)
  • 4 Output Ports (16 outputs)
  • 4 Input Ports (16 inputs)
  • Single Cycle Instruction/RISC
  • Harvard Architecture
  • 3 execution modes:
    • step by step
    • 3MHz (precise time base)
    • adjustable clock speed ( ≈ 1 Hz - 200 Hz)
  • No MPU/MCU or complex chips
  • No microcode
  • Indirect addressing to facilitate the implementation of subroutines
  • Program memory implemented with RAM to easy programming
  • It accepts 300 and 600 mils memories (for those with old DIP versions)
  • Supercapacitor or battery to keep the program in RAM (for low power version)
  • It can be manually programmed by switches or via Arduino/Esp32
  • Built with 74HCTxxx integrated circuits for low power consumption and compatibility with TTL circuits
  • All parts are through-hole for easy assembly
  • All control signals, registers and the program counter are available through the pin header connectors
  • Dual layer Single board with 295.9mm x 196.9mm

MikroLeo Architecture

Note that some buffers are used to allow viewing the contents of registers at any time, since this project is mainly intended for educational purposes.

The MikroLeo Instruction Set

Although MikroLeo has only 20 instructions, using the AMODE bit (b14) and the modifier bits (b13:b12), it is possible to encode 64 combinations of instructions, as can be seen below.

Instruction Set explanation and examples

In binary, the Instruction Word is coded as,

ROMH (Most significant byte of program memory)

b15b14b13b12b11b10b9b8
MICRO2_INAMODEMOD1MOD0MICRO3MICRO2MICRO1MICRO0

ROML (Least significant byte of program memory)

b7b6b5b4b3b2b1b0
MAddr3MAddr2MAddr1MAddr0Operand3Operand2Operand1Operand0

- Note: b15 = bit15 ... b0 = bit0


LDI - Load with Immediate

Description: Loads the operand value into a register.
Registers: ACC, RA, RB or RC
Operation: Register <─ Operand

Instruction Word
ROMHInstructionAffected Flags
0x00xn0x00LDI ACC,n
ZF
0x10xn0x10LDI RA,n
-
0x20xn0x20LDI RB,n
-
0x30xn0x30LDI RC,n
-

Examples,

Instruction Word
InstructionComment
0x0005LDI ACC,5
Load ACC with operand
0x1006LDI RA,6Load RA with operand
0x2007LDI RB,7Load RB with operand
0x300aLDI RC,10Load ACC with operand

The Instruction Word, for example, for LDI RA,6 is coded as,

0x1006
  ┆┆┆└──> Least significant Nibble => Operand[b3:b0] = 6
  ┆┆└───> Second Nibble => MAddr[b7:b4] = 0
  ┆└────> Third Nibble => MICRO[b11:b8] = 0
  └─────> Most significant Nibble => HiNB[b15:b12] = 1 

Also, the instruction word (in binary) to be manually programmed into MikroLeo using physical switches is,

0001 0000 0000 0110
  ┆    ┆    ┆    └─> Operand = 6
  ┆    ┆    └──────> MAddr = 0 (For this instruction, it doesn't matter)
  ┆    └───────────> MICRO = 0 (OPCode)
  └────────────────> HiNB = 1 (MICRO2_IN = 0, AMODE = 0, MOD = 1)

NAND - bitwise Nand
Description: Performs the bitwise Nand operation between ACC with (Operand n, RA, RB or RAM).
The result is stored in ACC.
Operations:
ACC <─ ACC NAND Operand
ACC <─ ACC NAND Register
ACC <─ ACC NAND RAM

Instruction WordROMHInstructionAffected Flags
0x01xn0x01NAND ACC,nZF
0x11x00x11NAND ACC,RAZF
0x21xn0x21NAND ACC,RBZF
0x31mn0x31NAND ACC,@RAMZF
0x71xx0x71NAND ACC,@RZF

Note:
The RAM address for @RAM is pointed by RC:MAddr:LAddr.
The RAM address for @R is pointed by RC:RB:RA.
The MAddr is represented by the letter "m".

Examples:

Instruction WordInstructionComment
0x0105NAND ACC,5NAND operation between
the accumulator
and the operand and stores it
in ACC
0x1106NAND ACC,RANAND operation between
the accumulator
and register RA and stores
it in ACC
0x2107NAND ACC,RBNAND operation between
the accumulator
and register RB and stores
it in ACC
0x310aNAND ACC,@0x0aNAND the contents of the
RAM address with ACC
and stores it in ACC.
In this case,
the RAM address = RC:0:a
0x7100NAND ACC,@RNAND the contents of the
RAM address with ACC
and stores it in...
Read more »

MikroLeoAsm_20221130.py

Python program to generate machine code for MikroLeo

x-python - 31.61 kB - 12/02/2022 at 14:35

Download

MikroLeo_Architecture_v0.19.pdf

MikroLeo Architecture

Adobe Portable Document Format - 125.04 kB - 11/28/2022 at 03:01

Preview

MikroLeo_Instruction_Encoding_v0.19_full.png

MikroLeo instruction encoding

Portable Network Graphics (PNG) - 1.48 MB - 11/28/2022 at 02:59

Preview

MikroLeo_Instruction_SET.pdf

MirkoLeo instruction set

Adobe Portable Document Format - 67.00 kB - 11/28/2022 at 02:56

Preview

MikroLeo_v0.19.dig

Simulation file for MikroLeo to be used in the Digital software (developed by Helmut Neemann)

dig - 525.87 kB - 11/28/2022 at 02:45

Download

View all 11 files

View project log

  • 1
    Building your own MikroLeo

    Coming soon...

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

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