Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 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 := FALSE; -- 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.  
  33. component U_D_Bin_Counter8bit port(
  34. CLK : in std_logic := '0';
  35. RESET_n : in std_logic := '0';
  36. CLK_EN : in std_logic := '0';
  37. UP1_DOWN0 : in std_logic := '0';
  38. COUNTER_BITS : out std_logic_vector(7 downto 0)
  39. );
  40. end component;
  41.  
  42. component Bidir_shift_reg port(
  43. CLK : in std_logic := '0';
  44. RESET_n : in std_logic := '0';
  45. CLK_EN : in std_logic := '0';
  46. LEFT0_RIGHT1 : in std_logic := '0';
  47. REG_BITS : out std_logic_vector(3 downto 0)
  48. );
  49. end component;
  50.  
  51. component MOORE_SM1 port(
  52. CLK : in std_logic := '0';
  53. RESET_n : in std_logic := '0';
  54. EXT_BUTTON : in std_logic := '0';
  55. EXT_ENBL : in std_logic := '0';
  56.  
  57. CLK_EN : out std_logic;
  58. LEFT_RIGHT : out std_logic;
  59. GRAP_ENBL : out std_logic;
  60. EXTENDER_OUT : out std_logic
  61. );
  62. end component;
  63.  
  64. component MOORE_SM2 port(
  65. CLK : in std_logic := '0';
  66. RESET_n : in std_logic := '0';
  67. GRAP_BUTTON : in std_logic := '0';
  68. GRAP_ENBL : in std_logic := '0';
  69. GRAP_ON : out std_logic
  70. );
  71. end component;
  72.  
  73. component Mealy_SM port(
  74. clk_input, rst_n, x_motion, x_LT, x_ET, x_GT, ext_out : IN std_logic;
  75. clk_en, UD_en, ext_en, error : OUT std_logic
  76. );
  77. end component;
  78.  
  79. component mux port(
  80. AL_1: in std_logic_vector (3 downto 0);
  81. CURRENT_X : in std_logic_vector (3 downto 0);
  82. TARGET_X : in std_logic_vector (3 downto 0);
  83. PB : in std_logic;
  84. OUT1 : out std_logic_vector (3 downto 0)
  85. );
  86. end component;
  87.  
  88.  
  89.  
  90. signal x_TARGET : std_logic_vector(7 downto 4);
  91. signal Y_TARGET : std_logic_vector(3 downto 0);
  92. signal EXT_BUT : std_logic; --EXTENDER TOGGLE
  93. signal GRAP_BUT : std_logic; --GRAPPLER TOGGLE
  94. signal EXT_ENBL : std_logic;
  95. signal GRAP_ENBL : std_logic;
  96.  
  97.  
  98. signal EXT_LED : std_logic_vector(7 downto 4); -- e
  99. signal GRAP_LED : std_logic;
  100. signal grappler_on : std_logic;
  101. -- signal own_use : std_logic_vector(2 downto 1);
  102. signal DIGIT1 : std_logic;
  103. signal DIGIT2 : std_logic;
  104.  
  105. -- for Moore_SM
  106. signal LR : std_logic;
  107. signal EXT_OUT : std_logic;
  108. signal GRAP_ON : std_logic;
  109.  
  110. signal CLK_EN : std_logic;
  111.  
  112.  
  113. BEGIN
  114.  
  115. -- input signals
  116. X_TARGET <= sw(7 downto 4);
  117. Y_TARGET <= sw(3 downto 0);
  118. EXT_BUT <= pb(1); -- CLK_EN
  119. GRAP_BUT <= pb(0); -- Left0_Right1 / Up1_Down0
  120.  
  121. EXT_ENBL <= '1';
  122. EXT_OUT <= '0';
  123.  
  124. --output signals
  125. seg7_char1 <= DIGIT1;
  126. seg7_char2 <= DIGIT2;
  127.  
  128. leds(7 downto 4) <= EXT_LED;
  129. leds(3) <= GRAP_LED;
  130.  
  131.  
  132. MOORE_EXTEND: Moore_SM1 port map(Main_CLK, rst_n, EXT_BUT, EXT_ENBL, CLK_EN, LR, GRAP_ENBL, EXT_OUT);
  133. MOORE_RETRACT: Moore_SM2 port map(Main_CLK, rst_n, GRAP_BUT, GRAP_ENBL, GRAP_LED);
  134. BIT_SHIFT: Bidir_shift_reg port map(Main_CLK, rst_n, CLK_EN, LR, EXT_LED);
  135.  
  136. --SEVEN_SEGMENT_1: SevenSegment port map(hex_A, seg7_A); -- X_TARGET
  137. --SEVEN_SEGMENT_2: SevenSegment port map(hex_B, seg7_B); -- Y_TARGET
  138. --SEVEN_SEGMENT_MUX: segment7_mux port map(clkin_50, seg7_A, seg7_B, seg7_data, seg7_char2, seg7_char1);
  139.  
  140. --INST1: Bidir_shift_reg port map(clkin_50, rst_n, ext_toggle, grap_toggle, temp); -- TBD needs to be replaced -- clkin_50 replace w Main_CLK ???
  141. --INST1: U_D_Bin_Counter8bit port map(clkin_50, rst_n, ext_toggle, grap_toggle, temp); ---------------------------
  142.  
  143. --MEALY1: Mealy_SM port map(Main_CLK, rst_n, ); -- x MOTION
  144. --MEALY2: Mealy_SM port map(Main_CLK, rst_n, ); -- Y MOTION
  145.  
  146.  
  147.  
  148. -- CLOCKING GENERATOR WHICH DIVIDES THE INPUT CLOCK DOWN TO A LOWER FREQUENCY
  149.  
  150. BinCLK: PROCESS(clkin_50, rst_n) is
  151. BEGIN
  152. IF (rising_edge(clkin_50)) THEN -- binary counter increments on rising clock edge
  153. bin_counter <= bin_counter + 1;
  154. END IF;
  155. END PROCESS;
  156.  
  157. Clock_Source:
  158. Main_Clk <=
  159. clkin_50 when sim = TRUE else -- for simulations only
  160. std_logic(bin_counter(23)); -- for real FPGA operation
  161.  
  162. ---------------------------------------------------------------------------------------------------
  163.  
  164. END SimpleCircuit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement