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