OpenCores
URL https://opencores.org/ocsvn/hicovec/hicovec/trunk

Subversion Repositories hicovec

[/] [hicovec/] [trunk/] [cpu/] [system.vhd] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 hmanske
------------------------------------------------------------------
2 4 hmanske
-- PROJECT:     HiCoVec (highly configurable vector processor)
3 2 hmanske
--
4
-- ENTITY:      system
5
--
6
-- PURPOSE:     top level module of processor
7
--
8
-- AUTHOR:      harald manske, haraldmanske@gmx.de
9
--
10
-- VERSION:     1.0
11
------------------------------------------------------------------
12
 
13
library ieee;
14
use ieee.std_logic_1164.all;
15
use ieee.std_logic_unsigned.all;
16
 
17
use work.cfg.all;
18
use work.datatypes.all;
19
 
20
entity system is
21
     port(
22
        clk: in std_logic;
23
        reset: in std_logic;
24
 
25
        rs232_txd: out std_logic;
26
        rs232_rxd: in std_logic
27
     );
28
end system;
29
 
30
architecture rtl of system is
31
 
32
    component cpu
33
        port(
34
            clk: in std_logic;
35
            reset: in std_logic;
36
            dbg_a: out std_logic_vector(31 downto 0);
37
            dbg_x: out std_logic_vector(31 downto 0);
38
            dbg_y: out std_logic_vector(31 downto 0);
39
            dbg_ir: out std_logic_vector(31 downto 0);
40
            dbg_ic: out std_logic_vector(31 downto 0);
41
            dbg_carry: out std_logic;
42
            dbg_zero: out std_logic;
43
            dbg_ir_ready: out std_logic;
44
            dbg_halted: out std_logic;
45
            mem_data_in: in std_logic_vector(31 downto 0);
46
            mem_data_out: out std_logic_vector(31 downto 0);
47
            mem_vdata_in: in vectordata_type;
48
            mem_vdata_out: out vectordata_type;
49
            mem_address: out std_logic_vector(31 downto 0);
50
            mem_access: out std_logic_vector(2 downto 0);
51
            mem_ready: in std_logic
52
         );
53
    end component;
54
 
55
    component memoryinterface
56
        port (
57
            clk:            in  std_logic;
58
            address:        in  std_logic_vector(31 downto 0) := (others => '0');
59
            access_type:    in  std_logic_vector(2 downto 0) := "000"; -- we, oe, cs
60
            data_in:        in  std_logic_vector(31 downto 0);
61
            vdata_in:       in  vectordata_type;
62
            data_out:       out std_logic_vector(31 downto 0);
63
            vdata_out:      out vectordata_type;
64
            ready:          out std_logic;
65
            we:             out std_logic;
66
            en:             out std_logic;
67
            addr:           out std_logic_vector(31 downto 0);
68
            di:             out std_logic_vector(31 downto 0);
69
            do:             in std_logic_vector(31 downto 0)
70
        );
71
    end component;
72
 
73
    component debugger
74
        port (
75
            clk_in: in std_logic;
76
            clk_cpu: out std_logic;
77
            clk_mem: out std_logic;
78
            reset_out: out std_logic;
79
            rs232_txd: out std_logic;
80
            rs232_rxd: in std_logic;
81
            a: in std_logic_vector(31 downto 0);
82
            x: in std_logic_vector(31 downto 0);
83
            y: in std_logic_vector(31 downto 0);
84
            ir: in std_logic_vector(31 downto 0);
85
            ic: in std_logic_vector(31 downto 0);
86
            mem_switch: out std_logic;
87
            mem_ready: in std_logic;
88
            mem_access: in std_logic_vector(2 downto 0);
89
            mem_access_dbg: out std_logic_vector(2 downto 0);
90
            mem_addr: in std_logic_vector(31 downto 0);
91
            mem_addr_dbg: out std_logic_vector(31 downto 0);
92
            mem_data: in std_logic_vector(31 downto 0);
93
            mem_data_dbg: out std_logic_vector(31 downto 0);
94
            carry: in std_logic;
95
            zero: in std_logic;
96
            ir_ready: in std_logic;
97
            halted: in std_logic
98
        );
99
    end component;
100
 
101
    component sram
102
        port (
103
            clk : in std_logic;
104
            we : in std_logic;
105
            en : in std_logic;
106
            addr : in std_logic_vector(31 downto 0);
107
            di : in std_logic_vector(31 downto 0);
108
            do : out std_logic_vector(31 downto 0)
109
        );
110
    end component;
111
 
112
    for sram_impl:              sram                use entity work.sram(rtl);
113
    for cpu_impl:               cpu                 use entity work.cpu(rtl);
