Step 13: Control Matrix

The control matrix of a computer tells each individual part when to take input and output its value. There are multiple states of each operation in a computer. These states are triggered by a type of counter called a ring counter. A ring counter only has one bit high at a time and cycles through its outputs consecutively. For instance, if a ring counter has 4 outputs it will first have its first output active. At the next clock pulse it will set its second output high (and the first low). The next clock pulse will advance the bit one output higher and so on. These stages are called T states. The computer in this Instructable uses 6 T states for the operation of one command. The first three T states are what is called the fetch cycle in which the current instruction is fetched and placed into the instruction register. The program counter is also incremented by one. The second set of three T states depends on what OP code is fed into the control matrix from the instruction register. The T states are as follows:

T1: The contents of the program counter are transferred into the memory address register. (Address State)
2: The program counter is incremented by one. (Increment State)
T3: The addressed byte in the program memory is transfered into the instruction register. (Memory State)
T4: Dependent on what command is being executed.
T5: Dependent on what command is being executed.
T6: Dependent on what command is being executed.

There are two primary ways to create a control matrix: using discrete logic and using ROM's. The ROM method is the easiest and most efficient. Using discrete logic involves designing a massive logic schematic that will output the correct control words for your computer based on an OP code input. ROM stands for read-only-memory. There are several types of ROM's that you can consider for use in your build. For my computer I originally used EEPROM (electronically erasable programmable ROM) but then shifted to NVRAM (non-volatile random access memory) after the EEPROM chips failed to write. I do not recommend NVRAM as it is meant for random access memory and not permanent storage. EEPROM is the most efficient solution in my opinion.

The control matrix will have three ROM chips each having at least 32 addresses of 8 bit storage (as well as the timing and counting elements). The binary word that is sent out from the control matrix is called the control ROM and contains all of the control bits for every component of your computer. You want to be sure to organize the control bits and know their order. For no operation you want a control word that renders every part of the computer inactive (except the clock of course). The control word for the computer described in this Instructable is 16 bits in length and is stored in two of the control ROM chips. The first three addresses of the control ROM chips hold the control words for the fetch cycle. The rest of the addresses on the chip hold the control words in pairs of three for each OP code. The third ROM chip holds the memory location for the start of the control word sequence for each OP code and is addressed by the OP code itself. For instance, in my computer if you give the control the OP code 0110 it will output binary 21, which is the address of the start of the JMP command. There is an 8-bit counter in between the OP ROM and the control ROM's that counts from 0-2 (first three T states) then on the third T state loads the address outputted by the OP ROM and counts from that position until the T1 state clears the counter again. The ring and binary counter for the control matrix are controlled by an inversion of the clock pulse so that control words are present when the rising clock pulse goes to the elements of the computer. The entire process in order is as follows:

1.) T1 state clears the counter to 0, the control word stored at 0 is sent out
2.) The clock goes high and the address state takes place
3.) The clock goes low and in turn the control counter increments and control word 1 is sent out
4.) The clock goes high and the increment cycle takes place
5.) The clock goes low and the control counter increments to 2, control word 2 is sent out
6.) The clock goes high and the memory state takes place and the OP code arrives at the instruction register, T3 is also active which means on the next low clock pulse the OP control address will be loaded
7.) The clock goes low and loads the counter with the address for the first of the three control words for the given OP code
8.) T4, T5 and T6 execute the OP code
9.) T1 resets the counter, the process continues until a HLT OP is received. The HLT command stops the clock.

