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