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.

Note:

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 ROM (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
    • 3MHz (precise time base)
    • adjustable clock speed
  • 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)

ROML (Least significant byte of program memory)

LDI - Load with Immediate

Instruction Word
Amode:Modifier:OPCodeInstructionAffected Flags
0x000n0x00LDI ACC,n
ZF
0x100n0x10LDI RA,n
-
0x200n0x20LDI RB,n
-
0x300n0x30LDI 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 0006
  ┆    ┆    ┆    └─> Operand = 6
  ┆    ┆    └──────> MAddr = 0 (For this instruction, it doesn't matter)
  ┆    └───────────> MICRO = 0 (OPCode)
  └────────────────> HiNB = 1 (MICRO2_IN = 0, AMODE = 0, MOD = 1)

...

Basic Documentation

- MikroLeo has four Registers
ACC - Accumulator (4 bit) - Stores the result of logical and arithmetic operations. Moreover, ACC stores data that is read from or written to RAM.
RA - 4 bit General purpose Register (also used for addressing).
RB - 4 bit General purpose Register (also used for addressing).
RC - 4 bit Special purpose Register used for addressing.

- Two Flags
Flags can only be checked by conditional jump instructions (JPC and JPZ).

CF - Carry Flag - It is Set (CF=1) by ADD Instruction if it produces a carry or by SUB/CMP instruction if it results in a borrow.
ZF - Zero Flag - It is affected by operations that modify the contents of the ACC and by CMP instruction. It is Set (ZF=1) if the result of the last operation was zero.

Example of how CF and ZF are Set:

LDI ACC,1
ADD ACC,0xF  

This code does it,

   0001
+  1111
-------
 1 0000
 ↓   ↓
CF  ACC

As the value zero is written to ACC, ZF=1.

- Addressing Modes

Immediate

In immediate addressing, the operand (n) is contained in the lower nibble of the instruction (b3:b0), and it is denoted by Operand, LAddr or OPR.

Example 1:

LDI ACC,1    ;Load the operand value into the ACC accumulator.

Example 2:

LDI ACC,0xA  

Example 3:

NAND ACC,0   ;Performs the NAND operation between the accumulator and the
             ;operand value and stores the result in the accumulator.

Example 4:

OUTA...
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
Download

MikroLeo_Instruction_Encoding_v0.19_full.png

MikroLeo instruction encoding

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

Preview
Download

MikroLeo_Instruction_SET.pdf

MirkoLeo instruction set

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

Preview
Download

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