 In this video we're going to study another element of computer systems, more precisely the bus. We can see that the bus is used to communicate several circuits and to exchange among them certain signals. And here we have the example of the control, address and data. But the most important observation is that several of these blocks over here are both having bi-directional communications through the signal call, the bus. So let's see more detail how a bus works. Let's talk about buses. Suppose we start with the following initial condition. We have two circuits, C1 and C2, and they would like to talk to each other. They would like to exchange signals, but let's assume that the signals they have to exchange are made out of a numerous number of bits, like for example 32. Let's represent it like this, 32. So what we're representing here is that circuit C1 needs to send 32 signals or 32 bits to circuit C2. But it could be the other way around that C2 also needs to send to C1 another 32 signals. Now there is an initial solution for this problem, which is, well, it's no big deal. We just use 64 wires to communicate between these two circuits. However, when the number of wires keeps increasing, this duplication can be avoided. And the way to avoid this duplication is the following. Let's draw this situation a bit bigger. So this is circuit 1, and this is circuit 2. And now what we're going to do is draw down here a line, thicker line, which maintains 32 wires, and this is what we're going to call the bus. Now the idea is for these circuits, C1 and C2 to exchange information. In other words, there should be information going from C1 to C2 and from C2 to C1. Typically, the way we represent this is by a bi-directional arrow like this. What this means is that this circuit over this set of lines, it has two possibilities. It either writes a value on the signal so that they are read by this circuit, or it reads the value from these signals into the circuit. However, a more detailed description of this behavior could be represented by two lines. One that represents the fact that the values in these 32 signals are read by the circuit. And another one, which we're going to give this symbol over here, represents the fact that this circuit is writing the values into these 32 signals. Now let's see more in detail what do we mean by this circuit over here. This circuit over here has an input, an output, and some signal called C. The behavior of this circuit is trivial. If C is equal to 1, then input, it's equal to output. If C is equal to 0, then, and this is the most important part, we have a disconnect. So this circuit over here offers the possibility of connecting and disconnecting this circuit from these 32 signals. Now let's suppose we have exactly the same situation here. We have one of these control signals over here to write into the bus and reading from the bus. So now let's think in terms of these four communications. Let's suppose now that C1 wants to write a value, C2 wants to read a value. In other words, C1 is producing certain information that needs to be transmitted to C2. How do we achieve this? Well, clearly, C1 in this case has to use this circuit over here because it wants to write values in the bus, where C2 has to use this connection over here to read the values from the bus. So in this case, if we call this control, this signal, we call it C1 and this signal over here C2. Therefore, C1 has to be equal to 1 and at the same time C2 equal to 0. Under these conditions, on these wires over here, only one circuit is setting or forcing a set of values and the other circuit is reading. If we wanted to work the other way around, then it is trivial. What we do is C1 now is reading and C2 is now writing. In this case, the signals are reversed. C1 is 0 and C2 is 1. In this case, C2 is turning on the signal and therefore the signal from here is being written in the bus and C1 is reading the signal. It needs no special condition for that. So as we can see, the advantage of this scheme over this one is that by using only 32 wires rather than 64, now we can manage to implement bi-directional communication between these two circuits. However, there is a very important property that we haven't mentioned that is fundamental for buses to work. Only one circuit is writing a value and this is represented here by the fact that the two possibilities of C1 sending information to C2 and C2 sending information to C1 are represented by these two sets of signals. And as you can see, only one circuit is writing on the bus. Now the next question we can ask is what happens if both of these signals C1 and C2 are equal to 1? Well, the best way to imagine what happens is that you will have 32 wires here. This circuit might be forcing certain value into these wires and these other circuits and other different value into these wires. And when that occurs, the value of these wires is what we call undefined or undetermined. And for this reason, this rule over here exists. So summarizing what we have described so far, one way to implement a bit more efficiently or saving certain number of wires, a bi-directional communication between two circuits is by sharing the same set of wires for two purposes. C1 sends information to C2 and C2 sends information to C1. Now the trade of here what we have exchanged is that C1 and C2 cannot exchange two data simultaneously. They have to be configured these two circuits either in this position or in this position. Another way of looking at it, this circuit in order to exchange two values between C1 and C2 has to follow two steps, whereas in this configuration, the two values could be exchanged at the same time. So this is the simple example of a bus that is connected to devices. But the power of a bus becomes even more evident when instead of two devices, what we have here is, and all of them have the same scheme for communicating. And by the way, all of them have the same width, 32 bits here, 32 bits here. All these signals over here are the same size of the bus, 32, all of them. Now, as we can see, if we want all these circuits to exchange values among themselves, this scheme is no longer valid because it will require a very large number of wires. Especially if each circuit over here has the capacity to communicate to each other circuit over here, the number of wires would be extremely high and therefore not feasible. However, in this scheme of the bus, we still have our scheme working perfectly. In any case, if one of these devices can communicate a value to another device, the most important thing is that device, the control signal of that device, let's call it CK here, C3 here, if this device sets the control signal CK to 1, the value of this circuit gets written into the bus and it gets transmitted to all the circuits over here and each one of them can read the value. Therefore, another property of the bus is that one single circuit or one single unit is writing several. So for the special case in which I want to communicate certain value from this circuit to these other circuits, the bus works perfectly because by virtue of writing this value on the bus, it is available to all of them and therefore all of them can read it through these inputs. So we can see here that when we have a significantly large number of devices or another possible situation is what if we want to expand the number of devices? In this case, the bus configuration is optimal because it allows me to plug yet another device to the bus as long as I observe this rule over here. Now, what happens when I have several of these circuits and all of them want to communicate something to the bus? In other words, how do we enforce this rule over here? There are various techniques, but one that is used very often is the design of a circuit specifically to enforce this rule which is called the bus arbiter. Now, the bus arbiter is a circuit. Typically, it's a circuit that controls the entire bus and it's a circuit with which all the circuits connected to the bus have to talk to and request the permission to write on the bus. And this circuit over here is in charge of distributing the access to that bus among all these circuits over here. Now, typically, what happens when all these circuits have to be put synchronously working in this bus is that we have an extra signal which is never drawn when we draw a bus, but it's always present, which is the clock. So the clock, which also is used by the arbiter, is this signal that allows all these circuits to make requests to the arbiter to write a value in the bus, and the arbiter will grant those requests in a one-by-one basis so that this rule over here is always enforced. So this is the advantage of the bus to communicate several circuits and to make sure the information can flow, large number of bits can flow between different units. Now, we go back to our image of the computer system. We can see the advantage of having a bus to communicate three elements, data, address, and control signals. These three buses, they have different widths. Here we have N, M bits, and C bits. But these three signals reach both the memory over here, the microprocessor. Within the microprocessor, they reach different places to the interruption controller over here and also to the input output subsystem. So this is the situation in which one, two, three, four major systems need to exchange a lot of signals and therefore the most appropriate decision is to use a bus.