プリンキピア

第5章アルゴリズムのハードウェアによる実現:コンピューターシステム設計

Instruction Set Architecture命令セットアーキテクチャー
The instruction set architecture (ISA) is the set of instructions recognized by each processor family. For example, both Intel and AMD processors use the same ISA, called x86-64, which is different from the ISA recognized by ARM or IBM. This makes us revisit the concept of compilers. A compiler takes as input a program written in an HLL, and we have a compiler for each HLL. The output of the compiler is an assembly program in a specific ISA, and we have a compiler for each different ISA (e.g., ISA 1 and ISA 2). So, if we have programs written in three HLLs and we need to generate assembly for processors of two different families, then we need six compilers as shown in Table 5.1.
英語のヒント
命令セットアーキテクチャー(ISA)は、各プロセッサファミリーが認識する命令の集合である。たとえば、IntelとAMDのプロセッサはどちらもx86-64という同じISAを使うが、それはARMやIBMが認識するISAとは異なる。ここで、コンパイラという概念をもう一度考えてみよう。コンパイラはHLLで書かれたプログラムを入力として受け取り、HLLごとにコンパイラが用意されている。出力は特定のISAのアセンブリプログラムなので、異なるISA(たとえばISA 1とISA 2)ごとにもコンパイラがある。したがって、3種類のHLLで書かれたプログラムがあり、二つの異なるファミリーのプロセッサ用にアセンブリプログラムを生成する必要があるなら、表5.1に示すように、6種類のコンパイラが必要である。
Compiler#
コンパイラ番号
Input to the Compiler
コンパイラへの入力
Output from the Compiler
コンパイラからの出力
1
HLL 1
ISA 1
2
HLL 2
ISA 2
3
HLL 3
ISA 1
4
HLL 1
ISA 2
5
HLL 2
ISA 1
6
HLL 3
ISA 2
Table 5.1 Compilers and Their I/O
表5.1 コンパイラとその入出力
As we saw earlier, the output of the compiler is the input to the assembler so we need assemblers for each ISA in existence to generate a machine language file (e.g., .exe file) that the processor can execute.
英語のヒント
先ほど見たように、コンパイラの出力がアセンブラへの入力になる。そのため、プロセッサが実行できる機械語ファイル(たとえば.exeファイル)を生成するには、存在するISAごとにアセンブラが必要である。

Processor Abstractionsプロセッサの抽象化

