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

Subversion Repositories hf-risc

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

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

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

powered by: WebSVN 2.1.0

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