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

Subversion Repositories simpcon

[/] [simpcon/] [trunk/] [vhdl/] [sc2ahbsl.vhd] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 martin
--
2 29 martin
--
3
--  This file is a part of JOP, the Java Optimized Processor
4
--
5
--  Copyright (C) 2001-2008, Martin Schoeberl (martin@jopdesign.com)
6
--
7
--  This program is free software: you can redistribute it and/or modify
8
--  it under the terms of the GNU General Public License as published by
9
--  the Free Software Foundation, either version 3 of the License, or
10
--  (at your option) any later version.
11
--
12
--  This program is distributed in the hope that it will be useful,
13
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
--  GNU General Public License for more details.
16
--
17
--  You should have received a copy of the GNU General Public License
18
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
 
21
 
22
--
23 18 martin
--      sc2ahbsl.vhd
24
--
25
--      SimpCon to AMBA bridge
26
--
27
--      Author: Martin Schoeberl        martin@jopdesign.com
28
--
29
--      2007-03-16      first version
30
--
31
 
32
Library IEEE;
33
use IEEE.std_logic_1164.all;
34
use ieee.numeric_std.all;
35
 
36
use work.sc_pack.all;
37
 
38
library grlib;
39
use grlib.amba.all;
40
--use grlib.tech.all;
41
library gaisler;
42
use gaisler.memctrl.all;
43
--use gaisler.pads.all; -- used for I/O pads
44
--use gaisler.misc.all;
45
 
46
entity sc2ahbsl is
47
 
48
port (
49
 
50
        clk, reset      : in std_logic;
51
 
52
--      SimpCon memory interface
53
        scmo            : in sc_mem_out_type;
54
        scmi            : out sc_in_type;
55
 
56
-- AMBA slave interface
57
    ahbsi               : out  ahb_slv_in_type;
58
    ahbso               : in ahb_slv_out_type
59
);
60
end sc2ahbsl;
61
 
62
architecture rtl of sc2ahbsl is
63
 
64
        type state_type         is (idl, rd, rdw, wr, wrw);
65
        signal state            : state_type;
66
        signal next_state       : state_type;
67
 
68
        signal reg_wr_data      : std_logic_vector(31 downto 0);
69
        signal reg_rd_data      : std_logic_vector(31 downto 0);
70
 
71
begin
72
 
73
--
74
--      some defaults
75
--
76
        ahbsi.hsel(1 to NAHBSLV-1) <= (others => '0');   -- we use only slave 0
77
        ahbsi.hsel(0) <= scmo.rd or scmo.wr;                     -- slave select
78
        -- do we need to store the addrsss in a register?
79 29 martin
        ahbsi.haddr(SC_ADDR_SIZE-1+2 downto 2) <= scmo.address; -- address bus (byte)
80 18 martin
        ahbsi.haddr(1 downto 0) <= (others => '0');
81 29 martin
        ahbsi.haddr(31 downto SC_ADDR_SIZE+2) <= (others => '0');
82 18 martin
        ahbsi.hwrite <= scmo.wr;                                                -- read/write
83
        ahbsi.htrans <= HTRANS_NONSEQ;                                  -- transfer type
84
        ahbsi.hsize <= "010";                                                   -- transfer size 32 bits
85
        ahbsi.hburst <= HBURST_SINGLE;                                  -- burst type
86
        ahbsi.hwdata <= reg_wr_data;                                    -- write data bus
87
        ahbsi.hprot <= "0000";          -- ? protection control
88
        ahbsi.hready <= '1';            -- ? transer done 
89
        ahbsi.hmaster <= "0000";                                                -- current master
90
        ahbsi.hmastlock <= '0';          -- locked access
91
        ahbsi.hmbsel(0) <= '0';                                                   -- memory bank select
92
        ahbsi.hmbsel(1) <= '1';                                                 -- second is SRAM
93
        ahbsi.hmbsel(2 to NAHBAMR-1) <= (others => '0');
94
        ahbsi.hcache <= '1';                                                    -- cacheable
95
        ahbsi.hirq <= (others => '0');                                   -- interrupt result bus
96
 
97
 
98
 
99
 
100
--
101
--      Register write data
102
--
103
process(clk, reset)
104
begin
105
        if reset='1' then
106
 
107
                reg_wr_data <= (others => '0');
108
 
109
        elsif rising_edge(clk) then
110
 
111
                if scmo.wr='1' then
112
                        reg_wr_data <= scmo.wr_data;
113
                end if;
114
 
115
        end if;
116
end process;
117
 
118
--
119
--      next state logic
120
--
121
process(state, scmo, ahbso.hready)
122
 
123
begin
124
 
125
        next_state <= state;
126
 
127
        case state is
128
 
129
                when idl =>
130
                        if scmo.rd='1' then
131
                                next_state <= rdw;
132
                        elsif scmo.wr='1' then
133
                                next_state <= wrw;
134
                        end if;
135
 
136
                when rdw =>
137
                        if ahbso.hready='1' then
138
                                next_state <= rd;
139
                        end if;
140
 
141
                when rd =>
142
                        next_state <= idl;
143
                        if scmo.rd='1' then
144
                                next_state <= rdw;
145
                        elsif scmo.wr='1' then
146
                                next_state <= wrw;
147
                        end if;
148
 
149
                when wrw =>
150
                        if ahbso.hready='1' then
151
                                next_state <= wr;
152
                        end if;
153
 
154
                when wr =>
155
                        next_state <= idl;
156
                        if scmo.rd='1' then
157
                                next_state <= rdw;
158
                        elsif scmo.wr='1' then
159
                                next_state <= wrw;
160
                        end if;
161
 
162
 
163
        end case;
164
 
165
end process;
166
 
167
--
168
--      state machine register
169
--      and output register
170
--
171
process(clk, reset)
172
 
173
begin
174
        if (reset='1') then
175
                state <= idl;
176
                reg_rd_data <= (others => '0');
177
 
178
        elsif rising_edge(clk) then
179
 
180
                state <= next_state;
181
 
182
                case next_state is
183
 
184
                        when idl =>
185
 
186
                        when rdw =>
187
 
188
                        when rd =>
189
                                reg_rd_data <= ahbso.hrdata;
190
 
191
                        when wrw =>
192
 
193
                        when wr =>
194
 
195
                end case;
196
 
197
        end if;
198
end process;
199
 
200
--
201
--      combinatorial state machine output
202
--
203
process(next_state)
204
 
205
begin
206
 
207
        scmi.rdy_cnt <= "00";
208
        scmi.rd_data <= reg_rd_data;
209
 
210
        case next_state is
211
 
212
                when idl =>
213
 
214
                when rdw =>
215
                        scmi.rdy_cnt <= "11";
216
 
217
                when rd =>
218
                        scmi.rd_data <= ahbso.hrdata;
219
 
220
                when wrw =>
221
                        scmi.rdy_cnt <= "11";
222
 
223
                when wr =>
224
 
225
        end case;
226
 
227
end process;
228
 
229
end rtl;

powered by: WebSVN 2.1.0

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