15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

to access them by some fixed regime, e.g. one after the other, in sequence (hence the name random<br />

access memory: RAM). We address the Program store by a function P : N → B 2n . The data store<br />

is also RAM, but a sequence or n-bit cells, which is addressed by the function P : N → B n .<br />

The value of the program counter is interpreted as a binary number that addresses a 2n-bit cell<br />

in the program store. The accumulator is the register that contains one of the inputs to the ALU<br />

before the operation (the other is given as the argument of the program instruction); the result of<br />

the ALU is stored in the accumulator after the instruction is carried out.<br />

Memory Plan of a Register Machine<br />

Program Store<br />

3<br />

2<br />

1<br />

P<br />

r<br />

o<br />

g<br />

r<br />

a<br />

m<br />

0 Operation Argument<br />

2n−bit Cells<br />

Addresses<br />

CPU<br />

ACC (accumulator)<br />

IN1 (index register 1)<br />

IN2 (index register 2)<br />

PC (program counter)<br />

load<br />

save<br />

c○: Michael Kohlhase 274<br />

3<br />

2<br />

1<br />

0<br />

Data Store<br />

n−bit Cells<br />

Addresses<br />

The ALU and the MMU are control circuits, they have a set of n-bit inputs, and n-bit outputs,<br />

and an n-bit control input. The prototypical ALU, we have already seen, applies arithmetic or<br />

logical operator to its regular inputs according to the value of the control input. The MMU is<br />

very similar, it moves n-bit values between the RAM and the registers according to the value at<br />

the control input. We say that the MMU moves the (n-bit) value from a register R to a memory<br />

cell C, iff after the move both have the same value: that of R. This is usually implemented as a<br />

query operation on R and a write operation to C. Both the ALU and the MMU could in principle<br />

encode 2 n operators (or commands), in practice, they have fewer, since they share the command<br />

space.<br />

Circuit Overview over the CPU<br />

ACC<br />

ALU<br />

Address<br />

Logic<br />

PC<br />

c○: Michael Kohlhase 275<br />

Program Store<br />

Operation Argument<br />

In this architecture (called the register machine architecture), programs are sequences of 2nbit<br />

numbers. The first n-bit part encodes the instruction, the second one the argument of the<br />

instruction. The program counter addresses the current instruction (operation + argument).<br />

153

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!