Skip to content

Von Neumann Architecture

A-Level Computer Science Topic 4 21:27 English narration · English + 中文 subtitles burned in

space play · ←/→ 5s · j/l 10s · f fullscreen · ,/. speed

Chapters

Transcript
For most of history, a machine did one job. 在历史的大部分时间里,一台机器只做一件事。
A loom wove cloth. 织布机织布。
A calculator added. 计算器做加法。
To make it do something new, you rebuilt it. 要让它做点新的事, 你就得把它重造一遍。
Then came a deceptively simple idea, from John von Neumann: store the instructions in memory, right alongside the data. 后来,约翰·冯·诺依曼提出了一个看似简单的想法: 把指令存进存储器里,就放在数据的旁边。
Suddenly, one single machine could become anything — a calculator, a writer, a game — not by rewiring it, but just by loading a different program. 忽然之间,同一台机器就能变成任何东西—— 一个计算器、一个写作工具、一个游戏——不是靠重新接线,而只是靠加载一个不同的程序。
That idea is inside every computer you own. 这个想法,就藏在你拥有的每一台计算机里。
Nearly every computer follows one blueprint: the Von Neumann architecture. 几乎每一台计算机都遵循同一张蓝图:冯·诺依曼体系结构。
Today: the parts of the CPU, the buses that connect them, the fetch-execute cycle that runs every instruction, how it finds its data, and how interrupts break in. 今天:CPU 的各个部件、 连接它们的总线、运行每一条指令的取指-执行周期、它如何找到数据,以及中断如何插进来。
Let's begin. 让我们开始吧。
Von Neumann's machine keeps one single memory — Cambridge calls it the Immediate Access Store — and it holds both the program instructions and the data those instructions work on. 冯·诺依曼机器只保留一个存储器——剑桥课程称它为立即存取存储器—— 它既存放程序指令,也存放这些指令要处理的数据。
Nothing marks a cell as code or as numbers; the same store holds both. 没有任何标记说明某个单元是代码还是数字; 同一个存储器把两者都装在里面。
The processor then works through the instructions one at a time, in order, address by address, unless a branch instruction changes the program counter and sends it somewhere else. 处理器接着一条一条地、按地址顺序执行这些指令, 除非有一条分支指令改变了程序计数器,把它送到别处。
That single store is the whole trick. 这个唯一的存储器就是全部诀窍所在。
Change what is stored, and you change what the machine does — no rewiring, no new hardware. 改变里面存的东西,你就改变了这台机器做的事——不用重新接线,也不用新硬件。
At the heart is the CPU, and inside it, a few key parts. 核心是 CPU,而在它内部,有几个关键部件。
The arithmetic and logic unit — the ALU — does the maths and the comparisons. 算术逻辑单元——ALU——负责运算和比较。
The control unit decodes each instruction and pulls the strings. 控制单元解码每一条指令,并操纵全局。
A clock beats out steady pulses to keep everything in step. 一个时钟敲出稳定的脉冲,让一切保持同步。
And registers — tiny, ultra-fast stores — each hold one crucial thing: the program counter tracks the next instruction, the accumulator holds the ALU's working value, and others shuttle addresses and data to memory. 还有寄存器——微小、极快的存储——每一个都保存着一件关键的东西: 程序计数器追踪下一条指令,累加器保存 ALU 正在处理的值,其余的则在存储器之间来回搬运地址和数据。
Look closer at two of those parts. 我们把其中两个部件看得更近一些。
The arithmetic and logic unit does two kinds of work: arithmetic — add, subtract, multiply, divide — and logic — AND, OR, XOR and comparisons. 算术逻辑单元做两类工作:算术——加、减、乘、除—— 以及逻辑——与、或、异或和比较。
It takes its operands from registers and puts the result straight back into a register, usually the accumulator. 它从寄存器取来运算数,再把结果直接放回一个寄存器, 通常就是累加器。
The control unit is the conductor. 控制单元是那个指挥者。
It decodes each instruction, then sends out control signals to carry it out: opening a data path, telling the ALU which operation to perform, and driving memory reads and writes. 它解码每一条指令,然后发出控制信号去执行它: 打开一条数据通路,告诉 ALU 该做哪种运算,以及驱动存储器的读和写。
The ALU calculates; the control unit decides who does what, and when. ALU 负责算;控制单元负责决定谁做什么、什么时候做。
Everything inside the chip marches to one beat: the system clock. 芯片内部的一切都按同一个节拍前进:系统时钟。
It sends out a steady stream of pulses, and every part changes state on those pulses, so nothing runs ahead of anything else. 它送出一串稳定的脉冲, 每个部件都在这些脉冲上改变状态,所以没有哪个部分会跑到别人前面去。
Each machine instruction takes a fixed number of clock cycles, so the number of pulses per second — the clock speed, three point eight gigahertz on a typical desktop — decides how many instructions get finished. 每条机器指令要占用固定数目的时钟周期,因此每秒的脉冲数——也就是时钟频率, 台式机上典型是三点八吉赫——决定了能完成多少条指令。
It is one factor in performance, and only one. 它是影响性能的一个因素,也只是一个。
Hold that thought; we come back to it. 记住这一点,我们后面还会回来。
Registers are tiny stores inside the CPU, and the special purpose registers each have one fixed job in the cycle. 寄存器是 CPU 内部极小的存储单元,而专用寄存器每一个在周期中都有一份固定的工作。
The program counter holds the address of the next instruction. 程序计数器保存下一条指令的地址。
The memory address register holds the address currently being read or written. 内存地址寄存器保存当前正在读或写的那个地址。
The memory data register holds the data travelling to or from memory. 内存数据寄存器保存往来于存储器的数据。
The current instruction register holds the instruction being decoded right now. 当前指令寄存器保存此刻正在被解码的那条指令。
And the accumulator holds the value the ALU is working on. 而累加器保存 ALU 正在处理的值。
Learn them as a chain, in the order the fetch uses them. 把它们当成一条链来记,顺序就是取指阶段用到它们的顺序。
Three more finish the set. 还有三个补齐这一套。
The status register holds flags — carry, zero, negative and overflow — single bits that record what the last operation did, and branch instructions test them. 状态寄存器保存标志位——进位、零、负和溢出—— 它们是记录上一次运算结果的单个二进制位,分支指令会去检查它们。
The index register holds an offset, used in indexed addressing to step through an array. 变址寄存器保存一个偏移量,在变址寻址里用来逐个遍历数组。
General purpose registers are yours as the programmer: scratch space for temporary values inside a calculation. 通用寄存器是留给你这个程序员的:计算过程中放临时值的草稿空间。
Movements between all of these are written in register transfer notation. 这些寄存器之间的搬移用寄存器传送记法来写。
MAR gets PC in square brackets means: copy the contents of the program counter into the memory address register. MAR 箭头方括号 PC 的意思是: 把程序计数器的内容复制到内存地址寄存器。
The brackets mean contents of. 方括号表示"其中的内容"。
The CPU talks to memory and devices over three buses — bundles of parallel wires. CPU 通过三条总线——一束束平行的导线——与存储器和设备交谈。
The address bus carries the location the CPU wants — and it flows one way only, from CPU to memory. 地址总线携带 CPU 想要的位置—— 而且它只朝一个方向流动,从 CPU 到存储器。
The data bus carries the actual data, both ways. 数据总线携带真正的数据,是双向的。
And the control bus carries the signals — read, write, interrupt — also both ways. 控制总线携带各种信号——读、写、中断——也是双向的。
Widen the address bus, and the CPU can reach more memory: n wires reach two-to-the-n locations. 把地址总线加宽,CPU 就能访问更多存储器: n 根导线能到达二的 n 次方个位置。
Bus width decides two limits, and examiners ask about both. 总线宽度决定两个上限,而考官两个都会问。
First the address bus: n lines carry two to the power n different addresses, so sixteen address lines reach sixty-five thousand five hundred and thirty-six locations, and thirty-two lines reach over four billion. 先看地址总线:n 根线能表示二的 n 次方个不同地址, 所以十六根地址线可以到达六万五千五百三十六个位置,三十二根线能到达四十多亿个。
Add one line and you double the memory the CPU can reach. 多加一根线,CPU 能访问的存储器就翻一倍。
Then the data bus: its width is how many bits move in one access, and that is usually the word size, so a sixty-four bit data bus carries eight bytes at a time. 再看数据总线:它的宽度就是一次访问能搬多少位, 而这通常等于字长,所以一条六十四位的数据总线一次运送八个字节。
Wider buses, and faster ones, simply move more data per second. 更宽、更快的总线,每秒就能搬运更多数据。
Every instruction runs through the same three-step loop. 每一条指令都跑过同样的三步循环。
First, fetch: the program counter's address goes to the memory address register, the counter ticks up to the next instruction, and memory hands the instruction back, through the data register, into the current instruction register. 第一步,取指:程序计数器里的地址送到内存地址寄存器, 计数器往上跳到下一条指令,存储器再把这条指令送回来,经过数据寄存器,进入当前指令寄存器。
Then, decode: the control unit works out what it means. 然后,解码:控制单元弄清楚它是什么意思。
Then, execute: the ALU computes, or data moves, or the program jumps. 然后,执行:ALU 进行计算,或数据搬移,或程序跳转。
And then it all repeats, millions of times a second. 接着这一切又重复,每秒钟数百万次。
Now the fetch stage exactly as a mark scheme wants it, in five steps. 现在按评分标准要求的样子来看取指阶段,一共五步。
One: the program counter's address is copied into the memory address register. 第一步:程序计数器里的地址被复制到内存地址寄存器。
Two: the program counter is incremented, so it already points at the next instruction. 第二步:程序计数器加一,于是它已经指向下一条指令。
Three: a read signal is sent along the control bus. 第三步:一个读信号沿控制总线发出。
Four: memory puts the instruction onto the data bus, and it lands in the memory data register. 第四步:存储器把这条指令放到数据总线上,它落进内存数据寄存器。
Five: it is copied from there into the current instruction register. 第五步:它再从那里被复制到当前指令寄存器。
Notice that the increment happens during the fetch, not at the end of the cycle — that is a mark on its own. 注意,加一是发生在取指过程中的, 不是在整个周期的末尾——这本身就是一分。
Decode: the control unit looks at the instruction now sitting in the current instruction register and splits it in two — which operation, and which operand or address. 解码:控制单元看着此刻停在当前指令寄存器里的那条指令,把它拆成两部分—— 是哪种运算,以及哪个运算数或地址。
Then execute, and it can take three shapes. 然后是执行,它可以有三种形态。
Arithmetic or logic goes to the ALU, and the result lands in the accumulator. 算术或逻辑运算交给 ALU,结果落在累加器里。
A load or a store moves data between memory and a register. 加载或存储在存储器和寄存器之间搬移数据。
A branch writes a new address into the program counter, so the next fetch starts somewhere else entirely. 分支则把一个新地址写进程序计数器,于是下一次取指就从完全不同的地方开始。
Jumps often use relative addressing, where the instruction gives an offset from the program counter instead of an absolute address. 跳转常常用相对寻址,也就是指令给出一个相对程序计数器的偏移量,而不是一个绝对地址。
Then the cycle begins again — fetch, decode, execute — millions of times every second. 接着这个周期又重新开始——取指、解码、执行——每秒钟上百万次。
When an instruction says load, how does the CPU find the value? 当一条指令说"加载"时,CPU 怎么找到那个值呢?
That is the addressing mode. 这就是寻址方式。
Immediate: the value is right there in the instruction. 立即寻址:值就直接写在指令里。
Direct: the instruction gives an address; go fetch what is there. 直接寻址:指令给出一个地址,去取那里的东西。
Indirect: that address holds another address, so you follow it one more hop. 间接寻址:那个地址里存的又是另一个地址, 所以你要再多跳一步去跟着它。
And indexed: add an index register to the address — perfect for stepping through an array. 而变址寻址:把一个变址寄存器加到地址上——最适合逐个遍历数组。
Same instruction, four different ways to reach the data. 同一条指令,四种不同的方式去够到数据。
Let's do the classic question. 我们来做那道经典的题。
Memory holds: location two hundred contains two hundred and fifty; location two hundred and fifty contains ninety-nine; location one hundred and five contains seven. 存储器里:地址二百存的是二百五十;地址二百五十存的是九十九; 地址一百零五存的是七。
The index register holds five. 变址寄存器里是五。
What is in the accumulator after each instruction? 每条指令执行后累加器里是什么?
Load immediate two hundred is immediate, so the operand is the number written in the instruction: two hundred. 立即加载二百是立即寻址,所以运算数就是指令里写着的那个数:二百。
Load direct two hundred is direct — go to location two hundred and take what is there: two hundred and fifty. 直接加载二百是直接寻址——去地址二百,把那里的东西取出来:二百五十。
Load indirect two hundred is indirect — location two hundred holds two hundred and fifty, which is another address, so go on to that location and take ninety-nine. 间接加载二百是间接寻址——地址二百里存的是二百五十,而它又是一个地址, 所以再往下走到那个地址,取出九十九。
Load indexed one hundred is indexed — add the index, so one hundred plus five is one hundred and five, and read seven. 变址加载一百是变址寻址——把变址值加上去, 一百加五等于一百零五,读出七。
Count the hops: immediate none, direct one, indirect two, indexed one once the index is added. 用"跳几步"来区分它们:立即零步,直接一步,间接两步, 变址在加完变址值之后是一步。
But what if something urgent happens — a key press, a network packet, a fault? 但要是有紧急的事情发生呢——一次按键、一个网络数据包、一个故障?
The device sends an interrupt: a signal that pauses the normal cycle so the CPU can handle an urgent event. 设备就发出一个中断: 一个信号,暂停正常周期,好让 CPU 处理紧急事件。
The CPU finishes its current instruction, saves its place — the program counter and registers — then jumps to a special routine that handles the event. CPU 完成它当前的指令,保存好它的位置—— 程序计数器和寄存器——然后跳到一个专门的例程去处理这个事件。
When it is done, it restores everything and carries on, exactly where it left off. 处理完后,它把一切恢复原样, 继续下去,恰好从它停下的地方接着走。
This is how a computer juggles many things at once. 这就是一台计算机如何同时兼顾许多事情的办法。
Where do interrupts come from? 中断是从哪里来的?
A key press or a mouse click. 一次按键或一次鼠标点击。
A network packet arriving. 一个到达的网络数据包。
A hardware fault, like a printer out of paper. 一个硬件故障,比如打印机没纸了。
A program error, like division by zero. 一个程序错误,比如被零除。
And the operating system's own timer, ticking to say another program's turn. 还有操作系统自己的定时器,滴答一下说:换另一个程序了。
Step three of the handling is the one to name precisely: the address of the interrupt service routine is loaded into the program counter, so the very next fetch runs the handler. 处理过程的第三步是要说准的那一步:中断服务程序的地址被装入程序计数器, 于是下一次取指就运行这个处理程序。
Without interrupts the CPU would have to keep asking every device whether anything had happened. 如果没有中断,CPU 就得不停地去问每一个设备有没有事情发生。
Interrupts are how an operating system multitasks. 中断就是操作系统实现多任务的方式。
The four-mark version of "explain how an interrupt is detected and handled": the device sends an interrupt signal that sets a flag in the interrupt register; the processor checks that register at the end of every fetch-execute cycle; if a flag is set and the interrupt has high enough priority, the contents of the registers are pushed onto the stack, the address of the interrupt service routine is loaded into the program counter, the routine runs, and then the saved values are popped off the stack so the interrupted program continues exactly where it stopped. 「解释中断是如何被检测和处理的」四分版本是: 设备发出中断信号,把中断寄存器里的一个标志位置位; 处理器在每个取指—执行周期结束时检查这个寄存器; 如果标志被置位而且中断的优先级足够高, 就把各寄存器的内容压入堆栈, 把中断服务程序的地址装入程序计数器,运行这个服务程序, 然后把保存的值从堆栈弹回来,让被打断的程序从原来停下的地方继续。
The processor only ever runs machine code: bit patterns, unreadable by eye, and specific to one architecture. 处理器真正运行的只有机器码:一串二进制位模式,肉眼读不懂,而且只对一种体系结构有效。
Assembly language is the readable form of exactly the same thing, written with mnemonics like L D D for load direct, A D D for add, and J M P for jump. 汇编语言就是同一样东西的可读形式,用助记符来写,比如 LDD 表示直接加载,ADD 表示加, JMP 表示跳转。
An assembler translates the mnemonics into those bit patterns. 汇编器把这些助记符翻译成那些位模式。
The relationship is one to one — one assembly instruction becomes one machine instruction — and that is what separates an assembler from a compiler, where a single line of high-level code may become dozens. 它们之间是一对一的关系—— 一条汇编指令变成一条机器指令——这正是汇编器和编译器的区别所在, 编译器里一行高级语言代码可能变成几十条。
An assembler usually reads the source twice, and there is a good reason. 汇编器通常把源程序读两遍,而这有很好的理由。
Pass one builds a symbol table: every time a label appears, it records the address that label stands for. 第一遍建立符号表: 每当出现一个标签,它就记下这个标签代表的地址。
No code is generated yet. 这一遍还不生成任何代码。
Pass two generates the code: each instruction is translated, and whenever one refers to a label, the address is looked up in the symbol table. 第二遍生成代码:每条指令被翻译出来,只要有指令引用某个标签, 就到符号表里查它的地址。
Why two passes? 为什么要两遍?
Because of forward references — a jump to a label that is defined further down the program. 因为有前向引用—— 跳到一个在程序后面才定义的标签。
On a single pass the assembler would reach the jump before it knew the address. 如果只扫一遍,汇编器会在知道地址之前就先碰到这条跳转。
What each pass does, in the assembler's terms. 用汇编器的说法,两遍各做什么。
Pass one reads each line, counts the address it will occupy, and records every label in the symbol table; it produces no code. 第一遍读每一行,计算它将占用的地址,并把每个标号记入符号表;这一遍不产生代码。
Pass two reads the program again and translates each line into machine code, replacing each mnemonic by its opcode and each label by the address pass one recorded for it. 第二遍再读一遍程序,把每一行翻译成机器码, 把每个助记符换成它的操作码,把每个标号换成第一遍为它记下的地址。
Cambridge uses one small generic instruction set, and it is printed in the paper, so learn the shape of it rather than the list. 剑桥用的是一套很小的通用指令集,而且它会印在试卷上,所以要记的是它的结构,不是那张清单。
Data movement: load direct, load immediate, load indirect, load indexed, store, and move between registers. 数据搬移:直接加载、立即加载、间接加载、变址加载、存储,以及寄存器之间的搬移。
Arithmetic: add, subtract, increment, decrement. 算术:加、减、加一、减一。
Logic and bit work: AND, OR, XOR, and the two shifts, left and right. 逻辑和位运算:与、或、异或,以及左移和右移这两个移位。
Compare and branch: compare, then jump always, jump if equal, jump if not equal. 比较与分支:比较,然后是无条件跳转、相等则跳转、不相等则跳转。
Input and output: in and out. 输入输出:输入和输出。
And end, to stop the program. 还有 END,用来结束程序。
To trace an assembly program, build a table before you start. 要追踪一段汇编程序,先在开始之前画好一张表。
One column for the program counter, one for the accumulator, one for the index register, one for each variable, and one for any flag the code tests. 一列给程序计数器,一列给累加器, 一列给变址寄存器,每个变量一列,代码检查的每个标志位也各一列。
Then step through the instructions one at a time, writing a new row after each, and follow a branch whenever it changes the program counter — do not just read down the page. 然后一条一条地走过指令,每执行一条就写一行新的,并且只要某条分支改变了程序计数器, 就跟着它走——不要只顺着纸面往下读。
Stop at end. 到 END 就停。
The pattern that comes up again and again is a loop that walks an array with indexed addressing, adding one to the index register each time round. 反复出现的那个套路, 是用变址寻址遍历数组的循环,每转一圈就给变址寄存器加一。
A logical shift slides every bit sideways and fills the empty positions with zero. 逻辑移位把每一位都往旁边挪,空出来的位置用零填上。
Take zero zero zero zero one zero one one: in denary that byte is eleven. 取零零零零一零一一: 这个字节换成十进制是十一。
Shift it left one place: every bit moves left, a zero comes in on the right, and the far-left bit drops off. 把它左移一位:每一位都往左挪,右边补进一个零, 最左边那一位掉出去。
You get zero zero zero one zero one one zero, which is twenty-two. 你得到零零零一零一一零,也就是二十二。
A left shift by one has multiplied by two. 左移一位就是乘以二。
Shift right one place instead and a zero comes in on the left, which is integer divide by two and throws away any remainder. 换成右移一位,则是左边补进一个零,这相当于整数除以二,余数被丢掉。
Shift by n places and you multiply or divide by two to the power n. 移 n 位,你就是乘或除以二的 n 次方。
Two variants matter. 有两种变体很重要。
An arithmetic right shift keeps the sign bit. 算术右移会保住符号位。
Take a negative signed byte, which starts with a one: instead of feeding in a zero from the left, the shift copies that leading bit back into itself, so the number stays negative and is still halved. 取一个带符号的负数字节,它开头是一: 移位时不是从左边补进一个零,而是把开头那一位复制回它自己, 所以这个数仍然是负的,而且仍然被减半。
A cyclic shift, also called a rotate, feeds the bit that falls off one end straight back in at the other end, so no bits are ever lost — useful in encryption and in checksums. 循环移位,也叫循环旋转, 把从一端掉出去的那一位直接从另一端补回来,所以一位都不会丢—— 这在加密和校验和里很有用。
In the exam, always say which kind of shift you mean: logical, arithmetic or cyclic. 在考试里,一定要说清你指的是哪种移位:逻辑、算术,还是循环。
Embedded systems often give one bit of a register its own meaning: bit two is that lamp, bit six is that motor. 嵌入式系统常常让寄存器里的某一位有它自己的含义:第二位是那个灯,第六位是那个马达。
To change one bit and leave every other bit exactly as it was, you use a mask — a byte you choose so that the operation only bites where you want it to. 要只改动一位、而让其他每一位都保持原样,你就要用掩码—— 一个你精心选定的字节,让运算只在你想要的位置起作用。
To set a bit, OR with a mask holding a one in that position and zeros elsewhere. 要置位, 就和一个在那个位置为一、其余全为零的掩码做"或"。
To clear a bit, AND with a mask holding a zero there and ones everywhere else. 要清位, 就和一个在那个位置为零、其余全为一的掩码做"与"。
To toggle a bit, XOR with a mask holding a one in that position. 要翻转一位, 就和一个在那个位置为一的掩码做"异或"。
And to test a bit — to ask whether it is on — AND the register with a mask holding only that bit, then check whether the result is non-zero. 而要检测某一位——问它是不是开着的——就把寄存器和一个只含那一位的掩码做"与", 然后看结果是不是非零。
Non-zero means the bit was set; all zeros means it was clear. 非零说明那一位原来是一;全为零说明它原来是零。
Remember the pairing: OR sets, AND clears, XOR toggles, and AND also tests. 记住这组配对:或用来置位,与用来清位,异或用来翻转,而与也用来检测。
Why bother? 为什么要这么做?
Bit manipulation is fast, it uses almost no memory, and one single byte can hold up to eight independent on-off states — exactly what a monitoring or control system needs. 位操作很快,几乎不占内存,而且一个字节就能装下最多八个互不相干的开关状态—— 这正是监测或控制系统需要的。
So what actually makes a computer fast? 那么,究竟是什么让一台计算机快起来?
Clock speed: more cycles per second means more instructions finished. 时钟频率:每秒周期更多,就意味着完成的指令更多。
Number of cores: a quad-core CPU genuinely runs four threads at the same time. 核心数量:一颗四核 CPU 真的能同时跑四个线程。
Word size: a sixty-four bit CPU handles sixty-four bit chunks in one go, and can address far more memory than a thirty-two bit one. 字长: 六十四位的 CPU 一次处理六十四位的数据块,而且能寻址的存储器远远多于三十二位的。
And the amount of RAM: more RAM keeps more of the working set in memory, while too little forces the operating system to page out to disk — and disk is thousands of times slower. 还有内存容量:内存越多,就能把越多的工作数据留在内存里, 而内存太少会逼操作系统把内容换页到磁盘上——磁盘要慢上几千倍。
Three more factors, then the judgement. 还有三个因素,然后是判断。
Cache memory: a small, very fast store beside the core, so more cache means fewer slow trips out to RAM and a lower average access time. 高速缓存:紧挨着核心的一小块极快的存储, 缓存越多,跑去内存的慢速往返就越少,平均访问时间也就越低。
Secondary storage: a solid state drive loads programs far faster than a spinning hard disk. 辅助存储: 固态硬盘装载程序比会转的机械硬盘快得多。
Bus width and speed: wider and faster buses move data between the parts more quickly. 总线宽度和速度: 更宽更快的总线在各部件之间搬数据更快。
Now the judgement examiners want. 现在是考官想看的判断。
Match the specification to the workload: a quad-core beats a dual-core on work that splits into parallel threads, but higher speed per core wins on single-threaded work. 让配置去匹配工作负载:在能拆成并行线程的工作上,四核胜过双核; 但在单线程的工作上,每个核心更高的频率才赢。
A port is a physical socket on the case for plugging in a peripheral. 端口就是机箱上一个用来插外围设备的物理插座。
U S B — Universal Serial Bus — is the general purpose one: keyboards, drives, phones. USB——通用串行总线—— 是通用的那种:键盘、移动硬盘、手机。
H D M I, High Definition Multimedia Interface, sends digital video and audio to a screen. HDMI,高清多媒体接口, 把数字视频和音频送到屏幕上。
V G A, Video Graphics Array, is the older analogue video output to a monitor. VGA,视频图形阵列,是较老的模拟视频输出,接显示器。
Ethernet, the R J forty-five socket, is wired networking, and the small round jacks carry audio. 以太网,也就是 RJ45 插座,是有线网络,而那些小圆孔插座传的是音频。
Different ports carry different signals, which is why an HDMI cable will not fit a USB socket. 不同的端口传不同的信号,这就是为什么一根 HDMI 线插不进 USB 插座。
USB-C is unusual: video, data and power down one cable. USB-C 很特别:视频、数据和电力都走同一根线。
One more property worth the word: a U S B device is plug-and-play — when it is connected the computer detects it, identifies it and loads the right driver without the user configuring anything. 还有一个值得记住这个词的性质: USB 设备是即插即用的——接上去的时候, 计算机会检测到它、识别它,并自动装载正确的驱动,用户不需要做任何配置。
Three marks to secure. 三个要拿稳的分。
First, know the fetch-execute cycle in register transfers, and that the program counter is incremented during fetch. 第一,用寄存器传送来掌握取指-执行周期,并记住程序计数器是在取指阶段被增加的。
Second, the address bus is one-way, while the data and control buses are two-way. 第二,地址总线是单向的,而数据总线和控制总线是双向的。
Third, tell the addressing modes apart by how many hops it takes to reach the data: immediate zero, direct one, indirect two. 第三, 靠够到数据要跳几步来区分寻址方式:立即零步,直接一步,间接两步。
Master these, and the Von Neumann machine is yours. 掌握这些, 冯·诺依曼机器就是你的了。
Two more marks worth having. 还有两分值得拿。
Fourth: be ready to explain performance — clock speed, number of cores, cache size and word length, each with a reason attached, not just a name. 第四:要能解释性能——时钟频率、核心数量、缓存大小和字长, 每一个都要带上理由,不能只报名字。
Fifth: for any binary shift, state whether it is logical or arithmetic, and remember that a left shift multiplies by two while a right shift divides by two. 第五:碰到任何二进制移位, 都要说清它是逻辑移位还是算术移位,并且记住左移是乘以二、右移是除以二。
And one habit that pays everywhere: name each register's job in a single line — program counter, the next address; memory address register, the address in use; accumulator, the ALU's working value. 还有一个到处都用得上的习惯:用一句话说出每个寄存器的职责——程序计数器,下一条指令的地址; 内存地址寄存器,正在使用的地址;累加器,ALU 正在处理的值。
That precision is where the marks live. 分数就藏在这种精确里。
The fixed-wording definitions, one answer only. 固定措辞的定义,只给一个答案。
The stored program concept: the program instructions and the data are both held in main memory, and instructions are fetched and executed one at a time. 存储程序概念:程序指令和数据都存放在主存储器中,指令被逐条取出并执行。
A register is a small, very fast storage location inside the processor with a specific purpose. 寄存器,是处理器内部一个很小、非常快、有特定用途的存储单元。
The program counter holds the address of the NEXT instruction to be fetched. 程序计数器存放下一条要取的指令的地址。
The memory address register holds the address of the location being read from or written to. 存储器地址寄存器存放正在读或写的那个存储单元的地址。
The memory data register holds the data or instruction just read from, or about to be written to, memory — never an address. 存储器数据寄存器存放刚从存储器读出的、或者即将写入的数据或指令——绝不是地址。
The current instruction register holds the instruction being decoded and executed. 当前指令寄存器存放正在被译码和执行的那条指令。
The accumulator holds the result of the last arithmetic or logic operation. 累加器存放上一次算术或逻辑运算的结果。
Cache is small, fast memory close to the processor holding frequently used instructions and data. 高速缓存是靠近处理器的小而快的存储器,存放频繁使用的指令和数据。
An interrupt is a signal that causes the processor to pause the current task and run an interrupt service routine. 中断,是使处理器暂停当前任务、转去运行中断服务程序的一个信号。
The traps. 陷阱。
The P C holds the address of the next instruction, not the current one. 程序计数器存的是下一条指令的地址,不是当前那条。
The increment of the P C happens as soon as the address has been copied to the M A R, not after the execute. 程序计数器的加一,发生在地址刚被复制到存储器地址寄存器之后,不是执行之后。
L D D 10 loads the CONTENTS of address 10; L D M hash 10 loads the number 10. LDD 10 装入的是地址 10 里的内容;LDM #10 装入的是数字 10。
A compare sets a flag only, so nothing goes in the accumulator column for it, and an output goes to the output column. 比较指令只置标志位,所以累加器那一列不填东西;输出要写到输出那一列。
An interrupt is not handled immediately — the processor finishes the current instruction and checks at the end of the cycle. 中断不是「立刻」被处理的——处理器先把当前这条指令做完,在周期结束时才检查。
And never use a logical right shift on a negative two's-complement number; only an arithmetic shift keeps the sign bit. 另外,对补码表示的负数绝不能用逻辑右移;只有算术右移才保住符号位。

Log in or create account

IGCSE, A-Level & AP