Codigo:
--------------------------------------------------------------------------------
-- Modulo para conectar un bus bidireccional.
-- El bus bus bidireccional es el puerto "data_bus".
-- Los datos que se quieren escribir en el bus vienen en el puerto "data_in".
-- Los datos que se leen del bus salen por el puerto "data_out".
-- Para controlar la dirección de los datos se utiliza la señal "control".
-- Si control vale 0 el bus se configura como salida, y si vale 1 como entrada.
--------------------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use ieee.numeric_std.all;
entity bus_bidir is
generic (
C_DATA_WIDTH : integer := 8 --Ancho de bus parametrizable, por defecto a 8 bits.
);
port (
data_bus : inout std_logic_vector(C_DATA_WIDTH-1 downto 0);
data_in : in std_logic_vector(C_DATA_WIDTH-1 downto 0);
data_out : out std_logic_vector(C_DATA_WIDTH-1 downto 0);
control : in std_logic
);
end entity bus_bidir;
architecture behavioral of bus_bidir is
begin -- architecture behavioral
with control select
data_bus <= data_in when "0", -- Conecta con la salida cuando control vale 0
(others => "Z") when others; -- Lo deja abierto cuando control vale 1
data_out <= data_bus; -- Bus de lectura
end architecture behavioral;
Codigo:
Net Entradas<3> LOC=c16;
Net Entradas<3> PULLUP;
Net Entradas<2> LOC=d16;
Net Entradas<2> PULLUP;
Net Entradas<1> LOC=e16;
Net Entradas<1> PULLUP;
Net Entradas<0> LOC=g15;
Net Entradas<0> PULLUP;
Codigo:
library ieee;
use ieee.std_logic_1164.all;
entity PAD is
port(PUERTO: inout STD_LOGIC;
DINOUT: in STD_LOGIC;
DOUTIN: out STD_LOGIC;
CONTROL: in STD_LOGIC);
end PAD;
architecture F of PAD is
signal pullup: STD_LOGIC;
begin
pullup <= "H";
PUERTO <= pullup;
with CONTROL select
PUERTO <= "Z" when "0", -- Buffer cerrado
DINOUT when others;
DOUTIN <= PUERTO;
end F;
Codigo:
constant RESOLUTION_TABLE : STDLOGIC_TABLE := (
-- ---------------------------------------------------------
-- | U X 0 1 Z W L H - | |
-- ---------------------------------------------------------
( "U", "U", "U", "U", "U", "U", "U", "U", "U" ), -- | U |
( "U", "X", "X", "X", "X", "X", "X", "X", "X" ), -- | X |
( "U", "X", "0", "X", "0", "0", "0", "0", "X" ), -- | 0 |
( "U", "X", "X", "1", "1", "1", "1", "1", "X" ), -- | 1 |
( "U", "X", "0", "1", "Z", "W", "L", "H", "X" ), -- | Z |
( "U", "X", "0", "1", "W", "W", "W", "W", "X" ), -- | W |
( "U", "X", "0", "1", "L", "W", "L", "W", "X" ), -- | L |
( "U", "X", "0", "1", "H", "W", "W", "H", "X" ), -- | H |
( "U", "X", "X", "X", "X", "X", "X", "X", "X" ) -- | - |
);
compiled.
.Codigo:
library ieee;
use ieee.std_logic_1164.all;
entity PAD is
port(PUERTO: inout STD_LOGIC;
DINOUT: in STD_LOGIC;
DOUTIN: out STD_LOGIC;
CONTROL: in STD_LOGIC);
end PAD;
architecture F of PAD is
signal PUERTOi: STD_LOGIC;
begin
PUERTOi <= "H"; -- Efecto pullup
with CONTROL select
PUERTOi <= "Z" when "0", -- Buffer cerrado
DINOUT when others;
PUERTO <= PUERTOi;
DOUTIN <= PUERTO;
end F;
Codigo:
library ieee;
use ieee.std_logic_1164.all;
entity PAD is
port(PUERTO: inout STD_LOGIC;
DINOUT: in STD_LOGIC;
DOUTIN: out STD_LOGIC;
CONTROL: in STD_LOGIC);
end PAD;
architecture F of PAD is
component pullup
port(o: OUT STD_LOGIC);
end component;
begin
u0: pullup port map(o => PUERTO);
with CONTROL select
PUERTO <= "Z" when "1", -- Buffer cerrado
DINOUT when others;
DOUTIN <= PUERTO;
end F;




