 Yn ysgol yw'r llunio, y llunio'r Llanferd wedi'i ddod o'r nefyd gan rai ffordd oeddennig oeddennig gwahanol, i'w ôl oeddennig oeddennig oeddennig, y ddweud oeddennig oeddennig oeddennig, mai'n gweithio'r cantol. Van's Elon Musk is already planning how to handle long-haul road transport for North America, and this is going to be a very disruptive period for the world as we know it. Three new technologies are converging and in the sort of 2030-2040 timescale, they're going to come together and they're going to create a very disruptive age of new technology. Now I'm probably not going to see much of that. I'm three quarters of the way through my engineering career, but it's the younger generation, it's the millennials born 17, 18 years ago that they are going to be the engineers that have to deal with those technologies. So we're going to see electrification, we're going to see enhanced storage of photovoltaic energy and this is going to be mixed in with terraflop computers and so we're going to need engineers that are going to be able to handle those disciplines. So how are we best going to educate that generation to be able to cope with those technologies? Are they going to get us a traditional education like we enjoyed, which was sitting in lecture halls and learning about Boolean logic and Karno maps or is accompanying the aforementioned disruptive technologies, is there going to be a disruption in the way that we educate? And the question that I'm asking at the moment is do we continue to give a traditional education or is there going to be a revolution in how we teach digital systems? Do we stop wiring things up and do we leave it all to hardware description languages? So what I'd like to do is review some of the things that we used to do and then point to some of the things that we may do in the future and I'll leave it to you to sort of think this through and see what you think. So I call this CS101, that's computers simplified 5. So computers are the most complex machines on the planet. There's two yard sticks for this, you've got a transistor count and you've got millions of lines of code and I've listed a few machines from the past and some very early machines that were right there at the forefront of the British computer industry and then moving through the decades we've got the 6502 that's 42 years old now. Within a year the Z80 had more than doubled the transistor count and then from that point on we reached a billion transistors in 2013 and allegedly 10 billion by 2015. So clearly we're on this exponential path of putting more and more transistors into silicon but how long can that go on? The second yard stick is lines of code and I've just listed a couple of examples there. There's a very nice graphic if you type in millions of lines of code and it tells you some of the major technology projects over the last decades and roughly how many millions of lines of code there were. Okay so computers are extremely sophisticated we need to break them down into simpler systems so that we can educate young students how they work. So last year I also did a talk here about an educational theme and you may remember I pointed out this book by Noam Nisen and Shimon Shotsky, Shokan rather, and it follows the development of a modern yet simple CPU. It goes through the hardware processes and it creates a very simple load store architecture 16-bit CPU that's nicknamed Hack. Now the learning resource materials are very good there's simulations written in JavaScript so they can run on many platforms but the one thing it does lack is real hardware. So I got thinking about this a couple of years ago and I thought well is there any way in which we could produce some real hardware to accompany this online learning course? So let's go right back to the mid 60s. This is diode transistor logic. The example is a two input NAND gate. It's made from three diodes to resistors and a transistor and the NAND gate is the fundamental building block of all digital logic systems both combinatorial and sequential. Computers in the mid 60s were made out of transistors and diodes and transistors at that time were very expensive about the equivalent of $10 or $15 at today's prices and yet diodes were really quite cheap. So the logic designers of that age they chose to use as many diodes as they could and as few transistors as they could. So the rate of operation of this circuit is was restricted to maybe one or two megahertz. So computers in the mid 60s typically use diode transistor logic and one classic example is the Apollo guidance computer that used a more integrated form of this. There were three input NOR gates on a single die and the Apollo guidance computer used three and a half thousand of these early integrated circuits and that went to the moon on several missions and it was also used as a flight navigation computer in certain military aircraft. If we move on teaching you to suck eggs clearly you can synthesize all the major logic families functions from two input NANDs. That's all the usual suspects and then you can build useful blocks like two input multiplexes where you can select either signal A or signal B this is all fairly elementary stuff I hope to most people. Then we have the problem of adding binary numbers and we have a full adder circuit there it's made out of two half adders and a half adder is basically an exclusive OR configuration which is the four NANDs arranged in the grouping that you see there plus an extra NAND gate to bring in the carry in and the carry out. Moving on to sequential logic we have the D-type flip flop. D-type flip flop has two cross coupled NANDs that's what characterizes it and it has two stable states so as well as the two NAND elements there we need to have a means to be able to clock those and the front end is a two input multiplexer which is the means to either feed the output back in again so it will persist and it will act as a register or to bring a new signal in. So it's about nine gates to build a clock D-type flip flop and if we think of as a bare minimum all of these gates are one transistor and three diodes. Now diode transistor logic it had a secret weapon you could get the OR function very easily from just adding extra diodes to the input the base of the transistors but because the collectors were essentially open collector you could take two signals and you could AND them together so you could kind of do away without having to have an extra NAND on the output of two signals that you wanted to AND together so this all helped to reduce the amount of logic that you needed. Okay but if you're building a computer the the transistors very soon add up and that's a list of how many you need for some simple structures that you'd find in a CPU you could build a computer out of transistors and diodes if you wanted several people have it's one of these things which I might say is don't try this at home it will turn into a into a serious project but there are those who have and there are some quite interesting examples of of those scattered around the around the net. Now the one example that I quote is the the pdp8 1965 that was a 12-bit computer it used just over 10,000 diodes and about one sixth of that number of transistors in order to implement its architecture. Okay so here is the accumulate a bit slice of a pdp8 and this is a classic case of the draftsman being told to I don't care how you do it just get it all on the one sheet. Right in the middle at the top you see the cross coupled transistors which forms the accumulator register that's the flip-flop in it and the six or seven transistors down the bottom I believe that they are implementing an exclusive ore so or two exclusive ores so this is an adder followed by a register but I've got the transistor and diode count there and you see that it's about 10 to 1 so in the pdp8 they needed 13 of these there were 12 to do the addition and then there was one for the one for the carry and also using the bit slice technique they they implemented the the memory address the memory data registers and also the program counter and if you look carefully at this you will see three very characteristically cross coupled transistors that are the register storage element plus some additional logic to in the case of the program counter to add one every time which I think you just believe you just need a half adder to do that and some way of jamming the program counter with the next count of where you want to jump to okay this is an iconic photograph taken sometime in the late 60s at that time the pdp8 was $18,000 and the the car that the the very nice lady is driving in that was about a tenth of that price so it this this was a computer that over the decade sold somewhere between 50,000 and 100,000 units but over that time it it was successively um it was successively uh redone using the new logic as that logic family became available and ultimately by the mid 1980s the pdp8 was reduced to a um a vlsi plug-in dip chip okay moving on so if you want to build a simple cpu you need certain building blocks we have the arithmetic logic unit the program counter a register that stores the output of the alu so it can be reused for the next operation an address register which can be used to to force the program counter to a next jump and then you need some sort of control unit to synchronize everything so that it works in the same way that an engine works so um going back to the nanta tetris uh course as i mentioned this is an outline of the the hack cpu and it shows how those various elements are connected together by basically a uh a data bus and uh you see the function of the address register that can jam the jam the program counter and provide an address into the alu so you can modify addresses so the ahar moment comes when you think we've got the interaction of an alu a program counter and some memory and this is all being fed by code and um it took me about 30 years to to come up with this diagram when i thought about it okay so supposing i did want to implement the hack computer as a bit slice well that's one bit slice uh the top stretches the alu then we've got three registers and the bottom one is a program counter so there are something like 80 nang gates there and remember for a 16 bit computer we need 16 of these so that's 1280 nang gates that is that on a 50 by 50 millimeter board but implemented in standard um hc ttl doable but a little bit tight and here just to show you the extent of it that's 16 two input nang gates on a package that's the size of a 40 pin dip so this is the don't do this at home please it's probably not worth it so last year this came out and this is the monster 6502 where a team somewhere in north america had recreated uh a 6502 to the closest uh re approximation of the original logic using just over 3200 transistors and this actually runs 6502 code it runs at about 116th of its original clock speed so it's about 60 kilohertz rather than one megahertz but it does actually work and as well as the uh 3200 transistors that are directly implementing the 6502 core they put lots of nice colored leds on it so as this executes instructions you can see bits of the leds light up and uh interesting its own right but they don't plan on making any more okay so the 6502 is historically significant because it appeared in september of 1975 and it appeared at a price which was one sixth of the nearest competition so everybody rushed out and bought them including steve wasniac from apple and uh it had been designed by a very small team who were only eight people they were a break away from motorola uh they got sued by motorola for having designs that were too close to what motorola had done in other words the 6800 and the 6809 um it was very simple it was designed to fit onto the smallest possible die size um approximately four by four millimeters and the reason for that is that the smaller the die the more you could get on the uh on the wafer and it meant that your yield would be much higher and with a high yield they could lower the cost so um it went into Commodore computers apple Atari acorn auric uh many more and it's been widely copied over the the decades uh improved um upgraded in speed and it's also available as an FPGA soft core so here we have an FPGA board and uh this is news just hot off the press uh that's a 6502 implementing the boot up screen of an acorn atom and the FPGA is supplying all the signals for the VGA i know it doesn't quite say acorn atom there yet but it's still booting up so um here we do the open source hardware plug um last year you may remember we featured the the mystorm uh FPGA um it's uh there are now a year on there are several ice 40 based open hardware FPGA boards available along with clifford wolf's project ice storm open source toolchain and um the amount of online tutorial information and worked examples is increasing and there's now a strong community group particularly in spain and FPGAs are becoming the new Arduino for makers and enthusiasts and so with the hardware description language there's a whole new dare i say fun way of creating complex digital designs that doesn't involve a lot of soldering of bits together so perhaps now we are seeing the the chasm opening up between the old way and the new way so um things that you can do on a CPU on an FPGA music synthesis retro computing architectures and experimental processor designs here's another few screens from the acorn atom implementation uh this work was by david banks who is part of a forum called anycpu.org and he had a very busy weekend last weekend okay so um you take your FPGA board and you add a a very low cost vga adapter and wire a ps2 keyboard straight in and you have yourself a computer system okay so one of the other themes running this week is edsac which was the 1949 machine implemented at cambridge university now it used 3000 valves there abouts uh it ran only 18 instructions of which arguably only about 16 were useful and it did it did 600 instructions per second now that might seem quite slow but compared to the mechanical desk calculators of that time it was 150 times the speed so can we learn anything from this ancient machine and maybe apply that and get some ideas of how we can possibly develop new cpus that are simple in hardware in their instruction set and architecture and many of them could be implemented on the fabric of a of an FPGA so there's the instruction set and the one thing that I took from this when I first looked at it was that all of the instructions are given a capital letter which some of them are fairly mnemonic in their representation so uh this got me thinking and um 25 years ago charles moore of uh of uh he was the creator of the fourth language he felt that he'd done everything he could do with fourth running on other people's hardware so he wanted to try and introduce a new class of fourth processor that used a minimum instruction set but those instructions were tailored specifically to execute fourth so he came up with this idea of the the MISC the minimum instruction set computer where typically you would have somewhere between 25 and 32 instructions and it was a case of picking those instructions and implementing them in hardware so that they could execute the fourth primitives and if you've got primitive instructions you can always put a few of them together and build up more complex instructions with fewer instructions you need less hardware it's cheaper it's simpler faster usually and easier to understand and charles moore has gone on to create the green arrays processor where on a single chip he's got 144 array of very simple MISC processors okay so if you were building a fourth processor you would pick a bunch of instructions which do fourth like things and the the main thing that highlights a fourth stack based architecture is that you need instructions to manipulate the stack and those stack instructions are on the third row so push pop drop swap over a knob and three lines up from the bottom where you've got a couple of register shifting commands one to load the stack into the to the return stack and the other to get the return stack register back on to the the normal stack stack machines are a whole class of computer architecture there's a really good book by philip coopman called stack computers the new wave about 20 years old but there's some good information there so i got thinking about well edsac used it used capital letters to make its instructions memorable and so i thought well maybe i could use single ascii characters to make this proposed simple cpu instruction memorable and rather than writing in assembler you write in symbols that represent the mnemonics and this is an idea that i've been developing for a number of years and i call it simple which is the serial interpreted minimal programming language and it's fourth like it uses single characters for command words and you can build a simple interpreter in very much less than a k a kilobyte of memory and you can port it to virtually any MCU and you don't need an IDE you just write using terra term on a 16 megahertz AVR this must have been the the Arduino implementation it it ran its virtual instructions at about one microsecond um so these are simple instructions rather than the low-level machine code and i have referred to it as a language but it's more actually like a useful toolkit which allows you to exercise new hardware and to check that it's working and make sure your GPIO is working and then being able to string bits of simple code together to uh to to do simple applications on new hardware so i sort of thought of it as a development tool to be able to explore some of these new CPUs that i believe that now we have the right tool set to go out and create on FPGAs the simple interpreter i'll just rattle through it it reads the character it says is it a colon um if it is it stores it into one section of memory otherwise it interprets it directly it looks to see if it's an alpha character a jump or a number and it interprets each of those separately and if it's one of the primitives like and xor add or multiply it goes off and executes a block of code and then goes back and reads the first character i'm hoping that i'll be able to demo some of this tomorrow um so there'll be more time to ask about some of this okay so we've effectively reduced machine language to a series of human readable single asca characters um inspired by edsac and why this is useful so many of our benchtop um manufacturing machines 3d printers um cnc router millers these basically just follow lists of instructions and with a simple processor you can get it you can get it to interpret these instructions from a file and control simple benchtop machines in the same way that we've been doing with gcode and various from years gone by so i'm out of time um thank you very much uh here's another shot of edsac with its creator morris wilkes and uh bill renick i think that is okay thank you