 Greetings, RISC-5 friends. Well, it's been a long slog trying to get this ALU up and running. So here I have boards that I've built and this is revision B and this is revision C and this is the current revision, revision D. I don't even know what happened with revision A. I think it was just messed up from the very beginning and I didn't even try it. So what happened was with revision B I found that the counters that I was using to load the ROMs into the RAMs were just the wrong counters and the wrong circuitry. So this never actually booted up. So then I went to revision C and I changed the counters to the proper chips and I thought I had everything you know set up and running and when I tested it it didn't work. So at that point I just decided to sit down and write a complete verilog simulation of the board for every single chip and for every connection between chips and I found a lot of things wrong as a result of simulating the board in verilog which is a good thing because now I know well number one I can't actually design something like this and keep it all straight without any testing. Number two it tells me that hardware design is essentially like software design. You have to test your circuitry through simulation or formal verification or something in order to make sure that it works the way you intended it to work. Let's see what else did I learn? What else did we learn? Well I've learned that to solder chips onto a board you need to use plenty of flux and I actually now have this bottle of flux that I got off eBay it's Kester 186 no clean well it says it's no clean but I don't know the board certainly needed cleaning. The interesting thing that I found is that I looked online for Kester 186 and basically all I found were these bottles and they look kind of sketchy you know because they have these homemade labels on it and I'm like what's going on why can't I just go to Kester and buy these. Well it turns out at least I think Kester only sells like these huge five gallon drums of these things basically so you know what resellers do is they buy a large container of it and then they break it up into small bottles and sell it to you out of profit which is great I think actually. So I found a whole bunch of things wrong with this it wasn't loading the Rams properly some of the logic was screwed up some of the buffers were actually connected to each other their outputs were connected to each other at certain times so it was really horrible so after I simulated everything and fixed all the problems I came up with revision D and that's what we're going to test today. So here we go and I have my what I've been calling my scoreboard because it's basically a bunch of lights and jumpers and I've got my booter over here I did actually find based on simulation that the booter was doing a little bit of the wrong thing it was actually strobing clock then right when it should have strobed right and then clock which kind of makes sense because when you reset the thing the counter is set to zero and then you want to write address zero into the Rams then you want to clock the counter so that you move to address one so you write first and then clock after that. So what I'm going to do is just plug this in and see what happens. So here is revision D it goes right in the back also you might notice that on this side I replaced the stupid thing which were these useless connectors over here with just a power LED and an ALU enabled LED. Okay so I am going to power up and let's see what happens. Alright power LED is on we're booting and we're booted so that's the theory anyway well I've got the function set to XOR so we've got XOR 0010 so this is actually 0010 and let's see if we get any XOR functionality out of this thing so let's go ahead and pull the jumper to enable the ALU. Alright so we've got one input has this bit set and this bit is not set which means that the output should be set and it is. It is a little bit hard to see because the input LED is kind of dim just because of the resistor selections that I used I wanted to make this sort of like a weak pull-up so that if there was any circuitry outputting to this bit that the jumper wouldn't actually short the output. Alright well if this is XOR then in theory I can set the same bit on the other input and the output bit should go out. Let's see if that actually works. Okay and indeed that actually worked so I can take the input bit off and then if I take the other input bit off that's an XOR function. Well let's see if the other bits actually work so I'm simply going to work my way 1, 2, 3, 4, 5, 6, 7 and so on. Alright that seems to work so let's try some other function. Let's try the OR function so the OR function means that I need to set bit 1 as a function. Okay and logic OR means that if both bits are zero then the output is zero if any one of the bits is one then the output should be one. So there is one and if I set it on the other input there is one as well and if I set both inputs the output is one so that is the OR function and I can just you know run through the bits and so far that all seems to work pretty well. Alright let's change the function to AND so I'm going to set function zero bit. Alright so now we're set up to do an AND so with an AND only if the bits on both input are set will there be an output so we have oops I missed the pins on that one. Alright so we have nothing on the output and we have nothing on the output and when we set both inputs get the jumper in the right way that's AND alright. Alright let's do something much more complicated which is add. So for add function is zero so let's add one to zero and we should get an output of one so that's correct. Let's add one plus one and the output should be two and that is correct as well excellent. Let's add three plus one and the output should be four. Excellent so far so good and let's add three plus zero and the output should be three. Excellent so far so good. Let us also because this has bit slices of four bits each let's go ahead and add one plus fifteen to make sure that we're getting spillover into the next bit slice. So there's fifteen now I'm just going to add one and we properly get sixteen. Excellent so so far this seems to work pretty well. Let's try a subtraction. Alright so for a subtraction function bit three needs to be set that's zero one two three that's the function bit oops I got the jumper in backwards alright so that's function bit three so we're now set up to do a subtraction so zero minus zero is zero and it's going to do let's see I think it's RS one minus RS two so if I have RS one set to one we should have one minus zero is one and one minus one should be zero excellent now zero minus one should be negative one or all ones and there we go all ones so subtraction actually seems to be working properly well according to my limited testing. Alright there are a few other functions to try one of them is set if equal so what's set if equal if both inputs are equal then I think it's bit zero should go high otherwise it should remain low so let's go ahead and set up function bits zero and two. Alright well zero is equal to zero so that's good let's just choose some bit like bit seven alright well that's obviously not equal let's set bit one on the other one that's obviously not equal let's also set bit seven on the second input that is also not equal and if both bit sevens are high then we're equal. Alright so that's set if equal alright we've got two other functions set if less than and set if less than unsigned so let's see if we can get that tested so let's try set if less than signed first okay so I've set up the function okay so set if less than obviously zero is not less than zero and I believe it is RS1 less than RS2 so let's set RS1 to zero and RS2 to one and the question is is zero less than one the answer should be yes and indeed the answer is yes and of course is one less than zero the answer is no. Now this is signed so if I set the 31st bit or the highest significant bit on RS1 what that actually is is the most negative value so we're going to see if the most negative value is less than zero and of course it should be this is signed and indeed it is notice that if I try to ask is one less than zero the answer is no so that bit obviously is an important bit it indicates that RS1 is negative alright now if we try and unsigned compare that's actually going to turn out to be different so let me set the function for unsigned comparison alright so we're checking is RS1 less than RS2 now of course it's not if I set a one on RS2 then the answer is yes now if I set the most significant bit on RS1 this is actually some high positive number and of course that positive number is not going to be less than one and there you go and I can even pull this off so that high positive number is not less than zero when you do an unsigned comparison so it looks like we've succeeded in creating an ALU so what this shows is that in hardware as in software testing is important especially when you have something as complex as this now the reason that I didn't go straight to testing is that I have always designed circuits with very few chips where I could hold the entire design in my mind and understand everything about it because it was just so simple well this is probably the most complex circuit that I've ever put together in my life and it turns out to be beyond the complexity threshold that I can handle so imagine now that you're the designer of this board which is a floating point unit from the I think early 80s well there's no way that you could just write the circuit down and assume that it's just going to work I am sure that they must have done some kind of simulation some sort of testing some sort of validation that this design actually worked this contains about 600 chips so yeah I think that they didn't just you know do what I did and throw together a circuit get the printed circuit board solder all the chips and then see if it worked so anyway I've learned something we've learned something we've learned a whole bunch of things number one test your hardware in simulation first then order the PCBs something else you're going to want to test every chip for bridges between consecutive pins I thought that I was doing well with my revision D board and I didn't see any bridges and then I tested every single pin and I found one bridge which could have been the end of this board so test your bridges when you are soldering use plenty of flux like Lewis Rossman does I found that the more flux you put the easier the chips would solder on and the fewer bridges that you would make and also when you created a bridge just stick more flux on it run the solder iron run the soldering iron on it and the bridge is gone especially on those flash chips which have very fine pitch Lewis Rossman probably deals with even finer pitch than I do but this is this is probably the limit of my capabilities let's see number three have plenty of indicators and number four when you are testing a board test it after you build it and make sure that you have appropriate testing gear so I think that the next thing that I'm going to do is see how fast this thing can actually add so or subtract so what I'm going to do is I'm going to subtract zero from one yeah I'm going to subtract one from zero actually and all the lights should turn on so basically this is exercising a lot of the ALU and I'm simply going to hook up a an oscilloscope and I'm going to hook up a signal generator to one of the bits and we'll see how fast we can actually go now in simulation I found that 10 megahertz is probably the limit of this I could probably go to 20 megahertz but beyond that the circuit would not settle so when I did my simulations I actually simulated actually the maximum delay on some of these chips so let's see what happens so again just to make sure I'm going to take zero and subtract one so this is me doing it manually and all the LEDs on the output light up now I'm going to keep this board in place because well that's how I'm going to connect the signals up now you might ask well okay so the ALU is going to be driving 32 LEDs isn't that going to slow things down and the answer is well yes and no the ALU is designed so that it has buffers on the output and buffers of course can do high currents and well this is actually a pretty good limit test because I don't think that I'll be drawing as much current as these LEDs do so just to start I have set up my function generator for 5 Hertz all right so we're doing some subtraction at 5 Hertz so now I can just say increase the speed okay so that's 10 Hertz so now we're at 20 Hertz and of course you know the lights are flickering and you can just sort of make it out but obviously if I go any higher you won't be able to see the flickering at all so now I need to pull out the oscilloscope okay so here I've got the oscilloscope hooked up to one of the output bits and we can see that we are outputting a nice square wave let's see the time is 10 milliseconds per division and it looks like we've got about two and a half divisions so that's 25 milliseconds which is well actually it's five divisions per cycle which is 20 Hertz so let's go ahead and increase the frequency and see what happens so I'm going to now increase the frequency to well let's go for broke one megahertz everything down and there we go so this is 200 nanoseconds per division and we've got five divisions per cycle which is one microsecond per cycle or one megahertz so we can successfully subtract at one megahertz which is great now can we go to two megahertz and it certainly looks like we can all right now can we go to three megahertz sure for yeah now you can see some bouncing that's a little disturbing to me all right let's go for five megahertz six seven eight nine ten so this is subtracting a ten megahertz and we've got quite a bit of bouncing going on so it could be the probe that I'm using it could be the fact that this board the scoreboard is actually not buffered so it's you know really not the right board for high speed for high speed anything to put on the bus but I mean you can see the basic waveform so we are going at 10 megahertz let's see if I can bump up the frequency even more to say 20 megahertz and you can see that you know we are sort of getting a 20 megahertz wave and right now I'm probably reaching the limitations of the board given you know the horrible impedance of this scoreboard can I go any higher with this frequency well I can only go to 25 megahertz and yeah it's really kind of hard to say obviously we do have a square wave so something's going on but you know I don't know if it's the correct square wave it does look kind of asymmetrical so you know we can call it 20 megahertz so that's pretty good I think I'm pretty satisfied with this so that's about it for the ALU design I really appreciate you sticking with me through my ALU struggles and hopefully we can continue with the risk 5 processor now that we've gotten past this difficulty so please click like down below or even dislike if you didn't like this video that's fine too hit subscribe if you haven't subscribed so that you can see all the designs that I'm doing and there's a little bell icon which should hopefully notify you when new videos come around also check my patreon links and also everything that I do will be posted to github again the link is down below thanks very much and I will see you on the next video I'm building a risk 5 processor not on an FPGA