New 8-bit Processor

  • Synergy
    30th Jul 2013 Member 6 Permalink

    UPDATE v1.5

    - added RAM(B) -> A

    - added RAM(B) -> B

    - increased ROM size to 116 instructions

     

    UPDATE v1.4:

    - added XOR

    - fixed bugs

     

    UPDATE v1.3:

    - added user input support.

    - fixed multiple quirks with registers and RAM

    - added functions to clear RAM addresses

     

    UPDATE v1.2:

    - instructions are now 25-bits (previously 24 bits). Details below.

    - added new function (A -> RAM while B = address)

    - fixed bug with IF EQUAL and JUMP

     

    UPDATE v1.1:

    -added decimal output support.

     

    This is the second processor/computer I have created with TPT.

     

    I have pre-loaded an example program here (calculates fibonacci sequence and places the results in RAM):

     

     

    I have quickly made a program maker. This should make it easier to create programs for the computer.

     

     

    --------------------

    CURRENT FEATURES

    --------------------

     

    100 bytes of RAM (100 x 8-bit)

    100 lines of ROM (100 x 24) (used for storing instructions)

    A/B/C registers

    ALU currently supports ADDITION, AND, OR, IF EQUAL, JUMP (will be adding SUBTRACTION and some other bitwise operations in the future. Primarily more IF (comparison) operations)

     Decimal output from RAM

     

    ----------------

    HOW TO USE

    ----------------

     

    First I will explain how the machine code works. The instructions you will be entering are 24-bit long (and will be stored in ROM). I could probably have created smaller instructions, but I couldn't be bothered with the extra space required by decoding (and probably the extra cycles).

     

    [00000000][0][0000000][0000][00000] (25-bits in total)

     

    -----------

    [00000000]

    -----------

     

    These first 8 bits are designated to hold an 8-bit value. For example, if you wanted to create an instruction to store [56] in RAM/A/B/C, you would write the value for [56] in this portion, like so [00111000].

     

    --------------

    ...............[0]

    --------------

     

    This bit is used in order to trigger the end of the program. Leave this bit 0 until the last line of your program. Giving it a value of 1 will stop the program after the current instruction.

     

    -----------------------

    ..................[0000000]

    -----------------------

     

    These 7 bits are used for 2 things.

     

    1. Specifying an address in RAM (when reading from RAM/writing to RAM). The computer features 100 bytes of RAM, and therefore only 7 bits was required in order to specify all posible locations (1-100).

     

    2. Specifying a JUMP address for ROM. Whenever you are using either a JUMP command or an IF command, you will need to specify an address using these 7 bits so that the ROM knows where to JUMP to.

     

    -----------------------------

    ...............................[0000]

    -----------------------------

     

    These 4 bits control the ALU. Depending on the state of these 4 bits, the ALU will output something different. Leave these 4 bits 0000 if you aren't using the ALU in the current instruction.

     

    0000: NOTHING (leave blank if you aren't using the ALU, ie. only shifting data between ROM/RAM/A/B/C)

     

    0001: ADD (adds A/B)

    example: [0000000][0][0000000][0001][01011] (adds A/B and places in C)

     

    0010: AND (performs AND operation on A/B)

    example: [0000000][0][0000110][0010][01100] (ANDs A/B and places in RAM SLOT 6)

     

    0011: OR  (performs OR operation on A/B)

    example: [0000000][0][0000000][0011][01011] (ORs A/B and places in C)

     

    0100: IF EQUAL (checks if A/B are equal. If they are equal nothing will happen, and the processor will continue to the next instruction. If they aren't equal, the processor will JUMP to a specified address in ROM)

    example: [0000000][0][0001111][0100][00000] (checks if A/B are equal. Jumps to ROM SLOT 15 if not equal)

     

    0101: JUMP (jumps to a specified address without an IF condition).

    example: [0000000][0][0001000][0101][00000] (JUMPs to ROM SLOT 8)

     

    NEW

     

    0110: XOR (performs XOR on A and B)

    example: [00000000][0][0000011][0110][01100] (performs XOR on A and B, stores in RAM SLOT 3)

     

    ----------------------------------

    .......................................[00000]

    ----------------------------------

    These 5 bits are used to direct the flow of data between ROM/RAM/A/B/C.

     

    00000: NOTHING

     

    00001: ROM -> A (sends a value from ROM to A. Requires you to specify a value)

    example: [00000111][0][0000000][0000][00001] (puts 7 in A)

     

    00010: ROM -> B (sends a value from ROM to B. Requires you to specify a value)

    example: [00000101][0][0000000][0000][00010] (puts 5 in B)

     

    00011: ROM -> C (sends a value from ROM to C. Requires you to specify a value)

    example: [00110010][0][0000000][0000][00011] (puts 50 in C)

     

    00100: ROM -> RAM (sends a value from ROM to RAM. Requires you to specify a value and location address)

    example: [00001110][0][0000001][0000][00100] (puts 14 in RAM SLOT 1)

     

    00101: RAM -> A (sends a value from RAM to A. Requires you to specify a location address AND the value of 255.

    example: [11111111][0][0000111][0000][00101] (reads from RAM SLOT 7 and puts in A)

    REMEMBER TO PUT [11111111] THE THE VALUE SLOT. THIS IS USED TO TRIGGER THE READ. IT WON'T PUT 255 ANYWHERE

     

    00110: RAM -> B (sends a value from RAM to B. Requires you to specify a location address AND the value of 255.

    example: [11111111][0][0001000][0000][00110] (reads from RAM SLOT 8 and puts in B)

    REMEMBER TO PUT [11111111] THE THE VALUE SLOT. THIS IS USED TO TRIGGER THE READ. IT WON'T PUT 255 ANYWHERE. THIS IS JUST A QUIRK

     

    00111: RAM -> C (sends a value from RAM to C. Requires you to specify a location address AND the value of 255.

    example: [11111111][0][0000001][0000][00111] (reads from RAM SLOT 1 and puts in C)

    REMEMBER TO PUT [11111111] THE THE VALUE SLOT. THIS IS USED TO TRIGGER THE READ. IT WON'T PUT 255 ANYWHERE

     

    01000: C -> A (sends the value in C to A)

    example: [00000000][0][0000000][0000][01000]

     

    01001: C -> B (sends the value in C to B)

    example: [00000000][0][0000000][0000][01001]

     

    01010: C -> RAM (sends the value in C to RAM. Requires location address)

    example: [00000000][0][0000001][0000][01010] (sends value in C to RAM SLOT 1)

     

    01011: A/B (ALU) -> C (sends A/B to the ALU, and then sends the ALU output to C. Requires you to specify specific ALU operation)

    example: [00000000][0][0000000][0001][01011] (ADDS A/B and places the result in C)

     

    01100: A/B (ALU) -> RAM (sends A/B to the ALU and then sends the ALU output to RAM. Requires you to specify a specific ALU operation and location address).

    example: [00000000][0][0100000][0011][01100] (performs AND on A/B and places the result in RAM SLOT 32)

     

    01101: RAM -> OUTPUT (outputs specified RAM location in decimal format. Requires you to specify a RAM location and also trigger all value inputs [11111111] in order to read from the RAM)

    example: [11111111][0][0000111][0000][01101] (outputs RAM SLOT 7 in decimal)

    REMEMBER TO PUT [11111111] THE THE VALUE SLOT. THIS IS USED TO TRIGGER THE READ. IT WON'T PUT 255 ANYWHERE

     

    NEW

    01110: A -> RAM, while B = address (outputs A to RAM. The address is specified via the value stored in B. Remember, there are only 100 slots for RAM, so it won't function properly if B is larger than 100).

    example: [00000000][0][0000000][0000][01110]

     

    NEW

    01111: CLEAR RAM SLOT (clears a specific RAM slot, specified by ROM)

    example: [00000000][0][0000101][0000][01111] (clears RAM SLOT 5)

     

    NEW

    10000: CLEAR RAM SLOT with A (clears a specific RAM slot, address is specified by the value in register A)

    example: [00000000][0][0000000][0000][10000] (clears RAM SLOT using register A for address)

     

    NEW

    10001: CLEAR RAM SLOT with B (clears a specific RAM slot, address is specified by the value in register B)

    example: [00000000][0][0000000][0000][10001] (clears RAM SLOT using register B for address)

     

    NEW

    10010: INPUT (user) -> RAM (takes decimal input from user and stores the value in RAM. Uses specified address)

    example: [00000000][0][0000011][0000][10010] (lets user input a value from 0-255 which is stored in RAM SLOT 3)

    In order to input a number like 147 for example, press any combination of values that will add up to it like: 50,50,40,7. When the full number is entered, press confirm.

     

    NEW

    10011: RAM(B) -> A (this command allows you to use B as the location variable for reading RAM, to A)

    example: [11111111][0][0000000][0000][10011] (B=20) (reads RAM(20) and sends it to register A)

    REMEMBER TO PUT [11111111] THE THE VALUE SLOT. THIS IS USED TO TRIGGER THE READ. IT WON'T PUT 255 ANYWHERE

     

    NEW

    10100: RAM(B) -> B (this command allows you to use B as the location variable for reading RAM, to B)

    example: [11111111][0][0000000][0000][10100] (B=25) (reads RAM(25) and sends it to register B)

    REMEMBER TO PUT [11111111] THE THE VALUE SLOT. THIS IS USED TO TRIGGER THE READ. IT WON'T PUT 255 ANYWHERE

     

     

    ---------------------------------------------------------------------------------------------

     

    Would appreciate feedback, and bugs if you find any. This is the most basic version, and I will be adding extra ALU operations soon + removing any bugs that might be found. If you don't want to learn how to use it, just open the save and press START to see the fibonacci sequence program run.

     

    Edited 10 times by Synergy. Last: 6th Aug 2013
  • dom2mom
    30th Jul 2013 Member 1 Permalink

    Absolutly incredible. Too bad there are only a few people who can really enjoy this :(.

    Edited once by dom2mom. Last: 30th Jul 2013
  • Synergy
    30th Jul 2013 Member 2 Permalink

    Cheers mate.

  • UnEntitled
    30th Jul 2013 Member 0 Permalink

    Really nice to see a new processor. Awesome job.

  • Ourous
    30th Jul 2013 Member 0 Permalink

    I'll never be able to make something this complex, but I know enough to appreciate this. Awesome.

     

    Now back to work on my gaussian distributor array

    Edited once by Ourous. Last: 30th Jul 2013
  • b-tenthousand
    31st Jul 2013 Member 0 Permalink
    This post has been removed by jacksonmj: offtopic
  • Ourous
    31st Jul 2013 Member 0 Permalink

    @b-tenthousand (View Post)

     Offtopic, go away.

  • plead-for-destruction
    31st Jul 2013 Member 0 Permalink
    @b-tenthousand (View Post)
    For knowing the admins you sure do break a lot of rules.
    @Synergy (View Post)
    What. The. ****?

    I can't even fathom the amazingness(hehe) of this! :D
  • Synergy
    31st Jul 2013 Member 0 Permalink

    Thanks guys.

     

    Also I just realized I should probably add an STDIN/STOUT function. Luckily I already have a binary to decimal converter for STDOUT.

     

    So things I will be adding should include:

     

    STDIN

    STDOUT

    SUBTRACTION (unless it slows things down too much)

    IF >

    IF <

    XOR

    INCREMENT

    DECREMENT

     

    It would be really nice if TPT had single pixel logic gates. I wonder why these elements haven't been implemented yet.

  • Ourous
    31st Jul 2013 Member 0 Permalink

    @Synergy (View Post)

     

    I'm going to sound like an idiot, but I can't seem to find exactly where the result of the program goes.

    Edited 2 times by Ourous. Last: 31st Jul 2013