 Let me show you a fun program that's installed in the Linux lab. It's called BLESS. BLESS is a hex editor, which means you can edit the hexadecimal values of files directly. The B in less stands for binary. You'll learn about less later in the semester. So basically it allows you to look at files at the binary level. Let me create a new file here. I'll call this file hello dot text. And let's just say hello cs101. I'm going to save this file, which is just a plain text file, and open it in BLESS now. Open desktop hello dot text. You'll notice on the right I have the text hello cs101, and on the left I have the hexadecimal value for each one of those characters. Let me make this a little bit smaller so it's all on the same screen here. 48, that's the hexadecimal value of the letter H. 65, that's lowercase e. 6c, now remember these are hexadecimal values, so the digits go from 0 to 9 and then from a to f. And the nice thing is down here on the right you can see both the hex value, the decimal value, and also the binary value of each of those characters. So right now we're looking at LLO space, or actually if I select this point right here, I have space cs space, so it's always showing you 4 bytes at a time. So where did these numbers come from? When you're reading the book you'll learn about the ASCII code. I'm just going to do a quick Google search for ASCII. It stands for the American Standard Code for Information Exchange, which is just a fancy way of saying this is the binary or hexadecimal value for every character. If I click on the images tab on Google I'll see a whole variety of ASCII tables. I recommend finding one that you like the way it looks. Let's take a look at this one. So here's the ASCII codes from 0 to 127. That means we're only concerned about 7-bit ASCII. And you'll notice a lot of the ASCII codes are characters that don't even print, like a tab character or a backspace or a new line character or a carriage return. But mainly the letters we care about are the capital letters a through z, the lowercase letters lowercase a to lowercase c, the digits 0 through 9, and then some other things like commas and punctuation and a tilde sign even. These are the codes that are interpreted by this BLESS file. So if I see 48 that's the hex character for capital H. Sure enough there's the 48 in my table on the left. So I'm not going to ask you to memorize conversion from ASCII to text. That's sort of tedious and computers do that for us anyway. But you should understand when you're looking at this series of codes in a hex editor that's where the text comes from. This Friday's lab will involve designing circuits. Let me give you a short demonstration of the tool we'll be using. It's called Logisim, which is short for Logic Simulator. You can find it online with a quick web search. L-O-G-I-S-I-M. There it is. Logisim is a graphical tool for designing and simulating logic circuits. This is the kind of circuit that you'll design in CS350 computer organization. We're just going to focus on the basics this week. By the way, every tool we'll be using in this class is freely available. I encourage you to install Logisim on your own computer. If you click on the download link, you can find instructions for Windows, Mac, and Linux. We also have it available in the lab. If you just click on the menu and type L-O-G-I, I guess that filters down all the menu entries that start with Logisim, you can click on Logisim. By the way, before I get into the actual software, make sure you look at this documentation on their website. In particular, I'd like you to look at the beginner's tutorial and work through those steps before coming to the lab on Friday. Now, let me show you an example logic circuit. You'll notice across the top here on the toolbar, you have the most common elements that you'll have in your diagram. I can put text in the diagram, or I can put pins, a knot gate, an AND gate, and an OR gate. I'm going to start by writing down in text what I'd like to do. Let's say if you study hard and if you come to class. That didn't quite fit, so I'm going to click the arrow sign and move that onto the diagram. And if I want to make a circuit that says, I study hard and come to class, I need an AND gate. Now, the inputs to this logic gate are pins. So I click Add Pin. I'll put one there, and I'll add a pin here. And these pins are what will represent studying hard and coming to class. At this point, I can draw wires between the pins and the AND gate. If I just put my mouse over the edge of the pin and drag a line, it connects into the gate, like so. And finally, the output of the gate needs to go somewhere. I'm going to put that in an output pin. So let me grab one of these pins, put it over here, and if you put it close enough, it will automatically connect the two. So now I have a circuit for study hard and come to class, and this little finger button here will toggle the values of those pins. So for example, I can turn that one on. You'll see the value of that pin is a positive charge. That's why it's 1 or light green. And if I toggle the other pin, look what happens to the output of the gate. 1 and 1 is 1, as we talked about in class. And you can play around with toggling those gates on and off to see what happens in the simulator. Now this is in a particularly interesting example. Let me make it a little bit more complex. So I'm going to move the output pin over here and add an OR gate to this. Let's say what I want to say in the end is whether I'll get an A in the class. So I'm going to make a little comment for that. Get an A. Looks like I'll need to move this over a little bit. And let's have a new input that says you already know the material. So if there's a senior computer science major taking this class, she already knows what we're teaching in this class from her experience in other classes. All right, I'm going to wire this up. So in this example, let's see here, I messed that one up just a little bit. Let's delete these extra wires that got added. All right, and I'm going to draw into that. And I'm going to say the output of my AND gate is an input into the OR gate as well. We got some extra wires again. So now either you study hard and come to class or you already know the material, and that determines whether you get an A. So in this case, the students in 101 are both studying hard and coming to class. If someone is coming to class but not studying hard, they don't get an A. So if they already know it and they're just coming to class, then they might get an A. So you can see how I have these circuits that connect three different pins with ANDs and ORs, and you can see the output of that operation by toggling them. Now let me show you a second example featuring the flip-flop circuit that's in the book. So if you look on, let's see what page was that again. Page 23 of the book, a simple flip-flop circuit. It looks like this. I have an AND gate in the middle, and this AND gate is actually facing the other direction. So I'll change the property here on the left instead of facing east facing west. I have an OR gate above that, and I have a NOT gate at the bottom. And there's two inputs to this circuit. I have one here and one here. Oops, that's an output. Let's make this an input. And finally, I do have an output on this side. We'll put that right up here. Now I'm going to draw the wires between the circuits, so this input goes into that gate, and this input goes into the NOT gate. Oops, got a little extra one there. Let's delete this one. And now if I wire up the rest of the circuit, sometimes if you want to draw a line that's a square, you have to let go of the mouse partway through, because logic symbol only makes a right angle. So now I can actually draw that loop back, and I can put the output of this circuit. Let go. Click again into the OR. And like we talked about in class, what really makes this circuit interesting is that the output of the gates are the input to the other gates, right? So the output of the OR becomes the input to the AND, and the output of the AND becomes an input to an OR. This loop structure is what makes it possible for this circuit to retain memory. And I'm going to take this circuit and put it into my output there. So I believe that's the whole circuit. Now let's play with this circuit and see how it works. Currently the value is 1. If I wanted to make it 0, I just clicked this bottom link. And notice that I can toggle it as many times as I want, and it still stays 0. But if I toggle the top one, it still stays 1. So this switch up here turns the bit onto 1. This switch down here toggles it to a 0. And regardless of what happens afterwards, that value stays the same. As long as the charge is flowing through these gates, this circuit remembers a single bit of information.