Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.93 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. USE ieee.std_logic_arith.all;
  4.  
  5. entity reltr is
  6.     Port (clk : in std_logic;
  7.         din : in std_logic_vector(3 downto 0);
  8.         dout : out std_logic_vector(3 downto 0));
  9. end reltr;
  10.  
  11.  
  12. architecture Behavioral of reltr is
  13.  
  14. signal add : integer := 0;
  15. signal dv : std_logic := '1';
  16. signal sdout : std_logic_vector(3 downto 0) := (others => '0');
  17. type memory1 is array (0 to 3) of integer;
  18. signal table : memory1 :=
  19.     (0 => 3,
  20.     1 => 2,
  21.     2 => 1,
  22.     3 => 0);
  23.  
  24. begin
  25.  
  26. process(clk) begin
  27.     if rising_edge(clk) then
  28.         if add < 3 then
  29.             add <= add + 1;
  30.         else
  31.             add <= 0;
  32.             dv <= '0';
  33.         end if;
  34.     end if;
  35. end process;
  36.  
  37. process(clk) begin
  38.     if rising_edge(clk) then
  39.         if dv = '1' then
  40.             sdout(add) <= din(table(add));
  41.         end if;
  42.     end if;
  43. end process;
  44.  
  45. dout <= sdout;
  46.  
  47. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement