Guest User

Untitled

a guest
Nov 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. clk_a : in std_logic;
  2. clk_b : in std_logic;
  3. reset : in std_logic;
  4.  
  5. -- cross-domain counter
  6. signal frm_cnt : standard_logic_vector(7 downto 0);
  7. -- control signal: increment counter (synced to clk_a)
  8. signal frm_cnt_inc : std_logic;
  9. -- control signal: decrement counter (synced to clk_b)
  10. signal frm_cnt_dec : std_logic;
  11. -- control signal, perform action on the counter
  12. signal frm_cnt_modif : std_logic;
  13.  
  14. frm_cnt_modif <= frm_cnt_inc or frm_cnt_dec; -- can also be xored
  15.  
  16. frame_counter : process(frm_cnt_modif, reset)
  17. begin
  18. if reset = RST_ACTIVE then
  19. frm_cnt <= (others => '0');
  20. elsif rising_edge(frm_cnt_modif) then
  21. if frm_cnt_inc = '1' then
  22. frm_cnt <= incr_vec(frm_cnt);
  23. elsif frm_cnt_dec = '1' then
  24. frm_cnt <= decr_vec(frm_cnt);
  25. end if;
  26. end if;
  27. end process;
  28.  
  29. control_synchronizer : process(clk_b, reset)
  30. begin
  31. if reset = RST_ACTIVE then
  32. frm_cnt_inc_sync <= '0';
  33. elsif rising_edge(clk_b) then
  34. if frm_cnt_inc_sync = '1' then
  35. frm_cnt_inc_sync <= '0';
  36. elsif frm_cnt_inc = '1' then
  37. frm_cnt_inc_sync <= '1';
  38. else
  39. frm_cnt_inc_sync <= '0';
  40. end if;
  41. end if;
  42. end process;
Add Comment
Please, Sign In to add comment