Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.NUMERIC_STD.ALL;
  4.  
  5. entity reg is
  6. generic (
  7. capacity : natural := 4;
  8. write_delay : time := 0 ns;
  9. z_delay : time := 0 ns;
  10. x_delay : time := 0 ns);
  11.  
  12. port ( D : in std_logic_vector (capacity-1 downto 0);
  13. C : in std_logic;
  14. E : in std_logic;
  15. Q : out std_logic_vector (capacity-1 downto 0));
  16. end reg;
  17.  
  18. architecture behavioral of reg is
  19. signal tmp: std_logic_vector (capacity-1 downto 0) ;
  20. begin
  21.  
  22. z: process (E, tmp)
  23. begin
  24.  
  25. if E = '1' then
  26. Q <= (others => 'Z') after z_delay;
  27.  
  28. elsif E = '0' then
  29. Q <= tmp after z_delay;
  30.  
  31. else
  32. Q <= (others => 'X') after z_delay;
  33.  
  34. end if;
  35.  
  36. end process z;
  37.  
  38.  
  39. r: process (C, D)
  40.  
  41. begin
  42.  
  43. if C = '0' then
  44. tmp <= D after write_delay;
  45.  
  46. elsif C /= '1' then
  47. tmp <= (others => 'X') after x_delay;
  48.  
  49. end if;
  50.  
  51. end process r;
  52.  
  53. end behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement