Advertisement
milanmetal

SEM_SEQUENCE_GEN

Jul 18th, 2019
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 4.58 KB | None | 0 0
  1. --------------------------------------------------------------------------------
  2. -- File : sem_driver.vhd
  3. -- Project : ASCP -- Autonomous Semaphore Control Module
  4. -- Creation : 18.7.2019
  5. -- Limitations : none
  6. -- Errors : none known
  7. -- Simulator :
  8. -- Synthesizer :
  9. -- Platform : CentOS7
  10. -- Targets : Simulation, Synthesis, Implementation
  11. ---------------------------------------
  12. -- Authors : Milan Nedic (minedic)
  13. -- Organization : ELSYS Eastern Europe
  14. -- Address : Omladinskih brigada 88b, Belgrade, Serbia/Europe
  15. --------------------------------------------------------------------------------
  16. -- Copyright Notice
  17. -- This work is licensed under the General Public License (GPL).
  18. --------------------------------------------------------------------------------
  19. -- Function description
  20. -- This module performs generation of select signals for interval counter's
  21. -- input interval routing based on a semaphore phase.
  22. --------------------------------------------------------------------------------
  23. -- Revision History
  24. -- Date        Author     Comments
  25. -- 18.7.2019   minedic    Created
  26. --------------------------------------------------------------------------------
  27. library ieee;
  28. use ieee.std_logic_1164.all;
  29. use ieee.numeric_std.all;
  30.  
  31. entity sem_sequence_gen is
  32.   generic (
  33.     SEQ_CNTR_WIDTH : integer := 2
  34.     );
  35.   port (
  36.  
  37.     ----------------------------------------------------------------
  38.     -- Clock and reset
  39.     ----------------------------------------------------------------
  40.     pi_clk   : in std_logic;
  41.     pi_rst_n : in std_logic;
  42.  
  43.     ----------------------------------------------------------------
  44.     -- Control signals
  45.     ----------------------------------------------------------------
  46.     preload_init_i  : in std_logic;
  47.     step_overflow_i : in std_logic;
  48.  
  49.     ----------------------------------------------------------------
  50.     -- Selection signals for routing in SEM_DRIVER and INTVL_COUNTER
  51.     ----------------------------------------------------------------
  52.     cnt_intvl_sel_o : out std_logic_vector(SEQ_CNTR_WIDTH-1 downto 0);
  53.     sem_phase_sel_o : out std_logic_vector(SEQ_CNTR_WIDTH-1 downto 0)
  54.     );
  55. end entity;
  56.  
  57. architecture beh of sem_sequence_gen is
  58.  
  59.   -- 2-bit counter, always 2 bit wide, generation mux select for
  60.   -- interval routing to the counter register.
  61.   signal seq_cntr_r        : std_logic_vector(SEQ_CNTR_WIDTH-1 downto 0);
  62.   signal seq_cntr_nxt      : std_logic_vector(SEQ_CNTR_WIDTH-1 downto 0);
  63.   signal routed_cntr_val_s : std_logic_vector(SEQ_CNTR_WIDTH-1 downto 0);
  64.   signal sem_phase_sel_s   : std_logic_vector(SEQ_CNTR_WIDTH-1 downto 0);
  65.   signal en_s              : std_logic;
  66. begin
  67.  
  68.   ------------------------------------------------------------------------------
  69.   -- Sequence counter, selects MUX inputs and routes selected value (01, 10, 11)
  70.   -- to the intvl_counter
  71.   ------------------------------------------------------------------------------
  72.   SEQUENCE_CNTR : process(pi_clk, pi_rst_n, preload_init_i, en_s)
  73.   begin
  74.     if(clk'event and clk = '1') then
  75.       if pi_rst_n = '0' then
  76.         seq_cntr_reg <= (others => '0');
  77.       else
  78.         if en_s = '1' then
  79.           seq_cntr_r <= seq_cntr_nxt;
  80.         end if;
  81.       end if;
  82.     end if;
  83.   end process;
  84.  
  85.   -- counter's next value
  86.   seq_cntr_nxt <= seq_cntr_r + '1';
  87.  
  88.   -- sensitive to counter's register output value.
  89.   SEQUENCE_MUX : process(seq_cntr_r)
  90.   begin
  91.     case seq_cntr_r is
  92.       when "00" => sem_phase_sel_s <= "01";
  93.       when "01" => sem_phase_sel_s <= "10";
  94.       when "10" => sem_phase_sel_s <= "11";
  95.       when "11" => sem_phase_sel_s <= "10";
  96.     end case;
  97.   end process;
  98.  
  99.   -- assign output signal with corresponding internal wire
  100.   sem_phase_sel_o <= sem_phase_sel_s;
  101.  
  102.   ROUTING_MUXES : process(preload_init_i, sem_phase_sel_s, routed_cntr_val_s,
  103.                           step_overflow_i)
  104.   begin
  105.     -- enable signal router
  106.     case preload_init_i is
  107.       when '0' => en_s <= '1';
  108.       when '1' => en_s <= step_overflow_i;
  109.     end case;
  110.  
  111.     -- 00 value router, used to select old counter register value
  112.     -- until it generates overflow decrementing earlier selected interval
  113.     case step_overflow_i is
  114.       when '0' => routed_cntr_val_s <= (others => '0');
  115.       when '1' => routed_cntr_val_s <= sem_phase_sel_s;
  116.     end case;
  117.  
  118.     -- final mux before module boundary, routes counter value to intvl_counter
  119.     case prelod_init_i is
  120.       when '0' => sem_intvl_sel_o <= "01";
  121.       when '1' => sem_intvl_sel_o <= routed_cntr_val_s;
  122.     end case;
  123.   end process;
  124. end beh;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement