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