Logic Cortex -Programmable Microprocessor (WIP)

    Joined
    Mar 1, 2015
    Messages
    291
    Reaction score
    176
    • Wired for Logic
    • Community Content - Bronze 2
    • Purchased!
    Logic Cortex model A: Logic Cortex
    My first functioning computer in starmade.
    Since the fleet competition finished, I quickly realized that I no longer needed to crank out ships, so I instead decided to return to the logic side of things. Suffice it to say, I have got a bit carried away with this one:

    This is the Logic Cortex Model A. My first foray into making a fully programmable microprocessor. It's intended use? To be put in anything that requires advanced control, like a giant robot. ;) The intended specifications are as follows:

    *4hz clock, hopefully allowing the system to execute one instruction cycle a second.
    *32 I/O pins. With up to four configurable interrupts.
    *16 8-bit registers.
    *64 13-bit program memory cells. 4-bit oppcode, 1-bit to define whether the value is a constant, and an 8-bit value.
    *Programming UI
    *CU with at least 3kb of cache memory.
    *ALU with add/subtract
    *Shift Register
    *Programmable Program Counter
    *Support for the following instructions:
    0000 Goto-Value(Resets program counter with a new value)
    0001 StoreCache-C/R-Value(Stores a number in the cache. Storing 00000000 will clear the cache)
    0010 Pinout-C/R-value(Outputs a value to the pins)
    0011 PinsIn-Selection(in byte-long steps)
    0100 Add-C/R-Value(added to cache, output by result)
    0101 Subtract-C/R-Value(added to cache, output by result)
    0110 Result-Memory Selection (Outputs the results of a calculation to a register)
    0111 AND-C/R-Value(added to cache, output by result)
    1000 OR-C/R-Value(added to cache, output by result)
    1001 NAND-C/R-Value(added to cache, output by result)
    1010 NOR-C/R-Value(added to cache, output by result)(with nothing in the cache, behaves like a NOT operation)
    1011 XOR-C/R-Value(added to cache, output by result)
    1100 A==B-Value(compared to cache, skips the next operation if false)
    1101 A>B-Value(compared to cache, skips the next operation if false)
    1110 A<B-Value(compared to cache, skips the next operation if false)
    1111 <<-Left/Right(output by result)

    If the programming is too difficult, I may alter the logic processor to take up less of the instruction set, or add another bit to each program cell to double my oppcodes.

    A more speciffic account on how the processor will work: The entire processor hopefully will be clocked at 4hs, however, it will take all four quarters of a second to execute one instruction cycle. The first stage is reading the program memory, the second is translating it into an action and executing it, the third step is reading the resulting value, and the fourth is iterating the counter or executing a GOTO. The processor works on 3kb of cache memory. One is temporary storage for storing the B-variable, typically being loaded up with direct input from a constant or a register. The other is long term storage for the A-variable, which is accessed by the StoreCache instruction. The result is that it works with a smaller program memory cell, but it is relatively inefficient.

    One thing I might try to do is change the program counter so that it can work with a pipeline. Difficulty is that it would have to pause on a GOTO every time in case the program can skip it. Any tips on how to reduce the time footprint, or increase the speed is appreciated.

    The only things I have not put in are the programming user interface, and the control unit. And possibly a pipeline if the system is too slow.

    Another pic:


    It is likely that I will perfect this over multiple iterations, as well as develop new models. I will document my progress on this thread.

    Any tips and comments would be appreciated.

    EDIT: Post reconstruction imminent!
     
    Last edited:
    Joined
    Jun 27, 2013
    Messages
    895
    Reaction score
    165
    4Hz clock cycle for something that complex sounds challenging, will it hold up under load/lag?
    I admit the most complex stuff I have built was a pseudo random generator quite some time ago, and it had occasional issues running with a very basic 2Hz delay clock.
     
    Joined
    Mar 1, 2015
    Messages
    291
    Reaction score
    176
    • Wired for Logic
    • Community Content - Bronze 2
    • Purchased!
    what would you use something like this for?
    I plan to put it in a giant robot.

    4Hz clock cycle for something that complex sounds challenging, will it hold up under load/lag?
    I admit the most complex stuff I have built was a pseudo random generator quite some time ago, and it had occasional issues running with a very basic 2Hz delay clock.
    No idea. The most laggy part is the program memory buffer. It barely handles 2hz... But I only have to run the memory components at 2hz(I think, never done this kind of thing before), even with the 4hz timer. Basically only the first and last clock cycles are used for the program counter, while the other processes run in between this time. Effectively the program code is run at 1hz, but the microcode (processes to run the program code) is clocked at 4hz.
     
    Joined
    Feb 25, 2016
    Messages
    1,362
    Reaction score
    268
    Mind blown.

    Now, the question is, how fast can you make a computer inside of a computer? Then, can you go all computer-ception and make that StarMade computer (Somehow...) run a computer of its own?
     
    Joined
    Mar 1, 2015
    Messages
    291
    Reaction score
    176
    • Wired for Logic
    • Community Content - Bronze 2
    • Purchased!
    A quick update, and sadly a step backwards:

    I am redoing the memory cells to use OR blocks in the memory bus, as opposed to the glitchy activator blocks. I kept getting really weird signals and glitches with the bus, so after failed attempts to add a noise terminator, I decided that an overhaul was in order.
     
    Last edited:
    Joined
    May 28, 2016
    Messages
    82
    Reaction score
    45
    You sir, have all the goddamn respect i can give !

    Btw, don't you spend more time connecting the logic together than actually building it ? I guess it takes some serious dedication !
     
    • Like
    Reactions: Trekkerjoe
    Joined
    Mar 1, 2015
    Messages
    291
    Reaction score
    176
    • Wired for Logic
    • Community Content - Bronze 2
    • Purchased!
    You sir, have all the goddamn respect i can give !

    Btw, don't you spend more time connecting the logic together than actually building it ? I guess it takes some serious dedication !
    Yes, the logic takes a long time to connect, however, copy/paste is your friend. It allowed me to build up the memory cells in a relatively short time, and allowed me to simply paste down many of the components so that I didn't waste time recreating them.

    Anyway, I'm off to resolve the cortex's sudden onset of amnesia.
     
    Joined
    May 28, 2016
    Messages
    82
    Reaction score
    45
    Oh alright ! Well then a question coming to my mind, when you copy paste a bunch of logic does the wiring stay the same in the copy ?
     
    Joined
    Mar 1, 2015
    Messages
    291
    Reaction score
    176
    • Wired for Logic
    • Community Content - Bronze 2
    • Purchased!
    Oh alright ! Well then a question coming to my mind, when you copy paste a bunch of logic does the wiring stay the same in the copy ?
    Usually. Sometimes I get an error, but I have not been able to find anything wrong with the circuits afterward.
     
    Joined
    Mar 1, 2015
    Messages
    291
    Reaction score
    176
    • Wired for Logic
    • Community Content - Bronze 2
    • Purchased!
    Another update:

    After resolving the sudden amnesia, I began working on the CU. So far I got only two commands working, but both of them were difficult to implement. The first one that I worked on was GOTO. What made this difficult was that it is actually part of the program timer, not the CU, so problems cropped up when I was working on the next command, StoreCache. I decided midway through development that I wanted some branching logic to allow me to store the variables of two registers in one command. This led to hours of work, and eventual adoption of a counter for the microcode so that everything synced up properly. This led to a conflict in GOTO that led to yet more hours of debugging.

    I have everything working now. Maybe not 100% reliable, but it works quite well. I tested it with a simple 3-line program. The complexity of the switching logic in the StoreCache command is ironically contrasted with my solution for switching logic for the code itself. Just skip a line if the condition returns false, which is simply force-feeding an iterate command into the program counter... All that debugging was beginning to wear me down when I (accidentally) found the solution.

    One problem I noticed with the system, however, is if you turn if off while it is trying to store data from multiple registers, it temporarily breaks. Another is that it gets progressively more ugly as I work on it. Still, I have laid the groundwork for for many of the other micro-instructions, so I am quite pleased.
     
    Joined
    Mar 1, 2015
    Messages
    291
    Reaction score
    176
    • Wired for Logic
    • Community Content - Bronze 2
    • Purchased!
    Update, I realized that I needed to set up the I/O if I was going to make every command in order of appearance:

    It may look lopsided, for I decided I needed an exploded view so that I could still have easy access to the CU. Don't worry, I will paste everything in the correct place when I'm done. I had renamed the commands for pins to to reflect that they are actually more like I/O ports.
    Ports 0-3 represent the 8-bit I/O , each with 8 bits of input, and 8 bits of output. A grand total of 32 pins for input, and 32 pins for output, 64 pins total. This is not counting port 4, which includes a barebones serial transceiver, which effectively adds another 8 bits of output, and 8 bits of input. However, I have not set it up to avoid data collisions, something I might address during the final touch-ups.

    I also spent the good part of my time writing descriptions for the instructions, for added usability, and to help me make the CU function as expected.

    Here is a massive GIF of the transceiver being demonstrated:

    Just another cog in this growing monstrosity.
     
    Joined
    Jul 21, 2013
    Messages
    2,932
    Reaction score
    460
    • Hardware Store
    Will this microprocessor always remain a microprocessor, or do you plan to include immedeatly attached forms of mass storage I(O) devices? (e.g. an adapted Punchcard Reader )
     

    DrTarDIS

    Eldrich Timelord
    Joined
    Jan 16, 2014
    Messages
    1,114
    Reaction score
    310
    I'd love to see your base-code in action. Tried out wireless for bootable media, or is this a hand-loader when it comes to the programming and reset-to-factory?
     
    Joined
    Mar 1, 2015
    Messages
    291
    Reaction score
    176
    • Wired for Logic
    • Community Content - Bronze 2
    • Purchased!
    Will this microprocessor always remain a microprocessor, or do you plan to include immedeatly attached forms of mass storage I(O) devices? (e.g. an adapted Punchcard Reader )
    It is already quite big, so I do not have any plans to include it, however, I am trying my best to allow players to attach peripherals like this. In fact, I can say with near certainty that you will be able to attach things like this.

    I'd love to see your base-code in action. Tried out wireless for bootable media, or is this a hand-loader when it comes to the programming and reset-to-factory?
    I have actually thought about wireless programming, and the lesser-known rail collision programming(sort of like a stationary punchcard reader.). I ultimately decided I wanted to have the programming UI built-in. It is not the most pretty UI, but it is functional, which is more than enough for a first go. When I'm finished with it, I plan to try operating a robot arm with it, and set it up for a simple form of CV.
     
    Joined
    Mar 1, 2015
    Messages
    291
    Reaction score
    176
    • Wired for Logic
    • Community Content - Bronze 2
    • Purchased!
    Update: Not anything worth a pic, just a quick update on the Cortex. I had, after much frustration, decided to simplify the CU a bit. Basically, I removed most of it's flexibility with reading code, and adopted a more rigid setup. I was trying to get it to load up the caches with register addresses from the Value before performing the calculation, but this led to too many exceptions to the rules I already laid out. Instead, you will have to instruct the Cortex to load up the caches in code. This will not impact it's speed, but it takes up more memory.

    Now that I got this out of the way, I was able to add in Add,Subtract and the ResultCache commands. You can now load up two variables into the cache, perform a calculation, and then store that calculation in a variable for later. While I wanted to do this in a minimum of two commands, it can accomplish the same in a minimum of three commands.

    Soon I will be done with the rest of the commands. Only have the logical commands and the conditionals to go! When I am finished I will update the OP to reflect this. Then comes testing!