Académique Documents
Professionnel Documents
Culture Documents
M1 Instrumentation
Exo 01 :
1. Il s’agit d’une machine MEALY car les sorties dépendent a la fois de
l’état présent et des entrées, donc elles sont indiquées sue les transitions
après une barre oblique.
2. On doit utiliser process.
3. On doit utiliser 1 seul process par ce que y a une CLOCK et le CLEAR.
4. Le code VHDL :
library ieee;
use ieee.std_logic_1164.all;
entity a is
port(clk,clr:in std_logic;
g:out std_logic);
end a;
architecture b of a is
signal s: etat;
begin
process(clk,clr)
begin
if clr='1' then
s<=s1 ; g<='0';
case s is
when s1=>
if x="01" then
s<=s2; g<='0';
end if;
when s2=>
if x="01" then
s<=s2; g<='0';
s<=s3; g<='0';
s<=s8; g<='1';
end if;
when s3=>
if x="11" then
s<=s3; g<='0';
s<=s4; g<='0';
s<=s7; g<='1';
end if;
when s4=>
if x="10" then
s<=s4; g<='0';
s<=s1; g<='0';
s<=s6; g<='1';
end if;
when s5=>
if x="10" then
s<=s5; g<='1';
s<=s1; g<='0';
s<=s6; g<='1';
end if;
when s6=>
if x="11" then
s<=s6; g<='1';
s<=s4; g<='0';
s<=s7; g<='1';
end if;
when s7=>
if x="01" then
s<=s7; g<='1';
s<=s8; g<='1';
s<=s3; g<='0';
end if;
when s8=>
if x="00" then
s<=s8; g<='1';
s<=s2; g<='0';
s<=s5; g<='1';
end if;
end case;
end if;
end process;
end b;
use ieee.std_logic_1164;
entity d is
port(clk,clr,d:in std_logic;
q:out std_logic);
end d;
architecture k of d is
begin
process(clr,clk)
begin
q<=0;
q<=d;
end if
end process
end k;
4. Code VHDL de la partie combinatoire :
library ieee;
use ieee.std_logic_1164;
entity d is
port(s:in std_logic_vector(1 downto 0);
p:in std_logic_vecotr(3 downto 0);
q:in std_logic_vecotr(3 downto 0);
rsi:in std_logic;
d:out std_logic_vector(3 downto 0));
end d;
architecture k of d is
begin
d(3)<= (rsi and not(s(1)) and s(0)) or (p(3) and s(1) and s(0)) or (s(1) and not(s(0)) and q(2) or
(not(s(1)) and not(s(0)) and q(3))
d(2)<= (q(3) and not(s(1)) and s(0)) or (p(2) and s(1) and s(0)) or (s(1) and not(s(0)) and q(1) or
(not(s(1)) and not(s(0)) and q(1))
d(1)<= (q(2) and not(s(1)) and s(0)) or (p(1) and s(1) and s(0)) or (s(1) and not(s(0)) and q(0) or
(not(s(1)) and not(s(0)) and q(1))
d(0)<= (q(1) and not(s(1)) and s(0)) or (p(0) and s(1) and s(0)) or (s(1) and not(s(0)) and lsi or
(not(s(1)) and not(s(0)) and q(0))
end k;