As we cross the layer of ISA in Figure 5.5, we cross the boundary between software and hardware. Before we discuss hardware, we need to understand two words: translator and interpreter. Both words mean “translating from language 1 to language 2” regardless of what those languages are. The main difference is the process by which translation is done. A translator takes a whole program in language 1 and generates another program in language 2. For example, the compiler takes an HLL as input (language 1) and generates the corresponding assembly language program (language 2). The interpreter takes one line (or command) in the program in language 1 and generates one (or more) instructions in language 2. Python is a popular example of an interpreted language.
英語のヒント
図5.5のISAの層を越えると、ソフトウェアとハードウェアの境界を越えることになる。ハードウェアを論じる前に、トランスレーターとインタープリターという二つの語を理解する必要がある。どちらも、対象がどんな言語であれ、「言語1から言語2へ翻訳する」ことを意味する。主な違いは、翻訳を行う手順である。トランスレーターは、言語1で書かれたプログラム全体を受け取り、言語2の別のプログラムを生成する。たとえば、コンパイラはHLL(言語1)を入力として受け取り、対応するアセンブリ言語のプログラム(言語2)を生成する。インタープリターは、言語1のプログラムから1行(または1コマンド)を取り出し、言語2の一つ以上の命令を生成する。Pythonは、インタープリターで実行する言語のよく知られた例である。
Understanding the hardware level allows us to see how computers execute programs. The main part of the computer hardware that does the execution is called the processor. The processor takes one instruction from the machine language file, executes it, and writes the results back in a designated place. Then, it fetches the following instruction and does the same. It keeps doing this until the program ends or an error occurs. This is an oversimplification, but it conveys the general idea. As you can see, it takes one instruction at a time, which is why the vertical arrow coming out of the machine language box in Figure 5.5 shows the word interpreter. But how does the processor do its job of fetching an instruction and executing it? To answer this question, we need to look at the main components of a processor.
英語のヒント
ハードウェアのレベルを理解すると、コンピューターがプログラムをどう実行するかがわかる。実行を担当するコンピューターハードウェアの主要部分を、プロセッサという。プロセッサは、機械語ファイルから命令を一つ取り出して実行し、結果を指定された場所に書き戻す。続いて次の命令を取り込み、同じことを行う。プログラムが終わるか、エラーが起きるまで、これを繰り返す。これは単純化しすぎた説明であるが、大まかな考え方は伝わるだろう。このように、一度に一つの命令を取り出す。そのため、図5.5の機械語の箱から出る縦の矢印には、インタープリターと記されている。では、命令を取り込んで実行するという仕事を、プロセッサはどう果たしているのだろうか。それに答えるには、プロセッサの主要な構成要素を見る必要がある。
LINK TO LEARNING学習リンク
The transistor is the building block of the hardware of any computer. A transistor is merely an on/off switch; when it is on, it lets the electrical current pass. When it is off, it blocks the electrical current. This is very similar to the light switch you find in your room. But with these transistors, we can do more: with transistors, we build computers. Read this article to learn more about transistors (https://openstax.org/r/ 76Transistors) and how they work.
英語のヒント
トランジスタは、どんなコンピューターでもハードウェアの基本構成要素である。トランジスタは、単なるオン/オフのスイッチである。オンのときは電流を通し、オフのときは電流を遮断する。部屋にある照明のスイッチとよく似ている。しかし、トランジスタを使えば、それ以上のことができる。コンピューターを作れるのだ。トランジスタとその仕組みをさらに知るには、この記事(https://openstax.org/r/ 76Transistors)を読んでみよう。
Microarchitectureマイクロアーキテクチャー
The architecture (i.e., design) of the microprocessor (i.e., the processor) is called microarchitecture (Figure 5.9). Its main job is to design the different components of the processor and decide how to connect them so that the processor can do its job. For example, one important piece inside the processor is the part that fetches the next instruction of the program. Another crucial part, called the control unit, is responsible for decoding, or understanding, what this instruction wants to do and then tells the other components of the processor to execute this instruction. So, the control unit’s job is to take an instruction as input and generate signals to control the rest of the processor to make it execute the instructions. Other parts of the processor include the execution units that do the actual computations such as divide, multiply, add, and subtract.
英語のヒント
マイクロプロセッサ、つまりプロセッサのアーキテクチャー(設計)を、マイクロアーキテクチャーという(図5.9)。主な仕事は、プロセッサのさまざまな構成要素を設計し、それらをどう接続すればプロセッサが役割を果たせるかを決めることである。たとえば、プロセッサ内部の重要な部分の一つは、プログラムの次の命令を取り込む部分である。制御装置という別の重要な部分は、その命令が何をしようとしているかをデコード、つまり理解し、ほかの構成要素に実行を指示す。したがって、制御装置の仕事は、命令を入力として受け取り、プロセッサの残りの部分を制御して命令を実行させる信号を生成することである。プロセッサのほかの部分には、除算、乗算、加算、減算などの計算を実際に行う実行ユニットがある。
Figure 5.9

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 5.9 Although it may just take seconds to execute, there are several steps included in a microarchitecture process to deliver results for the user. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図5.9 実行に数秒しかかからない場合でも、利用者に結果を届けるマイクロアーキテクチャーの処理には、いくつもの段階が含まれている。(出典:著作権 Rice University、OpenStax。CC BY 4.0ライセンス)
To summarize, inside the processor you find those different pieces that fetch instructions, decode them, and execute them. But what is inside each one of these black boxes?
英語のヒント
まとめると、プロセッサの内部には、命令を取り込み、デコードし、実行する、さまざまな部分がある。では、これらのブラックボックスのそれぞれの内部には、何があるのだろうか。