 Okay, guys, class begins. All right, so welcome to the second lecture of Digital Circuits. All right, so now class really begins. Okay, so welcome to the second week of Digital Circuits. As you might already observe, I'm not Professor Mutlu nor Chapkun, but I am here to present this lecture on FPGA boards and how you're gonna program basic circuits for the labs. My name is Duryun, and I am a doctor student in Surgeon Chapkun's group. So the slides that we're gonna use today are adapted from your first textbook and also slides by Professor Mutlu, Professor Chapkun, Doctors Kirkkernag, and Doctor Anjan Raghunathan. So first off, let's talk about some administrative thingies. Here are the lab sessions, and I believe most if not all of you already received an email from me telling you that essentially everybody gets to be assigned to their preferred, first preferred lab slots for each week. The lab sessions, just to reiterate again, are gonna be held on Tuesdays, Wednesdays, Fridays from eight to 10, and Fridays from 10 to 12. Primarily, these lab sessions are gonna be held in rooms E26.1 and E26.3, all in the main building. Now on Tuesdays, there are much more of you who signed up, but we have enough rooms, so eventually we opened up E19 for you to work in. So eventually if you don't find enough spaces here and there, you're free to go there, and there's gonna be assistance there as well for you. At other times slots, we might have some empty spaces for you to work with, so there is enough seating for you to hop around occasionally if your schedule for a certain week does not fit your allotted time. Okay, so other than that, assignments aside, in terms of the labs as an overview, there are gonna be nine labs in total, 25 points as you were informed of last week. These 25 points would be 25 points out of this 100 points you would earn throughout this semester, okay? So we're gonna put the lab manuals online every week before the lab starts for you to start working on it at home if you want to, and essentially during the labs, what you have to do is just to follow these lab instructions and perform them step by step, and you should be fine. Other than that, in terms of the grading, at the end of these lab manuals, you will find a report, at least some questions formatted into a report type layout, and these reports consist of certain questions that you should be able to answer or you would try to find the answer to to solve certain challenges. And there's an important thing to note this semester or this year is that there's no need to hand in the reports this time. The reports are optional for you to figure out the solutions, and we're gonna release the official reference solutions for you later in the semester as well for each of the labs, okay? However, in each of these reports and as well the lab instructions, whenever there is a mention of you that requires you to talk to the assistant or have an assistant check your work or circuits, please do so so that they can mark your corresponding grade on our internal sheet. The grades will also be made available to you by request later on, okay? So this is the important thing. The assistants need to check your work and they need to mark it down in their internal sheet. You should finish the labs within one week after they're announced. So for example, lab one starts next week and this means that after the next week, the lab at the same lab session that should be your deadline for finishing lab one, all right? We understand that sometimes it might be difficulties with some softwares or certain people may not be able to show up for certain times or weeks. We can make exceptions, that's not a problem at all. Just please inform us beforehand. You can inform me personally or the assistants during the labs. So here's the goal, all right? We want you to walk away from the lab sessions learning as much as you can and essentially what I want is for you to earn all of the points that is our goal as assistants. So please do feel free to talk to us whenever you have questions. If you can't solve certain problems, please feel free. It is in no way an exam where you're just giving the grade at the very end, okay? We try to make it as interactive as we can. All right, so if there are certain issues with the labs, please also let us know so we can immediately fix them for other day students. By the end of this lecture, you might find that you are, some of you might find that you are so interested in this course, you've done so well and you've had a great time that you would like to participate in the future and we definitely encourage this. So if you are really interested in the end, feel free to email the lecturers next year to volunteer to become an assistant for the course. Well, actually volunteer is the wrong word. We do pay assistance on our early basis. So actually we also realize that approximately half of the assistants we have for the labs are students who had taken the course in previous years and they are invaluable resources that can really offer you really up to date experiences on how to implement these circuits and complete your tasks, okay? So other than that, if there are any individual questions, please approach me during the break so I can sort them out for you. It's definitely not a problem, but are there any sort of high level overview questions you would like to ask, anybody? Okay, then I think we're all good. There's so many of you that I have to scan for a bit. All right, so that's the lab issues aside. Now, today's lecture. What are we gonna learn in today's lecture? Well, today and as well the lectures for tomorrow and the two coming weeks are gonna be telling you about the basics of circuit design. So these are the fundamental things that should bootstrap you to prepare to implement real world circuits on our board. So today we're gonna talk about programming logic devices, what they are. We'll use throughout the semester an FPGA and you need to know what it is, what it's composed of, how it actually works and how it differs from real world circuits. You're gonna know how it works and I will also reveal to you some of the details of the FPGA board, some of the features you can use later on for your own interest. For the labs in this year, we will also use a development software to implement the circuits. So basically that would be your portal where you write the FPGA code and have them synthesized and implemented on the real world circuits. And at the end, near the end of the lecture, I will give a short tutorial on how you can do that. The software is called the Vado, by the way. So finally, I will also go through the individual labs. We have nine labs in total. These individual labs I will introduce to you and tell you what you should expect, okay? All right, so let's begin with the first thing. Programmable logical arrays. So first of all, there are a lot of types of logical arrays that can be used for digital circuit design. We list two types here. The first one is the really basic one. It's called a programmable logical array. So these programmable logical arrays are simply an array or a block of many AND gates concatenate combined with, which is followed by a block of many OR gates. So these really are the basic building blocks that you can use to compose any building logic circuit, okay? Remember, in the first lecture, Professor Mutlu mentioned that using examples from train stations and such, the basic building block and the computer architecture can be really low level like transistors or even really high level like software components. And we're somewhere on the hardware side and these basic building blocks right now are these combinational circuits, which are AND gates, OR gates, and other basic circuits. So these programmable logical arrays or PLAs allow you to implement combinational logic only. And we're gonna get to that a bit later. So they're composed of fixed internal connections. So basically what a programmer or circuit designer has to do is to specify which of these connections to activate so that certain results from AND gates of inputs can be connected later on together in the OR gate, okay? So these are just building logic. More details will follow in the coming lectures. All right, so these are rather limited and what we're gonna be working with this semester are FPGAs, field programmable gate arrays. Now, FPGAs are somewhat more complicated. They do not compose a simple a concatenation with between an AND gate array and an OR gate array. What we do here in FPGAs is that each FPGA contains of multiple configurable logic blocks or CLBs. And it is in these logic blocks that you can indicate in detail specific functions of how you would like your output to be based on the given input, okay? So it doesn't have to be restricted to just being represented by AND gates and OR gates. It's actually really general. It performs combinational and sequential logic. Sequential logic is more powerful in combinational logic because it considers basically the result of sequential logic consists of inputs that you give to the circuit but also inputs that you gave to the circuit previously. So combinational logic essentially is, for example, one plus one equals two. So one plus one, it is always two and therefore there is no need to store whatever has happened before. However, an example in which you would use sequential logic would be, let's say, counters. If you wanna count the number of students in this classroom, you need to have a memory of how much you have counted. For example, if I have already counted until here, I would be counting, I'd say, maybe 80 students. And if I have to increment by looking at the next student, I would have to have memory of this number 80. So sequential circuits allow you to store what you have learned in the past, past inputs, and use them later on in the future. And this is what FPGAs give you. The difference between combinational logic circuits would be more thoroughly introduced in future lectures starting from tomorrow. There are also programmable internal connections within FPGAs and basically more complicated stuff you will see later on too. So FPGAs in more detail are composed of these configurable logic blocks we mentioned. And they perform the primary logic. However, to interface between this logic and your external input and output, we need this input and output buffers which act really as the gateway to map your circuit to input from outside like a switch or a button. And also the output of the logic should be linked to your, to the output such as maybe an LED, USB device storage, or maybe a display, something like that, okay? So there are also the programmable, programmable interconnections that are within FPGAs essentially connects the CLBs and IOBs together so that they form the complete implementation consisting of input and output and also the corresponding logic underneath. Some FPGAs do include other building blocks to make your design more efficient such as memory and multipliers. And as a matter of fact, the board that we're gonna be using this semester, they do contain multipliers, I believe it's pretty. And because multipliers are essentially more complicated to implement, that's why they sort of pre-built it in there for you so that it can be synthesized when your circuit needs them. Okay, here's the typical FPGA schematic. The schematic essentially consists of multiple CLBs, these configurable logic blocks, and at the very exterior you have these IOBs that connect whatever logic you have to your outputs, your buttons, switches, and lights. Okay, any questions here? Okay, I guess maybe some of you are already curious as to how CLBs are implemented. So if you wanna dig a little bit deeper into how CLBs are implemented, let's have a look here. So CLBs, they're composed of essentially lookup tables. So remember previously in these PLAs, programmable logical rays, we have essentially two primary components, right? An AND gate and then an OR gate, and then later they are composed together. These are somehow resemble the sum of products that you would later on see in the lecture. With CLBs and FPGAs, what we offer here are essentially a really general model of describing a circuit, namely lookup tables are used and these are essentially truth tables. So you can really define any function that might be much different than AND gates okay, so whatever you define as a truth table, you can modify it, you can specify it in these truth tables and the output would be according to whatever you like to design. So it doesn't have to be restricted to the concatenation or the OR of a bunch of ANDs. Now later on CLBs would also consist of flip flops. So flip flops are actually registers and they allow you to keep state, okay? So they allow you to keep store whatever results you have computed in the past, such as the counter example we had before, the current number of students we have counted so far. So at the very end of this CLB, there's a multiplexer. This is the symbol of a multiplexer. Note that these squares, these are not the symbols for LUTs or FS, okay? So they're really not that specific. But this is the symbol of a multiplexer. So a multiplexer allows you to multiplex between two inputs. More specifically, they allow you to specify which of these two inputs are you going to accept and send as the output? So think of it as a selector. You can select between the output of the LUT or the output of the flip flop, right? The interconnections between the LUTs and the flip flops essentially allows, and additionally, the results of the LUT to be stored in these flip flops. So they can later be used for future computation. The flip flops, given that they have memory, you will later realize that they would need a clock signal to progress to the next state. And they would also require a reset signal in case you need to reset the contents of this flip flop back to zero. All right, so have a look at this and let me know what you think. Okay, any questions for your confusion? Okay, we're so good. All right, you're keeping up. Good, so now that we know how these COBs are what they're composed of and knowing that we have a lot of them, we are ready to look at the overall design phase. So really right now I'm jumping to a higher level to see how you should design an FPGA, okay? So what you should keep in mind is that these COBs are resources on the FPGA. And therefore, these are pressure resources because oftentimes you might end up designing a really complicated circuit and you would need a lot of COBs. Now, a good designer, a good circuit designer would know to design a more simplified circuit such that it consumes less of the COBs and therefore you can fit much more functionality into an FPGA. And this is what later you will look at in one certain lab later on. You will evaluate the performance of your circuit based on how many COBs or lookup tables essentially that your circuit would take up. So let's go over this design flaw, flow. So the design float currently essentially goes like this. Use a cat tool like Vivato or any other software to design and implement a digital system. Now it is in these design tools that you are able to implement or describe your hardware, describe your circuits, and you can synthesize them and you can debug them using simulation, okay? So one of the labs later on, I believe it's lab six, you will also use simulation to validate the correctness of your circuit. So essentially what you do here is you enter your design using a schematic entry or an HDL. So this is really abstract here. A schematic essentially, back in the days, a lot of cat tools, they allow users to actually draw circuits in the computer on the software so that it can later be automatically synthesized into a circuit. Another way would be to use a hardware description language such as Verilog, which is what we're going to use in the semester. So that essentially writing code like C code. But please note that it is not C code and a lot of the things you've learned in the past about certain constructs in C code, they do not necessarily apply here even if they use the same syntax. But we get to that a bit later. So schematic entry, you will also learn to appreciate how one should comprehend and implement circuits in the first lab and you will also learn that is a pretty complicated process and you wouldn't wanna draw circuits one of your designs. Okay, so correct functionality can be verified using simulation and later on, after you designed your circuit using schematic entry or writing code, you can use the synthesis tool contained within Vivado to map your description onto the PGA. And the result, concretely speaking, is a bit file. So essentially this binary file that you would take and you would program this to essentially program the board with this binary file, okay? So the binary file is downloaded to the FBGA and therefore you can see how it works. All right, any questions on this flow? Okay, oh yes, please. Oh, an HDL stands for Hardware Description Language. Primarily, these are essentially these programming language you use to describe the circuit. And I will use one example later. I know of two primary types of HDL. One is called VHDL and the other is called Verilog. They all start with V but they're different languages. Okay, so think of it right now as just code that you write. All good? Great, so feel free to ask questions whenever you need to or want to. All right, so this is the board and later we're gonna, I'm gonna show you a small tutorial on how you can program it and hopefully you'll enjoy the experience. So the FBGA board that we're gonna use is a new board called Basis 3 and each group would get one board that you're supposed to take care of in this semester. So really try not to lose it because otherwise it costs them money, okay? All right, so the board contains a lot of things that you can play with, so namely the following. That's a lot, we're gonna break it down like this, okay? So the first of all what you're concerned with should be the switches here. Remember when I talked about inputs in the IOB and the input output buffer of an FPGA? So these are the inputs that you're gonna be looking at. Immediately see, you immediately see here that these are 16 switches. Basically each switch will represent the input of a zero or a one. And then you have these LEDs, okay? These LEDs are the outputs or at least some of the outputs that is supported by this board. At the heart of this board you see the FPGA chip and this is the chip where Insider contains a lot of these CLBs and they're in LUTs and all of the other cool abbreviations. So this is where you program your logic to and you can see other input and outputs. For example, you see this four, seven segment displays over here and essentially these allow you to show numbers or alphabets or as later on seen in the labs. You can do make up whatever animation you'd like with these displays. Also there are these buttons here. So from the constellation that they used here it would appear that you can maybe implement like a small video game, I don't know. All right, so going up to the top there's a video output, a VGA output and you can easily specify certain pins to, you can connect it to a monitor and specify whatever output you wanna send to this monitor in terms of RGB values. So it's pretty cool and you can actually try it out with some demo projects that are available on the resource websites of this board. The USB port here allows you to connect like a mouse, a keyboard to take further input. That's maybe a bit more complicated and that's outside of the scope of this course but again, feel free, you have an entire semester to use this board. Here you have the power switch and you have the micro USB. The micro USB this year is used both for powering the device so basically connect this board to your computer be it your laptop or the computer's in the lab and it's gonna be powered by that and also it's gonna be the interface where you program it, okay? So you just need one cable to program and power the device. Remember that when you wanna power it, when you wanna program it, be sure to flip the power switch on, okay? So hopefully this will not be one of the questions you ask the assistants this year. I'm trying to save some trouble as well. Anyway, there are other switches and these pins around here can adjust. Essentially, for example, how boards should be powered? Should they be powered by USB or should they be powered by an external power supply to give them? And here there are some switches where you can say, well, I want my board not to be programmed by USB but by some other JTAG interface, whatever. And there's a small button here to reset the software and these are just small things that you can play around with later on. Okay, any questions on any other parts of this board? You're good? All right, so essentially that is it for this board and later on I'll show you a live demo. Okay, so by the end of this semester, what we would like you to do is to implement your very own processor. Remember that in the previous lectures we kept talking about these building blocks one leading up to the next, right? One more, a simple one leading up to a more complicated one. So what we're gonna do here is use simple logic circuits like these AND gates, OR gates, NAND gates, NOT gates, whatever gates you had and later on in the end of the semester we're gonna build a processor that you will use and it's gonna be hopefully turn complete so you can run any program that you want. Each week we will have a new exercise, not all reconciles exercise would require the board so you don't have to carry it around with you all the time. I'll try to indicate this on the labs, okay? You also encourage experiments with the board on your own. As I mentioned, there are tons of IO ports there and clearly you can see also here you have other IO's you can attach. These four connectors here, you can actually connect multiple things over there like your extra LEDs, as extra inputs and I don't know some other displays of any sort, right? You can also maybe connect the board these boards together so you can have inner board connections and communication. So this was left of this, this was copied from last year's slides. It says it is not possible to destroy the boards by programming and I would still like to believe that holds true for this new board that we have this year. So do your worst, really try to play with the board a lot and do what you can. As a side anecdote, a few years back people used to use these FPGA boards to build Bitcoin miners. Anybody heard of Bitcoins? All right, so you're all like money. So they used to use FPGAs to build miners. Of course nowadays they are obsolete and they're replaced with these special built hardware that's called ASICs. But feel free, if you can find an implementation to mine Bitcoins and you can do that using the board that we give you for the semester, knock yourself out. Okay, so I like to quickly go over the labs and at the end of introducing you to the labs we can maybe take a short break and after that I'll give you a tutorial on the software. Okay, and feel free to ask me questions about the things here. So for lab one, lab one is actually really basic. We are not going to ask you to use any of the software of the boards in the sense that you don't require these software boards to complete lab one. And lab one we simply want you to use your pen and just draw a comparator circuit. So we just want you to start drawing circuits and appreciate how wires can be connected together and how they can really be found. So lab one, using an example as a comparator, you want to compute two inputs and essentially output one if they are the same. So if two inputs are both zero then you would output one. Yes, I heard somebody say it, I hope. All right, so if the two inputs are zero and one then you would output zero because they are not the same for example. All right, no FPGA programming but you can definitely try out the boards. We're gonna give you the boards next week and you can already try them out and try to maybe replicate whatever we did together today on the tutorial, okay? And maybe you can also try to implement this comparator circuit. All right, in lab two you will use the boards. In lab two you will design a full adder and a four-bit adder, okay? And these are just first examples of the combinational circuits that I mentioned before, namely these circuits that do not keep state and output results immediately, all right? Like for example, one plus one equals two. So you want to design first a full adder essentially taking two bits and outputting their sum and carry, okay? So the sum is maybe one plus one is, would be zero, right? And the carry would be one because you carry it off to the next digit. And then later on you will learn to instantiate or build on top of this full adder module and you're gonna construct a four-bit adder, all right? So this is an important technique in Verilog or in circuit design in general. You wanna build small modules and then later you instantiate these modules multiple times in your circuit whenever you need them, all right? So everything has a nice hierarchy here and you can debug certain independent modules and your entire processor at the end of the semester essentially consists of instantiations of these different modules, okay? You're gonna use the FPGA boards and the inputs you can use the switches and the output would be the LEDs. So you simply light LEDs up according to the binary computation result that you did. So hopefully I hope you have all gone through the reading assignment parts on binary numbers. Any of you? No? Okay. If you're best to go over it because, well, this lab needs it. And also maybe this would be important for the exam. I'm not sure. Okay, so remember in lab two, we were just outputting these computations in terms of binary on the LEDs. Now in lab three, we want you to map it to a seventh segment display. Essentially, if the result is eight, for example, you should show eight. And if the result is 11, or 12, for example, you should show C. And if the result is 16, you should show F. So just simple stuff here. As an optional challenge, you can also convert these hexadecimal representation of numbers to decimal, all right? So this is essentially what we want you to do. To show you that, hey, in addition to LEDs, there's much more out there on the FBGA board you can explore. Okay, in lab four, we're gonna do something a bit more fun. We're gonna implement a sequential circuit. So this is your first lab on sequential circuits. You will learn to implement a blinking, sorry, a set of blinking LEDs for a car's turn signals, all right? So it's gonna be this fourth Thunderbird car back in the days where the lights would blink one after the other when you wanna indicate left. There are three lights going on, like one, two, three blinking slowly right after the other, all right? So they're much more fun than the indicators we get nowadays on our cars. Okay, so this would be where you would learn how to first design a finite state machine and be able to differentiate between two types of finite state machines. And later on, mapping these finite state machines designed to your circuits and have them running, okay? In lab five, actually by the end of lab four, your training as a amateurish circuit designer is complete and starting from lab five, we're gonna build towards that NIPS processor we've been talking about in the beginning of the semester. All right, so lab five is first, what we're gonna do is we're gonna build, I would say maybe the core. The core would be an arithmetic and logic unit. Basically, it is an important part of the CPU that does computation on binary input, such as addition, subtraction, multiplication, and comparison, and basically any other things you've used in past, right? And also logic operations like N or not. So that's why it's called an arithmetic and logic unit. Now we understand that later on, you will realize that a NIPS processor consists of not just this core ALU, but also consists of like a control unit to tell other parts of the computer to activate, for example, write access to a memory or to enable taking inputs from external input that is mapped also by a memory address. That always comes a bit later. So lab five, you're supposed to do this and also you would synthesize the circuit and this is where you can look at how your design performs in terms of the space usage. You will use the synthesize tool and you will see how many lookup tables or how many CLBs you use in your design. Of course, the less the better, okay? Because the less there is, the less you use in the circuits, the more space you have to design more complicated circuits that you will later on, right? But don't worry, the FPGA should have sufficient story, a number of LUTs for any of your designs, okay? You'd surprise me if you managed to exceed it. All right, now the problem here is we're gonna be implementing a 32-bit ALU which means that it's gonna take in 32 inputs, right? 32 bits per input. But if you remember, when I showed you the board, we only have 16 inputs, right? 16 switches, maybe five more buttons. So naturally, it is not so feasible to verify to test whether or not your circuit works using the board. And that is why in Lab Six, we are gonna ask you to simulate your ALU design using simulation and verify it using a test bench, okay? We're gonna teach you about this later on as well. So you're gonna validate that your ALU is functionally correct in software and this is an important part in a lot of design processes that allows people to efficiently and quickly identify problems in their design and fix them accordingly. So after Lab Six, you should have a properly working ALU and Lab Seven, we're gonna jump a bit far, a bit higher on the abstraction level and have you start writing assembly code. So these are the assembly code that you would later use to run on your very own NITS processor. So it is important that you write correct code here as well. We want you to calculate, for example, some of the number ranges and perform some basic image manipulation. So these are the assembly code that you would write. You would just write an assembly and later on we'll use a tool to convert these assembly to binary code and it is these binary code that you would later send to the processor that you build and the processor should be able to parse these codes and perform the corresponding instructions. Now given that we're gonna be implementing a really basic processor, it is important to know that we only support, I think, seven instructions for now and in this lab, these are the only seven instructions you can use. Now by the way, in this lab, we don't use the board, we use an assembly simulator so there's no need to bring the board. All right, so in lab eight, you're gonna know how a processor is finally built together. Basically it consists of connecting your ALU with a control unit and oftentimes in a computer you also need some memory and you also need some input and output. So you're gonna put them all together and all of this will be done in the hardware description language we talked about before. Okay, and you're gonna complete your first design and this is really basic and you're gonna run a test snake program. This program is yet another assembly program we will provide you with and you can send this program to your design to see if your NIST processor can correctly process these instructions. What you should see more specifically should be this. So just a basic snake animation, okay? Maybe as a bonus we can add in future labs or for those interested, you can use those buttons that I mentioned which look like directional arrows to control the snake's direction. This is in no reference to the latest phones that Nokia released. All right, so lab nine. In lab nine you will learn to improve the performance of your NIST processor by adding some new instructions. In addition to the snake program there are also other programs that you use that for example summing numbers where you might not just use summation but you might also use other instructions such as multiplication based on whatever ways you come up with to calculate numbers and process them. So right now we would like here, sorry in this lab we would like you to implement multiplication functions in your NIST processor and then also bit shifting, okay? Bit shifting is a technique that allows you to quickly or efficiently multiply numbers by two or divide them by two, okay? All right, so these are all of the labs and essentially by the end we would like you to have a NIST processor running, be proud of your design and have it work, okay? Any questions here? All right, good. So also as a side challenge for lab nine we would also ask you to implement a variation of the snake program. You would be asked to add more switches to your code to support different speed modes of the snake so it could move at a much faster pace than that video I showed you, all right? So it's just on the side. Okay, so now that we've covered the labs, let's talk a little bit about how we can make this all come true. So Vivado, Vivado as I mentioned before is the software you use to program these FPGA boards. You get to design these circuits using hardware description languages. As I mentioned before these are the two languages that are the most famous right now and Verilog is the one that we use in this course. It looks very much like C but then again that's only for your benefit but for example, please do not interpret four statements in Verilog as actual four statements in C. Essentially if you write four statements for example in Verilog you are not really going through instructions the same instruction over and over again you're actually instantiating multiple instances of a particular hardware. So that may be one of the examples you can refer to later on to identify the difference. The Vivado software allows you later on to synthesize your circuit after you've written up the code and the synthesis actually generates a net list or think of it as a premature design that contains how the logic should be and how they should interact with input and output buffers. Through the implementation process you would generate the binary file that actually links these individual input and output buffers to their respective ports like the individual switches on the board and individual LEDs. So there's a part in this designing process that you not only have to write the logic circuit of your design but also indicate which input and output should correspond to which switch or lights or output or input there is on the board. And then finally with the bit file that's generated you would program it so there's just a click. And then you get to see whether or not your circuit is correct or not. This is all things done with the FPGA board with simulation as mentioned before you just do a test bench. You don't really have to program the board you just do test benches. And there you can verify not only whether or not your circuit is functionally correct but also whether or not it satisfies certain time constraints like if you want your circuit to finish within 20 nanoseconds would your current implementation actually satisfy this requirement. All right, so typical design process here just to reiterate again. You create a project. You implement your circuit. You set the constraint file to specify which IO device to use. You implement it, generate the bit file which is called the bit stream in Vivado and you program it to the board or let it known as the target, okay? So you'll want to connect your board at this time and power it on before you click that button. Okay, so any questions here? Okay, cool. Just out of curiosity who of you took the labs last year? Can you raise your hands? Okay, great. Also identify your colleagues who are raising their hands. There would be also people you can ask if questions later on. Anyway, if there are no questions let's take a quick break and we can resume later and I'll give you a short tutorial, okay? Thanks. Everything all right? This is so cool. Okay guys, class back in session. Can everybody hear me? Okay, all right, good. So as I mentioned before in this second part we're gonna go over a quick tutorial and together we will design our very first circuit. Just a reminder for all of you again, typical design process for the FPGA in our labs consists of the following. You start with Vado, create a project, add program sources to create your own circuit implemented using some hardware language which is Verilog and this is similar to when you're programming in C you add a C source file, a header file and the such. And then later you use the constraint file to specify to tie your input and outputs of your circuit to the actual input and output devices on the board. And finally you implement your circuit, you generate the bit stream and you program, you send this bit stream to the board, all right? So before we begin I have some things I'd like to announce. So one of your peers approached me in the break asking about these boards for those who are really interested. So we do have I believe enough boards for all of you in terms of groups and we have some spare ones, we should have some spare ones afterwards. So please write me, let's say at the end of next week to ask me again and I can give them to you if you wanna play with, if certain students would like to play with it with one of their own during the free time. And at least Leason doesn't have to be restricted just to master it can maybe borrow for a longer time if you'd like. Another question was on the boards. One of the questions I got before was when this bit file is programmed to the FPGA, how is this somehow configuration stored? How is it somehow stored, right? So it's stored because the controller on the FPGA board knows which parts, knows how to configure its LUTs so that they reflect your desired circuits. And this means that when the, and also when the power is turned off, this configuration is lost, okay? So it's somehow non-persistent memory. Yeah, so if you power it off you'd have to reprogram it. Sure, surely speaking. Another issue was the software Vivado. You can also install Vivado on your own computers. The latest versions I believe is 2016.4 and you should be able to install it without problems. Although if there are any issues, please do come by the lab sessions and our assistance would help you to complete the process. But basically the free license available on Xilinx alone would be sufficient for you to finish all of the labs this semester. We're not using a lot of complicated functions to provide this year. Yes. Oh, you mean the Vivado installation file? I think it is pretty huge. It's like, I don't know, 100 megabytes even up to one gigabyte, yeah. So it's pretty huge, yeah. Okay, so the moment we've all been waiting for, the unboxing. So this will be the IPA year boards you get. Actually it will not come like this. You're gonna have to fold these card boards, the boxes by yourself this year because you guys are the first years and you're gonna be touching your boards for the very first time using it, sorry. Okay, so this is the board you're gonna be using and this is the USB cable you will use to connect the board to the computer. All right, so fresh new board, we open it up, some phones here and there, but voila, this is your board. Okay, so it's much smaller than previous years, much easier to carry around and it's essentially exactly as shown in the photo I just showed to you before. Okay, so what I'm gonna do is connect it to the computer and power it on. All right, so new board, so let's be careful with this. All right, turn it on and there's gonna be this demo program running by default and essentially it counts from, I think zero all the way up to nine and then just loops, all right. If you turn switch on some of the switches here, you will see the corresponding LED right on top of it to light up. This is just the demo program, okay? So this is not what we want, just yet. So let's go back to this design process. I'm gonna use a running example here for this, okay, try to ignore that for this example for this tutorial and it's gonna be the AND gate. The output is true essentially, AND gate essentially does the following. It outputs one if both inputs are one. Wait, you've all heard of AND gate, right, show of hands? Okay, good, great, great, this is the best example. Okay, so we're gonna do that with Vivado. We're gonna implement an AND gate and what I want in the AND is to have this. I'm gonna have two switches here, one representing A, the other representing B and one of the outputs an LED here and it's gonna show light up one when both are turned on because that's what AND functions are for, okay? So let's quickly look at this Vivado software. I've started it up here already but otherwise you can find it in the start menu. So let's create a new project. I believe it should be here and I need to duplicate the screen. Now we have it, okay, so we create a new project and this leads to the wizard and you click next and I can specify the project name. So, any names come to mind? I'm sorry? Somebody said- And demo. And demo, okay, it's really creative. And demo. So it's an AND demo and everything else can somehow remain the same. The project location, there might be some issues if you place the project on the desktop in the machines in the labs. I tried, it's kind of weird. So if you want, you can maybe store it somewhere else like your flash drive or on drive D or C and then later copy it or make a backup of it, okay? All right, so we create a new project like this. It's gonna be an RTL project, okay? A registered transition level project. I'm gonna close this again and next. Now this is where we can add sources but we're gonna do everything from scratch this time. So let's not end it with anything here. Add existing IP, also ignore this. We're really just using the really basic functions here. And also, and then you click next, adding constraints. Again, we're gonna program our own constraints later, so ignore this part. And next. Now this is where you specify to Vivato which board you are using. So there are obviously a lot of boards down here, okay? And I'm gonna tell you exactly what to type here. Essentially what you're looking for is this basis three board and what you wanna type in here is X, C, seven, A, three, five, T, C, P, G, two, three, six, minus one. And then you get one match. It's not really magic, I just looked up all the specs and basically every board has different things that software needs to adjust to. All of this will also be available in the lab manuals, by the way, so hopefully it'll be complete. Okay, so after selecting this, you click next and I can create a new project. There are a lot of warnings here saying that you essentially have nothing as an empty project, but this is what we wanna start with anyways. So, finish. And you will see here in a minute this design environment, okay? So in this design environment, first I wanna point your attention to the left part, you have this flow navigator and essentially you see pretty much the flow that I mentioned to you before, right? You have the project manager that allows you to add sources to write in your code. IP integrator, we're not gonna do anything about that, so ignore that for now. Simulation, because typically you wanna simulate this before you synthesize, implement and program it to the board, so let's skip simulation for now because you do that in lab six. And then later on, there is gonna remove that. I don't know why it keeps popping up, sorry. Okay, so and then here you see synthesis, implementation, and finally the program part, programming it to the board. So what we do here first, I wanna add, start designing this very long implementation of the end gate, okay? So what I wanna do here is click add sources and here again you have different types of new sources that you can add or create. So just the design kind of sources this time, the design sources are essentially the very log files. And by adding, it actually means that you would have already a source and you would wanna add an existing source, but we don't, so we wanna create a new file. So end demo, so I would maybe go with end demo, camel case, but for free, so click okay. And then now you have this end demo.v, the extension v is very long essentially. So you click finish and now there's gonna be another pop-up window showing up asking you to define the module. Now oftentimes, experience designer, they wanna go through this process so they can quickly develop or type in what kind of inputs and output their module would take and give. But we are really starting from scratch here so we don't have to type it in here again, okay? Well we want you to type in the codes by yourself because later on these would be important for you to memorize and also helps you prepare for potential exam questions, okay? So you click okay by adding nothing here it asks me if I'm sure, definitely. Okay and now we have the source. So you see here the new design source. I feel like I have to do something about that. All right, so this design source, if that will click on it on the right part, this would be where you type writing your code, okay? Now the syntax of Verilog and its grammar will be taught in later lectures. But given that we're just implementing a basic ant circuit, it should be easy for you guys to understand what I'm trying to type here. So module and demo, it takes in two inputs, right? A and B and outputs X, okay? So what we're gonna do here is, right? Input A, input B and output X. That's it. This means that this module has these three IOs. So and you end the description of this module with N module. So this is simply the declaration followed by a semicolon and this is just the syntax for Verilog, right? The typical habit here, a good role of thumb is to only have one module for one source file. Namely, if you have two modules, it'd be good if you separate it into two source files. This is just good practice for modular design. So here what we want to do is simple. We want to have X, B, one, whenever A and B are both one. So the N function, you would assign X, two, A and B, right? So that's how it is. It's pretty simple, okay? Any questions here? No, good. All right, of course, naturally throughout the semester you're gonna come up with your own very complicated versions of designing simple circuits and a lot of times they do make sense and maybe later you also learn another way of implementing this N function here that might make sense if you draw it in schematics. Right now we're really just saying that, hey, behavior in terms of behavior, X should be A and B, okay? We're just indicating the behavior. All right, now that we're done with this, it is time to indicate, again, set the constraints, right? We have to say, well, the A should be mapped to, let's say, this switch and the B should be mapped to this switch over here. These are the inputs and let's say X would be mapped to one of the LEDs over here on the top. The hangout thing is used to set up this chat thing where later I can just show you on video because the classroom's pretty big. All right, so now we need to add constraints. Again, a constraint is another file that we use to specify it. So you click again, add sources and here you select add or create constraints. So here add or create constraints. You add, you would create a file and let's call it end demo constraints. How about that? Click okay and then you have the file here. The extension is XDC but that's just some special format that the company who makes Vivado and also the FPGA uses to specify the constraints. Click finish and then here you will see a new file. So this is where we are going to really physically, in terms of inside the software, tie these outputs to the ports. So these are fixed syntax. All right, why do I wanna go this round? Sorry, set property package pin. And the important thing right now what I want you guys to learn is how to identify these individual input and output ports. So when you get the board, you're gonna see that these input and output pins, they have some labels printed beside them, okay? And the ones that are in the parentheses are their IDs for these labels. So what I can see here, obviously you can, but here it says V17 for the write mode switch and then V16 for the second write mode switch, all right? And then the other one actually is not V15 but actually it's W16. So there's no, it would look appear a bit random, but you can find these mappings right on the board or you can find them in the corresponding data sheet. So I'm gonna write first the mapping for A and it's gonna be write most ones, it's gonna be V17. So V17 and the syntax here is get ports A. So this simply means that we're mapping the input A to the switch V17, all right? So make a copy here and then we can map B to V16. That would be the switch write adjacent. Now the output, again the output is the same, the output is X I believe, let's double check, right, X. And I'm gonna map it to one of the LEDs. So I'm gonna read it off on the board and it says actually U16. So it's gonna be U16, all right? Now with these silings files, there's some other details but essentially what you also wanna write at the end is I'm so sorry for this, I feel like I need to disable this. By protection, all right, quit it, okay, great choice. Okay, anyway, let's continue. So finally, there's some settings that you always have to write. You can ignore the reason for now. Standard, IO standard, L, V, C, M, O, S, three, three. And I'm gonna just write it and then I'll explain it. So essentially this line tells the FPGA controller to treat all of these three inputs and outputs as regular standard input, okay? There are many other types but we just use this type which is L, C, L, V, C, M, O, S, three, three, the three, three to give you some context represents I think that the input and output in terms of physical connections are using 3.3 voltage as the peak, all right? So now that we have these constraint files set, we store them and we're ready to start synthesizing and implementing it. So let's run synthesis and you can see the progress on the top right corner right here. It says running synthesis design and it's taking some time. So this is where Vivato converts your hardware description of the circuit to the net list, okay? All right, synthesis is complete and then Vivato is actually smart enough to ask you, hey, do you wanna do the following ones? It would be run implementation but let's do everything from the sidebar over here. So I clicked cancel. So I click, let's do run implementation over here and hopefully this demo would work. I'm more anxious than you are right now actually, let's see. Okay, so you can always look at the progress bar. When it stops, whenever there's an error, there's gonna be a pop up telling you the error and you can look at the corresponding debug error messages. We will not go through the typical error message to my encounter here but whenever you run into these error messages, feel free to consult an assistance and they would be able to help you out. All right, so this implementation process, they're running a lot of different things. I believe that this design, they're really hooking up or programming the circuit so that it really knows which CLBs to hook up with the lookup tables. And now finally at the end, the implementation is complete and you can proceed to generate the bit stream. Now again, you can also find the command for generating a bit stream here at the final part, okay? Because the bit stream is the final product you wanna send to the board, so it's at the program category. So if I click generate bit stream, it's gonna generate the bit stream file, okay? There's a lack here. But this is a really old laptop so hopefully you will run into less of an issue when you install Vivato on your own laptop and it should run pretty well. It supports Windows and Linux, I believe. Okay, all right, so there's an error and I believe I should look into the problem here. Put on my cheat sheet. There might be a typo in my code. All right, sorry. There's an underscore in this set property over here. Now whenever I find an error and fix it, you can always click on the part where you got an error and it's gonna rerun whatever corresponding steps necessary in the previous steps, okay? So hopefully this time it works. So as you can see, the error message is presented by Vivato. There are still a bit cryptic and it takes some time to go through it. Could go through with it, but hopefully you will be able to identify the issues here and there and fix it accordingly. If not, the system would be able to help you there. Okay, we just have to wait for it to finish. But any other questions during this process when you fill this gap? Yes. Yes. So I'm not sure about the specifics but the synthesis actually generates this net list, okay? So I haven't really introduced to you the concept of net lists just yet, but the implementation really converts these net lists into the actual design of the, or the actual implementation of the circuits. And it is also in this part that they verify whether or not the constraints are satisfied. You might wonder why I use the word constraints for these input and output bindings. Constraint is actually, there are actually two types of constraints in Verilog or at least in Vivato. The first type is these IO bindings. The second type, so the first type is these IO bindings that binds your input and output variables to the corresponding hardware port switches here and there. The second type is a timing constraint where you specify how long your circuit should run for a particular part, okay? So there are two types of constraints and it is also in these parts where throughout the process implementation that these constraints would be valid, would be checked against your design to see if your design satisfies these constraints, okay? For more details, there are also a lot of online resources for you to look into. I'm just trying to give you the really basic overview of how to get through the labs this way, okay? Good, so thanks for the question. And now we've done this together. So let's cancel this again and now the bitstream file has been generated. It says write bitstream complete and you can expand the open hardware manager here and just click on open target, auto connect. And if your board is successfully connected to the computer and also powered on, so please power it on, there's gonna be this thing saying that you're gonna see here the board is found by Vivato and it's connected and everything is all set. What you have to do is to click program device, okay? So just to make it still uniform to keep everything consistent, we can also click program device over here and there's gonna be a small menu popped up here and there's one selection just for this board essentially. You click on it and then here you can program the device. So again, it's a bitstream, right? And this is this bit file that I've been talking about. So it's essentially a file and by default it's gonna be right here. Don't put anything in debug files because we haven't really talked about that just yet. And we can just click program here, okay? All right, so programming the device, we're done and I'm gonna create a video call to myself. I'm not gonna give you the link just yet. Okay, let's see. So, right, oh, that's me there. All right, so what I'm gonna do is change the camera direction and you get to see yourself. Enough? All right, hi. Okay, good. Right, so that's really enthusiastic of you, thanks. So I'm gonna make it rotatable right here and all right, so this is the board and remember I had, I mentioned that I would use this switch and the second switch. All right, so this switch and the second switch over here as the input, okay? And the upper part, this LED would light up whenever both switches are on, okay? So, let's do it like this. If one is turned on, nothing happens but if both are turned on, voila, you have your light. All right. Yeah, thanks. Yeah, you have no idea how nervous I was when I, yeah. Okay, so that's the idea. So now I have a working circuit here and you can really change your settings. Like for now I've turned off one of the switches and it doesn't light up anymore. So later on, you will also see that throughout the labs you can modify other things and feel free to be creative. If we ask you to map a certain lights to the left-nose side, you can also light it up to any other place. As long as functionally we know that you've gotten things right, you will get the points, okay? Like I said, why don't you walk away with four points? Okay, so that is essentially it and next week you will all get the boards to in a group and you should have fun with it. So, just to quickly conclude, in this lecture we have talked about the following. A quick, whoa, okay, anyway, let's do this. So in this lecture, we have gone over a quick introduction of the FPGA. We've gone over a quick tutorial on the FPGA programming, the one I just showed you. And as a matter of fact, you can find a lot of online resources to get started and there are a lot of other much, much, much cooler demos that you can find here, okay? And they even allow you to connect to remote monitors and mouse and keyboards. We have gone over the overview of labs. They might change later on in the semester, but overall this should be what you should expect, okay? So tomorrow, Frank is gonna be here to talk about combinational circuits. There might already be a lot of people thinking about what they are when I was mentioning them in class, but tomorrow you're gonna figure out what they are, okay? So, any questions before we end the lessons? Okay, you're all good. Then please pay attention to the online resources and also our official website for announcements and have fun, guys, thanks.