c27a5a0ca32c93295b79258dbc6add5023bb8d22
[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 use work.extension_pkg.all;
8
9 package core_pkg is
10         
11         component fetch_stage is
12         generic (
13                         -- active reset value
14                         RESET_VALUE : std_logic;
15                         -- active logic value
16                         LOGIC_ACT : std_logic
17                         
18                         );
19         port(
20                 --System inputs
21                         clk : in std_logic;
22                         reset : in std_logic;
23                 
24                 --Data inputs
25                         jump_result : in instruction_addr_t;
26                         prediction_result : in instruction_addr_t;
27                         branch_prediction_bit : in std_logic;
28                         alu_jump_bit : in std_logic;
29                         int_req : in interrupt_t;
30                         new_im_data_in : in std_logic;
31                         im_addr : in gp_register_t;
32                         im_data : in gp_register_t;
33
34                 --Data outputs
35                         instruction : out instruction_word_t;
36                         prog_cnt : out instruction_addr_t
37                 );
38         end component fetch_stage;
39
40
41
42         component decode_stage is
43         generic (
44                         -- active reset value
45                         RESET_VALUE : std_logic;
46                         -- active logic value
47                         LOGIC_ACT : std_logic
48                         
49                         );
50         port(
51                 --System inputs
52                         clk : in std_logic;
53                         reset : in std_logic;
54
55                 --Data inputs
56                         instruction : in instruction_word_t;
57                         prog_cnt : in instruction_addr_t;
58                         reg_w_addr : in std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
59                         reg_wr_data : in gp_register_t;
60                         reg_we : in std_logic;
61                         nop : in std_logic;
62
63                 --Data outputs
64 --                      reg1_rd_data : out gp_register_t;
65 --                      reg2_rd_data : out gp_register_t;
66                         branch_prediction_res : out instruction_word_t;
67                         branch_prediction_bit : out std_logic;
68
69                         to_next_stage : out dec_op
70                 );
71         end component decode_stage;
72
73
74         component decoder is
75
76         port(
77                         instruction : in instruction_word_t;
78                         instr_spl : out instruction_rec
79                 
80                 );
81
82         end component decoder;
83
84         component execute_stage is
85         
86         generic (
87                         -- active reset value
88                         RESET_VALUE : std_logic
89                         -- active logic value
90                         --LOGIC_ACT : std_logic;
91                         
92                         );
93         port(
94                 --System inputs
95                         clk : in std_logic;
96                         reset : in std_logic;
97                         dec_instr : in dec_op;
98                         regfile_val : in gp_register_t;
99                         reg_we : in std_logic;
100                         reg_addr : in gp_addr_t;
101                         ext_reg  : in extmod_rec;
102             --System output
103             result : out gp_register_t;--reg
104             result_addr : out gp_addr_t;--reg
105             addr : out word_t; --memaddr
106             data : out gp_register_t; --mem data --ureg
107             alu_jump : out std_logic;--reg
108             brpr  : out std_logic;  --reg
109             wr_en : out std_logic;--regop --reg
110             dmem  : out std_logic;--memop
111             dmem_write_en : out std_logic;
112             hword  : out std_logic;
113             byte_s : out std_logic;
114                                 
115                         ext_data_out : out gp_register_t
116                 );
117         end component execute_stage;
118
119
120
121         component writeback_stage is
122         generic (
123                         -- active reset value
124                         RESET_VALUE : std_logic;
125                         -- active logic value
126                         LOGIC_ACT : std_logic;
127                         FPGATYPE : string
128                         );
129         port(
130                 --System inputs
131                         clk : in std_logic;
132                         reset : in std_logic;
133
134                         result : in gp_register_t;      --reg  (alu result or jumpaddr)
135                         result_addr : in gp_addr_t;     --reg
136                         address : in word_t;            --ureg 
137                         ram_data : in word_t;           --ureg
138                         alu_jmp : in std_logic;         --reg
139                         br_pred : in std_logic;         --reg
140                         write_en : in std_logic;        --reg  (register file)
141                         dmem_en : in std_logic;         --ureg (jump addr in mem or in address)
142                         dmem_write_en : in std_logic;   --ureg
143                         hword : in std_logic;           --ureg
144                         byte_s : in std_logic;          --ureg  
145
146                         regfile_val : out gp_register_t;
147                         reg_we : out std_logic;
148                         reg_addr : out gp_addr_t;
149                         jump_addr : out instruction_addr_t;
150                         jump : out std_logic;
151                         -- same here
152                         bus_tx : out std_logic;
153                         bus_rx : in std_logic;
154                         new_im_data_out : out std_logic;
155                         im_addr : out gp_register_t;
156                         im_data : out gp_register_t;
157                         
158                         sseg0 : out std_logic_vector(0 to 6);
159                         sseg1 : out std_logic_vector(0 to 6);
160                         sseg2 : out std_logic_vector(0 to 6);
161                         sseg3 : out std_logic_vector(0 to 6);
162
163                         int_req : out interrupt_t
164
165                 );
166         end component writeback_stage;
167
168
169
170 end package core_pkg;