Guest User

Untitled

a guest
Apr 4th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. entity BReg is
  2. port (
  3. clk : in std_logic;
  4. reset : in std_logic;
  5. RA : in std_logic_vector (4 downto 0);
  6. RB : in std_logic_vector (4 downto 0);
  7. RW : in std_logic_vector (4 downto 0);
  8. BusW : in std_logic_vector (31 downto 0)
  9. BusW2 : in std_logic_vector (31 downto 0);
  10. RegWrite : in std_logic;
  11. BusA : out std_logic_vector (31 downto 0);
  12. BusB : out std_logic_vector (31 downto 0)
  13. );
  14. end BReg;
  15.  
  16. architecture Behavioral of BReg is
  17. type reg_array is array (0 to 31) of std_logic_vector(31 downto 0);
  18. signal reg_file : reg_array;
  19.  
  20. begin
  21. process(clk)
  22. begin
  23. if (clk'event and clk='0') then
  24. if reset='1' then
  25. for i in 0 to 31 loop
  26. reg_file(i) <= "00000000000000000000000000000000";
  27. end loop;
  28. else
  29. if RegWrite = '1' then
  30. reg_file(conv_integer(RW)) <= BusW;
  31. end if;
  32. end if;
  33. end if;
  34. end process;
  35.  
  36. --get data stored at register RA
  37. BusA <= reg_file(conv_integer(RA));
  38. --get data stored at register RB
  39. BusB <= reg_file(conv_integer(RB));
  40.  
  41.  
  42. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment