kleine Ă„nderungen
[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                         jump_result : out instruction_addr_t;
16                         reg_wr_data : out gp_register_t
17                         
18                 );
19
20 end core_top;
21
22 architecture behav of core_top is
23
24                 signal jump_result_pin : instruction_addr_t;
25                 signal prediction_result_pin : instruction_addr_t;
26                 signal branch_prediction_bit_pin : std_logic;
27                 signal alu_jump_bit_pin : std_logic;
28                 signal instruction_pin : instruction_word_t;
29
30                 signal reg_w_addr_pin : std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
31                 signal reg_wr_data_pin : gp_register_t;
32                 signal reg_we_pin : std_logic;
33                 signal to_next_stage : dec_op;
34
35 --              signal reg1_rd_data_pin : gp_register_t;
36 --              signal reg2_rd_data_pin : gp_register_t;
37
38                  signal result_pin : gp_register_t;--reg
39                  signal result_addr_pin : gp_addr_t;--reg
40                  signal addr_pin : word_t; --memaddr
41                  signal data_pin : gp_register_t; --mem data --ureg
42                  signal alu_jump_pin : std_logic;--reg
43                  signal brpr_pin  : std_logic;  --reg
44                  signal wr_en_pin : std_logic;--regop --reg
45                  signal dmem_pin  : std_logic;--memop
46                  signal dmem_wr_en_pin : std_logic;
47                  signal hword_pin  : std_logic;
48                  signal byte_s_pin : std_logic;
49                  signal nop_pin : std_logic;
50
51
52 begin
53
54         fetch_st : fetch_stage
55                 generic map (
56         
57                         '0',
58                         '1'
59                 )
60                 
61                 port map (
62                 --System inputs
63                         clk => sys_clk, --: in std_logic;
64                         reset => sys_res, --: in std_logic;
65                 
66                 --Data inputs
67                         jump_result => jump_result_pin, --: in instruction_addr_t;
68                         prediction_result => prediction_result_pin, --: in instruction_addr_t;
69                         branch_prediction_bit => branch_prediction_bit_pin,  --: in std_logic;
70                         alu_jump_bit => alu_jump_bit_pin, --: in std_logic;
71
72                 --Data outputs
73                         instruction => instruction_pin --: out instruction_word_t
74                 );
75
76         decode_st : decode_stage
77                 generic map (
78                         -- active reset value
79                         '0',
80                         -- active logic value
81                         '1'
82                         
83                         )
84                 port map (
85                 --System inputs
86                         clk => sys_clk, --: in std_logic;
87                         reset => sys_res, -- : in std_logic;
88
89                 --Data inputs
90                         instruction => instruction_pin, --: in instruction_word_t;
91                         reg_w_addr => reg_w_addr_pin, --: in std_logic_vector(REG_ADDR_WIDTH-1 downto 0);
92                         reg_wr_data => reg_wr_data_pin, --: in gp_register_t;
93                         reg_we => reg_we_pin, --: in std_logic;
94                         nop => nop_pin,
95
96                 --Data outputs
97                         branch_prediction_res => prediction_result_pin, --: instruction_word_t;
98                         branch_prediction_bit => branch_prediction_bit_pin, --: std_logic
99                         to_next_stage => to_next_stage
100                 );
101
102           exec_st : execute_stage
103                 generic map('0')
104                 port map(sys_clk, sys_res,to_next_stage, reg_wr_data_pin, reg_we_pin, reg_w_addr_pin, result_pin, result_addr_pin,addr_pin,
105                 data_pin, alu_jump_pin,brpr_pin, wr_en_pin, dmem_pin,dmem_wr_en_pin,hword_pin,byte_s_pin);
106
107           writeback_st : writeback_stage
108                 generic map('0', '1')
109                 port map(sys_clk, sys_res, result_pin, result_addr_pin, addr_pin, data_pin, alu_jump_pin, brpr_pin, 
110                 wr_en_pin, dmem_pin, dmem_wr_en_pin, hword_pin, byte_s_pin,
111                 reg_wr_data_pin, reg_we_pin, reg_w_addr_pin, jump_result_pin, alu_jump_bit_pin);
112
113                 
114 --init : process(all)
115
116 --begin
117 --      jump_result_pin <= (others => '0');
118 --      alu_jump_bit_pin <= '0';
119 --      reg_w_addr_pin <= (others => '0');
120 --      reg_wr_data_pin <= (others => '0');
121 --      reg_we_pin <= '0';
122         
123 --end process;
124         
125         result <= result_pin;
126         nop_pin <= (alu_jump_bit_pin xor brpr_pin);
127
128         jump_result <= jump_result_pin;
129
130         reg_wr_data <= reg_wr_data_pin;
131 end behav;