Académique Documents
Professionnel Documents
Culture Documents
reconfigurable
Travaux pratiques :
a b y
0 0 0
0 1 0
1 0 0
1 1 1
2. Code :
a) Code de composant
library IEEE;
use IEEE.std_logic_1164.all;
entity and_port is
port (
a,b : IN std_logic;
y : OUT std_logic
);
end and_port;
c) Simulation
II. Port OR :
1.
2. Schéma et table de vérité :
a b y
0 0 0
0 1 1
a b y
1 0 1
1 1 1
3. Code :
a) Code de composant
library IEEE;
use IEEE.std_logic_1164.all;
entity or_port is
port (
a,b : IN std_logic;
y : OUT std_logic
);
end or_port;
begin
uut : or_port port map ( a => a, b => b,
y => y );
c) Simulation
a b y
0 0 0
0 1 1
1 0 1
1 1 0
2. Code :
a) Code de composant
library IEEE;
use IEEE.std_logic_1164.all;
entity xor_port is
port ( a,b : IN std_logic;
y : OUT std_logic);
end xor_port;
architecture dataflow of xor_port is
begin
y <= a xor b;
end dataflow;
b) Code test Bench
library IEEE; process
use IEEE.std_logic_1164.all; begin
entity xor_port_tb is wait for 10 ns;
end xor_port_tb; a <= '0';
architecture Behavioral of xor_port_tb is b <= '0';
component xor_port is wait for 10 ns;
port ( a <= '0';
a : in std_logic; b <= '1';
b : in std_logic; wait for 10 ns;
y : out std_logic ); a <= '1';
end component; b <= '0';
wait for 10 ns;
signal a: std_logic := '0'; a <= '1';
signal b: std_logic := '0'; b <= '1';
signal y: std_logic; wait for 10 ns;
end process;
begin end Behavioral;
uut : xor_port
port map (a => a, b => b, y => y);
c) Simulation
IV. Port mux 4-1 :
1. Schéma et table de vérité :
s1 s0 a3 a2 a1 a0 y
0 0 0 0 0 0 0
0 1 0 0 0 1 1
1 0 0 0 1 0 0
1 1 0 1 0 0 0
0 1 0 0 1 0 1
2. Code :
a) Code de composant
library IEEE;
use IEEE.std_logic_1164.all;
entity mux_4_1 is
port (
a0, a1, a2, a3 : IN std_logic;
s0, s1 : IN std_logic;
y : OUT std_logic
);
end mux_4_1;
V. Port demi-add :
1. Schéma et table de vérité :
a b sum carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
2. Code :
a) Code de composant
library IEEE;
use IEEE.std_logic_1164.all;
entity half_adder is
port (
a, b : IN std_logic;
sum, carry : OUT std_logic
);
end half_adder;
architecture dataflow of half_adder is
begin
sum <= a xor b;
carry <= a and b;
end dataflow;
c) Simulation
VI. Port Full add :
1. Schéma et table de vérité :
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
2. Code :
a) Code de composant
library IEEE;
use IEEE.std_logic_1164.all;
entity full_adder is
port (
a, b, c_in : IN std_logic;
sum, c_out : OUT std_logic
);
end full_adder;
c) Simulation
VII. Exercice :
1. Code :
a) Code de composant
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity div_freq is
generic (
DIV_FR: integer := 20;
TAILLE_PULSE: integer := 10;
N: integer := 45);
port (
clk, reset: in std_logic;
start_fb: in std_logic;
clk_bit: out std_logic
);
end div_freq;
begin
process (clk, reset)
begin
if (reset = '1') then
cnt <= 0;
clk_bit <= '0';
elsif rising_edge(clk) then
if start_fb = '1' then
cnt <= cnt + 1;
if cnt = TAILLE_PULSE-1 then
clk_bit <= '1';
elsif cnt = DIV_FR-1 then
clk_bit <= '0';
cnt <= 0;
end if;
end if;
end if;
end process;
end Behavioral;
b) Code test Bench
library IEEE; begin
use IEEE.STD_LOGIC_1164.ALL; process (clk, reset)
use IEEE.numeric_std.ALL; begin
if (reset = '1') then
entity div_freq is cnt <= 0;
generic ( clk_bit <= '0';
DIV_FR: integer := 20; elsif rising_edge(clk) then
TAILLE_PULSE: integer := 10; if start_fb = '1' then
N: integer := 45 cnt <= cnt + 1;
); if cnt = TAILLE_PULSE-1 then
port ( clk_bit <= '1';
clk, reset: in std_logic; elsif cnt = DIV_FR-1 then
start_fb: in std_logic; clk_bit <= '0';
clk_bit: out std_logic cnt <= 0;
); end if;
end div_freq; end if;
end if;
architecture Behavioral of div_freq is end process;
signal cnt: integer range 0 to DIV_FR ; end Behavioral;
c) Simulation