Device-Cheat

Untitled

Jun 23rd, 2020
2,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.25 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.STD_LOGIC_ARITH.ALL;
  4. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  5.  
  6. entity adc5bit is
  7.     Port ( enable : in STD_LOGIC;
  8.         comp : in STD_LOGIC;
  9.         clock : in STD_LOGIC;
  10.         reset : in STD_LOGIC;
  11.         sA : out STD_LOGIC;
  12.         sB : out STD_LOGIC;
  13.         s1 : out STD_LOGIC;
  14.         s2 : out STD_LOGIC;
  15.         s3 : out STD_LOGIC;
  16.         s4 : out STD_LOGIC;
  17.         s5 : out STD_LOGIC;
  18.         s6 : out STD_LOGIC;
  19.         eoc : out STD_LOGIC;
  20.         sh : out STD_LOGIC);
  21. end adc5bit;
  22.  
  23. architecture Behavioral of adc5bit is
  24.     type statetype is (state0, state1, state2, state3, state4, state5, state6);
  25.     signal state : statetype;
  26.     begin
  27.         process (clock,reset,enable)
  28.     begin
  29.         if reset = '1' then
  30.             state <= state0;
  31.             sA <= '1';
  32.             sB <= '1';
  33.             s1 <= '1';
  34.             s2 <= '1';
  35.             s3 <= '1';
  36.             s4 <= '1';
  37.             s5 <= '1';
  38.             s6 <= '1';
  39.             sh <= '0';
  40.             eoc <= '0';
  41.         elsif (clock'event and clock='1' and enable='1') then
  42.             case state is
  43.             when state0 => state <= state1;
  44.                 sA <= '1';
  45.                 sB <= '1';
  46.                 s1 <= '1';
  47.                 s2 <= '1';
  48.                 s3 <= '1';
  49.                 s4 <= '1';
  50.                 s5 <= '1';
  51.                 s6 <= '1';
  52.                 sh <= '1';
  53.                 eoc <= '0';
  54.             when state1 => state <= state2;
  55.                 sA <= '0';
  56.                 sB <= '0';
  57.                 s1 <= '1';
  58.                 s2 <= '0';
  59.                 s3 <= '0';
  60.                 s4 <= '0';
  61.                 s5 <= '0';
  62.                 s6 <= '0';
  63.                 sh <= '0';
  64.             when state2 => state <= state3;
  65.                 if comp='1' then
  66.                     s1 <='0';
  67.                     s2 <='1';
  68.                 elsif comp='0' then
  69.                     s2 <='1';
  70.                 end if;
  71.             when state3 => state <= state4;
  72.                 if comp='1' then
  73.                     s2 <='0';
  74.                     s3 <='1';
  75.                 elsif comp='0' then
  76.                     s3 <='1';
  77.                 end if;
  78.             when state4 => state <= state5;
  79.                 if comp='1' then
  80.                     s3 <='0';
  81.                     s4 <='1';
  82.                 elsif comp='0' then
  83.                     s4 <='1';
  84.                 end if;
  85.             when state5 => state <= state6;
  86.                 if comp='1' then
  87.                     s4 <='0';
  88.                     s5 <='1';
  89.                 elsif comp='0' then
  90.                     s5 <='1';
  91.                 end if;
  92.             when state6 => state <= state0;
  93.                 if comp='1' then
  94.                     s5 <='0';
  95.                 elsif comp='0' then
  96.                     s5 <='1';
  97.                 end if;
  98.                     eoc <= '1';
  99.             end case;
  100.         end if;
  101.             if enable = '0' then
  102.                 sA <= '1';
  103.                 sB <= '1';
  104.                 s1 <= '1';
  105.                 s2 <= '1';
  106.                 s3 <= '1';
  107.                 s4 <= '1';
  108.                 s5 <= '1';
  109.                 s6 <= '1';
  110.                 sh <= '0';
  111.                 eoc <= '0';
  112.             end if;
  113.         end process;
  114. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment