210 likes | 428 Views
HCL and ALU. תרגול 10. Overview of Logic Design. Fundamental Hardware Requirements Communication: How to get values from one place to another Computation Storage Bits are Our Friends Everything expressed in terms of values 0 and 1 Communication Low or high voltage on wire Computation
E N D
HCL and ALU תרגול 10
Overview of Logic Design • Fundamental Hardware Requirements • Communication: How to get values from one place to another • Computation • Storage • Bits are Our Friends • Everything expressed in terms of values 0 and 1 • Communication • Low or high voltage on wire • Computation • Compute Boolean functions • Storage • Store bits of information
0 1 0 Voltage Time Digital Signals • Use voltage thresholds to extract discrete values from continuous signal • Simplest version: 1-bit signal • Either high range (1) or low range (0) • With guard range between them • Not strongly affected by noise or low quality circuit elements • Can make circuits simple, small, and fast
a && b HCL (hardware control language) • HCL - A programming language used to develop and understand the control logic of processor architecture. - Describes the control logic of different processor design. • Logic Gate Types - Logic gates are always active - Input → ... time → output Falling Delay Rising Delay b Voltage a Time
Combinational Circuits and HCL • Combinational circuit - Combination of logic gates - Output cannot be connected together - Acyclic • Combinational circuit to test for bit equality - The output will equal 1 when both inputs are 0, or both are 1. HCL code : Booleq = (a && b) || (!a && !b)
Combinational Circuits and HCL Multiplexor - Sets a value depending on a control input signal - The output will equal a when s is 1, and b when s is 0. HCL code : Bool out = (s && a) || (!s && b)
Combinational Circuits and HCL HCL versus C - Change occurs over time - There is no real assignment, just assignment to expressions - Expressions cannot be partially evaluated Example: (a && !a) && func(b,c)
Combinational Circuits and HCL Word-level equality test circuit HCL code : Bool EQ = ( A == B)
Combinational Circuits and HCL Word-level multiplexor HCL (case expression) - 1 stands for default
Combinational Circuits and HCL Mux 4 int Out4 = [ !s1 && !s0 : A; !s1 : B; s1 && !s0 : C; 1 : D; ]; Min 3 int Min3 = [ A <= B && A <= C : A; B <= A && B <= C : B; 1 : C; ];
Arithmetic Logic Unit An arithmetic and logic unit (ALU) is a digital circuit that performs arithmetic and logical operations. The ALU is a fundamental building block of the Central Processing Unit of a computer, and even the simplest microprocessors contain one for purposes such as maintaining timers. The processors found inside modern CPUs and graphics processing units (GPUs) accommodate very powerful and very complex ALUs; a single component may contain a number of ALUs.
0 1 2 3 Y Y Y Y A A A A A L U A L U A L U A L U X + Y X - Y X & Y X ^ Y X X X X B B B B OF OF OF OF ZF ZF ZF ZF CF CF CF CF Arithmetic Logic Unit Combinational logic Continuously responding to inputs Control signal selects function computed Corresponding to 4 arithmetic/logical operations in Y86 Addition, Subtraction, AND, OR Also computes values for condition codes
Basic ALU (Combinational Circuit) • The basic ALU provides the basic logical and arithmetic functions: AND, OR plus addition. • Shift, multiplication and division are usually outside the basic ALU. Logical operations a b 0 1 result MUX select (AND or OR) 1 bit logical unit for AND/OR operations
0 1 2 3 4 5 6 7 0 1 2 DECODER c The ALU • ALU includes combinational logic. • Combinational logic a change in inputs directly causes a change in output, after a characteristic delay. • Different from sequential logic which only changes on the clock. • Two major components of combinational logic are – multiplexors & decoders which we previously talked about. 0 1 2 3 4 5 6 7 s2 s1 s0 3 X 8 multiplexor 3 X 8 Decoder
outputs inputs a b Cin sum Cout 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 Cin a b Cout 1 bit FULL adder (3,2) a b Carry out Carry in Cout Cin sum sum = (a b Cin) + (a b Cin) + (a b Cin) + (a b Cin) = a + b + Cin Cout =(b Cin) + (a Cin) + (a b) = ((a + b) Cin) + (a b) Adder hardware for Cout in 2 layers
a b sum Cout Cin a b sum Cout Full Adder from Half Adders • Half adder • Full adder from 2 half adders + or gate
1 Bit Simple ALU 1 bit simple ALU for logical / arithmetic operations - does not yet include subtraction. Cin select 2 a b 0 1 2 result + Cout
1 Bit Enhanced ALU Enhanced for subtraction invert Cin select 2 a b 0 1 2 result + 0 1 1's complement Cout For subtraction use Cin = 1 and inverse b subtraction: a + b + 1 = a + (b + 1) = a + (-b) = a - b
Cin operation = invert + select 3 Ripple Carry Type Adder Cin ALU0 Cout a0 b0 32 bit ADDER with ripple carry: result 0 • To produce a 32 bit result, we connect 32 single bit units together. • This type of ALU adder is called a ripple adder • Carry bits are generated in sequence. • Bit 31 result and Cout is not correct until it receives Cin from previous unit, which is not correct until it receives Cin from its previous unit, etc. • Total operation time is proportional to word size (here 32). Cin ALU1 Cout a1 b1 result 1 Cin ALU2 Cout a2 b2 result 2 . . . . . . Cin ALU31 Cout a31 b31 result 31 Cout