BASIC MC-162C - A homemade programmable processor! (Logisim)

Programming, for all ages and all languages.
Post Reply
danielbj
Member
Member
Posts: 36
Joined: Thu Dec 16, 2010 3:08 pm

BASIC MC-162C - A homemade programmable processor! (Logisim)

Post by danielbj »

Hello everybody!

Some years ago I started two hobbies that have now become my favourite things to do: OSdev'ing, and learning how a processor works. I will here present to you the last mentioned hobby of mine!

I have built many (5-6) processors since I started this little project of learning how a computer works. It started at a 4-bit CPU. Then 8-bits. Then pipelining. Then no pipelining again (I never really got my head around it... :( ). Then I expanded with some cool features like calls, conditional jumps and stacks.

Now I have finally created something that might be worth sharing! :D
This is the BASIC MC-162C. It's a 16-bit processor made in a logic simulation program call Logisim.

The processor has the following key features:
  • - General purpose registers: AX, BX, CX, DX. All four can be split to AH, AL, BH, BL etc.
    - Special Purpose registers: PC, SP, BP, CR and more advanced registers to control interrupt procedures
    - Both 16-bit and 8-bit operating mode
    - Interrupts
    - Conditional and unconditional jumping
    - Stack mechanisms
    - Call/return mechanisms
    - 16-bit address bus (64KB of memory)
    - In/out-instructions (also 16-bit)
    -A ROM-chip can be connected, and 'shade' an area of RAM. Then it can later be disabled (By clearing a bit in the control register) to 'free' the shaded RAM-area.


You can download a complete pack HERE!

This package includes:
  • - The processor itself (BASIC MC-162C.circ)
    - The BASIC CHIPS library needed in logisim (BASIC CHIPS.circ)
    - A manual, to get started with the processor (Not completed... yet.) (BASIC MC-162C Manual.odt)
    - My own personal notes and plans, for those interested... also, this contains the instruction table! (BASIC MC-162C Plans.odt)
    - The microcode for the processors control logic (You don't really need this to get it running...) (MICROCODE.bin)
    - Logisim itself

When you start up logisim, open 'BASIC MC-162C.circ'. It might ask you to locate 'BASIC CHIPS.circ'. This is the file included.

When loaded you should see a chip with 16 wires going out from each side. Underneath this you'll see another chip, with a lot of numbers on it. This the RAM-chip. Right click this, and select 'Edit contents' to enter your program here.

To start the simulation, go to the menu bar -> Simulate -> Simulation Enabled (Check this)

To start the clock (And start the processor), go to the menu bar -> Simulate -> Ticks Enabled (Check this).

To speed up the clock, go to the menu bar -> Simulate -> Tick Frequenzy -> Then select a preferred rate. (There is a maximum that your computer can handle though... Mine is around 40-50 hz...)

Have fun with my little baby! :)
If you have any questions or comments, just post below! Thanks :D

Daniel Broder Jensen
UNICORN OS
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: BASIC MC-162C - A homemade programmable processor! (Logi

Post by Yoda »

Nice work!
But why you didn't consider using Verilog/VHDL for CPU modelling?
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: BASIC MC-162C - A homemade programmable processor! (Logi

Post by NickJohnson »

Looks pretty cool.

You realize logisim has multi-bit wires, right? You'd probably save yourself a lot of work if you used those.
rdos
Member
Member
Posts: 3278
Joined: Wed Oct 01, 2008 1:55 pm

Re: BASIC MC-162C - A homemade programmable processor! (Logi

Post by rdos »

Nice project. Do you sell hardware chips as well? :wink:
danielbj
Member
Member
Posts: 36
Joined: Thu Dec 16, 2010 3:08 pm

Re: BASIC MC-162C - A homemade programmable processor! (Logi

Post by danielbj »

Yoda wrote:Nice work!
But why you didn't consider using Verilog/VHDL for CPU modelling?
I am not familiar with those programs, but i will take a look at them, and see if it's something for me :D

NickJohnson wrote:Looks pretty cool.

You realize logisim has multi-bit wires, right? You'd probably save yourself a lot of work if you used those.
Yes. I've seen lot's of CPU's that use logisim's features like multi-bit wires and adders and bit shifters. I have avoided using these smart features for three reasons:

1. - My goal is to get to know how a CPU works in detail. Therefore I have removed an appropiate amount of abstraction :wink:

2. - I feel like cheating when using that stuff... :(

3. - I like watching all the blinky wires :D


rdos wrote:Nice project. Do you sell hardware chips as well? :wink:
It won't take long before they hit the market! :lol:

Daniel Broder Jensen
UNICORN OS
Congdm
Member
Member
Posts: 48
Joined: Wed Aug 01, 2012 10:53 am

Re: BASIC MC-162C - A homemade programmable processor! (Logi

Post by Congdm »

My professor also teach Computer Architecture by Logisim too! Each student have to implement the simple micro-architecture in Tanenbaum book.

Your processor is really great, you must have a lot of patience for not using any Logisim built-in features. I am too lazy to make my processor as detail as your.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: BASIC MC-162C - A homemade programmable processor! (Logi

Post by Yoda »

danielbj wrote:
Yoda wrote:But why you didn't consider using Verilog/VHDL for CPU modelling?
I am not familiar with those programs, but i will take a look at them, and see if it's something for me :D
That are not programs. That are two most popular hardware "programming" languages (in fact, hardware description languages, HDL). They used in real chip-maker industry. You just describe the behavior of your IC in that language like in other programming languages. After that you may simulate and verify the IC logic by special simulation software, for example by Icarus Verilog. Then the first step for real IC is done. Many large projects were done first in such software HDL description layer even without real samples, for example, Babayan's Elbrus E2K processor.
For your ASIC you can find many ready open source blocks at OpenCores.org. Even ready RISC or other simple CPU cores, or other very useful units, for example FPU, network or interface blocks.
Good luck!
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
danielbj
Member
Member
Posts: 36
Joined: Thu Dec 16, 2010 3:08 pm

Re: BASIC MC-162C - A homemade programmable processor! (Logi

Post by danielbj »

It is an effecient way of creating IC's for sure, but not a very good way to learn how a CPU really works.

I like learning things at the lowest possible abstraction layer. That's why I start from the ground up: creating a cpu, programming in raw bytes, then moving up to assembly. Then I moved to x86 assembly in which I program my OS (Unicorn OS). I won't program anything in higher level languages (C, C+, Java, Forth, BASIC you-name-it) before I know the inner workings of that particular language... And yes... I'm gonna have a hard time, but it is the only way I can satisfy my OCD :lol:

Daniel Broder Jensen
UNICORN OS
Post Reply