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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
| library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity VHDL_2 is --file
Port (
--LEDR1 : in bit_vector (0 to 13) ;
OSC_SMA_ADC4 : in std_logic; --
CLOCK_50 : in std_logic; --
ADC_DA : in bit_vector (0 to 13) ;
DAC_DA : out bit_vector (0 to 13) ;
ADC_DB : in bit_vector (0 to 13) ;
DAC_DB : out bit_vector (0 to 13) ;
--GPIOa : out bit_vector (0 to 13) ;
GPIOb : out bit_vector (0 to 4) ;
LEDR : out bit_vector (0 to 13) ;
DAC_WRT_A : out std_logic; --dac
DAC_WRT_B : out std_logic;
GPIOa_2 : out std_logic;
GPIOa_1 : out std_logic;
GPIOa_4 : out bit_vector(0 to 7);
SMA_CLKIN : in std_logic;
SMA_CLKOUT : out std_logic);
end VHDL_2;
architecture Behavioral of VHDL_2 is
--type state_type is (idle, read, func, write);
--signal state : state_type := read;
signal cnt : integer range 0 to 14 := 0;
signal clkdiv : integer range 0 to 10 := 0;
signal risingedge : std_logic := '1';
signal reset : std_logic := '0';
--signal LEDR1 : bit_vector := '14';
signal LEDRt : bit_vector (0 to 13) ;
--signal GPIOa[2] : std_logic value := 0;
--signal GPIOa[1] : std_logic value := 0;
--signal GPIOa[4] : std_logic_vector value := "11010101";
--VARIABLE a : integer := 0;
CONSTANT st0 : std_logic_vector(0 TO 3) := "0000";
CONSTANT st1 : std_logic_vector(0 TO 3) := "0001";
CONSTANT st2 : std_logic_vector(0 TO 3) := "0010";
CONSTANT st3 : std_logic_vector(0 TO 3) := "0011";
CONSTANT st4 : std_logic_vector(0 TO 3) := "0100";
CONSTANT st5 : std_logic_vector(0 TO 3) := "0101";
CONSTANT st6 : std_logic_vector(0 TO 3) := "0110";
--CONSTANT st7 : std_logic_vector(0 TO 3) := "0111";
--SIGNAL state : std_logic_vector(0 TO 3) := "0111";
--SIGNAL state : bit_vector (0 to 3) ;
SIGNAL state : std_logic_vector (0 to 3) := "0000";
begin
--drive the adc and dac clock pins
SMA_CLKOUT <= SMA_CLKIN;
DAC_WRT_A <= SMA_CLKIN; --Input write signal for PORT A
DAC_WRT_B <= SMA_CLKIN; --Input write signal for PORT B
--OSC_SMA_ADC4
state <= st0;
main : process (SMA_CLKIN, reset)
begin
--loop1: FOR a IN 0 TO 6 LOOP -- la variable de boucle est a de 0 à 6
if rising_edge(SMA_CLKIN) then
DAC_DA <= ADC_DA;
DAC_DB <= ADC_DB;
case state is
when St0 => if state<=St0 then
GPIOa_2 <= '0';
state <= St1;
end if;
when St1 => if state<=St1 then
GPIOa_1 <= '1';
state <= St2;
end if;
when St2 => if state<=St2 then
GPIOa_4 <= "11010101";
state <= St3;
end if;
when St3 => if state<=St3 then
GPIOa_1 <= '0';
state <= St4;
end if;
when St4 => if state<=St4 then
GPIOa_2 <= '1';
state <= St5;
end if;
when St5 => if state<=St5 then
GPIOa_2 <= '0';
state <= St6;
end if;
when St6 => if state<=St6 then
GPIOb <= ADC_DB;
state <= St0;
end if;
end case;
elsif state = St0 then
LEDRt <= LEDRt;
end if;
--END LOOP loop1;
--end if;
end process main;
end Behavioral; |
Partager