Tác giả giữ toàn bộ bản quyền (All Rights Reserved) — không phải giấy phép mở. Bạn vẫn xem và học miễn phí trên OpenER; muốn tái sử dụng cần xin phép tác giả.
[MUSIC PLAYING] NIKOLIC GARCIA: Welcome back to our module that deals with virtual memory and operating system support.
By now, we have figured out pretty much how does virtual memory work. So what we'd like to do in order to complete our compute system is to add I/O devices.
So let's get into that. We made tremendous progress so far in this class. We built almost a computer.
So we started with a high level C program and practiced that through the first project. Then, we learned the assembly language for RISC-V ISA and practice that and really cemented it through project 2.
Then, we built a data pad that pretty much can execute our program from project 2 minus the e-calls. But that's not very difficult, although not too educational to implement over there.
It just added a burden. So we can assume that it can build. We can run pretty much everything we have built in project 2.
And we can also compile our project 1 and run it over on our core. We added cache memory.
And then we connected the virtual memory so all that what we need in order to have a computer is to add I/O devices, such that we can hook up a keyboard and a mouse and display our results on the screen and perhaps connected to a network.
The key thing here is we would like to understand the principles how these I/O devices are connected such that we don't have to do one at a time using some special procedure.
So let's get into that. So how do we interact with the devices? So we have a program running on a CPU.
And then it would like to print something on the printer or receive input from a keystroke. So how do we do that?
So we have our processor and a memory, and there is some code that is running on that. So we need to have an I/O interface for keyboards, network, mice, displays, and so on.
And we would like to do that in a uniform way such that we don't have to do it separately for each one of them. Generally, there will be a plethora of devices.
And they're going to have very different demands or the ways how they present their data or how do they take their data.
But we would like to try to treat them in a uniform way. They would be generally connected through some hierarchy of buses.
And the way how we can view these buses are like highways where a lot of data is moving at a relatively high rate.
And then there are things connected, off ramps, to that highway. We are not going to get into the depths and details of designing buses.
We can just view them as something abstract that is connected to the processor memory system.
Then, the way how these devices talk to the rest of the world is generally through standardized interface that consists of command and status registers and data registers.
And generally, it is the operating system that checks the status whether devices are ready to talk to us, and then orchestrates how do the processes underneath access these devices.
So standardized interface — they generally have commands — let's say, print something, and then the data register contains what to actually print.
All right, how do we support this kind of I/O interfaces through our ISA. So it's relatively basic.
At the very bottom, in the leaf level, what does the processor need to do?
It needs to be able to read the sequence of bytes and write a sequence of bytes, whether they're commands or the data. So how do we do that?
Well, we have two options. One, design special input/output instructions and the matching hardware that would be talking to each type of device. This used to be done in the past.
There used to be I/O instructions in processors. But that turned out not to be a good idea, because these devices change, we get new standards, new interfaces every few years.
And the old ones get old and abandoned. They're obsolete, and our ISA is stuck with supporting stuff that may be 10 or 20 or 40 years old.
So most of the things nowadays are actually done through something that is called memory mapped I/O. A portion of generally address space, so some low addresses in our memory space, in our memory locations, are dedicated to I/O. That's where our I/O command and data registers
are placed. So we don't use that part of a memory. It is not visible to our program. It is managed by the OS.
And our processes may be allowed to read or write from there. So if they're allowed, they can use normal load and store instructions to access them.
Or, they would be accessible through system calls. And this is the way how RISC-V does it. So here is an example. There are some addresses in this example.
All addresses below 7FFFFFFF are reserved for memory mapped I/O. That's where all our peripheral devices are going to copy their controlling status registers.
And they're going to read and write to them. That's going to be our way of communication.
So our program in data memory is going to start from the address 8000000, and go up to the top of the memory.
So every single I/O device is going to have a copy of its registers in the memory-mapped I/O region.
One thing to keep in mind, there is a variety of devices out there. And they may be running at very different speeds.
So if our microprocessor is just a single core, it's five processor, say it's five-stage pipeline operating at 1 gigahertz, it can do 4 gibibyte per second worth of loads and stores.
It can write in every cycle, assuming that the math is somewhere around one. It can, in every cycle, do one 4 byte load or 4 byte store.
But there is a whole bunch of devices that may not be able to use that, or generally will not be able to use them unless they're VRAM.
So let's take a look at what is out there.
So if you're working with a keyboard, keyboard, really, the rate that we talk to a keyboard is something of the order of tenths of bytes per second.
I mean, that's the maximum speed that we can type. Humans and human fingers can produce a few tenths of bytes at the max per second.
If it is minutes, maybe a few bytes per second.
And then if you're dealing with audio signals, which are typically associated, Bluetooth is now used to carry generally audio signals. It is few hundreds of qubits per second.
It can go up to 3 megabytes per second. And then when we talk about Wi-Fi and Ethernet and hard disk drives, we can go up to higher speeds.
But none of them get anywhere close.
They're typically at least an order of magnitude below the speed of what the processor can do, until we get to Thunderbolt and newer fresher DRAM interfaces.
Now those that exceed the bandwidth of what the core can read and write are designed to support higher end processors and those that have multiple cores, because each of these cores may have a desire to load or store the data to the memory.
So generally, common I/O devices neither deliver nor accept data matching the processor speed. We have to have some way to adjust to that.
And you're going to take a look at a few possible options, how to do that, after a quick break. See you then.
Đăng nhập để đánh giá học liệu này.
Đăng nhập để bình luận — chưa ai bình luận về học liệu này.
Không có khóa học liên quan.