Examen Practico
Examen Practico
1. A
entity fd is
Port (
A0: in STD_LOGIC ;
B0: in STD_LOGIC
);
end fd;
architecture Behavioral of fd is
component and2_1 is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : out STD_LOGIC);
component fjk is
K:in STD_LOGIC;
CLOCK: in STD_LOGIC;
Q: out STD_LOGIC;
component not1_1 is
Port ( a : in STD_LOGIC;
z : out STD_LOGIC);
component or2_1 is
Port ( b : in STD_LOGIC;
qq : in STD_LOGIC;
k : out STD_LOGIC);
begin
end Behavioral;
entity fjk is
K:in STD_LOGIC;
CLOCK: in STD_LOGIC;
Q: out STD_LOGIC;
end fjk;
begin
PROCESS(CLOCK)
TMP:=TMP;
TMP:='0';
else
TMP:='1';
end if;
end if;
Q<=TMP;
Q <=not TMP;
end PROCESS;
end Behavioral;
1. B
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.NUMERIC_STD.ALL;
--library UNISIM;
--use UNISIM.VComponents.all;
entity rs is
Port(A0 : in STD_LOGIC;
B0 : in STD_LOGIC;
C0 : out STD_LOGIC;
D0 : out STD_LOGIC
);
end rs;
architecture Behavioral of rs is
component ffsr is
component nor2_1 is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : out STD_LOGIC);
begin
end Behavioral;
entity ffsr is
end ffsr;
begin
PROCESS(CLOCK)
begin
tmp:=tmp;
tmp:='Z';
tmp:='0';
else
tmp:='1';
end if;
end if;
Q <= tmp;
end PROCESS;
end Behavioral;
SIMULACION
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity TB is
end TB;
component rs
port( A : in std_logic;
B : in std_logic;
CLK: in std_logic;
Q : inout std_logic;
end component;
signal A: std_logic:='0';
signal B: std_logic:='0';
begin
process
begin
CLK<='1';
A<= '0';
B<= '0';
CLK<= '0';
CLK<= '0';
CLK<='1';
A<= '0';
B<= '1';
CLK<= '0';
wait for 50 ns;
CLK<= '0';
CLK<='1';
A<= '1';
B<= '0';
CLK<= '0';
CLK<= '0';
CLK<='1';
A<= '1';
B<= '1';
CLK<= '0';
CLK<= '0';
end process;
end Testbench;
2. A
f(x,y,z)=Σ(1,2,3,4)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mx is
port (
E: in std_logic;
end mx;
begin
process (in,E)
begin
if E= '1' then
case i is
end case;
end if;
end process;
end Behavioral;
SIMULACION
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mux is
end mux;
architecture testbench of mux is
component mux
port (
i : in std_logic_vector(2 downto 0);
e : in std_logic;
salida : out std_logic);
end component;
signal in : std_logic_vector (2 downto 0) := (others => '0');
signal E : std_logic;
signal salida : std_logic;
begin
uut : mux port map(in=>in,E=>E,salida=>salida);
process
begin
e <= '1';
i<="000";
wait for 10ns;
i<="001";
wait for 10ns;
i<="010";
wait for 10ns;
i<="011";
wait for 10ns;
i<="100";
wait for 10ns;
i<="101";
wait for 10ns;
i<="110";
wait for 10ns;
i<="111";
wait for 10ns;
end process;
end testbench;
B.
f(x,y,z)=Σ(2,3,5,7)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mux is
port (
i : in std_logic_vector(2 downto 0);
e : in std_logic;
salida : out std_logic);
end mux;
end Behavioral;
SIMULACION
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity firstTB is
end firstTB;
architecture testbench of firstTB is
component first
port (
i : in std_logic_vector(2 downto 0);
e : in std_logic;
salida : out std_logic);
end component;
signal i : std_logic_vector (2 downto 0) := (others => '0');
signal e : std_logic;
signal salida : std_logic;
begin
uut : first port map(i=>i,e=>e,salida=>salida);
process
begin
e <= '1';
i<="000";
wait for 50ns;
i<="001";
wait for 50ns;
i<="010";
wait for 50ns;
i<="011";
wait for 50ns;
i<="100";
wait for 50ns;
i<="101";
wait for 50ns;
i<="110";
wait for 50ns;
i<="111";
wait for 50ns;
end process;
end testbench;
C.
f(x,y,z)=Σ(3,4)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity mux is
port (
i : in std_logic_vector(2 downto 0);
e : in std_logic;
salida : out std_logic);
end mux;
3. a
library IEEE;
use IEEE.std_logic_1164.all;
entity flipFlopD is
port (
status, notStatus : out std_logic;
clock, d : in std_logic
);
end entity;
begin
internalQ <= d;
end if;
report " internalQ=" & std_logic'image(internalQ);
end process;
SIMULACION
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity simulacion is
-- Port ( );
end simulacion;
);
end component ;
signal d: std_logic := '0';
signal clk: std_logic :='0';
signal q: std_logic ;
constant clk_period: time:= 10 ns;
begin
UUT: circ port map (d,clk,q);
clock_process: process
begin
clk<='0';
wait for clk_period/2;
clk <='1';
wait for clk_period/2;
end process;
stim_proc: process
begin
wait for clk_period*10;
d<='0';
wait for 100 ns;
d<='1';
wait for 200 ns;
d<= '0';
wait for 50 ns;
d<= '1';
wait;
end process;
end Behavioral
FLIP FLOP SR
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity d_ff_reset is
port(
clk, reset: in std_logic;
d: in std_logic;
q: out std_logic
);
end d_ff_reset;
4. A
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity demux1 is
Port ( A0 : in STD_LOGIC;
B0 : in STD_LOGIC;
C0 : in STD_LOGIC;
Q0 : out STD_LOGIC;
Q1 : out STD_LOGIC;
Q2 : out STD_LOGIC;
Q3 : out STD_LOGIC);
end demux1;
architecture Behavioral of demux1 is
component Not1 is
Port ( x : in STD_LOGIC;
y : out STD_LOGIC);
end component Not1;
component not2 is
Port ( x1 : in STD_LOGIC;
y1 : out STD_LOGIC);
end component not2;
component not3 is
Port ( x2 : in STD_LOGIC;
y2 : out STD_LOGIC);
end component not3;
component and2_1 is
Port ( a1 : in STD_LOGIC;
b1 : in STD_LOGIC;
c1 : out STD_LOGIC);
end component and2_1;
component and3_1 is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
z : out STD_LOGIC);
end component and3_1;
component or2_1 is
Port ( x3 : in STD_LOGIC;
y3 : in STD_LOGIC;
z3 : out STD_LOGIC);
end component or2_1;
component dm is
port(
F : in STD_LOGIC;
S0,S1: in STD_LOGIC;
A,B,C,D: out STD_LOGIC
);
F : in STD_LOGIC;
S0,S1: in STD_LOGIC;
A,B,C,D: out STD_LOGIC
);
end dm;
architecture Behavioral of dm is
begin
process (F,S0,S1) is
begin
if (S0 ='0' and S1 = '0') then
A <= F;
elsif (S0 ='1' and S1 = '0') then
B <= F;
elsif (S0 ='0' and S1 = '1') then
C <= F;
else
D <= F;
end if;
end process;
end Behavioral;
SIMULACION
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity demux_tb is
-- Port ( );
end demux_tb;
end process
end Behavioral;
B.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity demux2 is
Port ( A0 : in STD_LOGIC;
B0 : in STD_LOGIC;
C0 : in STD_LOGIC;
Q0 : out STD_LOGIC;
Q1 : out STD_LOGIC;
Q2 : out STD_LOGIC;
Q3 : out STD_LOGIC);
end demux2;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity demux2_tb is
-- Port ( );
end demux_tb;
end process
end Behavioral;
5.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity sum is
port (
sVect : out std_logic_vector (3 downto 0);
mainCarryOut : out std_logic;
aVect : in std_logic_vector (3 downto 0);
bVect : in std_logic_vector (3 downto 0);
mainCarryIn : in std_logic
);
end sum;
end Behavioral;
SIMULACION
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity sumador4bts_tb is
-- Port ( );
end sumador4bts_tb;
end Behavioral;