 C'est un tutoriel pour le design hardware. C'est très basique, mais il peut vous donner des conseils sur les choses que vous pouvez faire. Donc, c'est une chose comme ça, ce n'est pas pour le software. Et plus particulièrement, et plus particulièrement, c'est pour le design de ce type de circuit de chip. Et il y a deux types de chip, il y a des qui sont analogues, donc ils sont sous des signalés de valeur et il y a des qui sont digitales. Et donc, c'est seulement, c'est un talk about digital design, digital chip. Ok, la première chose à savoir est que le design de un chip est très complexe, il y a beaucoup de connaissances, beaucoup de tools et c'est aussi très, très, très expensif. Mais seulement une grande compagnie peut s'assurer de design un très complexe et un très, très grand chip. Hopfully, there are some kind of chips, like this one that can be programmable by user. So, the features of the chips are completely defined by the user. Usually, it's defined by the builder of the board, but you can buy a board with this kind of chips and program it by yourself. It's because it has a very particular architectures, which is composed of logical books, so you can define the logical function that will be done and a network of connection that is also programmable and the user will also define how the signal are routed within this network. And there are also pads, so what are available on the connectors. And they are also programmable, at least to set direction of the pad and other features. Well, it's a talk about digital circuit, so we are only speaking about zero and one. It's very simple, it's about binary logic. So, the way to do computation on binary logic is using gates. There, I would say, three basic gates, which is not gate, so it just inverse the signal. If you add a zero at the input, you get a one. If you add a one, you get a zero. It corresponds to the tilt in the C language. You have all gate, so as soon as one of the input is one, the output is one. If both inputs are zero, the output is zero. This corresponds to the pipe operator in C. And there is the end gate, which is, whose output is one, if and only if both inputs are set to one. And this corresponds to the end operator of C. This looks like very simple, maybe too simple. You can say, okay, what can we do with only three operators, three logical operators, but you get a lot of power by combining them. So for example, usually the exor, so, or exclusive or operator, which is expressed with a correct in C, can be created by all the previous gate. So here, if both outputs are one and not both inputs are zero, the output is one. This is the usual symbol for exor. And with exor gate, you can also do computation, mathematical computation, like for starting another. So another, one-bit adder is in fact exor gate. So another is a little bit simple, and we can complete it by designing what we call a full adder. So I would say half adder is a simple adder and the carry. So the carry is one only if both inputs are one. And if you want to be a little bit more complete, you can design a full adder with an input carry and output carry. So it becomes a little bit complex. It handles all the various cases of the possible inputs, values of the inputs, and generates the sum and the output carry. And usually it's too complex to be written like this. So on scheme, you abstract with a box saying, OK, it's an adder. And with this full adder, you can do things a little bit more complex because you can group them together. And here you have a four-bit adder. And if you want to start a two-bit adder, you can just replicate this scheme several times. So you have inputs A and input B, the sum, and at the end a carry that you can ignore. This is how you do a summation, an addition in hardware. And if you can add what, you can also multiply. So you replicate the adder several times, and you either, it's like a multiplication on the paper and pencil, you add only if the bit is set to one, and each time you shift. So this is how you can do a multiplier in hardware, starting from adder, starting from simple gates. So as you may have seen, just using simple logical gates, you can do, I would say, almost any mathematical function, well, almost any simple mathematical function in hardware. So you get your inputs, and you compute outputs. It's nice, but in fact it's not that powerful because very quickly your design becomes very, very big. You have seen how big is a multiplier. If you do a lot of multiplication in your computation, it will be very, very large. And one way to shorten the computation is to use recursion. You want to reuse the output as inputs. Unfortunately, as a matter of fact, you can't do that easily. The reason is because hardware is not about only logical concept, it's also about physical concept like time propagation. If you come back to the full adder, there are three inputs. And in fact, each time there is a gate, it takes time to compute the output because there are some capacity in the design that are hidden. It's not lightning fast, it takes time to compute the output. And as a consequence, the outputs are not ready at the same time. So you may expect a perfect output, like in this diagram, but in fact, for example, the output of A0 comes just before the output of A1. And if there is a loop, it will drift more and more. And for example, the output of A2 will be available much later. And because of that, you will have wrong outputs at many times. So you don't know where is the correct output. So you can try to avoid this nasty effect by, for example, balancing the circuit, but it's very, very, very hard. So the main rule when you do digital design is never have direct feedback. And the way to solve that is to use what we call a register, a memorizing element which needs a clock. And this particular gate, what we call it a flip flop, will only drive, will memorize the input and will reflect the input only at some times when the clock is active. So here, for example, the clock is active. So the input of the flip flop here will be reflected to the output just when the clock is active. Here, again, here the clock is active, the input is here and will be reflected on the output here. And with this kind of circuit, you have a perfectly clean output. That's the reason why we always use, well, almost always use clocks in digital circuit. And that's the reason why any digital circuit has a maximum clocked rate due to the time it takes for the loop. And I saw performance attached to any digital circuit. So most of the digital circuits are composed of logic gates that do computation and flip stops or registers that are used to synchronize the circuit, the computation. So that's the base of how to design a circuit, computation, circumcision. C'est possible to design a real circuit using schematic editor. It works well for very simple circuit, but as soon as it becomes a bit complex, people prefer to use an HDL, which is hardware description language. It's like a language, a C language or Java language, but the target specifically hardware. There are two main hardware language, Varylog and VHDL, and here we use VHDL. So we have this kind of board with a programmable circuit, FPGA, and since about two years, we have a complete open source software tools to program this kind of circuit. So there is a synthesizer named Yoziz, there is a place and route, I will explain that later, that is named directly place and route, and there is iStorm which is used to create the binary stream to program this circuit. So this board is about 20 euros, so very affordable, and it is supported by open source tools. So it's very nice for beginners. So the first, well, the only example using VHDL, this describes, well, an entity describes the interface of the circuit, which means how it will communicate with the environment. So there is one input, which is the clock, and on this board, the clock is generated by a circuit on the board, and five outputs, which are routed on this circuit on the five legs. Well, it's not very easy to see it, but I will show. So you just describe with an entity the interface, inputs and outputs, and in VHDL you have the architectures which describe the internal of the circuit. So I have an intermediate wire, which is internal clock, because the external clock is 3 MHz, and if I try to bring the led at 3 MHz, you will see nothing. So I use a divider to divide to 4 Hz, which is visible at this point. So all the leds will be linked together at 4 Hz. And how I convert from 3 MHz to 4 Hz, I just use a conter that is incremented each time the clock has a rising edge from 0 to 1. So each time the clock is rising, either I have reached the top of my conter, which is 3 million minus 1, and so I reset the conter to 0, and then I switch the clock. Or if I haven't reached the maximum of my conter, I just increment it. So the conter will increment it until 300, and then at 300 it will reverse to 0 and switch the 4 MHz clock. You have to know that in any hardware description of Grige, everything is parallel. So this is executed at the same time as this one, this one, this one, this one, and the process is executed at the same time as this one. Everything is parallel except that within the process, execution is sequential. So this is not a tutorial, a complete tutorial about VHDL, it's just a view of how it's done. So once you have written the entity and the architecture, we will go to the synthesis, which will convert it to binary code used to program the FPGA. And using the GHDL front-end, you first analyze the files, so you let the compiler know about these files, and then using the synthesizers, you say, OK, I want to generate un circuit pour LED, which is known here, and I want to target this FPGA. So this FPGA is ICE 40, and you specify the output file. So there is a lot of processing that is done on the input file, and it generates what we call a net list, which is a net of gates and of registers. And then you can use Arakli pnr to place all these gates, so it will try to assign each gate to the logical blocks of the FPGA and to route all the nets. It's very little bit technical, it's done completely automatically, and if it works, you're OK. And, well, usually it works, usually it works. It doesn't work if, for example, you are using too many gates, and there are not enough gates on the FPGA, or if you are just at the limit, the person router can say, oh, no, I cannot find all the routes. And when you place and route, you specify which paths is assigned to all the inputs. And then you have to program the FPGA. So in fact, on this board, you have a USB connector, and the USB connector is connected to a flash, so you write a binary to the flash, and the FPGA, when it is started, it will read the binary from the flash and program all the route network and the logical block. And once you have flashed, you have written your binary stream in the flash, it's OK. So it's not exactly the one I have programmed, but you could see LED blinking. In fact, it's rotating, it's a different, it's a more elaborative design, it's rotating, but almost the same. So this is all the open source tools I have used. OK, I am the developer of GHGL, so that's why I have used it. You see, it's a synthesizer, but it also, it's also the RELOAD front end, which is almost featureful, while the GHGL front end is just, well, it's still working progress. So you have a really tool chain, open source tool chain for this kind of FPGA. And that's it. Time for a couple of quick questions. Which kind of factor is the FPGA coming from? It's a late-test semiconductor. Well, if you look on Google for ICU-40, you will find it. Ha, debugging. Good question. Well, there are many answers. First, if you don't debug, you don't need to debug. Second, what you can do with, once you have written your design, you can simulate it. So it's completely software approach, and you can see, you can try to feed the inputs, and you can see what are the outputs. Or you can write text bench to be sure that your design behaves correctly. And sometimes, it behaves correctly on the paper, as we say, and when you program, it doesn't work. And then, it's not easy. Usually, you have to add some circuit to try to understand what happens. And using oscilloscope. But on that, this card is difficult. But then is it possible to digital proof for the live debugging? Yes, but only on the external parts. No. Unless you want to add your own circuit that try to read values net, and outputs on the external parts. But no. OK. Maybe I missed. Is it open source tool for simulations? Yeah. GHDL. GHDL does simulation for VHDL, and I can use Verilog does simulation for Verilog. So, it's complete. Please stand again.