50
1 Computer Architecture (CS 493) Name: Enanko Basak Roll Number: 1351047 Computer Science And Engineering 2 nd Year

Architecture(2)

Embed Size (px)

DESCRIPTION

Basic Architecture XIlinx

Citation preview

  • 1

    Computer Architecture (CS 493)

    Name: Enanko Basak Roll Number: 1351047 Computer Science And Engineering 2nd Year

  • 2

    DAY 1:

    15 .01.2015 Data Flow Architecture for Basic Gates

    AND GATE

    Code:

    entity and_gate is Port ( a : in std_logic; b : in std_logic; x : out std_logic); end and_gate;

    architecture DataFlow of and_gate is

    begin x

  • 3

    OR Gate

    Code:

    entity or_gate is Port ( a : in std_logic; b : in std_logic; x : out std_logic); end or_gate;

    architecture dataflow of or_gate is

    begin

    x

  • 4

    XOR Gate

    Code:

    entity xor_gate is Port ( a : in std_logic; b : in std_logic; x : out std_logic); end xor_gate;

    architecture DataFlow of xor_gate is

    begin

    x

  • 5

    NOT Gate

    Code:

    entity not_gate is Port ( a : in std_logic; x : out std_logic); end notgt;

    architecture dataflow of not_gate is

    begin

    x

  • 6

    NAND Gate

    Code:

    entity nand_gate is Port ( a : in std_logic; b : in std_logic; x : out std_logic); end nand_gate;

    architecture DataFlow of nand_gate is

    begin

    x

  • 7

    NOR Gate

    Code:

    entity nor_gate is Port ( a : in std_logic; b : in std_logic; y : out std_logic); end nor_gate;

    architecture DataFlow of nor_gate is

    begin

    y

  • 8

    DAY 2: 22.01.2015 DataFlow Architecture for Basic Gates using Universal Gates.

    AND GATE using NAND Gates

    Code:

    entity And_Nand is Port ( A : in std_logic; B : in std_logic; X : out std_logic); end And_Nand;

    architecture DataFlow of And_Nand is

    begin

    X

  • 9

    OR GATE using NAND Gates

    Code:

    entity Or_Nor is Port ( A : in std_logic; B : in std_logic; X : out std_logic); end Or_Nor;

    architecture DataFlow of Or_Nor is

    begin

    X

  • 10

    NOT GATE using NAND Gates

    Code:

    entity Not_nand is Port ( A : in std_logic; X : out std_logic); end Not_nand;

    architecture DataFlow of Not_nand is

    begin

    X

  • 11

    AND GATE using NOR Gates

    Code:

    entity ANo1 is Port ( A : in std_logic; B : in std_logic; X : out std_logic); end ANo1;

    architecture DataFlow of ANo1 is

    begin

    X

  • 12

    OR GATE using NOR Gates

    Code:

    entity Or_nor is Port ( A : in std_logic; B : in std_logic; X : out std_logic); end Or_nor;

    architecture DataFlow of Or_nor is

    begin

    X

  • 13

    NOT GATE using NOR Gates

    Code:

    entity not_or is Port ( A : in std_logic; X : out std_logic); end not_or;

    architecture DataFlow of not_or is

    begin

    X

  • 14

    Half Adder:

    Code:

    entity Half_Adder is Port ( A : in std_logic; B : in std_logic; S : out std_logic; C : out std_logic); end Half_Adder;

    architecture DataFlow of Half_Adder is

    begin

    S

  • 15

    Truth Table:

    Sum: Carry :

    Waveform:

  • 16

    Full Adder

    Code:

    entity full_adder is Port ( A : in std_logic; B : in std_logic; Cin : in std_logic; Sum : out std_logic; Cout : out std_logic); end full_adder;

    architecture DataFlow of full_adder is

    begin

    Sum

  • 17

    Sum:

    Truth Table: Sum: Carry:

    Waveform:

  • 18

    DAY 3: 29.01.2015 Behavioral Architecture of Basic Gates

    AND Gate: Code:

    entity and is Port ( A : in std_logic; B : in std_logic; X : out std_logic); end and; architecture Behavioral of and is begin

    process(A,B) begin if(A='0') then X

  • 19

    OR Gate

    Code:

    Entity or is Port ( A : in std_logic; B : in std_logic; X : out std_logic); end or;

    architecture Behavioral of or is

    begin process(A,B) begin if(A='1')then X

  • 20

    NOT Gate

    Code:

    entity not is Port ( A : in std_logic; X : out std_logic); end behavnot;

    architecture Behavioral of not is

    begin process(A) begin if(A='0')then X

  • 21

    NAND Gate Code:

    entity nand is Port ( A : in std_logic; B : in std_logic; X : out std_logic); end nand; architecture Behavioral of nand is begin process(A,B) begin

    if(A='0')then X

  • 22

    NOR Gate Code:

    entity nor is Port ( A : in std_logic; B : in std_logic; X : out std_logic); end nor;

    architecture Behavioral of nor is

    begin process(A,B) begin if(A='1')then X

  • 23

    XOR Gate

    Code:

    entity xor is Port ( A : in std_logic; B : in std_logic; X : out std_logic); end xor;

    architecture Behavioral of xor is

    begin process(A,B) begin if(A=B)then X

  • 24

    Half Adder: Behavioral Model

    Code:

    entity Half_Adder is Port ( A : in std_logic; B : in std_logic; C : out std_logic; S : out std_logic); end Half_Adder;

    architecture Behavioral of Half_Adder is

    begin process(A,B) begin if(A=B)then S

  • 25

    Full Adder: Behavioral Model

    Code:

    entity Full_Adder is Port ( A : in std_logic; B : in std_logic; Cin : in std_logic; Cout : out std_logic; Sum : out std_logic); end Full_Adder;

    architecture Behavioral of Full_Adder is

    begin process(A,B,Cin) begin if(A='0')then if(B=Cin) then Sum

  • 26

    Waveform:

  • 27

    DAY 4: 5 . 02. 2015 Design 2:1 MUX using Behavioral and DataFlow

    Behavioral:

    Code: entity mux_b is Port ( S : in std_logic; I : in std_logic_vector(1 downto 0); Y : out std_logic); end mux_b;

    architecture Behavioral of mux_b is

    begin process(I,S) begin case S is when '0' => y y null; end case; end process;

    end Behavioral;

    Schematic Diagram:

  • 28

    Truth Table:

    Waveform:

    MUX 2 : 1 Using Dataflow

    Code:

    entity mux_data is Port ( I : in std_logic_vector(1 downto 0); S : in std_logic; Y : out std_logic); end mux_data;

    architecture DataFlow of mux_data is

    begin

    process(I,S) begin Y

  • 29

    Schematic Diagram:

    Truth Table:

    Waveform:

  • 30

    Design 4:1 MUX using Behavioral Code: entity mux_41 is Port ( I : in std_logic_vector(3 downto 0); S : in std_logic_vector(1 downto 0); Y : out std_logic); end mux_41;

    architecture Behavioral of mux_41 is

    begin process(I,S) begin case S is when "00" => Y Y Y Y null; end case; end process; end Behavioral;

    DataFlow

    Code: entity mux_data is Port ( I : in std_logic_vector(3 downto 0); S : in std_logic_vector(1 downto 0); Y : out std_logic); end mux_data;

    architecture DataFlow of mux_data is

    begin

    process(I,S) begin

    Y

  • 31

    Design a Decoder using DataFlow and Behavioral Architecture

    DataFlow

    Code: entity 38decoder_d is Port ( B : in std_logic_vector(2 downto 0); D : out std_logic_vector(7 downto 0)); end 38decoder_d;

    architecture DataFlow of 38decoder_d is

    begin process(B) begin D

  • 32

    Behavioral

    Code:

    entity 38mux_b is Port ( B : in std_logic_vector(2 downto 0); O : out std_logic_vector(7 downto 0)); end 38mux_b;

    architecture Behavioral of 38mux_b is

    begin process(B) begin O O(0) O(1) O(2) O(3) O(4) O(5) O(6) O(7) null; end case; end process;

    end Behavioral;

  • 33

    Design a 4:1 MUX using when-else

    Code:

    entity muxwhen is Port ( I : in std_logic_vector(3 downto 0); S : in std_logic_vector(1 downto 0); Y : out std_logic); end muxwhen;

    architecture DataFlow of muxwhen is

    begin Y

  • 34

    DAY 5: 12 .02 . 2015

    Design 4 bit ALU Behavioral

    Code

    entity alu_4bit_vhd is Port ( A : in std_logic_vector(3 downto 0); B : in std_logic_vector(3 downto 0); S : in std_logic_vector(2 downto 0); Y : out std_logic_vector(3 downto 0)); end alu_4bit_vhd;

    architecture Behavioral of alu_4bit_vhd is

    begin process(A, B, S) begin

    case S is when "000" => Y Y Y Y Y Y Y Y NULL; end case; end process end Behavioral;

    Truth Table: Select Line Operation

    000 A And B 001 A Or B 010 A Xor B 011 Not A 100 A + B 101 A B 110 A + 1 111 A - 1

  • 35

    Waveform :

  • 36

    4-bit Comparator (DataFlow)

    Code:

    entity Comparator is Port ( A : in std_logic_vector(3 downto 0); B : in std_logic_vector(3 downto 0); Gr : out std_logic; Eq : out std_logic; Ls : out std_logic); end Comparator;

    architecture Dataflow of Comparator is begin Gr B else '0'; Ls

  • 37

    Parity Checker (Behavioral)

    Code:

    entityParity_checker is Port ( A : in std_logic_vector(3 downto 0); P_odd : out std_logic; P_even : out std_logic); endParity_checker;

    architecture Behavioral of Parity_checker is begin process(A) variable temp : std_logic; begin temp := A(0) xor A(1); for i in 2 to 3 loop temp := temp xor A(i); end loop; P_odd

  • 38

    DAY 5: 19 .02. 2015 Realisation Of Flip Flops

    SR Flip Flop Behavioral

    Code: entityS_R_FlipFlop is Port ( S : in std_logic; R : in std_logic; C : in std_logic; Q : out std_logic; Qout : out std_logic); endS_R_FlipFlop;

    architecture Behavioral of S_R_FlipFlop is begin process(S,R,C) begin if(C'event and C='1') then if(S='0' and R='1')then Q

  • 39

    D-Flip Flop

    Code:

    entityD_FlipFlop is Port ( D : in std_logic; C : in std_logic; Q : out std_logic; Qnot : out std_logic); endD_FlipFlop;

    architecture Behavioral of D_FlipFlop is begin process(D,C) begin if(C'event and C='1') then if(D='0') then Q

  • 40

    JK Flip Flop

    Code:

    entityJK_FlipFlop is Port ( J : in std_logic; K : in std_logic; C : in std_logic; Q :inoutstd_logic; Qnot :inoutstd_logic); endJK_FlipFlop;

    architecture Behavioral of JK_FlipFlop is

    begin process(J,K,C) begin if(C'event and C='1') then if(J='0' and K ='1')then Q

  • 41

    T Flip Flop

    Code: entity tff is Port ( T : in std_logic; C : in std_logic; Q : inout std_logic; QNOT : inout std_logic); end tff;

    architecture Behavioral of tff is

    begin process(T,C) begin Q

  • 42

    UP Counter

    Code:

    entityUP_Cnt is Port ( C : in std_logic; clear : in std_logic; Q : out std_logic_vector(2 downto 0)); endUP_Cnt;

    architecture Behavioral of UP_Cnt is

    Signal tmp :std_logic_vector(2 downto 0); Begin

    process(clear,C) begin if(clear = '1')then tmp

  • 43

    Down Counter:

    Code: entity Dn_Cnt is Port ( C : in std_logic; clear : in std_logic; Q : out std_logic_vector(2 downto 0)); endDn_Cnt;

    architecture Behavioral of Dn_Cnt is

    Signal tmp :std_logic_vector(2 downto 0);

    begin process(clear,C) begin if(clear = '1')then tmp

  • 44

    DAY 6: 26 . 02 .2015 Full adder using two half adders (Structural approach)

    Code: entityFull_Adder_s is Port ( x : in std_logic; y : in std_logic; cin : in std_logic; sum : out std_logic; cout : out std_logic); endFull_Adder_s;

    architecture Structural of Full_Adder_s is componentHalf_adder is Port ( A : in std_logic; B : in std_logic; S : out std_logic; C : out std_logic); end component;

    signali,j,k : std_logic;

    begin ha1: Half_adder port map (x,y,i,j); ha2: Half_adder port map (i,cin,sum,k); cout

  • 45

    Waveform:

    Ripple Carry Adder Code:

    entityRipple_carry_adder is Port ( x : in std_logic_vector(3 downto 0); y : in std_logic_vector(3 downto 0); cin : in std_logic; sum : out std_logic_vector(3 downto 0); carry : out std_logic); endRipple_carry_adder;

    architecture Structural of Ripple_carry_adder is

    componentFull_adder_impl is Port ( A : in std_logic; B : in std_logic; Cin : in std_logic; S : out std_logic; Cout : out std_logic); end component;

    signal c1,c2,c3 : std_logic; begin fa1 :Full_adder_impl port map (x(0),y(0), cin ,sum(0),c1); fa2 :Full_adder_impl port map (x(1),y(1), c1 ,sum(1),c2); fa3 :Full_adder_impl port map (x(2),y(2), c2 ,sum(2),c3); fa4 :Full_adder_impl port map (x(3),y(3), c3 ,sum(3),carry); end Structural;

    Waveform:

  • 46

    Adder Subtractor Composite Unit Code

    entity Composite_adder is Port ( x : in std_logic_vector(3 downto 0); y : in std_logic_vector(3 downto 0); cin : in std_logic; sum : out std_logic_vector(3 downto 0); carry : out std_logic); end Composite _adder;

    architecture Structural of Composite_adder is

    componentFull_adder_impl is Port ( A : in std_logic; B : in std_logic; Cin : in std_logic; S : out std_logic; Cout : out std_logic); end component;

    signal t : std_logic_vector(3 downto 0); signal c1,c2,c3: std_logic;

    begin t(0)

  • 47

    Full Adder using loop (Structural)

    Code: entityRipple_carry_adder is Port ( x : in std_logic_vector(3 downto 0); y : in std_logic_vector(3 downto 0); cin : in std_logic; sum : out std_logic_vector(3 downto 0); carry : out std_logic); endRipple_carry_adder;

    architecture Structural of Ripple_carry_adder is

    componentFull_adder_impl is Port ( A : in std_logic; B : in std_logic; Cin : in std_logic; S : out std_logic; Cout : out std_logic); end component;

    signal t : std_logic_vector(3 downto 0); signal c: std_logic_vector(4 downto 0);

    begin c(0)

  • 48

    DAY 8: 2 .03. 2015

    8to1 MUX(Structural) Code:

    entity mux81 is Port ( I : in std_logic_vector(7 downto 0); S : in std_logic_vector(2 downto 0); Y : out std_logic); end mux81;

    architecture Structural of mux81 is

    component Mux4_dataflow is Port ( I : in std_logic_vector(3 downto 0); S : in std_logic_vector(1 downto 0); Y : out std_logic); end component;

    component mux_2 is

    Port ( I : in std_logic_vector(1 downto 0); S : in std_logic; Y : out std_logic); end component; signalya: std_logic_vector(1 downto 0); begin mux1 : Mux4_dataflow port map (I(3 downto 0),S(1 downto 0),ya(0)); mux2 : Mux4_dataflow port map (I(7 downto 4),S(1 downto 0),ya(1)); mux3 : mux_2 port map (ya(1 downto 0),S(2),Y);

    end Structural;

    RTL Schematic:

  • 49

    Waveform:

    4-bit Serial In Serial Out Register Code:

    entity SISO is Port ( I : in std_logic; C : in std_logic; Q1 : inout std_logic_vector(3 downto 0); QNOT1 : inout std_logic_vector(3 downto 0)); end SISO;

    architecture Structural of SISO is

    component dff is Port ( D : in std_logic; C : in std_logic; Q : out std_logic; QNOT : out std_logic); end component; begin

    d1: dff port map(I, C, Q1(0), QNOT1(0)); d2: dff port map(Q1(0), C, Q1(1), QNOT1(1)); d3: dff port map(Q1(1), C, Q1(2), QNOT1(2)); d4: dff port map(Q1(2), C, Q1(3), QNOT1(3));

    end Structural;

    Schematic Diagram:

  • 50

    Waveform: