summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/interrupt/conserv.vhd
blob: f739f96181a394082c2e7ad75df69552b923ebe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
-- conserv.vhd
-- Eurobot 2004 : APB Team
-- Auteur : Pierre-Andr� Galmes
-- Lors de la d�tection d'un front, garde un �tat haut durant 2 cycles
-- d'horloge.


library ieee;
use	ieee.std_logic_1164.all;
use     ieee.std_logic_arith.all;
use     ieee.std_logic_unsigned.all;

use	work.isa_const.all;
use	work.nono_const.all;


entity conserv is
    port (
	clk : in std_logic;
	rst : in std_logic;
	data_in : in T_DATA;
	data_out : out T_DATA
    );
end entity;

architecture RTL of conserv is
    
    -- Signal interne
    -- registres � d�calage pour compter 2 cycles.
    signal cycle0 : std_logic_vector (1 downto 0);
--    signal reg_dec 1 : std_logic_vector (2 downto 0);
--    signal reg_dec 2 : std_logic_vector (2 downto 0);
--    signal reg_dec 3 : std_logic_vector (2 downto 0);
--    signal reg_dec 4 : std_logic_vector (2 downto 0);
--    signal reg_dec 5 : std_logic_vector (2 downto 0);
--    signal reg_dec 6 : std_logic_vector (2 downto 0);
--    signal reg_dec 7 : std_logic_vector (2 downto 0);

begin
    -- process s�quentiel
    process (rst, clk)
    begin
	if (rst = '1') then
	    data_out <= x"00";
	    cycle0 <= "00";

	-- TODO : Ne peut-on pas faire en concurentiel ? L�, ne vat-il pas y
	-- avoir un retard entre data_out(0) et data_out(7) si on les met en
	-- s�quentiel ?
	elsif (clk'event and clk = '1') then
	    -- Remise � z�ro.
	    if (cycle0 = "10") then 
		cycle0 <= "00";
		data_out(0) <= '0';
	    end if;
	    --
	    if (data_in(0) /= '0' or cycle0 = "01") then
		cycle0 <= cycle0 + "01"; -- TODO : v�rifier que valable.
		data_out(0) <= '1';
	    end if;
	
	end if;
    end process;

    -- process combinatoire.

end RTL;