op_pkg.vhd 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use work.core_pkg.all;
  4. package op_pkg is
  5. type alu_op_type is (
  6. ALU_NOP,
  7. ALU_SLT,
  8. ALU_SLTU,
  9. ALU_SLL,
  10. ALU_SRL,
  11. ALU_SRA,
  12. ALU_ADD,
  13. ALU_SUB,
  14. ALU_AND,
  15. ALU_OR,
  16. ALU_XOR
  17. );
  18. type exec_op_type is
  19. record
  20. aluop : alu_op_type;
  21. alusrc1 : std_logic;
  22. alusrc2 : std_logic;
  23. alusrc3 : std_logic;
  24. rs1 : reg_adr_type;
  25. rs2 : reg_adr_type;
  26. readdata1 : data_type;
  27. readdata2 : data_type;
  28. imm : data_type;
  29. end record;
  30. constant EXEC_NOP : exec_op_type := (
  31. ALU_NOP, -- alu_op_type
  32. '0', -- alusrc1
  33. '0', -- alusrc2
  34. '0', -- alusrc3
  35. (others => '0'), -- rs1
  36. (others => '0'), -- rs2
  37. (others => '0'), -- readdata1
  38. (others => '0'), -- readdata2
  39. (others => '0') -- imm
  40. );
  41. type memtype_type is (
  42. MEM_B,
  43. MEM_BU,
  44. MEM_H,
  45. MEM_HU,
  46. MEM_W
  47. );
  48. type branch_type is (
  49. BR_NOP, -- no branch
  50. BR_BR, -- branch
  51. BR_CND, -- branch conditional
  52. BR_CNDI -- branch conditional (condition inverted)
  53. );
  54. type memu_op_type is
  55. record
  56. memread : std_logic;
  57. memwrite : std_logic;
  58. memtype : memtype_type;
  59. end record;
  60. type mem_op_type is
  61. record
  62. branch : branch_type;
  63. mem : memu_op_type;
  64. end record;
  65. constant MEMU_NOP : memu_op_type := (
  66. '0', -- memread
  67. '0', -- memwrite
  68. MEM_W -- memtype
  69. );
  70. constant MEM_NOP : mem_op_type := (
  71. BR_NOP, -- branch
  72. MEMU_NOP -- mem
  73. );
  74. type wbsrc_type is (
  75. WBS_ALU, -- ALU result
  76. WBS_MEM, -- MEM result
  77. WBS_OPC -- old PC + 4
  78. );
  79. type wb_op_type is
  80. record
  81. rd : reg_adr_type;
  82. write : std_logic;
  83. src : wbsrc_type;
  84. end record;
  85. constant WB_NOP : wb_op_type := (
  86. ZERO_REG, -- rd
  87. '0', -- memtoreg
  88. WBS_ALU -- regwrite
  89. );
  90. type reg_write_type is
  91. record
  92. write : std_logic;
  93. reg : reg_adr_type;
  94. data : data_type;
  95. end record;
  96. end package;