Convertidor ADC de doble pendiente VHDL

0

Hola, estoy tratando de escribir un código para ADC de doble pendiente. Y no estoy seguro de si mi lógica es incorrecta o si hay algo más que no funciona.

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.NUMERIC_STD.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY lab7 IS
    PORT(GTZ    : IN  STD_LOGIC;
         clck   : IN  STD_LOGIC;
         Cone   : OUT STD_LOGIC;
         Ctwo   : OUT STD_LOGIC;
         Cthree : OUT STD_LOGIC;
         LED    : OUT std_logic_vector(7 DOWNTO 0));
END lab7;

ARCHITECTURE AD_converter OF lab7 IS

    SIGNAL first_time   : integer               := 0;
    SIGNAL counter      : integer RANGE 0 TO 31 := 0;
    SIGNAL counter_two  : integer RANGE 0 TO 33 := 0;
    SIGNAL intermediate : std_logic_vector(4 DOWNTO 0);

BEGIN
    PROCESS(clck)
    BEGIN
        IF (rising_edge(clck)) THEN
            now_if_1 : IF (first_time = 0) THEN
                now_while_1 : IF (counter < 31) THEN
                    Cthree  <= '1';
                    counter <= counter + 1;
                ELSE
                    first_time <= 1;
                    counter    <= 0;
                    Cthree     <= '0';
                END IF now_while_1;
            ELSE

                counter_if : IF (counter < 31) THEN
                    Cone <= '0';
                    Ctwo <= '1';
                    Cthree <= '0';
                    counter <= counter + 1;
                ELSE
                    counter <= 0;
                    Cone <= '1';
                    Ctwo <= '0';
                    Cthree <= '0';
                    IF (GTZ = '1') THEN
                        counter_two <= counter_two + 1;
                    ELSE
                        IF (counter < 1001) THEN
                            Cone <= '0';
                            Ctwo <= '0';
                            Cthree <= '1';

                            intermediate <= std_logic_vector(to_unsigned(counter_two, intermediate'length));

                            counter_two <= 0;

                            first_time <= 0;
                            CASE intermediate IS
                                WHEN "00000" =>
                                    LED <= "01111110";
                                WHEN "00001" =>
                                    LED <= "00100100";
                                WHEN "00010" =>
                                    LED <= "01111001";
                                WHEN "00011" =>
                                    LED <= "01101101";
                                WHEN "00100" =>
                                    LED <= "00100111";
                                WHEN "00101" =>
                                    LED <= "01001111";
                                WHEN "00110" =>
                                    LED <= "01011111";
                                WHEN "00111" =>
                                    LED <= "01100100";
                                WHEN "01000" =>
                                    LED <= "01111111";
                                WHEN "01001" =>
                                    LED <= "01101111";
                                WHEN "01010" =>
                                    LED <= "01110111";
                                WHEN "01011" =>
                                    LED <= "00011111";
                                WHEN "01100" =>
                                    LED <= "01011010"; -- c
                                WHEN "01101" =>
                                    LED <= "00111101";
                                WHEN "01110" =>
                                    LED <= "01111011";
                                WHEN "01111" =>
                                    LED <= "01010011";

                                WHEN "10000" =>
                                    LED <= "11111110";
                                WHEN "10001" =>
                                    LED <= "10100100";
                                WHEN "10010" =>
                                    LED <= "11111001";
                                WHEN "10011" =>
                                    LED <= "11101101";
                                WHEN "10100" =>
                                    LED <= "10100111";
                                WHEN "10101" =>
                                    LED <= "11001111";
                                WHEN "10110" =>
                                    LED <= "11011111";
                                WHEN "10111" =>
                                    LED <= "11100100";
                                WHEN "11000" =>
                                    LED <= "11111111";
                                WHEN "11001" =>
                                    LED <= "11101111";
                                WHEN "11010" =>
                                    LED <= "11110111";
                                WHEN "11011" =>
                                    LED <= "10011111";
                                WHEN "11100" =>
                                    LED <= "11011010"; -- c
                                WHEN "11101" =>
                                    LED <= "10111101";
                                WHEN "11110" =>
                                    LED <= "11111011";
                                WHEN "11111" =>
                                    LED <= "11010011";
                                WHEN OTHERS =>
                                    LED <= "11111111";
                            END CASE;
                            counter    <= counter + 1;
                        ELSE
                            counter <= 0;
                        END IF;
                    END IF;
                END IF counter_if;
            END IF now_if_1;
        END IF;
    END PROCESS;
END AD_converter;

Cthree es básicamente un interruptor de reinicio en el segundo comparador. Cono es el interruptor para conectar el circuito a la tensión de referencia y C2 es el interruptor para conectarse a la entrada analógica. ¿Alguien puede avisarme si hay algún error en la lógica para implementarlo?

    

0 respuestas

Lea otras preguntas en las etiquetas