Computer Systems Design

innocentzero

csd

Moore's Law: The number of transistors in a dense integrated circuit doubles every two years.

How to represent a bit (What makes a good bit):

Using voltage to represent bits

transistors

Two types, n type and p type.

N-type acts as a wire when given high voltage at the gate and acts as an open circuit when given a low voltage. P-type works exactly the other way around. These are called Mosfets.

Logic gates using mosfets

Basically two complementary networks for pull-up and pull-down respectively. Pull up is made from pmos and nmos is used for pull down.

  1. Duality

    To have the n type equivalent of a p type sub network, do the following:

    • If A and B are in parallel in p type ( A¯+B¯\overline{A} + \overline{B} ), in n type they will be in series (AB¯\overline{A\cdot B}).

    Also holds the other way.

Power losses

Boolean Algebra

Minterms

Maxterms

Universal gates

Boolean Logic simplification

KMaps:

For 4 bits,

ABAB ABA~B AB~A~B AB~AB
CDCD Item2.1 Item3.1 Item4.1 Item5.1
CDC~D Item2.2 Item3.2 Item4.2 Item5.2
CD~C~D Item2.3 Item3.3 Item4.3 Item5.3
CD~CD Item2.3 Item3.3 Item4.3 Item5.3

Combinational circuits

Comparators

Decoder

Encoder

  1. Priority encoders
    • To resolve the issue of multiple terms being active in an encoder, use don't care conditions in the KMaps.
    • Basically we don't care what the output at that instance will be. We can choose it according to our own convenience.

Multiplexer

Adder

For subtraction of two numbers, just add the 1's complement of the number that is to be subtracted and add 1.

Sequential circuits

  • Latches and flip-flops have 10+ transistors per bit.
  • SRAM has 6 mosfets/transistors per bit.
  • DRAM has 1 transistor + 1 capacitor per cell.
  • Non-volatile storage: no transistors. Yay!

R-S Latches

Gated D Latch

When write-enable is zero, it holds the previous value. When it is 1, it sets the value of Q equal to D.

D flip-flops

Latches are retarded because they are level triggered. We want stuff to be edge triggered. Hence flip-flops. They are edge triggered enough to be suitable for most purposes and gives a singular time point (for all practical purposes it is a time point) when the flip flop does its action.

There is a slight delay in the NOT gate that is achieved with an RC circuit.

The rest of the circuit is the same as gated D latch. In both cases write-enable is connected to the clock with the only difference being in the triggering patterns and the extra circuitry involved in it.

JK flip-flops

Pretty much the same as a R-S latch except with a write-enable feature and edge triggering.

There are 4 modes :

Unlike RS latch there will be on problem with toggling here because the clock pulse is too small for a race condition.

Excitation table: like truth table but tells you what the current JK / D configuration should be to obtain the desired next value.

Counters and frequency dividers

Same as ring counter except Q¯\overline{Q} is fed as input to the first one.

Registers

Multiple flip-flops with the same write enable. Can hold multibit values.

A variant called shift register is used for bit shift operations within the register.

Finite State Machines

Five components:

If there are 2k states, map them to k flip-flops and use the inputs to determine how the states and outputs change.

Two types:

Final Computer architecture

8 bit instruction architecture. First 4 bits are instructions and last 4 are data.

Assembly Machine Code


NOP 0x0 LDA 0x1 STA 0x2 ADD 0x3 SUB 0x4 LDI 0x5 JMP 0x6 OUT 0x7 JNZ 0x8 SWAP 0x9 HALT 0xF

Basic structure of all commands

The T-states we talk about over here are similar to pipelining in processors.

  1. LDA: Load from address into reg A

    4 T-States

    First T-State takes the output of program counter and gives to the memory address register.

    1 << PC_OUT | 1 << MAR_IN

    Second takes the output of memory register and sends it to the instruction register. This is possible because MAR output is always connected to Memory input and as soon as MAR receives an input the memory starts pointing to the location saved in the MAR. Program counter is also incremented at this point to get the next instruction from memory.

    1 << PC_INC | 1 << MEM_OUT | 1 << IR_IN

    These two T-States together constitute the fetch and mem-lookup cycle and are present for every control word.

    The next two T-States are specific to LDA. The first takes the output of IR which has the memory address and sends it to MAR. The second one takes the output from memory and sends it to reg A.

    1 << IR_OUT | 1 << MAR_IN

    1 << MEM_OUT | 1 << RA_IN

  2. ADD and SUB: Load into reg B from address and add/subtract and store the result in reg A

    First two T-States are the same. Third is also same as LDA. In the fourth one, the value is loaded to B instead of A.

    At the end of second T-State, the IR has the instruction that is to be executed. That time, the output of IR is directly connected to the Instruction Decoder, that checks for the instruction and sends the appropriate action to the ALU.

    So the ALU already knows what to do. Once the 4th T-State is over, the ALU has computed the result and just needs to output it.

    Fifth T-State ensures that.

    1 << PC_OUT | 1 << MAR_IN

    1 << PC_INC | 1 << MEM_OUT | 1 << IR_IN

    1 << IR_OUT | 1 << MAR_IN

    1 << MEM_OUT | 1 << RB_IN

    1 << ALU_OUT | 1 << RA_IN

  3. NOP: Does nothing just like the useless piece of shit you are

    Only has a fetch + mem_lookup cycle.

Software Based Control Logic

For every instruction, there is a corresponding address where the T-State's information is stored. For Gajendra-1 architecture, it is as follows:

This gives the address of the control ROM where that T-State is stored.