No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

br.vhd 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 11:29:59 04/13/2021
  6. -- Design Name:
  7. -- Module Name: br - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  23. use IEEE.NUMERIC_STD.ALL;
  24. --use UNISIM.VComponents.all;
  25. entity br is
  26. Port ( A_addr : in STD_LOGIC_VECTOR (3 downto 0);
  27. B_addr : in STD_LOGIC_VECTOR (3 downto 0);
  28. W_addr : in STD_LOGIC_VECTOR (3 downto 0);
  29. W : in STD_LOGIC;
  30. Data : in STD_LOGIC_VECTOR (7 downto 0);
  31. RST : in STD_LOGIC;
  32. CLK : in STD_LOGIC;
  33. QA : out STD_LOGIC_VECTOR (7 downto 0);
  34. QB : out STD_LOGIC_VECTOR (7 downto 0));
  35. end br;
  36. architecture Behavioral of br is
  37. type reg is array (0 to 15) of STD_LOGIC_VECTOR(7 downto 0);
  38. signal registres: reg;
  39. begin
  40. process
  41. begin
  42. wait until rising_edge(CLK);
  43. if W = '1' then
  44. registres(to_integer(unsigned(W_addr))) <= Data;
  45. end if;
  46. if RST='0' then
  47. registres <= (others => "00000000");
  48. end if;
  49. end process;
  50. QA <= registres(to_integer(unsigned(A_addr))) when W ='0' or A_addr /= W_addr
  51. else Data;
  52. QB <= registres(to_integer(unsigned(B_addr))) when W ='0' or B_addr /= W_addr
  53. else Data;
  54. end Behavioral;