Last active
January 19, 2022 22:16
-
-
Save Wasabules/ba3d5a81384dacdefb224a0844df41a0 to your computer and use it in GitHub Desktop.
COMPOSANTS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Question 4 | |
4.a, Le comptage va commencer quand il y a un signal Echo de perçu, il s'arrête de compter quand il n'y a plus. | |
La vitesse de comptage se fait à une période de 10µs vu que c'est l'horloge qui est connecté. | |
n c'est le nombre du compteur. | |
4.b, Le compteur va faire le calcul de la distance avec n d'où n*p/q, la distance est en centimètre. | |
4.c La distance max est 2.5m, soit 250cm, il faut stocker un nombre allant jusqu'Ã 250, soit un bus de 8 bits (monte jusqu'Ã 255) | |
4.d s_dist va prendre les 8 bits de poids faible du signal s_d | |
Question 5 | |
library ieee; | |
use ieee.std_logic_1164.all; | |
use ieee.std_logic_arith.all; | |
library work; | |
use work.sonar_hc_sr04; | |
Question 6 | |
entity sonar_ctrl is | |
port ( | |
echo, mesure, init : in std_logic; | |
clk50Mhz : in std_logic; | |
trig : out std_logic; | |
e0,e1,e2,e3 : out std_logic; | |
) | |
end sonar_ctrl | |
Question 7 | |
architecture beh of sonar_ctrl is | |
component cpt_150_ms | |
port( | |
clk : in std_logic; | |
n : out std_logic_vector; | |
); | |
end component; | |
component comp_trig | |
port( | |
clk : in std_logic; | |
n : in std_logic_vector; | |
trig : out std_logic; | |
); | |
end component; | |
component fsm | |
port( | |
clk : in std_logic; | |
n : out std_logic_vector; | |
); | |
end component; | |
component inc_p | |
port( | |
clk,echo,mesure,init : in std_logic; | |
e0,e1,e1,e3 : out std_logic; | |
en_save : out std_logic; | |
en_inc : out std_logic; | |
raz : out std_logic; | |
); | |
end component; | |
Question 8 | |
entity cpt_150_ms is | |
port( | |
clk : in std_logic; | |
n : out std_logic_vector; | |
); | |
end cpt_150_ms ; | |
architecture Behavioral of cpt_150_ms is | |
begin | |
process (clk) is | |
begin | |
if cmpt = 0 then | |
cmpt <= 7500000; | |
else | |
cmpt <= cmpt - 1; | |
end if; | |
end process; | |
n <= cmpt; | |
end Behavioral; | |
Question 9 | |
raz <= '1' WHEN state=e0 ELSE '0'; | |
en_inc <= '1' WHEN state=e2 ELSE '0'; | |
en_save <= '1' WHEN state=e3 ELSE '0' | |
Question 10 | |
PROCESS (clock) BEGIN -- 1er process | |
CASE (state) IS | |
WHEN e0 => IF (mesure='1' AND trig='1') THEN state=e0 ELSE state=e0; | |
WHEN e1 => IF echo='1' THEN state=e2 ELSE state=e1; | |
WHEN e2 => IF echo='0' THEN state=e3 ELSE state=e2; | |
WHEN e3 => IF mesure='0' THEN state=e4 ELSE state=e3; | |
END PROCESS; | |
Question 11 | |
iowr: process(CLK) | |
begin | |
if (rising_edge(CLK)) then | |
if (IO_wr = '1') then | |
case IO_A is | |
when PORTA => init(7 downto 0) <= IO_Dwr; | |
when PORTB => mesure(7 downto 0) <= IO_Dwr; | |
when ADCH => led(7 downto 0) <= IO_Dwr; | |
when others => | |
end case; | |
end if; | |
end if; | |
end process; | |
Question 12 | |
iord: process(IO_rd,IO_A,e,distance) | |
begin | |
-- | |
if IO_rd = '1' then | |
case IO_A is | |
when PINA => IO_Drd <= e(7 downto 0); | |
when PINB => IO_Drd <= distance(7 downto 0); | |
when others => IO_Drd <= X"AA"; | |
end case; | |
end if; | |
end process; | |
Question 13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment