Transcripts
1. Introduction: Hi, welcome to my yard communication course. If you want to learn about your transmission from 0 and write down a VHDL code. And I will explain you about my design and everything within this document about the physical layer of a uart, about the packets and everything you need to know in order to communicate with uart with your FPGA. I will share with you my design for the UR transceiver and we will go through the your transmitter and receiver. We will also simulate the design, of course, and I will show you everything you need to know and explain you about the serial communication. And specifically in this course about neurotransmission, in this course of three courses about serial communications. So you're welcome to join my course and start layering from 0, how to write down in your art controller from 0. So you're welcome to join my course and start writing down your URL, VHDL code, the form 0.
2. What is UART: Hi, welcome to the next lecture. In this lecture we'll talk about what is a new art. Before I'm starting, you have this document. You can download it. Okay. I wrote here a couple of things, okay. And if I will add more, I will just upload it to this lecture, okay, so you can download it right here. Okay, so let's start and you're at is the Universal Asynchronous Receiver Transmitter, okay? It's a serial communication, very old one, Okay. Now, the protocol is used for exchanging data between two devices, okay? It used only two wires, TX and RX for each direction. And what it means actually is that for sending data from receiver to the transmitter, actually, to make them communicate with each other, we need only two wires, one on each direction. And uart is up to full duplex transmission. That means that he can be in simplex mode, which in transmission means that one side can send data to the other side. Okay? Half-duplex. It just two sides can speak, but only one at a time. And full-duplex means that. And this what you're supports. Full-duplex means that both sides can send data at the same time. Okay? So if you think about a uart, gay, it looks like this guy. I will touch on in this second case. And the format of the data is a frame, which set of rules? We'll talk about this on the next lectures. Now if, If we will talk about, if we think about the UR to k, we have a shift released her to transmit the data and we have a shift register to receive the data. This is why, why eats a full-duplex transmission. Okay, and let us take look, okay, so this is how it's actually connected between two components. Again, if we're not thinking right now about the FPGA ward, okay. We have two components. They can speak with each other in a uart portico case, serial communication. Okay, so right here I wrote again a common used serial protocol, okay? Mostly it's been used in your PC, in your comm ports, in a RS232 modems and more. Okay. Yeah, we already said it's an assay horns communication. But therefore, Okay. The transmitter and the receiver do not share a common clock. Okay? And when I'm saying that they don't have a common clock. Okay. It doesn't mean that they don't have a frequency. Ok. So the frequency between the boat yards need to be set, okay, preset. Every beat has its own time k. So we need to know what is the bit time phase. We will talk about this later on. Okay? Now most uart communication or just using a RX and TX signals, sometimes we will see RTS and CTS inbuilt in your chipset. And CTS mean clear to send. An RTS mean Ready, ready to send. And these signals are used for controlling the transmission itself. And that just means that sometimes you want having some control over over the uart protocol, gay. So think about two pieces, for example, connected chip to chip. So if you will have the RTS and CTS, you will want you to tell the other, I am ready to send. Okay, so what it means, actually if we have cheap, too cheap direct URL link, okay? Okay, So if this uart want to tell this URL to gay that it's ready to receive data. It will cent, ready to send, and this one will get there clear to send gas. So it means that the Sea Route telling the other uart am ready to receive data. Okay. So just controlling, not so commonly used Gay. Okay, in this course, of course we will connect only the arcs to the ticks. In this is the most communist communication for today. Right here we can see a regular connection between two computers k. Now, this is where we are coming to the physical layer. The physical layer will be on ours to 32. And this just means that your communication being okay, the voltage is being transmitted to a different voltages types, okay? So the uart communication itself is just a protocol for the communication, okay? How the frame set, how the frequencies and the boundaries and everything. It doesn't include what voltages we are going to use a, how the, how the data will change according to our board gated where even been on. Okay, so if you want up to 85 meters cable for example, you can use RS-232, okay? So it's not so commonly used to connect tip too cheap directing direct URL link, okay? Mostly it will go through RS232 line buffer or to a COM ports Gay. Okay. These are the common air about rates. Okay. The standard baud rates are going to be between these numbers. Okay? So it's just, you can see it's jumping. If you are familiar with these numbers, you can see it in your PC, in your comports gay. When you're setting up the baud rate, sometimes k. You can see this if you used Arduino, okay, For example, you can see these numbers. I think this one is the most common used in Arduino and these 12, okay? Okay, and this is for this lecture, and I will see on the next lecture, and this is for now. And thank you.
3. UART and its physical layer: Hi, welcome to the next lecture. In this lecture we'll talk about the uart physical layer. Okay, so S for the UR, the York is actually a protocol standard for a protocol for the communication protocol. And about the physical layer. There is no such thing. Physical layer or for your, okay, actually, that means that the, your protocol itself doesn't include the voltages that need to be sent, okay? That means that we need buffers, okay? Just as I showed you right here, OK, We need buffers. Actually connect between two yards. Of course we can connect tip to tip. This will be TTL or cmos, but we want to use to 32. And as for the protocol here, okay. So in order to connect the URL to a nine BC comb canine been com, gay, for example, we have to use the arrows to 32 buffer for converting the voltages to be polar signaling. Okay? That just means that if you guys want to connect between two pieces and you have a board, okay, that you have created. You will need to use something like this case, some buffer like this one, okay? And just connect the TX and RX of the UR that we are going to create right into EPC D19 connector, which is actually this connector. And right here you can see these are going to be the signals. We're just going to use the RX dy and dx dy being 2 and 3. And of course, we are going to use the ground, okay, and this is the way we are going to connect it to pin 32 and the ground. Okay? So if you are going to create your own board, if you're bored developer. Okay? This is what you should use. Of course, there are many other components in the market that are converting between the serial communication of the uart, two different types of communications, like RS 485, okay, four to two. And you can use whatever you want gate. And actually this is it for this lecture. And I will see you in the next lecture and thinking.
4. How does UART data packet looks like: Hi, welcome to the next lecture. In this lecture we'll talk about the yard packet. Okay, So as for New York Beckett, we can see that a packet being built from one start beat, okay? Five to nine data bits, 0 to one party bit and one to two stop bits. These are going to be our dataframe game. Most commonly use are seven beats for ascii numbers in eight bits, which is one byte. Small thing about the ascii numbers, okay? It ascii numbers are our keyboard numbers. Okay, so our keyboard in, in our PC being represented by seven bits of data, okay? So each H key that you are pressing, for example, 0 will be a charity in hexadecimal, okay, it will be 7 bits of data. Now let's talk about the packet itself, okay? Okay, So the stock beats gave for the packet that actually recognizing the start of a packet in the receiver will be 0. Okay? So every time the receiver recognize a 0, it means that the packet, packet come in right after it. Okay? Now of course, the receiver and transmitter needs to know, needs to be at the same dataframe, okay? So it needs to know how many bits we have inside the data. Okay, so he didn't know how many, too simple. And then it we know when the party coming, if there is a parody or not, how many stop bits we have. Okay, so all of these needs to be exactly the same in the receiver and the transmitter. Okay? So the dark debate, as we said, five to nine data bits and the parity bits, 0 or one, a parity bits. Now let's say that we have one parity bit. Let us talk about the parity bits. What does it mean, the parity bit, okay? So we have two types of parity bits. We have an even parity bits and an odd parity bit. And that just means that in an even parity bit that the number of 1s must be even. Okay? Now, when we are saying the number of ones, it means the dataframe plus the parity needs to be even, Okay, so the number of ones in the dataframe and the party itself needs to be even gay when we're talking about an odd parity, okay, of course, the number of 1s must be odd. And I wrote, you hear that? If you want to set your parity bit when you're sending a frame, for example, you want to store all of the beads and, and this will be your party but beat that you are going to send. If you will calculate the XOR of all of the bits, you will see that you just completed, right as it should for even parity. And for odd parity bit, we need to store all of the beats and to invert. Okay, what we got. So it's not x4, pay off all of the bits. This will be the value of the parity bits. Now let's talk, let's give an example. Okay, So we will understand more. So the parity example, when we say the number of ones, it means, okay, to all of the bits, including the data in the party as I told you. So for example, we have this data, okay? So, so this will be 36 in hex, 0, 0, 1, 1, 0, 1, 1, 0, okay? This is 36. Now, for even parity, the number of ones right here is already even, okay? We have four ones, okay? So it's already even. So the parity bit will be 0 because we want an even parity, you an even number of ones. Now for an odd parity, the number of ones is even and we want an odd part, an odd number of 1s case. So the parity bit will be also one, okay? And this way we will have an odd number of one's gay in the frame. And now therefore, the value of the parity bit is always SAW or not x4 of the data bits k. So for example, even number of 1s will give us 0. Okay? So let us go back right here. So if you're exploring these number, we have an even number of ones. This will give us 0. Every time you're going to X4 0 with 0, you will get another 0. So when we are solving an even number of funds will get 0. Okay? So for even parity, the parity can be just XOR of the beats and XOR of odd number of 1s will give us 1. Okay? So far our example for even poverty will just saw all the bits and get 0, and this will be our party, okay, for odd parity, will AX4 the beats and get 0. But we need to invert the party to be one. Therefore, it will be just saw, okay? And the answer of the value of the poverty, which is actually one, okay? So the parity, the parity bits itself k. You need to know that it can only take one fleet bit gain because we are exploring the data. Now we can understand it. Only if one bit is flipped, k it can detected. Now think about this. Why? Why do we said only one flipped bit? Because we are, for example, right here we are exploring and we have an even number of 1s if two beats got flipped, for example, these two ones, for example, Okay? We will say that the party is the same parity, so we cannot recognize it, okay? Now if only one here just flipped, we will get from the XOR here 0. Now, that just means that the receiver, when the receiver, receiver receives the data, it needs to store all of the bits, okay? And to compare it to the party, of course, if it's an event, it will XSOAR, if it's odd, it will exert an invert and then compare. Okay? So what we are going to do with the data, we are going to store all of the bits, okay? And actually just check it with the party. Now, this is how the transmission itself looks like. Okay, this is a transmission on one wire, okay? So every time it's idle, we don't have anything to transmit. The line will be one, okay, or high, or five volt or whatever physical area are going to use. And when we have 0, it's the start bit, okay? Right after that, we have the first bit until the last bit, it's going to be from five to nine, okay. And starting with ALS bit first. And of course, this is what I meant when I told you before that we have okay, that we have time. Okay, So this is the time of the bits, okay? It's one divided by the baud rate, okay? For example, 9,600. And right here we have no parity, okay? If we had the priority, it will be just like an another beat here. And after that we have a stop. And stop. It just means that we are going to one, okay. Back again to either. Okay, so in this course, we are going to do this. You are transmission with no poverty when one, with one stop it, one start bits and eight bits of data. And of course, we will go through, this will be this code, okay? Okay, that I wrote. We'll go through this code. This is the transmitter, the receiver. Okay? And as far as for another code, okay, with the parity, with more generic stuff, okay, right here you can see I have only constants here. And right here, I have another code guide that I wrote. I have the option of generic, okay? Now, generic means that you can, you can choose, you can choose your party type, even or odd. If you have or not have parity at all. Number of topics, K, 012, okay. This can be, you can change from five to 15, although that it needs to be a five to nine, okay? And number of bytes. You can send packets after packets of data, okay? So you can send, you can transmit many, many, many of data one after one. Okay? Okay, and this code can be found in the last lecture. I will add it. You can have every dare. You can get there. And we will go through this simple code, okay, on the next lecture to come. And this is it for now, gay. And I will see you in the next lecture and then Q
5. How to sample the UART data packet: Hi, welcome to the next lecture. In this lecture, we'll talk about how to simple the uart transmission. Okay, so first thing first, the everything that I'm going to say is about assembling the neurotransmission and every communication. Transmission. Okay. The metal is the same. Now if you've watched my VHDL course, I talk about how to simple data that come in from the outside world. Okay? If not, I will be happy for you to join my VHDL course. Okay, now let us start and think about this. First of all, we have a transmission between two York's gay or to FPGAs for, or from a my FPGA to a PC, or from my FPGA to another URL to K. So we can think about is that we have the uart guy right here. It will be the ticks go into the RX and vice versa. Okay. This would be like, Sorry, submit the RX and submitted takes, yeah. Now when we are sending data to the uart, for example, we need to sample it with a clock, okay? So this is, for example, this is the uart and we have here a fast clock, okay? In our project I'm going to use 25 megahertz, okay? Because our FPGA can use a really fast clock, and we need a faster clock. Then the transmission itself. The transmission itself, as, as we said, it has a really low baud rate, around a hundreds of hertz to 100 thousands of hair cells. Okay? So the boundary rate is really low. Okay? This, your transmission is really low about rights, gay. It's, it's, it's a slow communication protocol quick. Now for simple in its right k, we need to think about the outside world, okay, what happened to the signal outside? Okay? Now, the signal can be something like this. As you think about it, usually will say that's essentially just looking something like this, okay, going up, going down. But in reality, this is not the case, okay? So this is wrong to think like this K, your signal is always looking something like this case. So there is a rising time, okay? Most of the time the falling time will be faster. Okay. And again, two is arising time and a falling time. And the thing is that I, if I'm going to sample this one's gay for example, about a real you are gay. So every day you are going to be idle and then somewhere at the time it's going to fall to 0, k. So this would be our starting, okay, Starting bit. And then it's going to go up. For example, this is the data case can go up, it's going to stay low. Okay? And let us say Togolese bit, okay? So I can say that this is not a 012 and so on. Until we get to the stop bit a, this will be the stop. This will be the start. And what's happening here is that I'm sampling it k. So every time I'm sampling the data, okay, with this fast clock. And I want to see when I'm going to get this first start, okay? Now what I want to do in a, in a couple of URLs in the market. Okay? We're going to work in a really easy to understand. You are, okay. And I will explain you the step-by-step for recognizing this 0. For example, if we have a fast clock, I'm going to first many, many times k. Now for example, if I, if I sampled here, somewhere over here, I don't know if it's 0 or one. Okay? And around here it's going to be only zeros, okay? Every time that I will sample the FPGA, we recognize it as a 0. And right here, I don't know, it's in this area. I don't really know if it's going to be 0 or 1, okay? Now, another thing that can happen also is that the signal will go like this. Okay? Or more like, more like this, okay? And most of the time it happened in with the rising edge, you will see E can see something like this. Okay, so if you're going to look at the scope, and this is happening when you're receiving back, okay. Data on the transmission line. Okay? This, this is something with a transmission line. So again, if you will sample over here, this can really destroy of everything that we do. Now first thing first, we wanna do, we know that, we know the baud rate of this guy. So first thing you can do, if you sample the first 0, you know that if you will count, okay. Bye, okay, bye the boundary to you can you can tell how much you need to count. You know, we're, we're where to where to sample right here. Okay. So you know how to sample here if you have if you have a counter, okay? So let's say that I recognize the first 0 right here, okay? So I can set a counter and then I will simply write here. And then I will again have the same counter and simple right here. Okay? So this is why both of the US needs to know the same bound, right? Okay? So they will know the time of every beat, okay? So they can know the time off every bit. A different method for this. And it's not about it's not about a timer. It's about when to start the timer. If we want to get rid of these things here, okay? If we don't want, we don't want to start here, okay? This will be bad for us. So here we can recognize 0. And if we start here, the counter, we will go on and simple white here. So we can simply 0 instead of simple one. Okay? So what we want to do, and this will be only in my pro uart k. What I'm going to do, and this is some trick we do every time. Okay? We can have a register. Okay? I will use the register or 4-bits. As, as long as this register B, k, the better your recognition of the data. But you also need to remember that if the clock is not so fast, you need, you need to put smaller register, okay? Because if you're assembling only twice, you can put the 4 bit register. It will be, it will simple here, here. And then we do simple these two. Okay, so if we have really fast clock that sampling many may times, let's say 100 times here. So we're good with the four bits. Now what does it do? Is that we just going to say that if this vector is going to be all zeros or all ones, okay? We will set, we will, we can say that the beat is 0 or one. For example, what happened here? If we have this, if we were going to use this, okay? So if we're going to use this, and we are right here, okay, This is a nice example here. So we are, if we're going to have four times that we are assembling. And we actually want to sample this one, okay? So we will have, for example, as one. And then it will recognize 0, 1, 1, 1, 1, 0, 1, 1. And I can't I can't say that I'm I'm on, you know, on a one logo. Okay. I can't say that I got the one that I wanted. Okay. Now, as long as this register will be okay, we will have more samples. If we have more samples, we can recognize more of this space that we have here. An issue, okay? So we want this to be a long Guan Gei, but we don't want it to be too long, okay? And also you need to think, we're talking about FPGAs, okay? So in FPGAs, if you make a really large registers, you will just take many loads and you don't want to, you don't want your uart to become, you know, a massive okay. Design because you're up next to be a light and cheap. Okay. When we are talking about the space and the time that you are putting into your, you're designing. Ok. And this is it actually for this lecture. And I will see you in the next lecture.
6. Our UART structure design: Hi, welcome to the next lecture. In this lecture I'm going to talk about our uart structured design. Okay, So first of all, every uart consists of receiver and transmitter. And right here we have our reset and clock. Okay? So every time you are creating a component or anything else, he would have been a reset and clock. Okay. And I'm I'm calling this uart a transceiver, which is transmitter, receiver. Okay? So we have both things in our yard, okay, we want it to send data and receive data. Now because I told you we're going to do some really easy design, GA4GH you are, okay just for you to understand the method. Later on you will be able to change our design to whatever you need. You can add more state in the state machines, for example, if you want to sample the priority too, okay? Or you can just go on to the last lecture and find my other design, okay, which is more complicated design for a year or two. And you will have there all the generic says I told you in the previous lectures. Okay, so what can we see here in the transceiver? We will start with the transmitter, okay, on the next lectures, we will talk first on the transmitter and later on on the receiver. So as you can see right here from the transceiver beside the reset n clock, okay, right here in this transmitter, we have the data input, okay? So all the data been inputs simultaneously, okay? So it's going to be a parallel input with eight bits, okay? And we have the right data input, which is enabling actually the right. Okay, so every time I'm, I'm, I'm just going to set the data and then assert the right data in. Okay? And we will have, you know, the transmission on this serial outputs, okay? And of course we'll have the eggs ready. So these at the ready is just a nice to have seen. Okay, I'm not going to use it on the outside world. And you will see it in the simulations. Okay? Now about the r x will have an Arctic serial input, okay? And they read the out, okay, so about the 3D out there, just go on and I will delete this. Okay, so right here you can see all of the signals, what they're actually do. Okay, so every time we have new data, okay, this one is the old data in new data, okay, on the D out, okay? And you parallel data of the receiver, okay? They're not out. New, will be asserted to 11 clock, okay? And the data out where the will be asserted all of their time until we will assert the read the out. Okay. When we, when we will assert the readout on the next rising edge, the outwardly will be the asserted. Now, this happens because we didn't know if someone right here was really in the data. So if you're reading a lot of you will have to reset the 3D out, okay? If not, you're not really in the data. Every time that new data is coming in, these pools will jump. This one will stay asserted until you will read that data and the asserted, this the outer ready. Okay? So this is just an overkill for our receiver, okay? And you can use these bits. It's not a mass thing to do. You can just look on the Delta nu, see when there is new data and read it. Now because we are using FPGAs and it's not a CPU. Okay, so you're not going, you don't, you're not always having any other process to do. So. It's not like a CPU, okay, because we're working in a parallel way. But sometimes even in FPGA, the FPGA, something behind on the backend is not ready yet, okay, So you have all of the signals. You can use them, okay? Now, I want to go and start with the transmitter. Okay? So the transmitter will be much easier to understand. Okay? So you will see inside this document we have the transmitter blocks, gay, and now everything is connected. Okay, this is what you will see inside the code. We will go through this on the next lectures. And right here you will have actually the transmitter state machine, okay? Okay, and more of these constants, okay, so we are going to use these constants, okay, It's going to be 2500 hertz. Okay? These baud rate, okay. 115200. And you will have this T1 count. Okay? I will explain you on this just in a second. Okay. Let's go to the steam before we're even going next to the receiver and explaining about this. Now right here you can see we have the data in. We have all the inputs and outputs that we have seen right here on the transmitter. Okay? So we have the clock and risks of course, that come in every two, every component actually and write data and we have the data in and write data in. Okay, so right here we're going to, you know, this assert all the eight beats of the data input. And we have a shift register. And the shift register actually shifting the data from the LSB to the MSB. Okay? So if you want to change these little NDM to begin the end, you can change the data in, in the code to be seven and then you will be okay. Okay, So don't forget of course, to change the shift register way. Okay, so it's shifting to one way. You want to start shifting to the other way. Okay, so in this way we are going to enable the right data in. And as you can see, we have an end gate here, so the state machine actually controlling on the transmission, okay, So it will control when we are enabling this end by setting enable load one. And actually it will tell us that the transmit is ready. Also, we have all of these controlling signals for controlling this flip-flop for the transmission out. Okay? Now, another thing we have here is this timer, okay? Now this time error, I need to explain your bodies or so we have, you remember that I told you on the previous lectures. We have every beat has its own time. Okay? So right here you will see that T1 count equal to 217. Now what is this number? Okay, I want to go to on this number. Explain you this. Okay, So as I wrote over there, we're working in a 25 megahertz. Okay? This is our clock, okay? And about rate of the transmission itself is going to be this one, okay? This is of course with hertz, okay? So the T1 counter is going to be equal to the clock k divided by the bowed. Wait. Okay, what does it gives us? Okay, so let's think that we have our bowed rate, okay? For example, this is our slow clock, okay? The uart changing time phase. Okay, so we don't have a clock, but in every Okay. Sorry, in every this amount of time. Okay. We'll call it t bowed. Every this amount of time, we have the data changing, okay? So we don't have this clock actually in the actual system. But right here we will see that transmission. So for example, we are on idle and then we have the start bit, okay? And then let's say that I'm going to 11 K, for example, 0. Okay? Sorry. And this will be like this. So this is actually the time, okay? This is the time of the day. This is one beat. This is the start bit. This is data 0 and that U1 and so on. Okay? This is item k and either I told you it's going to be one, okay? Now, if we are sampling with this cloak, okay? Now this block is going to be really fast. A, let's say like this. It's going to be like this really, really fast, really fast. Okay, more than that even. Okay, So we're assembling a lot of time k. Now, let's say that right here in this place, because I told you that the data doesn't really look like this. Okay? So the data can be like this, for example. Okay? The South, the data will look in the actual word, okay? Let's say okay, that, let's say that right here. Okay, let us erase this one. Okay. Let's say that. Right in this time, Okay, I found my starting beat a found my 0. Okay? I want to wait. Okay. I want to weight this amount of time, okay? For example, I want to weight this amount of time because I can tell that in this amount of time. Okay. I will call it T one, okay. I will be exactly in the right place, okay? To simple the D, okay? And if I will wait again, T1 will be exactly in the right place to simple D1, okay? Just because I recognize the 0 right here. Now this is the Met hood of this code, okay? And as I told you in the code on the next lecture, on the last lecture, sorry. I will have there not only one simple, I will sample 4 times k. So every time I'm simple in four times, I will wait and then I will simple again four times, okay? So I can't really count on this gap between the beats. So right here I'm just, I'm just counting on this gap between the bits. Now this will give us 217. This is mean that I'm going to simple here to a 117 times, okay? And I will have a clock actually that counting two to a 117 and when I'm getting to 217, okay, I know that I got to this spot. Okay? So this is the method of dividing here. Of course, if you will, Evan different clock or a different baud rate, this number will be different. Okay? Now let us go back right here. So this is about this timer, okay, so it's just simple. In every time the beats are, we showed this right here in the state machine in a second. Okay? Okay, and right here we have the d count, okay, that the count is set to seven. It just shifting the data is telling us how many data left. And this is set to seven, but we have eight bits K. Don't forget. Now if you need the nine beats, of course, you need to put your eight, okay? So it just the number of bits you want to shift a minus1, Okay? This would be the this value k in the code. Okay, so let's talk about the transmitter state machine. Okay? So right here we start with the idle, okay? And right here on the right side you will see this is the trigger and beneath here, this is the actual, okay, so on idle, write data input. When we want to write data out, we need to set it to one, okay? Every time that it's 0, we're staying here, okay? Because 0 and it's inverted, it's going to be one. And when y dot.me that we want to write a data, okay? Right here we are sending the start bit, okay? After sending the start bit, we have to wait T1, okay, As I told you, we are waiting one beat gap, okay? And after that, when we are getting to T1, we're going to clear this T1 timer and go back and send the data. Okay, so right here, this circle, just sending the data, waiting one beat gap, okay, waiting for T1 and shifting the data. Again, sending the data and shifting, shifting into account, sorry, we're shifting the count discount, okay, So we're counting how many bits we actually send. Okay? And this will go on until we get to here on seven. And this is, needs to get to seven because when we got the state, we already send one data, so it's one plus seven is eight bits, okay, As I told you right here, it's seven, but it's actually sending eight bits. And right here on the end of we are ending the count. Okay? Eoc, it's end of count. And we are sending the stop bit waiting for T1, okay, So we will have a stop bit width with a T01 wheat, okay. And then back again to idle and resetting all the things we need to reset. Okay, this is the transmitter. Now, of course this is the, this is the calculation of the 217. Okay, now let's talk about the receiver. Okay, so the receiver, we are going to receive the data from the outside world. We don't know where it came from, so we want to synchronize the data. Ok. Again. This is a really simple synchronizer. Okay, in our, in, in the code that I told you that it's more for experts. I'm going to synchronize four beats. So it's going to be four D flip-flops. Gay and I'm going to check this register that is equal to all zeros or ones. Okay, so it's a better synchronization. Now you can also add it to this code right here. Okay? It's not a problem to synchronize with more D flip flops, okay? Now, right here we have the state machine. And it's all looks the same, okay? Like the transmitter. Okay, So we actually receiving the data right here into the shift register, okay? So every time we receive in a bit, we're going to save it right here, okay? And when we done, we are going to put everything outside. Guy, all the eight bits to the data out. And of course we have here the shift enable. We are going to shift every time that T1 is going to tell us to shift. We will see this later on. And Y2 we have another team that called T two, okay? And I will show you this in the state machine and we will talk about this. Okay? We just go on and look on the state machine. This make everything more clear. Okay? Okay, so the T2 actually has k. It's going to make the synchronization more finer, okay, if I can say so. Now look at this. We're going to be on idle when receiving a start bit. Okay, We're going to wait t2, okay. We're going to wait T2 time. I'm going to tell you exactly what T2 is in a second, okay? Then we have the start check, which is going to be where we're checking that we are still on the start. Okay? We still have 0, okay, so we checked two times, one here, one here. We also weighted T2 time, okay? And then we're going to weight the data. Okay? So actually checking right here, it's going to just the data weight here, sorry, the data weight here is waiting t1. Now what happened in here? Okay? So I just told you a second ago that if I have this data that come in, sorry, that come in like this, okay, this is the start bit, okay, for example, let's say that this is my data somehow and then it's going to want, okay, so right here it's the start bit. Psalm going to check if this is going to be 0 and then waits T2, T2. This is the value of T two, okay? The value of t2 is half of T1, okay? Now what does it mean? It just means that I'm going to wait. Okay, instead of waiting, okay, so this is going to be T1, for example. Actually this is going to be t1 is the time of a beat. Okay? So instead of waiting from here to here, okay? I want to be more in the middle guy, so I'm going to wait half of the beat somewhere right here. Okay, so this is like a half of the beat. This is going to be t two. And from here start jumping d1 every time. Okay? So I'm going to sample here, simple here, Symbian here. Now the data in real life looks like this, is, you don't really know where is the 0, where is D1? Okay? You just, I can tell you if I could put a marker on T1. So this is going to be T1. For example. This is going to be again, the one. Okay? So if I'm waiting right here, half of the beats, okay, I'm stealing side the start bits. Sorry, the start bit. And then I'm going to wait T1. Okay? So there is something you need to know about about sampling, okay. And about some organizations and stuff. I'm talking about the scene, my VHDL learn from the beginning course, okay? So let's say that we have a signal from the outside world. Okay? In electronics there is something called the hold. Sorry, the, you will see these in the data sheet. The T hold in the setup, okay, set, okay. So what we want to do, okay, one side, it's going to be the T Hall. Okay. This is going to be the Ts are in the setup. Okay. And then you will have the T Hall. Now most of the time that the setup, the data sheets of every unknown components will tell you that you need to wait a lot of time on the tee setup. And then that the whole doesn't really matter. It's going to be around, even around 0. Okay? So you need to simply lost somewhere right here, okay? Now this is just due to the fact that okay, signals are getting crazy on the beginning, okay? They can be like this. Okay? Most of the time they are just looking like this. And wind are going to change, okay. The falling is going to be really smooth and looks like this. Okay, sorry, more, more even like this. Okay? So the following is going to be really fast, okay? But the rising time is going to be crazy. So you have problems simple in here. You will always want to sample around here, okay? This is like a safe zone to simple. Okay? So right here, if we recognize the start over here, and then we are weighting T2, T2 gay for example. We are going to be somewhere on before the end of the beat, okay? Because thing that we've sampled k somewhere here. And then we are weighting T2 time k, It's half of T1, T2. And then we're going to sample right here. So we are like around these safe zone. Now why I don't, I think this desynchronization a is less better. Okay. Then the experts in Hosea, okay, when you're counting with register because of these, okay. This doesn't take into account in this design, okay? Now, if you're a good board designer or you know, you want to have this issue, okay? But for example, if you have this issue, okay, and you sampled, okay, yours, Let's say that you need to simple these zeros, for example, or anything else. So let's say that you have simple Dwight here, okay? Let's say that you have simple your one, okay, this is going to be one. So I've sampled right here, I'm saying, oh, great, I have one, but you have here, you're just started. Okay, just, it was just some delta jumping here. So from here to here you will have T2 and then you are not so much in the safe zone, okay, So it's less better, but it's do the work. Okay. So we don't have any issue with this. Okay? So right here after we check the start, okay, we're waiting for data here, this receiving the data. Okay? We're receiving the data every time here. Gay, and of course, a shift in it. Okay. So you can see it right here. We're just receiving the data and the shift enabled, just shifting the data, okay. When we're ending the counting okay, of the data, we're going to stop. Okay, to wait for a stop bit. Now if you want a parity bit, this is where you need to put the state, okay? Right between waiting for a stop way to go, you need to wait for a parity bit. And before doing, before we even jump in here, you will have every time be right here two XOR all the bits and then compare it. Okay? So right here we just go straight to the stop bit, okay, we don't have a poverty bit. Okay, So we are stopping and checking. If if the stop bit is valid. I'm going all the way outside. If it's not, I'm breaking. Okay. And this is the state machine of the receiver. You will see it right in my code. We'll go through my code okay, on the next lectures. Okay? And this is for now. Okay, I'll see you on next lecture and thank you.
7. UART Transmitter: Hi, welcome to the next lecture. In this lecture, we're going to talk about the transmitter. Okay, so first thing first, I uploaded this code, go to this lecture. And as I told you, if you want the professional code, as I said in a previous lecture, go to the last lecture. Okay? You can see, you can see in there, okay, you can go and subscribe and get the full code of professional code. Okay? So we're going to talk on about this easy code, okay? So it can be easier for you to understand the method, okay? Okay, so we're going to actually create this design, okay, so i've, I've created this design right here inside this code. And as you can see right here in the entity, we have all the inputs and the outputs as here, okay? That the e1, which is eight bits, okay? If you want it to be larger or smaller, you can change this one. As I told you that we already talked about this. You will see it right here in the code. Okay? Right here you can see the component here. You are at our x. So this is the receiver. Okay? I just used it for for simulating the transmitter gate. So just ignore IT, guy, you can actually ignore it. Right now in this lecture. And when we will simulate the transmitter, we will use the receiver to actually simulate the transmitter, okay? Okay, so next thing you're going to see in the code is a distinct, we already talked about this, this hour clock. This clock needs to actually come from the outside world. Okay? So your FPGA, we receive this clock gates here like your system clock, okay? And this is going to be our bounce rate, Okay? Now, all of this URL, you will see we are going to use some clock guy that come in right here from the outside world with a reset n, Okay? Now this clock from the outside world is going to be the 25 megahertz. This boundary, this is the boundary it we are about to use. Now if you have a different clock and a different boundary that you want, like 9,600, you can just change, change it here. These are all going to be the signals, and this is going to be the state machine. Now this state machine is the exact state machine here. Okay, let's see the names. Okay, so we have the idle, the right data in start. This is the sand start, actually gave clear CLR timer is the clear timer. Okay. Send data is right, right. Dean data, okay. Right here we have the testy of C shift count. And the right Dean stop is the sense though. Okay. So these are going to be going RB state machine. Now note that for the state machine we have 22 signals that are taking this type of state machine the day. So we have the present state and next state. And right here I want to just ignore this, okay? So all of this, all of these lines are going to be for the uart receiver, inside the transmitter. And right here, I have this process, okay, that actually what it's doing every clock, okay? You just loading the next state to the present state. Okay? So if you take a look right here, you will see that this process is not a clocked process, okay? So it doesn't have any clock inside it, okay, and not the reset gate. So every time we are going inside this process, you just need to understand that all of these lines Suite will happen. Okay? Unless we got into this state, into any of these cases, any of these ones. Okay. So the last one is the one that taken into account. So what do I mean? Okay, So for example, if we have here, they enable the count and it's 0, okay? But let's say that the present state is going to be okay right here, the shift count, okay? So they enable the count. Gay will be one. Okay. So this is going to be the last that taken into account, okay. Because it's coming after that. Okay. So if you have watched my VGA learn from the beginning course gay, I told you that if you're writing two lines like. One after one. Okay. This one will be taken into account okay. Because it's coming after. Okay. So this I know you need to note the steam good. So right here inside the present state, let us take a look inside quickly. Okay? So on the idol. And just take a look right here. Okay, so on the idle, I told you this is the trigger, this is the action. Okay, so the trigger to move from idle to the next state will be right. Data in, okay? So write that n is 0. We're staying on idle. If it's one, we are going to the next state. Okay? And then what happened on the next clock? Okay, the next state is loading the present state, okay? And right here inside the chi-square looking on the present state, okay. And when it's loading on the next clock, the present state, we're going inside the process k. Now, this is one way to write down a process with the state machine. I have so many different ways to write it. You do whatever you find, easier and right for you to understand, okay? Okay, so right here I have this three Okay. These three signals okay, that I set them as, as I shoot. Okay? So I want to clear the data count. I want to enable the load and that takes ready is 0 because we don't have any data that we send right now. Okay, now when we are starting in sending the start, we said in the dy dx, ready? Okay? These, let's just take a look right here. Okay? So this TE, just enabling the timer. Okay. So enabling the timer. So we will know when to, you know, when to send the next guy. The next right here, the next bit. Okay? And just take a look. So outside of this process, we have this process, okay. So this is the time era of the T-account. Okay? So when, whenever we are whenever we are enabling the timer, okay? This, the count will go and count up until it's equal to this T-account. And D1 count is 217 for these 25 megahertz. And the baud rate we have chosen. Whenever it's not equal to 217, it will keep rising. Okay, when, when it's equal to it, it will just stop, okay? Now, right here. Okay? If the one count is equal to the count, okay? So if the one count, if sorry, t count is equal to 217, we will get a one gate to the one else. It will be 0. So let's just see what T1 is doing right here. So T1, whenever it's 0, we are staying right here. Okay, whenever t1 is one, we're going to clear the timer. So do you just do this process right here, sorry, this state right here, just clearing the timer and go to send the data right away. Okay? So it stayed there only one clock of 25 megahertz. It's really a small amount of time comparing to the baud rate, okay, So you will not even notice this, okay? When you are sending the data. So right here we're dumping to write data in. We said in this signal so again, that the eggs ready is already one. Right here we are. We enabling again the counter, okay, for 217, the bit width, and we enable the transmission. Okay? Let's see what these do. Right here. Okay, so enabling the x. So after, after we actually right here, sorry. Let's see. I wanted to show you something before I'm continuing talking about this. So I want to talk about these two process before we are continuing. Okay? So we have seen this timer. We have the counter of the data. Okay. Of course he just counting the data when we're shifting it. Okay. Right in here in this process, okay? And right here we have this shifter, Okay? Okay, and this is actually the, the trick that I want to talk about. Okay? So right here on this clear TeX, this is actually. Okay, The signal that going out, let us take a look. Okay? So this, the x sig is going to the transmission. Okay? So actually if you want to take all of this, if you want to ignore something here, you shouldn't ignore this one. Okay? So the teak see right here on the clear dx is 0 day because this is the starting with the set. The x is going to be one I guess is it's right here. Okay? So it's under stop writing. So this is the stop bits. So it's start with Stop it. And right here is, is the data. Okay? Now if you want it to be, if you want it to be big-endian gave from the MSB to LSB. You just need to change this line. And this right here, this needs to be seven and you need to change the way you shift the data. Okay? So you want it to be shifting to the left instead of shifting to the right. Okay? Okay, so right now we're on in there, enabled the Xt process. We are right here, okay, so we are enabling the data transmission, okay? Now every time that the one is getting to D1, get into one, okay, We just finished a bit, 1-bit. So we are going to test Yossi. Okay. It's not an end of counts, so we are going to shift. Okay. Because we are not We didn't end we didn't end the, you know, the phase of sending all of the data. So we're going to shift count. Okay? You have a towel right here. Okay, so we're going to shift down, we're going back to data. This is going like seven times and then we are going back right here. Okay, So let us see the end of it. So when it's end of count is going to be one. Let's just see when. So the end of count is going to be one when the count is seven. Okay? And then we're going to write the top k. So this is actually the transmitter, okay? It's not so complicated. You can read the code. You just need to go step-by-step and use this transmitter state machine mostly and some of this. Okay, now you could see that I just, what I did actually, I just took every Let's call it a component and I made it like a process. Okay, I separate them and I just connected all the things right here. So this is, this is the way to take a complex. Any other complex design. You haven't make it easier for you. So sometimes I make like really hard designs for DMA with DDR and it's just, it's just a mess. So this is one way to design, right? So if you're working in, you know, in a serious company, you will know that you have two ways to design stuff. We invade the area of the top to bottom. Okay, Matt, who then you have the bottom to top. So it means that top to bottom, you're building a lot of components and then you are going inside, okay? Or you can build all of the components, okay? Like, like here, and then just connect them. Okay? It depends. It depends how complex is the model. Right here? I did bottom to top. Most of the time I do top to bottom guy because it's easier to understand everything. So I just build one big component and then I'm going inside and a bill more components. Okay. So right here, it was just one page, so I don't need to get crazy with this. Okay, and this is for this lecture, okay, on the next lecture we will talk about the receiver and then we will simulate everything. Okay? And this is it for now. And then Q
8. UART Receiver: Hi, welcome to the next lecture. In this lecture we're going to talk about the receiver. Okay? So as I told you, as I showed you before in the previous lectures, we have this diagram and the state machine. Okay, now, this is a very large scale as state machine. Let us take a look right here. Okay, so this is the code of the euro to receiver. Now beside the inputs and outputs, as well as the transmitter, which is equivalent to this diagram. Okay, so we can see here the recent and O'clock, our x readout. Are you ready? Okay, it's the same names. Data out. Which of course we are receiving a serial data and we want to output it in a parallel data, okay? So it would be a harness data, okay? Right here, eight beats. Again, if you want to receive five beats or otherwise, you need to change it nice and you need to change in the code. So you will see that the code of the receiver is almost the same like the transmitter with small changes, okay? Because it's just the opposite way if you take about escape. So just the opposite way. Okay, so we are counting. Again, we will see that we have the counter, It's the same counter. We have the timer. We just have your 32 timer, which I've already explained to you about this on the previous lectures. So you will see here that T2 count, which is actually T1 count divided by two, okay, so it's 108. Of course, if you choose, different clocks are different baud rate. These numbers are going to be different. Now here you can see all the signals that we need for this York. And right here you can see the state machine, which is, let us go one by one right here. Okay, let's us take a look. Go so we have the idle, the start weight, start chick. Okay? So start weight we waiting for 0, starting with Star Trek is just waiting one more clock, okay? To check that we are still on the starting width, okay? And then we are going to dot the weight. Okay, then we have a data check. Okay? And again, it's the same method, like sending. This will be this receiving the data. Okay? Now we have here, Stop, Wait, stop, check stock weight. So after receiving all the data where we want to wait for a stop bit, okay, Now again, I told you if you want a parity bit, you can add here more states, you can play with this. Or you can go on and download my other code, which is more generic, more global. You have there everything that you need for any URL transmission, okay, So it just supports all of the options that are available in the market. So you can go to my last lecture and just download it from there. Okay, so you can find it over there. Just, okay, So let us continue. So this is waiting for this top here. It's checking that we are still on the stop. Okay? And if if this is not the case gate, so we are going to break, if this is the case, we're going to just back to idle. Okay? We're going to update the output, okay? The output is going to be the parallel data. Okay, Then we're going to say a, we have an output, okay? So the d'Arthur new is going to be enabled. So you can see all of these right here, okay, Again, we have the same thing with the next state and present state. Of course, these two signals will take the type of the states, okay? So every one of them have all of these states k. So every clock of 25 megahertz here. The next set will be loaded to the present state. And right here inside this combinational part, okay, we're going to do everything that we need. Okay? Now let us take a look right here. What, what happened, okay? What is going on? So right here on the idle, okay? When we are, when there are excess, which is logistic, look what is our excess? Okay? So our excess, again, let us take a look right here. Our excess. The synchronized input of the RX, because as I told you, we don't know how the wave is looking like. Looks like here. I want to be sure that I'm on 0 or one day. Of course this doesn't solve all of their synchronizations options, as I told you on the previous lecture. So this is just synchronize one time, okay? Most of the time we want to do a double double assembles, okay? So two samples. For a good synchronization. If you do more, it's going to be better. But don't to do too much, okay, As I told you in previous lectures, if you do too much, you can get out of the beat at time k and then you will be in another beat there. You will keep sampling too much. If you're symphony too much, it's not good if you separate into two. If you simply less that, then what you need, It's not good either. Okay, so you want to sample a decent amount of time, depends on your clock and your bowed rates. Okay, So okay. And yeah, this is about this. Okay, So our excess, It's just a process, okay, That's assembling our x in each rising edge. Okay, so we just something RX and putting it into our access. And when I access is one, we don't have started. Okay, so we stain on idol, Hey, we are waiting for star bit when our access is 0, it will go to the else and we have started with, we can start counting t2, okay, So this will enable the counter. Again. We have the T0, T0 enabling where both of the counters, okay, So it will enable. So right here we just care about enabled in this counter. So we have here a T2, okay, So both of them will run when t is one, but we only taking a loop, we will take a look right here and start Waitangi on T2 on half of the bit, as I told you. Okay? And we will check if you're still on 0. If it wasn't just a glitch or just, you know, and noise. Okay, so we we still keep in on and looking for a data. Okay. So if it was a glitch or some, you know, some noise that come in from the outside world. On the stock check we will not see the arc system 0 because it was just, you know, jumping too low and too high. So we'll go back to idle. So if we were having 0 on here on Star Trek, guy right here, we will jump to trust our check. If we have a 0, still have a 0 and started, we will go to wait for the data. Okay, so right here again, we are enabling that T2, okay? As I told you before, note that when we're right here on the Start, check, the T E will be equal to 0. Okay? Because right here we are on Star Trek and there is nothing else that overriding this value. Okay? So whenever I want to start weight for example, or start weight, these values overriding this value, okay? Because they are the last one that being initiated. And right here it will not happen. So T will be 0 and the counters will be 0. And right here we will start again counting. Okay, So when T1 k equal to 1, we want to check the data. And again, if we have, if then we did an end the accounting, okay, We will go to the count and then again to wait to the next bit, okay? When we end the count will go to stop. Wait. Again. End of the count. We means that we just simple story. We just received, yes, sampled seven beats, k plus one beat as I told you in previous lectures. Okay? So right here, you just counting seven, but when we came here, it's already simple, the first one, so it's seven plus 1, it's 8, eight bits or one byte. And again we're going to stop, wait. And you just go again like that transceiver, okay. Okay. So we're going here to stop and check that we have a stop bit. Gay. If there are excess is 0, there is no stop bit. We want to break it out. If it's one, we are updating the output. Okay? So update the output is this guy. Let's see what happened in on updating the output. What does he do? Okay, So right here, that out enable is one, the data Shift K, right here we shift again if you want to, if you're receiving okay. Big Endian, okay. If you change the receiver and transmitter, sorry, you will have to change the receiver. And this R x x will come right here. And you will write here six down to 0. So it will look like, so if you're changing this to a big endian, it will looks like this K, I just want to show you this, okay, So it would be looking like six down to 0. So right here you will rotate to the left. This will be rotating to the right. Okay? Okay, so the Alt Shift right here under the outer enable the shift will be equal to the outside and the outside is always equal to the data out. Okay? So we have something that's saying, hey, they're not out is ready and the data out to the outside, which has been rotated all this time. Okay? One more thing. We need to tell that the output is ready. So the new telling us say the output is ready and all of these things equal to this case. So this will, what will happen. And we will see it in the simulation on the next lectures. Okay? And actually, this is it for now about the receiver. You can go through this, okay, I will upload this to this lecture. And this is for now. Okay, I'll see you in the next lecture. And then Kim.
9. Receiver simulation: Hi, welcome to the next lecture. In this lecture we are going to simulate the uart receiver. Okay, so first thing first, we have the receiver file gay called the yard are x-dot VHD. And I also uploaded to this lecture, okay, the test bench for the uart receiver gate. So let us go through these testbench, okay? And after that, we will go on and open a product inside modal same and simulate the receiver. So you will understand more about your transmission. So Okay. Okay, so let's start right here. Okay, so inside the test bench, of course we have the component of the Earth receiver, gay. We have couple of signals here, the reset, the clock, the read data out, and they are now about these outputs. I left them open. We will just take a look right into the component, okay, inside the component, we don't need to just look at this. So we can just look at the output itself, okay? Okay, so right here we have the clock gay for 25 megahertz. Okay, and we have a reset gate that active low reset. Yeah, so inside this is the actually the testbench a itself. So right here you can set the baud rate, okay? If you want a different, if you are going to change the baud rate right here and the clock, of course, you need to change it over here, okay? The clock and the bounce rate, okay? Another thing that you need to change here, if you want to change it to k, the number of data that you have inside the packet guy. Here it's one byte. Okay, so right here you can see that every 100 microseconds we are going to send to the receiver, different serial data go into the RX. So the thing is that we're going to send with these four, okay, this beets, okay. This is going to be the first data. This is going to be the second data, and so on. And inside these 44 we can see that we're just rotating the data. We just every time we are sending bits from 0 to seven. So another thing, if you want to change from a Little Endian, too big endian, and so on. You need to change these loops from seven down to a 0, okay? Or just flip the bits. Of course, you should just change the for loops from seven down to 0. Okay? So let us go on and see how it goes. And what do we get when we are sending this to the receiver? And other, one more thing that I wanted to say. So right here before we are sending all of this. So we're setting the r x to be 1. So it's item, this is the start bit, and right here it's the Stop it. Okay? So if you want to add a parity bit k to the code here, you can add it between the end of the loop to the stop bit. But also you can go on and go to the last lecture. Okay. I'll go into my site and download the, the receiver and transmitter that I have there, which are professional and checked on many, many products. Okay. This also been checked on development boards and projects. But again, the other one in just overkill. And it's really professional. Okay. So what we want to do right now, go ahead and just go on. And I already did. I already changed the directory case. So this is where I'm going to work under my courses folder. Okay, I'm going to create new project. This is called it work. Okay. Call it the REX, doesn't matter. Okay. And add existing files K. Let me just take this. Yeah. So right here. So on both of them get it as close. This compile all of them. Okay, and I want to go to the library. And right here simulate gay. Now if you don't have this Windows, you can go here on under view, sorry, under View. And here you have the library and project X. Okay. So after it's been opened, you will see this sim window guy. This is the test bench. Okay, let us edit here. Let us call it TV. Press here. Let's create another one. Sorry. This is the receiver, the receiver unit. Let us add everything, okay? And let us run it. Let's see how much we want, okay, because it's really slow. Let's go on one millisecond here. Okay, So this is the simulation phase. Let us take a look and see what we got. Okay? First thing first, let us take a look on the first one. Okay? So right here we are sending c and c k right here we're sending 35. Okay? So if, if you find it hard to understand how you can go to the calculator, you have any windows press right here, programmer go to binary. And right here and paste. And you can see this one is CC in hex. And this one is going to be, I can delete this. This one is going to be 35 in hex, okay? The last one is going to be F and 0, okay? And right here you can see we did this. I did a f, a frame error. Okay. So it needs to break from this because there is no there is a frame her arrow here because the end, there is no end. Okay? So the ID is going to be 0. Okay, so we're going to have a frame arrow because we're sending 0 instead of a 140 ending beat. And white here. We just put in a short pools for the starting pools. Okay? So we just checked that if the, okay, the start pools is really short, what will happen? Okay? And we want to see what happened in these two. So we only actually looking for these two guy for CC and 35. Now if you look at this leg that you can see that the data out saying CC and 32 with the data out new. And right here. And right here, nothing happened. And this will be the short start in beat, and this will be the frame error. And another thing you can see here, that's right here, you just break. Wait. Okay, on the other ones, It's got into idle. And let us go through these and see what's going on. So I can zoom in right here. Okay, and I will explain you the thing with the t2 and t1, okay? So under our x we get 0. First. Let us add one more of these of the coarser. So right here it's getting to 0. Let us look this one up. Okay? And as you can see, we can tell that the next change is going to be right here. Okay. Let us see. So if we are dividing, just let us go back to the scientists thick. One divided by 1152 thousand and it's going to be 8.68, hey, 0.798. Okay? Okay, so this is going to be our, actually our beats, k1 beats. And just take a look again. Let's take another one, okay? 8.8. Okay. So, so because we're working with 25 megahertz and you want to receive 115 to a 100. And we have a small deviation, okay? So there is a, you can actually create, buy yourself a table of deviation, gay. Or you can find in the internet. So in what club they want to work to receive the smallest deviation K for a certain uart about right? Ok, so you can do that India Internet. You don't even need me to do this. So right here we can see. Okay, The first beat coming up, okay, It's going to be 0 in the next bit that we're want to receive right here is going to be this 100 and then one, okay? So it's going to be 0 and then another 0 from here to here, okay? And right here it's going to be 11. Okay? So what happened in here? It's just when it's getting to go into 0, we have a start weight, we are on to start weight, okay? And after that, we're going to we're going to start check. Okay. When we got 22 is going to one, we're going to start to check. Okay? After a T2 got to one, we're waiting again. Okay, that await. We are waiting for the data, the one and then we want to sample every time in the middle of the beat. Okay? So we're every time that T1 right here guy is going to jump up to one. We are actually, as I told you in the previous lectures, okay? So we actually want to be in the middle of the BD2K. So if this is the, this might be 000 001. Okay, so every time that T1, because we have this shift of T2 and then we are starting counting the T1. Okay? So the t, we are going to simple right in the middle of the beat. Okay? So every time we are assembling, and when we're assembling, something happens here, okay? And you should take a look at this, okay? Right here, the data out shift is getting shifted, if I will open this one. And let's just zoom out a bit. You can see that it's moving. Okay? So it's shifting itself until we get in C and C. On the end here, we have the data away, all the data weight. Okay, on the end we have the stop, wait, waiting for the stop. Okay? Then we are checking that we are actually on the stop. Then update outputs. Okay, we're saying that the output is valid. Let's just see right here. Okay. So the data out new is valid and render that out where the Israeli, okay. Now because we don't have anyone to read it, you can see that the dot out ready is waiting all the time so until I will read it, okay, if I'm going to read it right here, the dot out Verdi will go to a 0. Okay? So we actually can do something. Nice here. Let us, let us go on and, and let us go on and read it right here. Okay, Let us see when we just go and really tried here. Okay, let me just find that time, the right time. Okay, so we're going to read it on 153 microseconds and then see the data out ready going down to 0. Okay? So if you're a receiver, sorry if you're, if you're on the backend of the receiver K in FPGA side. And you have the receiver. And you are reading from the back-end, it should go to 0. Okay, So let us take a look on this. So I will just run 100, 53 microseconds, okay? And right here, let us go on and read the dot out, K SOM. Tell him I'm like, you know, looking on dot out. Okay. If I'm the backend, okay. And I'm saying, hey, I, I was really neat. Okay. Omri the needs. Okay. So let us jump one microsecond. Okay, that's enough. And as you can see, when I was really neat, okay, the data out ready is going to 0. Okay, Let us now press no force, okay? So we'll go back to 0. And now when we run again, you will see that the data out ready will go up only on the next data that is waiting. Okay? So if you want to work right with the backend, when you, when you are reading this, you can simply, whenever the dot outwardly or you can just go on and take a look on there that out new. And whenever there are new, if you know, this is depends. If you know that your back-end is going to be busy. Okay? And you can't really read right here you want. You have something that you're doing on the backend. I don't know. You have a FIFO that they might be full, maybe. Okay. If you have alone a lot of transmission and your a fully enough FIFO, Okay. You can't you can't read a right away and you want to read it right here, okay? So you can take a look on New. You will have to take a look on the data, our 20 and say Okay, that out is ready. Okay, I can read, Okay, And then he will tell it I'm reading and on the next data that out Wednesday will be one again. Okay. But if your back-end is LU is, is, is okay and you don't have anything that they're stuck in you from receiving the data. So you can just take a look on the data out new. Okay, So whenever it's one, you're just going to read and continue on. Okay? So there are two methods of reading the data here. It depends what you want to do on the backend. Okay, so right here we can see that. Let's see what happened here. So it's got to stop, wait, stop, check. Okay, it's checking the stop bit, but the stop bits right here is going to be 0, okay, So this topic cannot be 0 and you just break weight. And note that the output was enabled, so it's Break weight and gone, gone to idle. Okay? So it's going to idle. So it's going to either whenever the line is going back to one guy. And this is the idle mode whenever x is 1, okay? And white here, of course we just have a small right here, we have just small jump to the start weight and then let us see what happened here. Okay? So right here what I did here, okay. So instead of being you remember it was 8.8.8. Okay. So this is two points, 17 microseconds, okay? This is a two small start in a bit. So T2 was counting, okay? And white here, we checked it, okay? And we check that if it's valid, okay, and it wasn't valid, Let us see. Okay, so we check the start and it wasn't valid and we'll just go back OK, to idle because it wasn't valid. Okay? Okay, and this is it for this lecture. Okay, on the next lecture, we will just simulate the transmitter K and we will use the receiver. I will explain how we're going to do that. Okay? And this is it for now. And 10 Q
10. Transmitter simulation: Hi, welcome to the next lecture. In this lecture we are going to simulate the transmitter of the uart. Okay, so first thing first, in the uart DEX file that you have already downloaded and Ampere's lectures. You can find right here that the component you are, our x is going to be also inside the code, gay. And I told you you can take it down if you're not simulating. But right now we're going to simulate, so you will have to enable this guy. Just leave it like this. Now the reason that we are putting the Earth REX okay, inside, I want to show you first. This is not a Desmond over dx, just a second. So this is, you have also right here under this lecture, this uart takes testbench k. So I will just show you right now what we're doing in the uart ticks. And then we will explain about this component and why, why did we actually edit the Earth, our x inside, okay, so what do we actually do? We have the uart takes k and we have the data input. We want to load the transmitter with a parallel data, okay, one byte here, for example. And we want to write to enable the right. And then we want to see the transmission outputs in the serial output with a boundary that we said and everything. Now the thing is that we can't really check by our eye if the transmission is okay. Okay, so what we're going to do right here, before setting it out to the output inside the ERT x, let us take a look. Okay, we have the ticks signal gate and the peak signal is always going out to the ticks. We're going to actually connected the exceed inside the uart REX. And actually this will check our simulation. Okay, So instead of, you know, just taking, taking a close look on each beat and, you know, it will really be hard for us to check it and to check that this ok, that the communication is right. We will just connect the serial outputs to the uart RX and the York RX will actually check it for us. We will see again the dx transmission in the uart RAX. And we will see the data out here toggle in the same data that we just added. So let us take a look on the, okay, on the test bench. So right here we have, of course the RTX a, we need to connect this one. Of course we have the clock of the 25 megahertz reset. And right here all the things are going to happen, okay? So right here inside the process, you will see that the first sending will be right here. Okay? So we're sending 0 and just adding the age. And what does it mean? We are adding the ascii values. And the ascii value of the age character of our keyboard j will be 48 hex. How do I know that? You can go to Google? Just write down ascii table and you will find tongs of ascii tables, okay? And just take a look on this table and understand, okay, so age, character in your keyboard, if you want to print from your FPGA to your PC, the age character, for example, you will have to write to the PC 4800 hex. Okay, So if you take a look right here, you can see that there is a column name, char, gay character. And right here under the age, you will see that the decimal value is 72. The hexadecimal value is 48. Okay? So this is actually what is going to be sent. These value 48 in hex or a 72 in that CMO. Of course we are working, we tax now. People are saying ascii numbers represented by seven bits. Okay, That's right. But when we are connecting our FPGA to our computer and we're going to talk with the terror term cater at them. We didn't go through this, but let us write it down here and I will show you what does it mean. So you have you have two options to connect. Your yeah. I mean, you have many options, okay. But you have two main applications that are going to be communicating with serial communication. And one is Tera Term, okay? It's an open source, of course. You can download it. This, the terror term, okay? So when you download it, it will just look like this, okay? And you can choose a cereal and the COM port in your PC. Good is being connected to your. Your development board, and you will have more option to choose over there. You can choose what boundary it you're going to use, and how does the beats looks like and more. Okay? So you can actually choose between five to nine beats. You can choose wheat poverty without poverty, one to two stop bits and so on and so on. Okay? The other one, which is really nice, called Pucci, okay. This one is free to download too. Okay. It's really strong tool to, okay, I like both of them. I'm mostly I'm using terror term, but it actually doesn't matter. The boys both. Really good. Okay. So this is about this thing. Okay, so if you're going to use and you want to print to yourself, you know, stuff to your PC. You can use eight bits, okay? It's all depends what you're going to set on the terror term or on the potty. So it will be okay to, you know, to write down eight bits even that if you will go on and write down ascii, for example, and you will read about it. You will see that the ascii numbers are going to be represented by seven beats, okay, It's a 7-bit character, okay? So just don't, don't ignore these, okay? This is what the, I think you should do. And now right here on the first, we're going to send the age Carter, Okay. And we're going to over there, just do everything we need. Okay? So right here we just load the data to the transmitter. We don't do any toggling off the start and stop bit. The neurotransmitter need to do it by itself. Okay, so we'll send high k h I. And then we are, we can send this to okay, so this is just a cartridge return and this will just go, it's like an enter, okay? So if you want to like person enter, you will write down so dark boat coming together, a CR and n lf. So you will see it like ending the transmission and going one line. Okay? So it's called CRLF. Are these called a line feed? Okay. And this called cartridge return. Okay, so this is just something for you to know. You don't have to print both of them, but it can be a nice thing to do. Okay, and right here inside this process, we will also check the transmit gay. So this will be the second way to check the transmission. Okay, So we have one way right here inside the transmitter. We just implemented the uart receiver K. Of course, if you are using the code as I told you, you can ignore these indices just for simulation. And we have another thing that just, I'm going to check our transmitter K. So it just, again, that takes our x, is that signal the output of the ureteric scale. It's actually the output. So this process will just check that we have start bits in the for loop. It will take 11 by one all of the bits to the D input and just put it to the day out k. And it will show us what value do we got here. Of course, it's checking here the stop bit and everything. And it's a really simple process. Okay, now let us go on and start simulating. Okay, so right here I have the file, again, new product. Let's go at work. We can call it the x. It doesn't really matter. Okay. Add existing files. And why do you want to add all the three files? Okay? The transmitter and the transmitter, a testbench, okay. And the RX darks will just check us that everything is fine. Right-click compile all. And right here inside the library we go to work. Right-click on the Test-Ban stimulate. And you just should pop up. Everything should pop up right now. Just take in a second and write u. Let us go on and add some divider. So this will be our test bench. Just write down here. This is when we are a transmitter and let us write down here the receiver inside the transmitter, okay? Our aches inside the IQ scale. So you will understand what is this? So this is the test bench. Right here. We have that the transmitter. They can press right here for the names and right here with the receiver. Okay. Now, let us go on and run everything. Okay? So what do we do? What do we see? Sorry. So right here, we can see that we added here the data in, okay? Okay, so what we want to do here, we can choose a different color. Let me just take this one. Okay, Right here, right now you can see what's going on. Okay, so I can zoom in. So we put in the data input k, The 48 we talked about, okay, this age, Carter, and we write in the car there into the transmitter. Okay, so right here inside the transmitter inputs, you will see that at the input and the right in is jumping one. Okay? And what's going on? When we do this? Let us take a look on the output, okay, on the case of the ticks is going to 0. This is the starting bit, okay? And then it's starting sending Something, something, I don't know. We can actually, what we can do, gay, what we actually can do. We can go on and calculate it. I can just put the cursors. This is what I meant. We can't actually tell what did we sent here. Okay. So I can do really hard work and go on and put, you know, with the cursors in the right spot. And our rights both is around 88, seeks to 8.8 microseconds. Okay. So we can actually add more of them. Okay, So I can I can put it over here. Okay. And if we were taking a close look on the T x again, a little go on and change the wave quarter. Okay, let us go for this home. Okay, so you can see it's 0, the starting date and then 000 001, I guess it's 001. Okay, and so on and so on. Okay. And I can see the Stop it. Now. I can't really tell what do we send here. Okay. Now, if I want if I want to see what did we send again, this is why we added here the receiver. Ok. So the receiver guts inside these are the same thing. Okay? You got the same transmission. And then on the output you can see the transmitter just added to the stake off all these courses so that the receiver just got the transmitter transmits, okay? And of course on the output you will see our 48. That means that we really got this. Okay, As we wanted to. And also you can see on the test bench itself, so this is this part right here. Okay? So this is just process here. So on the doubt, okay. You can see are the 48. So you have we have two processes that checking it out. Okay. We have this process, okay. On the test bench itself and we have the receiver that checking our transmissions. So you can actually take a look on the next thing we're going to load the case. So it will be the next thing we're going to load is going to be 69. And again, I don't even have to bother about this. Okay. So we have just sent 69. Okay. So the transmission send 69. And I again, just go on. Sorry. I can just go right here to the receiver, inside the transmitter and see that it actually send a 69. It actually send the 0 d k and it's sending the a k. Let us take a look right here. Okay, so it's D and a. And of course this one was the 69. Now, this is actually how we are going to test our transmitter K. And this is it for this lecture. Don't forget to download that one's meter Testament file. And don't forget the need of the three files, okay. And actually this is it for this lecture, okay? And I will see on the next lecture, go on and check it out. Okay. Check the next lecture if you want. You know, my, my best. Your transceiver, VHDL code. Okay, so go on and check the next lecture, and this is it for now. I'll see you in the next lecture and thank you.
11. Bonus Lecture: Hi everyone. Thank you for joining my course and finishing it. If you want my code, this code that is a generic code, okay? So you can actually choose everything that you want, okay? You can send many, many backends we did. You can choose the bite size, the number of stop bits, and the parity. If there will be parity or not, the type of poverty. If you want this code, okay, you have these three files. Just go onto my site, subscribe and you will get my professional code. Gay. I work really hard for this code. So please, if you want these code, you go, you can go on and subscribe. Also with this subscription, you will get my other courses, coupons two to three times a month, okay? And you'll get updates whenever I'm going to release a new course about everything in electronics, FPGAs, VHDL, the Arduino, whatever I'm doing, k. So just go onto my site. You can check out. Don't forget to join our Telegram deck group. And you can also subscribe and join my Facebook group and do my YouTube channel. And this is the open joined the course. If you have any questions, don't hesitate to message me. And of course, I will really appreciate if you review my course or leave the comment, okay? And this is it for now, okay, I'll be enjoying. I enjoyed the course and I hope to see you on my other courses. Okay, so go in and check out my other courses. So I'm going to release new courses about other communication protocols. So you can also, so if you want to be updated about them, so there's go on and subscribe, Okay. You will receive a device right after subscription, okay. So wherever subscribe we'll get these files. It doesn't matter when. And this is for now. I'll see you on my next courses. Thank you for joining this course.