Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4.  
  5. use work.core_pack.all;
  6. use work.op_pack.all;
  7.  
  8. entity fwd is
  9. port (
  10. clk : in std_logic;
  11. reset : in std_logic;
  12. stall : in std_logic;
  13. exec_op_de : in exec_op_type; --output of decode, contains rs and rt
  14. rd_em : in std_logic_vector(REG_BITS-1 downto 0); --output of execute
  15. wb_op_em : in wb_op_type; --contains regwrite
  16. rd_mw : in std_logic_vector(REG_BITS-1 downto 0); --output of execute
  17. wb_op_mw : in wb_op_type; --contains regwrite
  18. mem_aluresult_in : in std_logic_vector(DATA_WIDTH-1 downto 0);
  19. wb_result_in : in std_logic_vector(DATA_WIDTH-1 downto 0);
  20. mem_aluresult_out : out std_logic_vector(DATA_WIDTH-1 downto 0);
  21. wb_result_out : out std_logic_vector(DATA_WIDTH-1 downto 0);
  22. forwardA : out fwd_type;
  23. forwardB : out fwd_type
  24. );
  25.  
  26. end fwd;
  27.  
  28. architecture rtl of fwd is
  29.  
  30.  
  31.  
  32. begin -- rtl
  33.  
  34. process(mem_aluresult_in, wb_result_in, wb_op_em, wb_op_mw, rd_em, rd_mw, exec_op_de, reset, stall)
  35. begin
  36. if reset = '0' then
  37. forwardA <= FWD_NONE;
  38. forwardB <= FWD_NONE;
  39. mem_aluresult_out <= (others => '0');
  40. wb_result_out <= (others => '0');
  41. else
  42. if stall = '0' then
  43. forwardA <= FWD_NONE;
  44. forwardB <= FWD_NONE;
  45. mem_aluresult_out <= mem_aluresult_in;
  46. wb_result_out <= wb_result_in;
  47.  
  48. ----------- EX Harzard -------------
  49. if (wb_op_em.regwrite = '1') and (rd_em /= (REG_BITS-1 downto 0 => '0')) and (rd_em = exec_op_de.rs) then
  50. forwardA <= FWD_ALU;
  51. end if;
  52. if (wb_op_em.regwrite = '1') and (rd_em /= (REG_BITS-1 downto 0 => '0')) and (rd_em = exec_op_de.rt) then
  53. forwardB <= FWD_ALU;
  54. end if;
  55. ----------- END EX Harzard -------------
  56. ----------- MEM Harzard -------------
  57. if (wb_op_mw.regwrite = '1') and (rd_mw /= (REG_BITS-1 downto 0 => '0')) and not((wb_op_em.regwrite = '1') and (rd_em /= (REG_BITS-1 downto 0 => '0')) and (rd_em = exec_op_de.rs)) and (rd_mw = exec_op_de.rs) then
  58. forwardA <= FWD_WB;
  59. end if;
  60. if (wb_op_mw.regwrite = '1') and (rd_mw /= (REG_BITS-1 downto 0 => '0')) and not((wb_op_em.regwrite = '1') and (rd_em /= (REG_BITS-1 downto 0 => '0')) and (rd_em = exec_op_de.rt)) and (rd_mw = exec_op_de.rt) then
  61. forwardB <= FWD_WB;
  62. end if;
  63. ----------- END MEM Harzard -------------
  64.  
  65. end if;
  66. end if;
  67. end process;
  68.  
  69. end rtl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement