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] BORA NIKOLIC: Welcome to the next module in 61C.
We are going to dive down to the next level of abstraction and cover the RISC-V instruction set architecture and the RISC-V assembly language.
Remember, early in the class, we talked about the ideas of layering different layers of abstraction to represent complex compute systems. On the top, there is a high level language.
And hopefully people have mastered C by now. Below that is the assembly language. Below that is the machine readable version of the assembly language, which is the machine code.
And below that are different implementations of the architecture, implemented perhaps, as block diagrams that can execute that code.
Below that level of abstraction, there are logic gates that actually replace things that are inside these boxes in the block diagram. Logic gates are not the very bottom of the compute stack.
They're also an abstraction. They're built out of transistors. Transistors are also an abstraction. Transistors consist of different kinds of materials.
They're also wires. And all of them are there to carry electrons and holes. And we can talk about deeper than — deeper layers of abstraction than that. C is not the highest level language.
As we already know, there are more complex things that are built on top of it. There are operating systems. There are productivity languages. There are software frameworks.
And this entire world is built — or at least the software view of the world is built on top of that.
It is important to point out that there are always well-defined interfaces between these layers of abstraction. Typically, we don't write assembly language code.
We can, but most commonly, it is being produced by a compiler. Assembler produces a machine readable code.
Instruction set architecture is what defines what will be executed by the hardware. And then there are different layers, different ways of implementing things below that.
When we are thinking about the assembly language, we think about the instructions executed by the processor. The basic job of a CPU is to execute lots of instructions.
When I say lots, I mean lots.
When we speak about the processor that is running at a modest speed nowadays at 1 gigahertz, that means that one cycle in a processor lasts for one nanosecond.
And that's approximately a time that it takes to execute one instruction, sometimes more, sometimes less. But let's say of the order. So each processor will execute 1 billion instructions per second.
And that's a lot. These instructions are primitive operations that CPU executes.
They essentially constitute some kind of an action, like a sentence where the operations are like verbs apply to operands, which are objects that are processed in sequence.
Now, there are many different processor architectures out there and different sets of instructions. Different CPUs implement different sets of instructions.
A particular set of instructions that applies to a processor, a class of processors, is called the instruction set architecture. So when we — there are many known instruction set architectures out there.
The most common that you'll encounter nowadays is the ARM instruction set architecture. And it is deployed in pretty much all of the cell phones that are out there in the world.
And many, many other things. Very popular is Intel x86. That is implemented in laptops, desktops, and many of the servers and cloud processors.
There is IBM Power, implemented in servers as well. There used to be very popular IBM Motorola PowerPC that was used in older Macs. There is MIPS.
And there is RISC-V. We're going to be talking about RISC-V in this module and beyond.
There is a book that actually was pointed to me by Dan, Programming From the Ground Up. And I'm just going to read a little of it from its excerpt from its review.
The reviewer says here, "I found that the key difference between mediocre and excellent programmers is whether or not they know assembly language.
Those that do tend to understand computers themselves at a much deeper level." This really strikes deep with me.
That's why we are trying to cover assembly language such that people really understand how is the software being executed.
Also, many of the — I had quite a bit of experience with them within assembly language of a particular architecture of olden times.
Those old computers, like an Apple computer, just came with a basic interpreter. Didn't have really an operating system.
And if you wanted to do something other than write code in BASIC, that was a language of that time, you had to write assembly language.
For example, I had to write a lot — this was my first computer. I still have it. Not quite sure if it works. It's a simple ZA Spectrum.
That was a British type of machine. It was very inexpensive, plug it into a TV and just keep coding. It also had BASIC. But I really wanted performance out of it.
So I had to write a lot of assembly code.
Back to instruction set architectures. As the computers were developing somewhere in the '70s and the '80s, there was a trend to try to build more and more complex instructions.
That led something to a division, or to a trend, of building something that is called complete instruction set architect computers, or what's then, as an acronym, known as CISC.
There was, in the early '80s, emerged a — or a little bit earlier than that by John Cocke in IBM to try to build very simple instruction sets, very basic instruction sets.
That was picked up and really taken to the full extent by Dave Patterson at Berkeley and John Hennessey at Stanford.
The idea there was to keep instructions that small and simple and make it easier to build fast hardware. So each instruction per cycle would do less.
But you would have fast hardware and will be able to execute more instructions in a given time. And then we'll use software to build complicated operations by composing simpler ones.
Patterson and Hennessy won. There was a long debate. But they eventually won.
And even though there are CISC instruction sets out there, like x86, if you look at the way how the processor is built, that is really, in the essence of it, is a RISC engine.
And these complex instructions are added by concatenating simpler ones inside the machine. One would say he who laughs last, laughs best.
Patterson and Hennessey, as we know, won the Turing Award two years ago. When teaching computer architecture, people, both the instructors and the students, have a tough choice.
Instructions, in particular, need to choose an instruction set architecture to teach the architecture in an architecture class.
So the choice there is to try to teach x86. But it's very complex. And there is often quite a bit of pushback by students in trying to teach some subset of x86.
Alternatives to that are to try to use some older instruction set, like MIPS, or an old RISC, or to come up with a made up instruction set.
The advantage of teaching x86, whoever survives a class is that then they can run any software on that architecture. And they will understand, because there is a rich x86 system built out there.
But it's easier to understand older instruction sets or made-up instruction sets. But the problem there is no really software that you can get to run on that.
It's really hard to even get a basic compiler running. So there came RISC-V. About 10 years ago, it was conceptualized.
It really took off in the past four or five years. It is open source and license free. What means there is that anybody can use it.
You don't have to pay anybody the rights to use those instructions. So it became very popular in both teaching. But it immediately jumped into a commercial world.
So we have now a rich commercial ecosystem that builds RISC-V processors. But there is a well supported software stack.
So we got everything now, a simple instruction set that can be extended, and is being extended, that we can teach in classes.
And there is a soft — there is a rich collection of software that will run on it. RISC-V comes in different kinds of variants to support from tiny microcontrollers to big computers.
It comes in 32, 64-bit, and 128-bit variants if you like. That says how big are these words that the processor operates on.
32 bits are 4 bytes that we have seen before. 64 bits are 8 bytes that it operates on at a time.
In class, we are using 32 bits, because, believe me, your projects — project 3 is a lot easier to implement when it's 32 bits than when it's 64 bits.
But the book covers a 64-bit version of the architecture that is called RB64. Our variant is called RB32.
What we're covering in class really fits on one page. And this is what I'm going to be talking about over the next few of these video segments.
That one page captures the entire architecture definition of RISC-V and is called the green card.
That is named after the IBM360 green card, which was very popular back in the '60s.
Actually had an opportunity to program IBM360 when I was in high school and used the punch cards and line printers.
And really understood what does that slash n mean in C code. Otherwise, it will not return the line if it does — if you don't put that in.
RISC-V, just a few words about where it came from and where it's going. It started in summer 2010 to support classes exactly like this one, 61C.
It was built for 61C, but also for 152 and 151.
But a lot of the instructions that you'll find there are the same instructions that you found in the old RISC-I and RISC-II in the '80s.
As RISC-V project matured, it started getting adopted by industry.
And it got moved into an open — non-profit foundation that maintains its open source inscription. It's called riscv.org.
And there, as I said, many research projects based on RISC-V. And there are products that may be open source, but maybe proprietary.
People say will be, next year, about a billion processor cores built in RISC-V. That is quite exciting. You can read more about the history and the lineage on the riscv.org page.
And I'll jump — in the next video segment, I'm going to jump into the elements of the architecture. See you there.
Đă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.