Lecture Overview
- multiplexers
- Flip-flops and registers.
- these slides show a latch (which is a simple version of a flip-flop). The behavior is as follows: there are two inputs (D and T) and an output Q. When T is one, the input value on D is "stored" or latched and output on Q. When T is zero, the input value D is ignored and the "stored" value is output on Q.
- Each flip-flop "stores" a single bit so flip-flops are combined into registers to store larger values. Each register stores a single 8, 16, 32, 64, etc value, depending on the CPU design.
- The fetch-decode-execute cycle:
- A sample instruction is
add register 1 to register 3 and put the result in register 4
. To implement these kinds of instructions, the CPU is wired as follows.
- The output of the registers are muxed and then passed to the ALU. The muxes select which registers should be the input to the ALU.
- Additional muxes inside the ALU decide which operation (add, multiply, greater than, etc) is executed.
- The output of the ALU is fed back to the input of every register.
- There is a decode circuit (also called control unit) which takes as input the instruction and outputs all the control signals for all the muxes and also the T input for the registers.
- Using additional muxes and connections to memory, memory values can be loaded into registers and registers can be stored to memory.
- To talk to devices like network cards, the following trick is used. In a 64-bit cpu, a 64-bit integer is used for memory addresses which allows the CPU to address around 17 billion gibibytes of memory. Of course almost no computer has that much memory so all the software will have to be aware that only addresses in a certain range are available for memory. The "unused" addresses are repurposed to pretend to be devices. So to send data to the network card, the kernel uses instructions to send the contents of registers to certain memory addresses that are routed not to memory but to the device.
There are many things missing from my picture, in particular the clock, instruction pipelines, how the instruction is loaded, interrupts like the timer interrupt, and more.
Exercises
Convert the following boolean expression into a boolean circuit:
(W and not(X) and not(Y)) or (not(W) and Z) or (X and Y)
A majority function is a function which outputs one if the input variables have strictly more ones than zeros. The output is zero otherwise. Design a 3-input majority circuit. Hint: you can do it using four gates.
To submit this homework, draw the circuits on a piece of paper and hand it in during discussion.