114
    for memoryinterface_impl:   memoryinterface     use entity work.memoryinterface(rtl);
115
    for debugger_impl:          debugger            use entity work.debugger(rtl);
116
 
117
 
118
    -- sram signals
119
    signal we, en: std_logic;
120
    signal addr, di, do: std_logic_vector(31 downto 0);
121
 
122
    -- debugger signals
123
    signal clk_cpu:         std_logic;
124
    signal clk_mem:         std_logic;
125
    signal reset_cpu:       std_logic;
126
    signal mem_switch:      std_logic;
127
 
128
    -- cpu signals
129
    signal dbg_a, dbg_x, dbg_y, dbg_ir, dbg_ic: std_logic_vector(31 downto 0);
130
    signal dbg_carry, dbg_zero, dbg_ir_ready, dbg_halted: std_logic;
131
 
132
    -- memory interface signals
133
    signal mem_access, mem_access_cpu, mem_access_dbg: std_logic_vector(2 downto 0);
134
    signal mem_address, mem_address_cpu, mem_address_dbg: std_logic_vector(31 downto 0);
135
    signal mem_data_out, mem_data_out_cpu, mem_data_out_dbg: std_logic_vector(31 downto 0);
136
 
137
    signal mem_data_in: std_logic_vector(31 downto 0);
138
    signal mem_vdata_in, mem_vdata_out: vectordata_type;
139
    signal mem_ready: std_logic;
140
 
141
    -- attributes for xilinx synthesis tool
142
    attribute clock_signal : string;
143
    attribute clock_signal of "clk" : signal is "yes";
144
    attribute clock_signal of "clk_cpu" : signal is "yes";
145
 
146
begin
147
    -- include debugger
148
    debugger_gen: if use_debugger generate
149
        debugger_impl: debugger
150
            port map (
151
                clk_in => clk, clk_cpu => clk_cpu, clk_mem => clk_mem, reset_out => reset_cpu,
152
                rs232_txd => rs232_txd, rs232_rxd => rs232_rxd, a => dbg_a, x => dbg_x, y => dbg_y, ir =>
153
                dbg_ir, ic => dbg_ic, mem_switch => mem_switch, mem_ready  => mem_ready, mem_access =>
154
                mem_access_cpu, mem_access_dbg => mem_access_dbg, mem_addr => mem_address_cpu,
155
                mem_addr_dbg => mem_address_dbg, mem_data => mem_data_in, mem_data_dbg => mem_data_out_dbg,
156
                carry => dbg_carry, zero => dbg_zero, ir_ready => dbg_ir_ready, halted => dbg_halted
157
            );
158
 
159
        -- allow memory access from debugger unit
160
        mem_access <= mem_access_cpu when mem_switch = '0' else mem_access_dbg;
161
        mem_address <= mem_address_cpu when mem_switch = '0' else mem_address_dbg;
162
        mem_data_out <= mem_data_out_cpu when mem_switch = '0' else mem_data_out_dbg;
163
    end generate;
164
 
165
    -- dont include debugger
166
    not_debugger_gen: if not use_debugger generate
167
        reset_cpu <= reset;
168
        clk_cpu <= clk;
169
 
170
        -- allow memory access only from cpu
171
        mem_access <= mem_access_cpu;
172
        mem_address <= mem_address_cpu;
173
        mem_data_out <= mem_data_out_cpu;
174
    end generate;
175
 
176
    cpu_impl: cpu
177
        port map (
178
            clk => clk_cpu, reset => reset_cpu, dbg_a => dbg_a, dbg_x => dbg_x, dbg_y => dbg_y,
179
            dbg_ir => dbg_ir, dbg_ic => dbg_ic, dbg_carry => dbg_carry, dbg_zero => dbg_zero,
180
            dbg_ir_ready => dbg_ir_ready, dbg_halted => dbg_halted, mem_data_in => mem_data_in,
181
            mem_data_out => mem_data_out_cpu, mem_vdata_in => mem_vdata_in, mem_vdata_out => mem_vdata_out,
182
            mem_address => mem_address_cpu, mem_access => mem_access_cpu,  mem_ready => mem_ready
183
        );
184
 
185
 
186
    memoryinterface_impl: memoryinterface
187
        port map (
188
            clk => clk_mem, address => mem_address, access_type => mem_access, data_in => mem_data_out,
189
            vdata_in => mem_vdata_out, data_out => mem_data_in, vdata_out => mem_vdata_in, ready => mem_ready,
190
            we => we, en => en, addr => addr, di => di, do => do
191
        );
192
 
193
    sram_impl: sram
194
        port map (
195
            clk => clk_mem, we => we, en => en, addr => addr, di => di, do => do
196
        );
197
 
198
end;
199
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.