Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 4.86 KB | None | 0 0
  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.ALL;
  3. USE ieee.numeric_std.ALL;
  4.  
  5. ENTITY LogicalStep_Lab4_top IS PORT
  6.     (
  7.    clkin_50     : in    std_logic;
  8.     rst_n           : in    std_logic;
  9.     pb              : in    std_logic_vector(3 downto 0);
  10.     sw              : in  std_logic_vector(7 downto 0); -- The switch inputs
  11.    leds         : out std_logic_vector(7 downto 0); -- for displaying the switch content
  12.    seg7_data    : out std_logic_vector(6 downto 0); -- 7-bit outputs to a 7-segment
  13.     seg7_char1  : out   std_logic;                          -- seg7 digi selectors
  14.     seg7_char2  : out   std_logic                           -- seg7 digi selectors
  15.     );
  16. END LogicalStep_Lab4_top;
  17.  
  18.  
  19.  
  20. ARCHITECTURE SimpleCircuit OF LogicalStep_Lab4_top IS
  21.    
  22. ----------------------------------------------------------------------------------------------------
  23.     CONSTANT    SIM                         :  boolean := TRUE;     -- set to TRUE for simulation runs otherwise keep at 0.
  24.    CONSTANT CLK_DIV_SIZE                :   INTEGER := 26;    -- size of vectors for the counters
  25.  
  26.    SIGNAL   Main_CLK                        :  STD_LOGIC;           -- main clock to drive sequencing of State Machine
  27.  
  28.     SIGNAL  bin_counter                 :  UNSIGNED(CLK_DIV_SIZE-1 downto 0); -- := to_unsigned(0,CLK_DIV_SIZE); -- reset binary counter to zero
  29.    
  30. ----------------------------------------------------------------------------------------------------
  31.  
  32. component U_D_Bin_Counter8bit port(
  33.     CLK             : in std_logic := '0';
  34.         RESET_n         : in std_logic := '0';
  35.         CLK_EN          : in std_logic := '0';
  36.         UP1_DOWN0       : in std_logic := '0';
  37.         COUNTER_BITS    : out std_logic_vector(7 downto 0)
  38. );
  39. end component;
  40.  
  41. component Bidir_shift_reg port(
  42.     CLK             : in std_logic := '0';
  43.     RESET_n         : in std_logic := '0';
  44.     CLK_EN          : in std_logic := '0';
  45.     LEFT0_RIGHT1: in std_logic := '0';
  46.     REG_BITS    : out std_logic_vector(7 downto 0)
  47. );
  48. end component;
  49.  
  50. component SevenSegment port (
  51.    hex      :  in  std_logic_vector(3 downto 0);   -- The 4 bit data to be displayed
  52.    sevenseg     :  out std_logic_vector(6 downto 0)    -- 7-bit outputs to a 7-segment
  53. );
  54. end component;
  55.  
  56. component segment7_mux port (
  57.    clk          : in  std_logic := '0';
  58.     DIN2            : in  std_logic_vector(6 downto 0);
  59.     DIN1            : in  std_logic_vector(6 downto 0);
  60.     DOUT            : out   std_logic_vector(6 downto 0);
  61.     DIG2            : out   std_logic;
  62.     DIG1            : out   std_logic
  63. );
  64. end component;
  65.  
  66. component Compx4 port(
  67.     CURRENT             : in std_logic_vector(3 downto 0); --MUST RENAME
  68.     DESIRED             : in std_logic_vector(7 downto 4);
  69.     FURNACE_ON          : out std_logic;
  70.     AT_TEMP             : out std_logic;
  71.     AC_ON                   : out std_logic
  72. );
  73. end component;
  74.  
  75. component mux port(
  76.     CURRENT_X    : in std_logic_vector (3 downto 0);
  77.    TARGET_X   : in std_logic_vector (3 downto 0);
  78.    PB         : in std_logic;
  79.    OUT1       : out std_logic_vector (3 downto 0)
  80. );
  81. end component;
  82.  
  83.     -- input signals
  84.     signal target_x     : std_logic_vector(7 downto 4);
  85.     signal target_y     : std_logic_vector(3 downto 0);
  86.     signal x_drive_en       : std_logic;
  87.     signal y_drive_en       : std_logic;
  88.     signal ext_toggle       : std_logic;
  89.     signal grap_toggle  : std_logic;
  90.    
  91.     --output signals
  92.     signal digit_1          : std_logic;
  93.     signal digit_2          : std_logic;
  94.     signal ext_pos          : std_logic_vector(7 downto 4);
  95.     signal grappler_on  : std_logic;
  96.     signal TBD              : std_logic_vector(2 downto 1); --manual says "for your use", unsure as to what that means right now
  97.     signal error            : std_logic;
  98.     signal x_display        : std_logic; -- these are the two output signals from the mux
  99.     signal y_display        : std_logic; -- to be displayed on seven seg display
  100.    
  101.    
  102. BEGIN
  103.  
  104.     -- input signals
  105.     target_x        <= sw(7 downto 4);
  106.     target_y        <= sw(3 downto 0);
  107.     x_drive_en  <= pb(3);
  108.     y_drive_en  <= pb(2);
  109.     ext_toggle  <= pb(1);
  110.     grap_toggle <= pb(0);
  111.    
  112.     --output signals
  113.     seg7_char1          <= digit_1;
  114.     seg7_char2          <= digit_2;
  115.     leds(7 downto 4)    <= ext_pos;        
  116.     leds(3)                 <= grappler_on;
  117.     leds(2 downto 1)    <= TBD;            
  118.     leds(0)                 <= error;
  119.  
  120.     --X_VAL_MUX: mux( );  
  121. --  --Y_VAL_MUX: mux( );
  122. --  CURRENT             : std_logic_vector(3 downto 0); --MUST RENAME
  123. --  DESIRED             : std_logic_vector(7 downto 4);
  124. --  FURNACE_ON          : std_logic;
  125. --  AT_TEMP             : std_logic;
  126. --  AC_ON                   : std_logic;
  127.    
  128.    
  129.    
  130.     -- FIGURE OUT CONNECTIONS   SHIFT_REGISTER:
  131.  
  132.  
  133.    
  134. -- CLOCKING GENERATOR WHICH DIVIDES THE INPUT CLOCK DOWN TO A LOWER FREQUENCY
  135.  
  136. BinCLK: PROCESS(clkin_50, rst_n) is
  137.    BEGIN
  138.         IF (rising_edge(clkin_50)) THEN -- binary counter increments on rising clock edge
  139.          bin_counter <= bin_counter + 1;
  140.       END IF;
  141.    END PROCESS;
  142.  
  143. Clock_Source:
  144.                 Main_Clk <=
  145.                 --clkin_50 when sim = TRUE else             -- for simulations only
  146.                 std_logic(bin_counter(23));                             -- for real FPGA operation
  147.                    
  148. ---------------------------------------------------------------------------------------------------
  149.  
  150. --  COUNTER:    U_D_Bin_Counter8bit port map();
  151. --  COMPX4 :    Compx4 port map();
  152. --  --MEALY_SM:     Mealy_SM port map(clkin_50, rst_n, x_drive_en,  );
  153. --  SEVEN_SEG:  SevenSegment port map();
  154.  
  155. END SimpleCircuit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement