f146d8d4855b42b36a6c7889fcdf834255efecb5
[calu.git] / cpu / src / core_top.vhd
1 library IEEE;
2 use IEEE.std_logic_1164.all;
3 use IEEE.numeric_std.all;
4
5 use work.common_pkg.all;
6 use work.core_pkg.all;
7
8 entity core_top is
9
10         port(
11                 --System input pins
12                         sys_clk : in std_logic;
13                         sys_res : in std_logic;
14                         result : out gp_register_t
15                         
16                 );
17
18 end core_top;
19
20 architecture behav of core_top is
21
22                 signal jump_result_pin : instruction_addr_t;
23                 signal prediction_result_pin : instruction_addr_t;
24                 signal branch_prediction_bit_pin : std_logic;
25                 signal alu_jump_bit_pin : std_logic;
26                 signal instruction_pin : instruction_word_t;
27
28                 signal reg_w_addr_pin : std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
29                 signal reg_wr_data_pin : gp_register_t;
30                 signal reg_we_pin : std_logic;
31                 signal to_next_stage : dec_op;
32
33 --              signal reg1_rd_data_pin : gp_register_t;
34 --              signal reg2_rd_data_pin : gp_register_t;
35
36                  signal result_pin : gp_register_t;--reg
37                  signal result_addr_pin : gp_addr_t;--reg
38                  signal addr_pin : word_t; --memaddr
39                  signal data_pin : gp_register_t; --mem data --ureg
40                  signal alu_jump_pin : std_logic;--reg
41                  signal brpr_pin  : std_logic;  --reg
42                  signal wr_en_pin : std_logic;--regop --reg
43                  signal dmem_pin  : std_logic;--memop
44                  signal dmem_wr_en_pin : std_logic;
45                  signal hword_pin  : std_logic;
46                  signal byte_s_pin : std_logic;
47
48
49 begin
50
51         fetch_st : fetch_stage
52                 generic map (
53         
54                         '0',
55                         '1'
56                 )
57                 
58                 port map (
59                 --System inputs
60                         clk => sys_clk, --: in std_logic;
61                         reset => sys_res, --: in std_logic;
62                 
63                 --Data inputs
64                         jump_result => jump_result_pin, --: in instruction_addr_t;
65                         prediction_result => prediction_result_pin, --: in instruction_addr_t;
66                         branch_prediction_bit => branch_prediction_bit_pin,  --: in std_logic;
67                         alu_jump_bit => alu_jump_bit_pin, --: in std_logic;
68
69                 --Data outputs
70                         instruction => instruction_pin --: out instruction_word_t
71                 );
72
73         decode_st : decode_stage
74                 generic map (
75                         -- active reset value
76                         '0',
77                         -- active logic value
78                         '1'
79                         
80                         )
81                 port map (
82                 --System inputs
83                         clk => sys_clk, --: in std_logic;
84                         reset => sys_res, -- : in std_logic;
85
86                 --Data inputs
87                         instruction => instruction_pin, --: in instruction_word_t;
88                         reg_w_addr => reg_w_addr_pin, --: in std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
89                         reg_wr_data => reg_wr_data_pin, --: in gp_register_t;
90                         reg_we => reg_we_pin, --: in std_logic;
91
92                 --Data outputs
93                         branch_prediction_res => prediction_result_pin, --: instruction_word_t;
94                         branch_prediction_bit => branch_prediction_bit_pin, --: std_logic
95                         to_next_stage => to_next_stage
96                 );
97
98           exec_st : execute_stage
99                 generic map('0')
100                 port map(sys_clk, sys_res,to_next_stage, result_pin, result_addr_pin,addr_pin,
101                 data_pin, alu_jump_pin,brpr_pin, wr_en_pin, dmem_pin,dmem_wr_en_pin,hword_pin,byte_s_pin);
102
103           writeback_st : writeback_stage
104                 generic map('0', '1')
105                 port map(sys_clk, sys_res, result_pin, result_addr_pin, addr_pin, data_pin, alu_jump_pin, brpr_pin, 
106                 wr_en_pin, dmem_pin, dmem_wr_en_pin, hword_pin, byte_s_pin,
107                 reg_wr_data_pin, reg_we_pin, reg_w_addr_pin, jump_result_pin, alu_jump_bit_pin);
108
109                 
110 --init : process(all)
111
112 --begin
113 --      jump_result_pin <= (others => '0');
114 --      alu_jump_bit_pin <= '0';
115 --      reg_w_addr_pin <= (others => '0');
116 --      reg_wr_data_pin <= (others => '0');
117 --      reg_we_pin <= '0';
118         
119 --end process;
120         
121         result <= result_pin;
122
123 end behav;