OpenCores
URL https://opencores.org/ocsvn/hf-risc/hf-risc/trunk

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [hf-riscv/] [platform/] [spartan3_starterkit/] [spartan3.vhd] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 serginhofr
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_unsigned.all;
4
 
5
entity hellfire_cpu_if is
6
        generic(
7
                address_width: integer := 14;
8
                memory_file : string := "code.txt";
9
                uart_support : string := "yes"
10
        );
11
        port (  clk_in:         in std_logic;
12
                reset_in:       in std_logic;
13
                int_in:         in std_logic;
14
                uart_read:      in std_logic;
15
                uart_write:     out std_logic
16
        );
17
end hellfire_cpu_if;
18
 
19
architecture interface of hellfire_cpu_if is
20
        signal clock, boot_enable, ram_enable_n, stall, stall_cpu, busy_cpu, irq_cpu, irq_ack_cpu, exception_cpu, data_access_cpu, ram_dly, rff1, reset: std_logic;
21
        signal address, data_read, data_write, data_read_boot, data_read_ram, irq_vector_cpu, inst_addr_cpu, inst_in_cpu, data_addr_cpu, data_in_cpu, data_out_cpu: std_logic_vector(31 downto 0);
22
        signal ext_irq: std_logic_vector(7 downto 0);
23
        signal data_we, data_w_n_ram, data_w_cpu: std_logic_vector(3 downto 0);
24
begin
25
        -- clock divider (25MHz clock from 50MHz main clock for Spartan3 Starter Kit)
26
        process (reset_in, clk_in, clock)
27
        begin
28
                if reset_in = '1' then
29
                        clock <= '0';
30
                else
31
                        if clk_in'event and clk_in='1' then
32
                                clock <= not clock;
33
                        end if;
34
                end if;
35
        end process;
36
 
37
        -- reset synchronizer
38
        process (clock, reset_in)
39
        begin
40
                if (reset_in = '1') then
41
                        rff1 <= '1';
42
                        reset <= '1';
43
                elsif (clock'event and clock = '1') then
44
                        rff1 <= '0';
45
                        reset <= rff1;
46
                end if;
47
        end process;
48
 
49
 
50
        process (reset, clock, ext_irq, ram_enable_n)
51
        begin
52
                if reset = '1' then
53
                        ram_dly <= '0';
54
                        ext_irq <= x"00";
55
                elsif clock'event and clock = '1' then
56
                        ram_dly <= not ram_enable_n;
57
                        ext_irq <= "0000000" & int_in;
58
                end if;
59
        end process;
60
 
61
        stall <= '0';
62
        boot_enable <= '1' when address(31 downto 28) = "0000" else '0';
63
        ram_enable_n <= '0' when address(31 downto 28) = "0100" else '1';
64
        data_read <= data_read_boot when address(31 downto 28) = "0000" and ram_dly = '0' else data_read_ram;
65
        data_w_n_ram <= not data_we;
66
 
67
        -- HF-RISCV core
68
        core: entity work.datapath
69
        port map(       clock => clock,
70
                        reset => reset,
71
                        stall => stall_cpu,
72
                        busy => busy_cpu,
73
                        irq_vector => irq_vector_cpu,
74
                        irq => irq_cpu,
75
                        irq_ack => irq_ack_cpu,
76
                        exception => exception_cpu,
77
                        inst_addr => inst_addr_cpu,
78
                        inst_in => inst_in_cpu,
79
                        data_addr => data_addr_cpu,
80
                        data_in => data_in_cpu,
81
                        data_out => data_out_cpu,
82
                        data_w => data_w_cpu,
83
                        data_access => data_access_cpu
84
        );
85
 
86
        -- peripherals / busmux logic
87
        peripherals_busmux: entity work.busmux
88
        generic map(
89
                uart_support => uart_support
90
        )
91
        port map(
92
                clock => clock,
93
                reset => reset,
94
 
95
                stall => stall,
96
 
97
                stall_cpu => stall_cpu,
98
                busy_cpu => busy_cpu,
99
                irq_vector_cpu => irq_vector_cpu,
100
                irq_cpu => irq_cpu,
101
                irq_ack_cpu => irq_ack_cpu,
102
                exception_cpu => exception_cpu,
103
                inst_addr_cpu => inst_addr_cpu,
104
                inst_in_cpu => inst_in_cpu,
105
                data_addr_cpu => data_addr_cpu,
106
                data_in_cpu => data_in_cpu,
107
                data_out_cpu => data_out_cpu,
108
                data_w_cpu => data_w_cpu,
109
                data_access_cpu => data_access_cpu,
110
 
111
                addr_mem => address,
112
                data_read_mem => data_read,
113
                data_write_mem => data_write,
114
                data_we_mem => data_we,
115
                extio_in => ext_irq,
116
                extio_out => open,
117
                uart_read => uart_read,
118
                uart_write => uart_write
119
        );
120
 
121
        -- instruction and data memory (boot RAM)
122
        boot_ram: entity work.ram
123
        generic map (memory_type => "DEFAULT")
124
        port map (
125
                clk                     => clock,
126
                enable                  => boot_enable,
127
                write_byte_enable       => "0000",
128
                address                 => address(31 downto 2),
129
                data_write              => (others => '0'),
130
                data_read               => data_read_boot
131
        );
132
 
133
        -- instruction and data memory (external RAM)
134
        memory0lb: entity work.bram
135
        generic map (   memory_file => memory_file,
136
                                        data_width => 8,
137
                                        address_width => address_width,
138
                                        bank => 0)
139
        port map(
140
                clk     => clock,
141
                addr    => address(address_width -1 downto 2),
142
                cs_n    => ram_enable_n,
143
                we_n    => data_w_n_ram(0),
144
                data_i  => data_write(7 downto 0),
145
                data_o  => data_read_ram(7 downto 0)
146
        );
147
 
148
        memory0ub: entity work.bram
149
        generic map (   memory_file => memory_file,
150
                                        data_width => 8,
151
                                        address_width => address_width,
152
                                        bank => 1)
153
        port map(
154
                clk     => clock,
155
                addr    => address(address_width -1 downto 2),
156
                cs_n    => ram_enable_n,
157
                we_n    => data_w_n_ram(1),
158
                data_i  => data_write(15 downto 8),
159
                data_o  => data_read_ram(15 downto 8)
160
        );
161
 
162
        memory1lb: entity work.bram
163
        generic map (   memory_file => memory_file,
164
                                        data_width => 8,
165
                                        address_width => address_width,
166
                                        bank => 2)
167
        port map(
168
                clk     => clock,
169
                addr    => address(address_width -1 downto 2),
170
                cs_n    => ram_enable_n,
171
                we_n    => data_w_n_ram(2),
172
                data_i  => data_write(23 downto 16),
173
                data_o  => data_read_ram(23 downto 16)
174
        );
175
 
176
        memory1ub: entity work.bram
177
        generic map (   memory_file => memory_file,
178
                                        data_width => 8,
179
                                        address_width => address_width,
180
                                        bank => 3)
181
        port map(
182
                clk     => clock,
183
                addr    => address(address_width -1 downto 2),
184
                cs_n    => ram_enable_n,
185
                we_n    => data_w_n_ram(3),
186
                data_i  => data_write(31 downto 24),
187
                data_o  => data_read_ram(31 downto 24)
188
        );
189
 
190
end interface;
191
 

powered by: WebSVN 2.1.0

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