L10 Ex Register

download L10 Ex Register

of 36

Transcript of L10 Ex Register

  • 8/6/2019 L10 Ex Register

    1/36

    Register and Counter Design

  • 8/6/2019 L10 Ex Register

    2/36

    Registers in the Basic Computer

    Registers are basic building blocks in

    digital systems.

    store information auxiliary circuits may modify stored

    information or steer it to and from register

  • 8/6/2019 L10 Ex Register

    3/36

    Registers and Counters

    A register is a set of flip flops, often supplemented byadditional circuits to control input and output.

    - can have parallel I/O or serial I/O or combination

    Usually, registers are used to store a set of related bits.-bits that collectively represent an integer value

    bits of an ASCII character code

    -status bits for a device in a computer system (diskcontroller)

    Counters are registers that store numeric values along with circuits to increment/decrement the stored value.

  • 8/6/2019 L10 Ex Register

    4/36

    counters

    - up-counters, down-counters, up-down

    counters

    - generalized counters- BCD counters, gray-code counters, ...

  • 8/6/2019 L10 Ex Register

    5/36

    Simple Parallel Load Register

    Four bit register.

    if LD is high when clockrises,new values are stored

    LD should change only whileCLK is high

    Registers using gated clocks

    -can lead to timing problems.

    - increases clock skew

    - may lead to violations of flip-flop setup, hold time specs

    - extra care needed to ensurecorrect operation

    safer to avoid clock gatingwhenever possible

  • 8/6/2019 L10 Ex Register

    6/36

    Preferred Parallel Load

    RegisterMultiplexer for eachregister bit.

    new value loaded whenLD

    is low otherwise, old valuestored, No gated clock,

    - minimizing clock skew.

    simplifies checking ofsetup and hold timespecs.

    can focus on delaysbetween connected flipflops Increases gatecount by about 30%.

  • 8/6/2019 L10 Ex Register

    7/36

    4-bit Shift Register

  • 8/6/2019 L10 Ex Register

    8/36

    2-bit Register

  • 8/6/2019 L10 Ex Register

    9/36

    Serial-in-serial-out Shift Register

  • 8/6/2019 L10 Ex Register

    10/36

    Design of SR FF

    library ieee;

    use ieee.std_logic_1164.all;

    entity ff is

    port ( s,r : in std_logic;

    q,qbar : out std_logic

    );end ff;

    architecture behave of ff is

    begin

    process

    begin

    if (s = '0' and r = '0') then

    q

  • 8/6/2019 L10 Ex Register

    11/36

    SR FF (cont..)elsif (s = '1' and r = '0') then

    q

  • 8/6/2019 L10 Ex Register

    12/36

  • 8/6/2019 L10 Ex Register

    13/36

    D-flip flop

    library ieee;

    use ieee.std_logic_1164.all;

    entity dff is

    port (d, clk : in std_logic;

    q, qbar : out std_logic);

    end dff;

  • 8/6/2019 L10 Ex Register

    14/36

    architecture behave of dff is

    signal temp : std_logic;begin

    process (clk)begin

    if (clk'event and clk = '0') then

    temp

  • 8/6/2019 L10 Ex Register

    15/36

  • 8/6/2019 L10 Ex Register

    16/36

    SR flip-flop (process)library ieee;

    use ieee.std_logic_1164.all;

    entity ffclk is

    port ( s,r,clk : in std_logic;

    q,qbar : out std_logic

    );

    end ffclk;

  • 8/6/2019 L10 Ex Register

    17/36

    architecture behave of ffclk is

    signal temp,tempbar : std_logic;begin

    process (clk)begin

    if (clk = '1') thenif (s = '0' and r = '0') then

    temp

  • 8/6/2019 L10 Ex Register

    18/36

    elsif (s = '1' and r = '0') then

    temp

  • 8/6/2019 L10 Ex Register

    19/36

  • 8/6/2019 L10 Ex Register

    20/36

    counter

    library ieee;

    use ieee.std_logic_1164.all;

    use ieee.std_logic_unsigned.all;

    use ieee.std_logic_arith.all;entity counter4bit is

    port (load,clear, clk : in std_logic;

    d : in std_logic_vector (3 downto 0);

    q : out std_logic_vector (3 downto 0));

    end counter4bit;

  • 8/6/2019 L10 Ex Register

    21/36

    architecture behave of counter4bit is

    signal temp : std_logic_vector (3 downto 0);

    begin

    a:process (clk,load,clear,d)begin

    if (load = '1') thentemp

  • 8/6/2019 L10 Ex Register

    22/36

    temp

  • 8/6/2019 L10 Ex Register

    23/36

  • 8/6/2019 L10 Ex Register

    24/36

    With second process (b)

  • 8/6/2019 L10 Ex Register

    25/36

    Serial-in-parallel-out Shift

    Register

  • 8/6/2019 L10 Ex Register

    26/36

    Synchronous Counter

  • 8/6/2019 L10 Ex Register

    27/36

    Ring Counter

  • 8/6/2019 L10 Ex Register

    28/36

    Up/down counter

    library ieee;

    use ieee.std_logic_1164.all;

    use ieee.std_logic_unsigned.all;

    use ieee.std_logic_arith.all;

    -- up/down counterentity counterupdown is

    port (load,reset, clk : in std_logic; -- control signal

    dir : in std_logic; --

    directiond : in std_logic_vector (3 downto 0);

    q : out std_logic_vector (3 downto 0));

    end counterupdown;

  • 8/6/2019 L10 Ex Register

    29/36

  • 8/6/2019 L10 Ex Register

    30/36

    Waveform (up/down counter)

  • 8/6/2019 L10 Ex Register

    31/36

    Binary counter

    library ieee;

    use ieee.std_logic_1164.all;

    use ieee.std_logic_unsigned.all;

    use ieee.std_logic_arith.all;entity binarycounter is

    port (clk : in std_logic;

    q : out std_logic_vector (3 downto 0));

    end binarycounter;

  • 8/6/2019 L10 Ex Register

    32/36

    architecture behave of binarycounter is

    signal temp : std_logic_vector (3 downto 0);begin

    a:process (clk)beginif (clk'event and clk = '0') then

    temp

  • 8/6/2019 L10 Ex Register

    33/36

    Waveform (binary counter)

  • 8/6/2019 L10 Ex Register

    34/36

    Mod 2 counter

    library ieee;

    use ieee.std_logic_1164.all;

    use ieee.std_logic_unsigned.all;

    use ieee.std_logic_arith.all;entity mod2 is

    port (clk : in std_logic;

    q : out std_logic_vector (3 downto 0));

    end mod2;

  • 8/6/2019 L10 Ex Register

    35/36

    architecture behave of mod2 is

    signal temp : std_logic_vector (3 downto 0);

    begina: process (clk)

    begin

    if (clk'event and clk = '0') then

    if (temp = "0010" ) thentemp

  • 8/6/2019 L10 Ex Register

    36/36

    Waveform (mod 2 counter)