13ac38243997008feb252339661fa1bd8eea3c1b
[calu.git] / cpu / src / core_pkg.vhd
1 library IEEE;
2
3 use IEEE.std_logic_1164.all;
4 use IEEE.numeric_std.all;
5
6 use work.common_pkg.all;
7
8 package core_pkg is
9         
10         component fetch_stage is
11         generic (
12                         -- active reset value
13                         RESET_VALUE : std_logic;
14                         -- active logic value
15                         LOGIC_ACT : std_logic
16                         
17                         );
18         port(
19                 --System inputs
20                         clk : in std_logic;
21                         reset : in std_logic;
22
23                 --Data inputs
24                         jump_result : in instruction_addr_t;
25                         prediction_result : in instruction_addr_t;
26                         branch_prediction_bit : in std_logic;
27                         alu_jump_bit : in std_logic;
28
29                 --Data outputs
30                         instruction : out instruction_word_t
31
32                 );
33         end component fetch_stage;
34
35
36
37         component decode_stage is
38         generic (
39                         -- active reset value
40                         RESET_VALUE : std_logic;
41                         -- active logic value
42                         LOGIC_ACT : std_logic
43                         
44                         );
45         port(
46                 --System inputs
47                         clk : in std_logic;
48                         reset : in std_logic;
49
50                 --Data inputs
51                         instruction : in instruction_word_t;
52                         reg_w_addr : in std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
53                         reg_wr_data : in gp_register_t;
54                         reg_we : in std_logic;
55
56                 --Data outputs
57 --                      reg1_rd_data : out gp_register_t;
58 --                      reg2_rd_data : out gp_register_t;
59                         branch_prediction_res : out instruction_word_t;
60                         branch_prediction_bit : out std_logic;
61                         to_next_stage : out dec_op
62                 );
63         end component decode_stage;
64
65
66         component decoder is
67
68         port(
69                         instruction : in instruction_word_t;
70                         instr_spl : out instruction_rec
71                 
72                 );
73
74         end component decoder;
75
76         component execute_stage is
77         
78         generic (
79                         -- active reset value
80                         RESET_VALUE : std_logic
81                         -- active logic value
82                         --LOGIC_ACT : std_logic;
83                         
84                         );
85         port(
86                 --System inputs
87                         clk : in std_logic;
88                         reset : in std_logic;
89                         dec_instr : in dec_op;
90
91                 --System output
92                         result : out gp_register_t;--reg
93                         result_addr : out gp_addr_t;--reg
94                         addr : out word_t; --memaddr
95                         data : out gp_register_t; --mem data --ureg
96                         alu_jump : out std_logic;--reg
97                         brpr  : out std_logic;  --reg
98                         wr_en : out std_logic;--regop --reg
99                         dmem  : out std_logic;--memop
100                         dmem_write_en : out std_logic;
101                         hword  : out std_logic;
102                         byte_s : out std_logic
103                 );
104         end component execute_stage;
105
106
107
108         component writeback_stage is
109         generic (
110                         -- active reset value
111                         RESET_VALUE : std_logic;
112                         -- active logic value
113                         LOGIC_ACT : std_logic
114                         
115                         );
116         port(
117                 --System inputs
118                         clk : in std_logic;
119                         reset : in std_logic;
120
121                         result : in gp_register_t;      --reg  (alu result or jumpaddr)
122                         result_addr : in gp_addr_t;     --reg
123                         address : in word_t;            --ureg 
124                         ram_data : in word_t;           --ureg
125                         alu_jmp : in std_logic;         --reg
126                         br_pred : in std_logic;         --reg
127                         write_en : in std_logic;        --reg  (register file)
128                         dmem_en : in std_logic;         --ureg (jump addr in mem or in address)
129                         dmem_write_en : in std_logic;   --ureg
130                         hword : in std_logic;           --ureg
131                         byte_s : in std_logic;          --ureg  
132
133                         regfile_val : out gp_register_t;
134                         reg_we : out std_logic;
135                         reg_addr : out gp_addr_t;
136                         jump_addr : out instruction_addr_t;
137                         jump : out std_logic
138                 );
139         end component writeback_stage;
140
141
142
143 end package core_pkg;