SIMPLE COMPUTER
18 Stars     5266 Views    

Author: SDC

Project access type: Public

Description:

If you have any questions about this or other designs, feel free to shoot me an email at [email protected] I don't check it very often (since it's a secondary account), and you may not receive a reply for around a week.

A simple computer with an added RAM module. A work in progress, with much more I want to add, such as bitwise operators, a larger bus size, data type support including unsigned and signed integers, floating point numbers, conditional instructions, and more. There are two programmed versions, one that calculates the fibonacci sequence, and the other uses conditional instructions to determine whether it should increment a number, or halt the program. And there is also the first design I've made, which has a lot of unneeded parts in it.


UPDATE 1: added a jump instruction to allow loops and other useful applications.

UPDATE 2: Made a second version of the design, and made a better instruction set for it, removed the Memory register, since it's totally unnecessary with a RAM module. The second version also calculates the Fib sequence.

UPDATE 3: Added signed integer addition and subtraction support to version 2. Of course, this limits the positive range of integers to 127, rather than 255, but c'est la vie, I'm going to expand the size of the bus anyway.

UPDATE 4: Version 2 is temporarily down, since I'm finally adding bitwise operator functions to the ALU.

UPDATE 5: Version 2 is now back in action, with some added functions such as increment and decrement by 1, as well as left bit shifting. The ALU still needs some more work, since I'm having trouble implementing a right bit shift function. Once I have bit shifting working, I might make a program that can multiply using the shift/add method.

UPDATE 6: Version 2 now has magnitude comparison and bit-shifting functions. Conditional jumps still in the works.

UPDATE 7: Version 2 finally has a conditional jump register. It can be loaded with a Boolean from either RAM or the ALU, or directly set to either 1 or 0 by way of a set instruction. I still need to add a flag register to the design, so it can detect overflows (and maybe in the future, interrupts).

BONUS UPDATE: After a few months of studying processor and computer design, I discovered that I've unwittingly designed a Von-Neumann architecture computer (as opposed to the Harvard architecture. Reference Wikipedia if these terms are unfamiliar). Frankly, I went into this project relatively blind, and just a week ago discovered that this kind of design had a name. Well, the more you know.

UPDATE 8: I've created a new CPU design, some of which I will implement into this main circuit later this summer.  Here's the link to that design: https://circuitverse.org/users/3464/projects/19687. Also, I plan to overhaul the entire design to minimize cycle inefficiencies.

Created: May 12, 2019

Updated: Apr 19, 2021


Comments

I forked the project and I am confused by how to to program it.

Posted on Aug 14 2019 at 05:16AM UTC.
+0
SDC

Hi @galaxy_wonderer, yeah, it's a little confusing because I don't separate the instructions from the data.

The general format is an instruction-first/data-second. If you're familiar with functions with computer programming,

it's kind've similar to function call/args formats. There is a slight catch though. The first byte in ROM is always

treated as an instruction. If the instruction requires an argument, the next byte is treated as data. After the instruction

and data is executed, the computer defaults to instruction mode again.

Posted on Aug 14 2019 at 09:42PM UTC. Last modified by SDC on Aug 14 2019 at 09:55PM UTC.
+0
SDC

So let me break the magnitude example program down for you, in case the above sounds confusing:

(you can follow along by examining the instruction reference sheet if you like. Note: I use Hexidecimal code, hence the 0x before each instruction, so brush

up on it if you don't remember how the numbering system works. Also, a 0d prefix before a number means I converted the hex number to Decimal )

Posted on Aug 14 2019 at 09:45PM UTC. Last modified by SDC on Aug 14 2019 at 09:49PM UTC.
+1
SDC

0x05 = ROM to ALUb transfer. (transfer the very next byte in memory to register A )

0x05 (remember, certain instructions cause the computer to treat the next byte as data, so 0x05 is the number 5)

0x1C = A > B (check if A is greater than B, and store it in the output register)

0x24 = Load boolean to Cond. Reg. from ALU (essentially, prepares the jump register. Since the operation 0 > 5

is false, a 0 is loaded into the conditional register)

0x01 = Jump to instruction if Cond. Reg. (This means, "go to the byte at address 0x?? if conditional register has a 1". Since

the register holds a 0 this round, it doesn't jump)

0x10 = address 0d16 (used in previous instruction as the destination address. Since the cond. reg. holds a 0, the computer doesn't jump)

0x13 = Increment A by 1 (self explanatory here. The amount in A, whatever it is, gets a 1 added to it)

0x0A = ALUout to ALUa transfer (we want to test the number we just incremented, so in order to do that, we need to move

the result to the A register)

0x21 = Set cond. register to true (So we can loop back to instruction 0x02)

Posted on Aug 14 2019 at 09:49PM UTC. Last modified by SDC on Sep 01 2019 at 11:17PM UTC.
+1
SDC

So you might be wondering after all of this, "What is this program doing?" It's very simple; count up to a number greater than 5 (here, that number is 6),

and stop the program when done. If it isn't greater than yet, continue looping until it is greater, then jump to the END instruction at ROM address 16

(the actual instruction is labeled as 0x0F in my instruction reference).

If you have any other questions, I'm happy to answer them. And have fun with my little project!

Posted on Aug 14 2019 at 09:51PM UTC. Last modified by SDC on Aug 14 2019 at 09:52PM UTC.
+1

I forked and increased the execution speed here:

https://circuitverse.org/users/4699/projects/simple-computer-620cfb6a-7dc8-45b5-8e6b-6cdadf29e860

Posted on Jan 13 2021 at 07:43PM UTC.
+0

the other project you linked is gone

Posted on Nov 03 2021 at 06:31PM UTC.
+0
SDC

Probably because it was set to private some time ago by someone that's very stupid... namely me. It's back to public again, though there isn't much to see. I haven't done much to it in the past year.

Posted on Nov 03 2021 at 07:47PM UTC.
+0

ok.

Posted on Jan 11 2022 at 12:54PM UTC.
+0

You must login before you can post a comment.