trabajo vhdl

Upload: nixon-estefano-ortiz-morales

Post on 14-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 Trabajo Vhdl

    1/18

    Vhdl semaforo

    library IEEE;

    use IEEE.STD_LOGIC_1164.ALL;

    use IEEE.STD_LOGIC_ARITH.ALL;

    use IEEE.STD_LOGIC_UNSIGNED.ALL;

    -- Uncomment the following library declaration if using

    -- arithmetic functions with Signed or Unsigned values

    --use IEEE.NUMERIC_STD.ALL;

    -- Uncomment the following library declaration if instantiating

    -- any Xilinx primitives in this code.

    --library UNISIM;

    --use UNISIM.VComponents.all;

    entity semaforo is

    Port ( clk : in STD_LOGIC;

    luces : out STD_LOGIC_VECTOR (11 downto 0));

    end semaforo;

    architecture Behavioral of semaforo is

    type estados is (s0,s1,s2,s3,s4,s5,s6,s7);

    signal q,qmas: estados;

    signal cuenta: STD_LOGIC_VECTOR(6 downto 0);

    constant verderojo: STD_LOGIC_VECTOR(6 downto 0):= "1111000";

    constant amarillo: STD_LOGIC_VECTOR(6 downto 0):= "0001111";

  • 7/27/2019 Trabajo Vhdl

    2/18

    begin

    process(clk,q,cuenta)

    begin

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

    q

    if cuenta < verderojo then

    qmas

  • 7/27/2019 Trabajo Vhdl

    3/18

    else

    qmas

  • 7/27/2019 Trabajo Vhdl

    4/18

    if cuenta < amarillo then

    qmas

  • 7/27/2019 Trabajo Vhdl

    5/18

    Funcion_de_salida: process(q)

    begin

    case q is

    when s0 =>

    luces

    luces

    luces

    luces

    luces

    luces

    luces

    luces

  • 7/27/2019 Trabajo Vhdl

    6/18

    vhdl alu

    library IEEE;

    use IEEE.STD_LOGIC_1164.ALL;

    use IEEE.STD_LOGIC_ARITH.ALL;

    use IEEE.STD_LOGIC_UNSIGNED.ALL;

    -- Uncomment the following library declaration if using

    -- arithmetic functions with Signed or Unsigned values

    --use IEEE.NUMERIC_STD.ALL;

    -- Uncomment the following library declaration if instantiating

    -- any Xilinx primitives in this code.

    --library UNISIM;

    --use UNISIM.VComponents.all;

    entity alu is

    Port ( A : in STD_LOGIC_VECTOR (4 downto 0);

    B : in STD_LOGIC_VECTOR (4 downto 0);

    G: in STD_LOGIC_VECTOR(2 downto 0);

    z : out STD_LOGIC_VECTOR (4 downto 0));

    end alu;

    architecture Behavioral of alu is

    begin

    process(G,A,B)

    begin

  • 7/27/2019 Trabajo Vhdl

    7/18

    case G is

    when "000" => z z z z z z z z z

  • 7/27/2019 Trabajo Vhdl

    8/18

    -- Uncomment the following library declaration if using

    -- arithmetic functions with Signed or Unsigned values

    --use IEEE.NUMERIC_STD.ALL;

    -- Uncomment the following library declaration if instantiating

    -- any Xilinx primitives in this code.

    --library UNISIM;

    --use UNISIM.VComponents.all;

    entity maquinas is

    Port ( clk : in STD_LOGIC;

    y : in STD_LOGIC;

    m : out STD_LOGIC_VECTOR (3 downto 0));

    end maquinas;

    architecture Behavioral of maquinas is

    type estados is (s0,s1,s2,s3,s4,s5,s6);

    signal q,qmas : estados;

    signal cuenta: STD_LOGIC_VECTOR(5 downto 0);

    constant sesenta: STD_LOGIC_VECTOR(5 downto 0):="111100";

    constant treinta: STD_LOGIC_VECTOR(5 downto 0):="011110";

    begin

    process (clk,y,cuenta,q)

    begin

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

    q

  • 7/27/2019 Trabajo Vhdl

    9/18

    end if;

    case q is

    when S0 =>

    if cuenta < sesenta then

    qmas

  • 7/27/2019 Trabajo Vhdl

    10/18

    end if;

    when S2 =>

    if cuenta < sesenta then

    qmas

  • 7/27/2019 Trabajo Vhdl

    11/18

    when S4 =>

    if cuenta < treinta then

    qmas

  • 7/27/2019 Trabajo Vhdl

    12/18

    when S6 =>

    if cuenta < treinta then

    qmas

  • 7/27/2019 Trabajo Vhdl

    13/18

    m

    m

    m

    m

    m

    m

  • 7/27/2019 Trabajo Vhdl

    14/18

    --library UNISIM;

    --use UNISIM.VComponents.all;

    entity bcd is

    Port ( clk : in STD_LOGIC;

    S : in STD_LOGIC;

    contador : out STD_LOGIC_VECTOR (3 downto 0));

    end bcd;

    architecture Behavioral of bcd is

    type estados is (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9);

    signal q,qmas :estados;

    begin

    process(clk)

    begin

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

    q

    if S = '1' then

  • 7/27/2019 Trabajo Vhdl

    15/18

    qmas

  • 7/27/2019 Trabajo Vhdl

    16/18

    else

    qmas

    if S = '1' then

    qmas

  • 7/27/2019 Trabajo Vhdl

    17/18

    qmas

    if S = '1' then

    qmas

  • 7/27/2019 Trabajo Vhdl

    18/18

    contador

    contador

    contador

    contador

    contador

    contador

    contador