Professional Documents
Culture Documents
LOGIC IN COMPUTER
SYSTEMS
Credits to:
Mi Lu,
Texas A&M university
1
)Conventional
, r (radix)
,
1) bits ?
: log 2 1
2) conventional
radix system?
:
(r),
.
n-1
-
., ,
.
:
-
(diminished radix compliment)
(radix compliment)
RNS(Residue Number System)
LNS(Logarithmic Number System)
,
MSB
Diminished Radix
Compliment
(r-1),
, :
N
Radix Compliment
r
4 Bit
Signed-Digit
, ,
. , r>1 :
:
non-redudant( ),
( , ,
). .
Singed Digit,
continued
!
signed digit
.
-3 (=-3 , n=4, r=2, (
)=0 ) :
Floating point
numbers
( ,
)
(fixed-point).
,
,
.,
, mantissa()
exponent(E)
Normalization
,
,
MSB(Most Significant Bit) mantissa
0.
Residue Number
System(RNS)
=(x1,x2....xn) xi>1 .
mi=(m1,m2...mn) .
xi :
x i = X mod
mi
9 RNS :
RNS (104)
mi .
, tradeoff
mi
Logarithmic Number
System(LNS)
- ,
r.
( Lx) n bit
k bits , LNS
:
, :
RNS: RNS
.,
2 RNS
1
.
LNS: ,
.
. LNS
Hidden Markov Models( viterby)
.
:
Time complexity ( ):
.
g
NAND NOR
Area complexity( ) :
( 1 layer).
1 g
NAND NOR.
Half Adder
Full Adder
, ai bi =d i borrow-out(
carry) bit l .i
,
.
hardware(
) A- +(-)
Subtractor circuit
1scomplement
Negation Circuit with enable
2s
complement
2 ,
0 1 1 0
1. , hardware 1's
complement circuit
.
2s
complement no2
:
,continued
,continued
:
( 2)
( 1).
Full 1bit
adder/subtractor
,
=0 =1.
.
Overflow
overflow
Ripple Carry
schematic
Ones complemet
addition
+ :
1) :
2.
2) :
,
1.' end-arround carry(Cn
)
3) (||>||)
end-arround Carry,
end-arround carry
Ones complemet
addition
mod 2^n ( 1) ,
||-||-1, ||-||.
, implement end arround
carry
, FA 1's complement
Sign- Magnitude
addition
Sign- Magnitude
addition
Pre-Complement(P): 1
Post-Complement(Q): 1
, ||>=||
:
2
(||>=||)
||<|
Sign- Magnitude
addition
Conditional Sum
Addition
Circuit of Conditional
Sum
Carry Completion
Sensing Addition
(CCSA)
CCSA addition
IC carry
carry IC
DC carry.
:
1: IC carry
2: DC carry
3: 2 IC DC carrys
mod2( carry
2 )
CCSA circuit
CCSA complexities
Carry Look-Ahead
Adition(CLA)
,
CLA
carrys. ,
1)Carry-Lookahead adder
2)Carry- Blockahead adder
2 n bits.
Carry generation G i= A iBi Carry
propagation function P i= A i exor B i
H carry generation
carry i, carry propagation
carry in bit i carry in
bit i+1.
CLA
To C i1 C i
Carry Look-Ahead
Adder schematic
Carry-Save
adders(CSA)
2,
.
carry-out
, .
carry ( bits
)
CSA algorithm
CSA circuit
CSA vs CLA
Bit-partitioned multiple
addition
, -,
bit .
bits 1
( ROM PLA).,
(
left shift).
.
.
,
64 bit .
.
Links
VHDL codes
VHDL
.
vhdl
.
,
.
, ( ) .
Carry Look-Ahead
adder
vhdl 8bit Carry
look Ahead Adder. carry, ,
P G.
AND-OR 2
carry.
CLA VHDL
implementation
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY c_l_addr IS
PORT
(
x_in
: IN STD_LOGIC_VECTOR(7 DOWNTO 0);
y_in
: IN STD_LOGIC_VECTOR(7 DOWNTO 0);
carry_in : IN STD_LOGIC;
sum
: OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
carry_out : OUT STD_LOGIC
);
END c_l_addr;
ARCHITECTURE behavioral OF c_l_addr IS
SIGNAL
SIGNAL
SIGNAL
SIGNAL
h_sum
: STD_LOGIC_VECTOR(7 DOWNTO 0);
carry_generate : STD_LOGIC_VECTOR(7 DOWNTO 0);
carry_propagate : STD_LOGIC_VECTOR(7 DOWNTO 0);
carry_in_internal : STD_LOGIC_VECTOR(7 DOWNTO 1);
CLA VHDL
implementation
BEGIN
h_sum <= x_in XOR y_in;
carry_generate <= x_in AND y_in;
carry_propagate <= x_in OR y_in;
PROCESS (carry_generate,carry_propagate,carry_in_internal)
BEGIN
carry_in_internal(1) <= carry_generate(0) OR (carry_propagate(0) AND carry_in);
inst: FOR i IN 1 TO 6 LOOP
carry_in_internal(i+1) <= carry_generate(i) OR (carry_propagate(i) AND
carry_in_internal(i));
END LOOP;
carry_out <= carry_generate(7) OR (carry_propagate(7) AND carry_in_internal(7));
END PROCESS;
sum(0) <= h_sum(0) XOR carry_in;
sum(7 DOWNTO 1) <= h_sum(7 DOWNTO 1) XOR carry_in_internal(7 DOWNTO 1);
END behavioral;
Conditional Sum
Adder VHDL code
adder 2
16 bits Conditional Sum addition.
,
4 .
1: conditional sums carries i-
bits .
2: bits (level 2 bits)
1 . , bits 1
2. carry
carry
2
Conditional Sum
Adder VHDL code
3: , carrys 3
2 .
4: 2,3.
.
(16bit)
.
Conditional Sum
Adder VHDL code
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity Adder_CS_16bit is
port (a, b: in std_logic_vector(15 downto 0);
cin: in std_logic;
sum: out std_logic_vector(15 downto 0);
cout: out std_logic);
end Adder_CS_16bit;
architecture behavioral of Adder_CS_16bit is
signal s10: std_logic_vector(15 downto 0) := "0000000000000000";
signal s11: std_logic_vector(15 downto 0) := "0000000000000000";
signal c10: std_logic_vector(15 downto 0) := "0000000000000000";
signal c11: std_logic_vector(15 downto 0) := "0000000000000000";
signal s20: std_logic_vector(15 downto 0) := "0000000000000000";
signal s21: std_logic_vector(15 downto 0) := "0000000000000000";
signal c20: std_logic_vector(15 downto 0) := "0000000000000000";
signal c21: std_logic_vector(15 downto 0) := "0000000000000000";
signal s30: std_logic_vector(15 downto 0) := "0000000000000000";
signal s31: std_logic_vector(15 downto 0) := "0000000000000000";
signal c30: std_logic_vector(15 downto 0) := "0000000000000000";
signal c31: std_logic_vector(15 downto 0) := "0000000000000000";
signal s40: std_logic_vector(15 downto 0) := "0000000000000000";
signal s41: std_logic_vector(15 downto 0) := "0000000000000000";
signal c40: std_logic_vector(15 downto 0) := "0000000000000000";
signal c41: std_logic_vector(15 downto 0) := "0000000000000000";
signal P: std_logic := '0';
signal G: std_logic := '0';
Conditional Sum
Adder VHDL code
begin
-- - 1
process (a, b)
begin
P <= a(0) xor b(0);
G <= a(0) and b(0);
end process;
process (a, b, P, G, cin)
begin
s10(0) <= P xor cin;
c10(0) <= G or (P and cin);
for i in 1 to a'length - 1 loop
s10(i) <= a(i) xor b(i);
c10(i) <= a(i) and b(i);
c11(i) <= a(i) or b(i);
end loop;
end process;
process (s10)
begin
s11 <= not s10;
end process;
Conditional Sum
Adder VHDL code
-- 2
process (s10, s11, c10, c11)
begin
s20(0) <= s10(0);
if c10(0) = '1' then
s20(1) <= s11(1);
c20(1) <= c11(1);
elsif c10(0) = '0' then
s20(1) <= s10(1);
c20(1) <= c10(1);
end if;
for i in 2 to a'length - 1 loop
if (i mod 2 = 0) then
s20(i) <= s10(i);
s21(i) <= s11(i);
if c10(i) = '1' then
s20(i+1) <= s11(i+1);
c20(i+1) <= c11(i+1);
elsif c10(i) = '0' then
s20(i+1) <= s10(i+1);
c20(i+1) <= c10(i+1);
end if;
Conditional Sum
Adder VHDL code
if c11(i) = '0' then
s21(i+1) <= s10(i+1);
c21(i+1) <= c10(i+1);
elsif c11(i) = '1' then
s21(i+1) <= s11(i+1);
c21(i+1) <= c11(i+1);
end if;
end if;
end loop;
end process;
-- 3
process (s20, s21, c20, c21)
begin
s30(1 downto 0) <= s20(1 downto 0);
if c20(1) = '1' then
s30(3 downto 2) <= s21(3 downto 2);
c30(3) <= c21(3);
elsif c20(1) = '0' then
s30(3 downto 2) <= s20(3 downto 2);
c30(3) <= c20(3);
end if;
Conditional Sum
Adder VHDL code
for i in 4 to a'length - 1 loop
if (i mod 4 = 1) then
s30(i downto i-1) <= s20(i downto i-1);
s31(i downto i-1) <= s21(i downto i-1);
if c20(i) = '1' then
s30(i+2 downto i+1) <= s21(i+2 downto i+1);
c30(i+2) <= c21(i+2);
elsif c20(i) = '0' then
s30(i+2 downto i+1) <= s20(i+2 downto i+1);
c30(i+2) <= c20(i+2);
end if;
if c21(i) = '0' then
s31(i+2 downto i+1) <= s20(i+2 downto i+1);
c31(i+2) <= c20(i+2);
elsif c21(i) = '1' then
s31(i+2 downto i+1) <= s21(i+2 downto i+1);
c31(i+2) <= c21(i+2);
end if;
end if;
end loop;
end process;
Conditional Sum
Adder VHDL code
-- 4
process (s30, s31, c30, c31)
begin
s40(3 downto 0) <= s30(3 downto 0);
if c30(3) = '1' then
s40(7 downto 4) <= s31(7 downto 4);
c40(7) <= c31(7);
elsif c30(3) = '0' then
s40(7 downto 4) <= s30(7 downto 4);
c40(7) <= c30(7);
end if;
-- level - 4
process (s30, s31, c30, c31)
begin
s40(3 downto 0) <= s30(3 downto 0);
if c30(3) = '1' then
s40(7 downto 4) <= s31(7 downto 4);
c40(7) <= c31(7);
elsif c30(3) = '0' then
s40(7 downto 4) <= s30(7 downto 4);
c40(7) <= c30(7);
end if;
Conditional Sum
Adder VHDL code
c40(i+4) <= c30(i+4);
end if;
if c31(i) = '0' then
s41(i+4 downto i+1) <= s30(i+4 downto i+1);
c41(i+4) <= c30(i+4);
elsif c31(i) = '1' then
s41(i+4 downto i+1) <= s31(i+4 downto i+1);
c41(i+4) <= c31(i+4);
end if;
end if;
end loop;
end process;
Conditional Sum
Adder VHDL code
-- 5
process (s40, s41, c40, c41)
begin
sum(7 downto 0) <= s40(7 downto 0);
if c40(7) = '1' then
sum(15 downto 8) <= s41(15 downto 8);
cout <= c41(15);
elsif c40(7) = '0' then
sum(15 downto 8) <= s40(15 downto 8);
cout <= c40(15);
end if;
end process;
end behavioral;
Sequential
Multiplication
.
add-shift.
:
Pencil-And-Paper
Multiplication
----------Partial Product
Add-And-Shift
Approach
partial product
, partial product
.
bit bit
, partial product
bit .
O indirect multiplication :
Add-And-Shift
Approach (cont.)
Register Occupation
Indirect Multiplication
Schemes
1. Unsigned Number Multiplication
2. Sign-Magnitude Number Multiplication
3. Ones Complement Number Multiplication
4. Twos Complement Number Multiplication
Unsigned Number
Multiplication
H
n+1 (n bit
).
C0
C1,...,Cn
.
Sign-Magnitude Number
Multiplication
H n
.
C0
bit
FF As Bs
MSB
AX MR
.
A s Bs
Ones Complement
Number Multiplication
H n+2
.
C0
C1
.
C2 Cn
loop
Cn+1
.
Twos Complement
Number Multiplication
H n+4
.
C0
,
C1
C2
.
C3 Cn+1
loop
Cn+2 Cn+3
Recoding
Technique
1. Non-Overlapped Multiple Bit Scanning
2. Overlapped Multiple Bit Scanning
3. Booths Algorithm
4. Canonical Multiplier Recoding
Non-Overlapped Multiple
Bit Scanning
1
string
of 1s
1
beginning of string
1 0
string.
long string 1
begging of string end of
1
string 1
0
Recoding Triplets
Booths
Algorithm
string property ,
B D, 2 bit B
bit D :
string of 1s 0
, dummy 0 LSB string.
O ,
.
Booths Algorithm
(cont.)
:
Booth :
2
, pre
post-complement.
Booths
Algorithm
(example)
Radix-4
Canonical
Multiplier
Recoding
signed-digit (SD).
minimal SD .
canonical SD minimal SD D=dn-1d1d0
- di x di-1=0 1 i n-1.
D=dndn-1d1d0
n+1 bits dn 0.
canonical (n+1)/2 bit..
Canonical Multiplier
Recoding (example)
Scan Pattern
Canonical Multiplier
Recoding (example)
Multiples Selection
Canonical Multiplier
Recoding (example)
Parallel
Multiplication
,
.
.
.
Wallace Trees
.
.
Wallace tree slice-bit
bit bit position.
Unsigned Array
Multiplier
Unsigned Array
Multiplier (cont.)
summands
-------------->
---------------------->
------------------------------>
-------------------------------------->
----------------------------------------------->
5 5 Multiplication Example
Partial Products
Unsigned Array
Multiplier (cont.)
H FA
Carry
Lookahead Adder
.
latch registers
FA.
.
Twos Complement
Array Multiplier
:
i 1-i 0 1 .
Baugh-Wooley Twos
Complement Multiplier
Baugh-Wooley Twos
Complement Multiplier(cont.)
O .
:
BW=[2(m+n) + 1]g
Modular Structure
.
Modular
Structure(example)
Baugh-Wooley Twos
Complement Multiplier(cont.)
Additive Multiply
Modules
AMM
.
Additive Multiply
Modules(example)
Additive Multiply
Modules(example)
Sequential Division
Substract And-Shift
Approach
,
:
,
j=0,1,...,n-1, o
R(j)
, j-
R(0) ,
R(n) ,
,o
Pencil-And-Paper
Division
Q=q0.q1q2....q(n)
R(0)<D , D0
R(0)D
Restoring Division
: 0R(0)<D
D
.
T D (restoring)
To :q(j+1)=(number of
subtractions -1).
Binary Restoring
Division
R(j+1) , q(j+1)=1.
R(j+1) , q(j+1)=0.
Binary Restoring
Division Hardware
Binary Non-Restoring
Division
(restoring
addition).
:
D>0.
H
:
2R(j)=0 .
SRT Division
Sweeney, Robertson & Tocher------>SRT
qj+1 {-1, 0, 1}
(D R ).
Robertson Diagrams
Convergence
Division
To
.
.
.
.
1 .
Convergence Division
Methodologies
m:
N D
:
Convergence Division
Methodologies (cont.)
Ri :
Ri Ri = 2 Di-1
The end!