<p>Great manual!</p><p>I've made it using Your design, but on an unusual medium: pixels :D Here's the simulator if you wanna see this in motion operating: <a href="https://realhet.wordpress.com/2015/09/02/bitmap-logic-simulator/" rel="nofollow">https://realhet.wordpress.com/2015/09/02/bitmap-lo...</a></p><p>I programmed it to calculate the Fibonacci series, it has an extra 16 byte ROM for the program, the fetch is only 2 cycles and different instructions can break the micro-word sequence earlier as when they finish, so instruction times are ranging from 3 to 5 cycles.</p><p>It was fun to input a program only using switches, like in ancient sci-fi movies. Well, it was fun for the 1st time... After I rather made a ROM.</p>
<p>Good job bro...Nice software</p>
<p>Realhet, that is spectacular! I really like your idea of using simple CA rules to make a logic sim. It is almost like Redstone in Minecraft, but so much more powerful and less latent (and also devoid of a jungle of wires, that must be nice). Congrats on the great project. Do you know of any other users of your program yet? I'll make sure to keep an eye on your site for updates, and I'll share your work with my friends. I'm sure they will really enjoy it.</p>
<p>what if you made it using leds instead of wires. could u see where the signals were going </p>
<p>How would you program an if-statement?</p>
<p>You don't need a new opcode. What you need is a value that represents true and false as 1 and 0. You load that value into the accumulator and subtract 1. Then you do a conditional jump. If the value was 1 (true), the subtraction will cause an overflow and the conditional jump performs. If the value was 0 (false), no overflow and thus no jump occurs.</p>
<p>Since there is a register (accumulator) that stores the previous sum from the ALU you can check if the result gives a negative, positive, or zero number then with that you can add a new opcode that checks that state and jumps if the condition is true.<br><br>for example</p><p>4 - 10 = -6 -&gt; -6 is negative so any branch command with the N bit set to 1 would jump</p><p>assembly: BRN RA This would branch on negative to location stored in A</p><p>binary assuming opcode is 1000: 10001000</p><p>Where this is the bit breakdown of the opcode</p><p>BR: 1000</p><p>N: 1 | 0</p><p>Z: 1 | 0</p><p>P: 1 | 0</p><p>0: 0 | 0</p><p>Also if you want to make it more versatile you can try adding the ability for B to set the bus value then the last bit '0' could be for A or B as 0 or 1 respectively.</p>
Crikey, you've got some patience!
<p>I've got a question. All of the parts in the list are there with the exception of 2.<br>the tri state buffers and the jk flip flops<br>There was a different website with the same model as the tri state buffers<br>but<br> there wasn't a JK flip flop replacement, do I have to use the exact <br>same model as you listed or can I use a different model? and if so which<br> model should I use?<br></p>
<p>Hey! I know that this is an older post but could you give me some updated links for the Tri State Buffers and the JK Flip Flops? I tried researching the products but I don't know which models to use. Thanks in advance!</p>
<p>I'm interested in making a simple CPU that I can use to type on an LED or even LCD screen. Is this the project for me or can you point me in better direction please?</p><p>I am a complete novice at this. I'm a carpenter trying to make some kind of wooden computer!</p>
<p>Instead of building a CPU you should just build a computer with a wooden case. Computers may cost quite a bit, but you can actually get them under $300. Try using this site: pcpartpicker.com</p>
<p>Thanks for this. I hope there are parts thin enough. I want it to be like a calculator for words. I'll check out the link :D</p>
<p>If all you want it to do is act as a calculator, you might want to look into Raspberry Pi. It'll be much smaller and cheaper, Pi's are like the size of a phone.</p>
<p>Now that I think about it, the Pi can do pretty much anything a full desktop computer can, it's just much smaller. There's probably some sort of software you can use for it.</p>
<p>Thank you for your reply :D</p><p>Shortly after my original comment I actually found this guy: <a href="https://www.etsy.com/shop/writeotron?ref=unav_listing-r" rel="nofollow"> https://www.etsy.com/shop/writeotron?ref=unav_lis...</a></p><p>We're going to work together on a new one. It's a Pi!</p>
<p>Its wonderful and encouraging me to make one of my own..</p><p>sure i will press &quot; I made it &quot;. I kinda in process to build it. hee hee its awesome digital electronics</p>
<p>can someone please tell me the part list with the total no. of them used. </p><p>i did saw the part list but not the total number. I havnt read the whole tutorial yet so before i start would love to have evrything beforehand. and also please can anyone tell me based on this how much would i be able to increase its functionality . </p>
<p>Hi, don't start counting how many ic's you need... Just study the first component (I recommend clock, mar or program counter), design it and buy the integrated circuits you need. Do the same for all the components.</p><p>Not giving you the exact number and id of integrated circuits means that you can develop YOUR solution</p>
<p>How did you decide between active-low and active-high bits?</p>
<p>I mean for the control words that you used.</p>
<p>Subscribed just to push &quot;I Made it!&quot; button and to say a <strong>BIG</strong> thank you to K.H.! :D</p>
<p>Wow! I love the modular setup of the boards. That is a fantastic idea both aesthetically and functionally. I ran into EM interference issues with my breadboards' close proximity. I would imagine a setup like this has much less of a problem. Congrats again!</p>
<p>and what do you do with the carry out of the lasy 1-bit adder?</p>
It gets connected to the carry in for subtraction operations
<p>Help, I am trying to build a 8 bit computer from this but I don't understand, im building this so I can show off to my little brother... I don't understand how many chips he used and I dont understand anything past the ALU's basic add and subtract, and the register, any help would be great, please email me at hurster100@gmail.com... Once again thanks</p>
<p>What do you recommend for a power supply? I really want to do this project, but I have no idea what to do for a power supply.</p>
<p>Hi, I'm thinking about starting this project, I find it really intresting and my question is Should I make it, because I'm 17, I know binary and some eletronics, please help!</p>
<p>i want to ask about about the uses of this 8 bit computer</p>
<p>Since its 8-bit, you can do anything that requires 16 bytes of memory ( depending on your RAM ). Unless you add some external drive... which would allow you to do so much more. But just with 16 bytes of RAM you can probably do operations like:</p><p>A+B=C, then</p><p>C+B=D,then</p><p>D+A=Z,</p><p>I think.</p><p>But with an external drive of some sort your 8 bit computer will be able to do stuff like this https://www.youtube.com/watch?v=qYvr0b8jqbg ...i think?-e-dah-puzi-1998</p>
<p>16 bytes? How did you get that? Surely an 8-bit address buffer should be able to address 2^8=256 bytes of memory?</p>
<p>i am new in this topic </p><p>i think we can point to 16 Bytes memory with 5 bit address.</p><p>16 Bytes = 4 * 4 (bytes) = 32 * 32 (bit) =&gt; 2^5 = 32</p><p>am i wrong ?</p>
<p>or is it right?</p><p>to say memory we calculate this way !!!</p><p>4*16 or 5*32 or 6*64 </p><p>so if this is true </p><p>4*16 = 64 bit </p><p>64/8 = 8 byte</p><p>so for 8 byte memory we can address with 4 bit .??!!!!</p>
<p>Yeah....some people like to have a 4 bit memory address and 4 bit op code...I would personally do an 8 bit op code and memory address.</p>
<p>I mean I guess if you're not addressing much memory then it's Ok, but it would severely limit what you could do with the thing. With 256 bytes, you could even do some kind of really simple pong game.</p>
<p>Yeah....some people like to have a 4 bit memory address and 4 bit op code...I would personally do an 8 bit op code and memory address.</p>
<p>how many wires do I need? </p>
A thousand?
<p>That is a lot of wires! COOL!!!! Do you play Super Mario Bros. on it?</p>
<p>How do I use the CD4029 as a ring counter? I bought it and all I've been able to get it to do is count up/down in binary, resetting at either 15 or 9. Any help?</p>
<p>I am looking forward to making this project! I couldn't find anything like it no matter how hard I looked! Thank you for making this project available. :3</p>
<p>How do you ensure that the program counter starts out at zero?</p>
<p>What type of PROM are you using? I didn't see any parts listed for the PROM?</p>
<p>good jop, i motivated by your project, i am gonna make one sooner . i want to know how much this projects coast you ? is there any additional advice to build one like any mistakes must avoid or things that may save time ?</p>
Sure! Try using shorter breadboard wires, and plan out the layout of your computer beforehand. This will save you a bunch of grief in the future of dealing with EMF related issues and dirty clock signals.
<p>Very well structured into topics. Very well explained and crafted. Awesome job!</p>
<p>your funny</p>
<p>I think someone forgot to cable manage :P</p>
<p>Im guessing your a linus fan. ( By your picture and your comment).</p>
<p>Yes I am definitely a Linus fan :) But, my image is not a parody of Linus's image, rather its a parody of Steve Jobs famous image, so is Linus's. The comment inspiration is more Luke, not Linus. </p>

About This Instructable




Bio: All of my life I have been interested in learning the way things work. It was always hard for me to use something and just ... More »
More by spel3o:How to Build an 8-Bit Computer Make a Pocket Watch Chain for Your iPod How To Change Your MAC address (Snow Leopard) 
Add instructable to: