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

Subversion Repositories hf-risc

[/] [hf-risc/] [trunk/] [hf-riscv/] [platform/] [spartan3e_nexys2/] [spartan3e_nexys2.vhd] - Blame information for rev 21

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 18 serginhofr
entity hfrisc_soc is
6 13 serginhofr
        generic(
7
                address_width: integer := 15;
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 18 serginhofr
end hfrisc_soc;
18 13 serginhofr
 
19 18 serginhofr
architecture top_level of hfrisc_soc is
20 13 serginhofr
        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 18 serginhofr
        signal address, data_read, data_write, data_read_boot, data_read_ram, irq_vector_cpu, address_cpu, data_in_cpu, data_out_cpu: std_logic_vector(31 downto 0);
22 13 serginhofr
        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 18 serginhofr
        -- HF-RISC core
68 13 serginhofr
        core: entity work.datapath
69
        port map(       clock => clock,
70
                        reset => reset,
71
                        stall => stall_cpu,
72
                        irq_vector => irq_vector_cpu,
73
                        irq => irq_cpu,
74
                        irq_ack => irq_ack_cpu,
75
                        exception => exception_cpu,
76 18 serginhofr
                        address => address_cpu,
77 13 serginhofr
                        data_in => data_in_cpu,
78
                        data_out => data_out_cpu,
79
                        data_w => data_w_cpu,
80
                        data_access => data_access_cpu
81
        );
82
 
83
        -- peripherals / busmux logic
84
        peripherals_busmux: entity work.busmux
85
        generic map(
86
                uart_support => uart_support
87
        )
88
        port map(
89
                clock => clock,
90
                reset => reset,
91
 
92
                stall => stall,
93
 
94
                stall_cpu => stall_cpu,
95
                irq_vector_cpu => irq_vector_cpu,
96
                irq_cpu => irq_cpu,
97
                irq_ack_cpu => irq_ack_cpu,
98
                exception_cpu => exception_cpu,
99 18 serginhofr
                address_cpu => address_cpu,
100 13 serginhofr
                data_in_cpu => data_in_cpu,
101
                data_out_cpu => data_out_cpu,
102
                data_w_cpu => data_w_cpu,
103
                data_access_cpu => data_access_cpu,
104
 
105
                addr_mem => address,
106
                data_read_mem => data_read,
107
                data_write_mem => data_write,
108
                data_we_mem => data_we,
109
                extio_in => ext_irq,
110
                extio_out => open,
111
                uart_read => uart_read,
112
                uart_write => uart_write
113
        );
114
 
115
        -- instruction and data memory (boot RAM)
116
        boot_ram: entity work.ram
117
        generic map (memory_type => "DEFAULT")
118
        port map (
119
                clk                     => clock,
120
                enable                  => boot_enable,
121
                write_byte_enable       => "0000",
122
                address                 => address(31 downto 2),
123
                data_write              => (others => '0'),
124
                data_read               => data_read_boot
125
        );
126
 
127
        -- instruction and data memory (external RAM)
128
        memory0lb: entity work.bram
129
        generic map (   memory_file => memory_file,
130
                                        data_width => 8,
131
                                        address_width => address_width,
132
                                        bank => 0)
133
        port map(
134
                clk     => clock,
135
                addr    => address(address_width -1 downto 2),
136
                cs_n    => ram_enable_n,
137
                we_n    => data_w_n_ram(0),
138
                data_i  => data_write(7 downto 0),
139
                data_o  => data_read_ram(7 downto 0)
140
        );
141
 
142
        memory0ub: entity work.bram
143
        generic map (   memory_file => memory_file,
144
                                        data_width => 8,
145
                                        address_width => address_width,
146
                                        bank => 1)
147
        port map(
148
                clk     => clock,
149
                addr    => address(address_width -1 downto 2),
150
                cs_n    => ram_enable_n,
151
                we_n    => data_w_n_ram(1),
152
                data_i  => data_write(15 downto 8),
153
                data_o  => data_read_ram(15 downto 8)
154
        );
155
 
156
        memory1lb: entity work.bram
157
        generic map (   memory_file => memory_file,
158
                                        data_width => 8,
159
                                        address_width => address_width,
160
                                        bank => 2)
161
        port map(
162
                clk     => clock,
163
                addr    => address(address_width -1 downto 2),
164
                cs_n    => ram_enable_n,
165
                we_n    => data_w_n_ram(2),
166
                data_i  => data_write(23 downto 16),
167
                data_o  => data_read_ram(23 downto 16)
168
        );
169
 
170
        memory1ub: entity work.bram
171
        generic map (   memory_file => memory_file,
172
                                        data_width => 8,
173
                                        address_width => address_width,
174
                                        bank => 3)
175
        port map(
176
                clk     => clock,
177
                addr    => address(address_width -1 downto 2),
178
                cs_n    => ram_enable_n,
179
                we_n    => data_w_n_ram(3),
180
                data_i  => data_write(31 downto 24),
181
                data_o  => data_read_ram(31 downto 24)
182
        );
183
 
184 18 serginhofr
end top_level;
185 13 serginhofr
 

powered by: WebSVN 2.1.0

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