Showing posts with label full adder. Show all posts
Showing posts with label full adder. Show all posts

Tuesday, December 13

CHAPTER 7: THE PROCESSOR

SINGLE CYCLE CPU DATAPATH

That sure sounds complicated. So let's try making it sounds as simple as we possibly can. 

Before that, you need to know... what is a combinational circuit??

Credits to Google


A combinational circuit is only right if it comes together with some combinational elements.

Introducing the Combinational Logic - half adder & full adder.

Half Adder
- Two inputs and two outputs (carry and sum)


One output will represent sum and the other will represent carry.

Full Adder
- Three inputs and two outputs (carry and sum)



Now, something to not be confuse about - sequential circuit.

What is a sequential circuit??

Credits to Google

Sequential logic circuit is said to be a combinational logic circuit but with the addition of state (memory).

In sequential logic, we have 2 types - synchronous and asynchronous logic. I'm gonna be focusing on the synchronous logic circuit since most CPUs are that type. In synchronous logic, a sequence of repetitive pulses known as the clock signal is distributed to all the memory elements in the circuit. There is a technique known as pipeline, which purpose is to improve the clock rate.

Now, you need to know CPU clocking. Keep in mind that

single cycle = one instruction per second

Clock cycle is typically long to ensure each instruction to complete all stages without interruption. So, each cycle will take a constant amount of time to execute every instruction (in one cycle), regardless of the complexity of the instructions. It can be a big disadvantage of single cycle CPU as it operates at the speed of the slowest instruction to complete the exeution in one clock tick.

One cycle CPU consists of the following:-

Step 1: Instruction fetch (fetched from memory)
Step 2: Decode/ Register read (read the opcode to determine instruction types and field lengths)
Step 3: Arithmetic-Logic Unit (the real work; arithmetic, shifting, logic and comparisons)
Step 4: Memory Access (only for the load and store instructions as the others remain idle)
Step 5: Register write (write the result of some computation into a register)


Multiple cycles CPU on the other hand requires multiple cycles to execute a single instruction. The number of cycles needed to execute a certain instruction is flexible depending on the complexity of the instruction.

In the CPU, there are 2 other parts which is Control Unit and Datapath.

Control Unit
It does not execute any program instructions but instead it tells the datapath what needs to be done. It deals with the ALU and memory.

Datapath
It perform operations required by the program instructions.


To summarize, processor has 4 main functions which are fetch, decode, execute and write back. And the basic elements of a processor are:

1. Arithmetic Logic Unit (ALU)
- which is the core to arithmetic and logic operations

2. Floating Point Unit (FPU)
- specializing in solving numbers quicker than a basic microprocessor circuitry can

3. L1 and L2 cache memory
- saves time compared to retrieving data from the RAM

Briefly, processor is most commonly referred to as the Central Processing Unit (CPU) but

DO YOU KNOW?

CPU isn't the only processor in a computer. There is also Graphics Processing Unit (GPU) and other hardwares performing some processing independently within a computer!

The main competitors for processor in the current market - Intel and AMD

Pheww! Hope you find this post to be somewhat helpful. If there seems to be any mistake, don't hesitate to hit me up! Til then, ALL THE BEST!!


Glossary:

state - In computer science, the state of a digital logic circuit is a term used for all stored information.
clock rate - An indicator to the frequency of the processor's speed.
clock cycle - Measurement for a clock rate is clock cycles per second or the SI unit is known as hertz (Hz).
throughput - Number of instructions completed per second.
CPI - Cycles per instruction


Reference 1
Reference 2
Reference 3
Reference 4

Friday, October 28

CHAPTER 2 : DIGITAL LOGIC



LOGIC DESIGN

  • Digital electronics operate with only two voltage levels
         * high voltage and low voltage
  • Computer used binary system (0,1).
  • Combinational logic block contains no memory.
  • Logic block with n inputs, there are 2n entries (possibility) in the truth table.

TRUTH TABLES






BOOLEAN ALGEBRA



  • Boolean algebra laws





GATES

  • Logic blocks are built from gates that implement basic logic functions.
  • Any logical function can be constructed using AND gates, OR gates, and inversion.
  • Two common inverting gates are called NOR and NAND.

DECODER



  • Use decoder to build larger components.
  • The most common type of decoder has an n-bit input and 2n-bit outputs, where only one output is asserted for each input combination.
  • This decoder translates the n-bit input into a signal that corresponds to the binary value of the n-bit input.
  • The outputs are shows a 3-bit decoder and the truth table. This decoder is called a 3-to-8 decoder.
  • Since there are 3 inputs and 8 (2 power of 3) outputs. There is also a logic element called an encoder that performs the inverse function of a decoder, taking n inputs and producing an n-bit output.


MULTIPLEXER (Selector)

  • The output is one of the inputs that is selected by a control.



  • Multiplexers can be created with an arbitrary number of data inputs.
  • If there are only two inputs, the selector is a single signal that selects one of the inputs.
  • If it is true (1) and the other if it is false (0). If there are n data inputs, there will need to be [log2n] selector inputs.


  • To associate the inputs with selector values, we often label the data inputs numerically.

ARITHMETIC LOGIC UNIT (ALU)

  • ALU – perform arithmetic operation (addition, subtraction and logical operation : AND, OR).
  • Constructs an ALU from four hardware building blocks (AND and OR gates, inverters, and multiplexors) and illustrates how combinational logic works.
  • MIPS word is 32 bits wide, so need 32-bit-wide ALU (connect 32 1-bit ALUs ).


1-Bit ALU












This adder is called a full adder; it is also called a (3,2) adder because it has 3 inputs and 2 outputs. An adder with only the a and b inputs is called a (2,2) adder or half-adder.







Specify the outputs of this "black box" based on its inputs, as in truth tables.