Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 25.03.2019 18:44:12
  6. -- Design Name:
  7. -- Module Name: IF - 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.  
  21.  
  22. library IEEE;
  23. use IEEE.STD_LOGIC_1164.ALL;
  24. use IEEE.STD_LOGIC_ARITH.ALL;
  25. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  26.  
  27. -- Uncomment the following library declaration if using
  28. -- arithmetic functions with Signed or Unsigned values
  29. --use IEEE.NUMERIC_STD.ALL;
  30.  
  31. -- Uncomment the following library declaration if instantiating
  32. -- any Xilinx leaf cells in this code.
  33. --library UNISIM;
  34. --use UNISIM.VComponents.all;
  35.  
  36. entity ifSchema is
  37. Port(SRST : in STD_LOGIC;
  38. CLK : in STD_LOGIC;
  39. en : in STD_LOGIC;
  40. bAddr : in STD_LOGIC_VECTOR(15 downto 0);
  41. pcSRC : in STD_LOGIC;
  42. jAddr : in STD_LOGIC_VECTOR(15 downto 0);
  43. jump : in STD_LOGIC;
  44. instruction : out STD_LOGIC_VECTOR(15 downto 0);
  45. nextPc : out STD_LOGIC_VECTOR(15 downto 0));
  46. end ifSchema;
  47.  
  48. architecture Behavioral of ifSchema is
  49. type rom_array is array(0 to 15) of STD_LOGIC_VECTOR(15 downto 0);
  50. signal rom : rom_array := (
  51. B"000_000_000_001_0_001", --0011 add $1, $0, $0
  52. B"001_000_100_0000111", --2207 addi $4, $0, 7
  53. B"000_000_000_010_0_001", --0021 $2, $0, $0
  54. B"000_000_000_101_0_001", --0051 $5, $0, $0
  55. B"100_001_100_0001011", --860B $1, $4, 11
  56. B"000_111_111_111_0_000", -- 1FF0 xor $7, $7, $7
  57. B"010_010_011_0000000", --4980 lw $3, 0($2)
  58. B"001_000_111_0000001", --2381 addi $7, $0, 1
  59. B"000_011_111_111_0_000", --0FF0 xor $7, $3, $7
  60. B"000_111_011_111_0_111", --1DF7 slt $7, $7, $3
  61. B"110_111_000_0000010", --DC0D bgtz $7, 2
  62. B"000_101_011_101_0_001", --15D1 add $5, $5, $3
  63. B"001_010_010_0000001", --2901 addi $2, $2, 1
  64. B"001_001_001_0000001", --2481 addi $1, $1, 1
  65. B"101_0000000000100", --A004 j 4
  66. B"011_101_000_0001010", --740A sw $5, 10($0)
  67. others => x"9999");
  68.  
  69. signal regOut : STD_LOGIC_VECTOR(15 downto 0);
  70. signal muxOut : STD_LOGIC_VECTOR(15 downto 0);
  71. signal regOut_1 : STD_LOGIC_VECTOR(15 downto 0);
  72. signal muxOut2 : STD_LOGIC_VECTOR(15 downto 0);
  73.  
  74. begin
  75.  
  76. process(clk)
  77. begin
  78. if rising_edge(clk) then
  79. if SRST = '1' then
  80. regOut <= x"0000";
  81. elsif en ='1' then
  82. regOut <= muxOut;
  83. end if;
  84. end if;
  85. end process;
  86.  
  87. regOut_1 <= regOut + 1;
  88.  
  89. nextPc <= regOut_1;
  90.  
  91. instruction <= rom(CONV_INTEGER(regOut(3 downto 0)));
  92.  
  93. process(pcSRC)
  94. begin
  95. case pcSRC is
  96. when '0' => muxOut2 <= regOut_1;
  97. when '1' => muxOut2 <= bAddr;
  98. end case;
  99. end process;
  100.  
  101. process(jump)
  102. begin
  103. case jump is
  104. when '0' => muxOut <= muxOut2;
  105. when '1' => muxOut <= jAddr;
  106. end case;
  107. end process;
  108.  
  109. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement