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

Subversion Repositories simpcon

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

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

Line No. Rev Author Line
1 18 martin
--
2
--      sc2ahbsl.vhd
3
--
4
--      SimpCon to AMBA bridge
5
--
6
--      Author: Martin Schoeberl        martin@jopdesign.com
7
--
8
--      2007-03-16      first version
9
--
10
 
11
Library IEEE;
12
use IEEE.std_logic_1164.all;
13
use ieee.numeric_std.all;
14
 
15
use work.sc_pack.all;
16
 
17
library grlib;
18
use grlib.amba.all;
19
--use grlib.tech.all;
20
library gaisler;
21
use gaisler.memctrl.all;
22
--use gaisler.pads.all; -- used for I/O pads
23
--use gaisler.misc.all;
24
 
25
entity sc2ahbsl is
26
 
27
port (
28
 
29
        clk, reset      : in std_logic;
30
 
31
--      SimpCon memory interface
32
        scmo            : in sc_mem_out_type;
33
        scmi            : out sc_in_type;
34
 
35
-- AMBA slave interface
36
    ahbsi               : out  ahb_slv_in_type;
37
    ahbso               : in ahb_slv_out_type
38
);
39
end sc2ahbsl;
40
 
41
architecture rtl of sc2ahbsl is
42
 
43
        type state_type         is (idl, rd, rdw, wr, wrw);
44
        signal state            : state_type;
45
        signal next_state       : state_type;
46
 
47
        signal reg_wr_data      : std_logic_vector(31 downto 0);
48
        signal reg_rd_data      : std_logic_vector(31 downto 0);
49
 
50
begin
51
 
52
--
53
--      some defaults
54
--
55
        ahbsi.hsel(1 to NAHBSLV-1) <= (others => '0');   -- we use only slave 0
56
        ahbsi.hsel(0) <= scmo.rd or scmo.wr;                     -- slave select
57
        -- do we need to store the addrsss in a register?
58
        ahbsi.haddr(MEM_ADDR_SIZE-1+2 downto 2) <= scmo.address;        -- address bus (byte)
59
        ahbsi.haddr(1 downto 0) <= (others => '0');
60
        ahbsi.haddr(31 downto MEM_ADDR_SIZE+2) <= (others => '0');
61
        ahbsi.hwrite <= scmo.wr;                                                -- read/write
62
        ahbsi.htrans <= HTRANS_NONSEQ;                                  -- transfer type
63
        ahbsi.hsize <= "010";                                                   -- transfer size 32 bits
64
        ahbsi.hburst <= HBURST_SINGLE;                                  -- burst type
65
        ahbsi.hwdata <= reg_wr_data;                                    -- write data bus
66
        ahbsi.hprot <= "0000";          -- ? protection control
67
        ahbsi.hready <= '1';            -- ? transer done 
68
        ahbsi.hmaster <= "0000";                                                -- current master
69
        ahbsi.hmastlock <= '0';          -- locked access
70
        ahbsi.hmbsel(0) <= '0';                                                   -- memory bank select
71
        ahbsi.hmbsel(1) <= '1';                                                 -- second is SRAM
72
        ahbsi.hmbsel(2 to NAHBAMR-1) <= (others => '0');
73
        ahbsi.hcache <= '1';                                                    -- cacheable
74
        ahbsi.hirq <= (others => '0');                                   -- interrupt result bus
75
 
76
 
77
 
78
 
79
--
80
--      Register write data
81
--
82
process(clk, reset)
83
begin
84
        if reset='1' then
85
 
86
                reg_wr_data <= (others => '0');
87
 
88
        elsif rising_edge(clk) then
89
 
90
                if scmo.wr='1' then
91
                        reg_wr_data <= scmo.wr_data;
92
                end if;
93
 
94
        end if;
95
end process;
96
 
97
--
98
--      next state logic
99
--
100
process(state, scmo, ahbso.hready)
101
 
102
begin
103
 
104
        next_state <= state;
105
 
106
        case state is
107
 
108
                when idl =>
109
                        if scmo.rd='1' then
110
                                next_state <= rdw;
111
                        elsif scmo.wr='1' then
112
                                next_state <= wrw;
113
                        end if;
114
 
115
                when rdw =>
116
                        if ahbso.hready='1' then
117
                                next_state <= rd;
118
                        end if;
119
 
120
                when rd =>
121
                        next_state <= idl;
122
                        if scmo.rd='1' then
123
                                next_state <= rdw;
124
                        elsif scmo.wr='1' then
125
                                next_state <= wrw;
126
                        end if;
127
 
128
                when wrw =>
129
                        if ahbso.hready='1' then
130
                                next_state <= wr;
131
                        end if;
132
 
133
                when wr =>
134
                        next_state <= idl;
135
                        if scmo.rd='1' then
136
                                next_state <= rdw;
137
                        elsif scmo.wr='1' then
138
                                next_state <= wrw;
139
                        end if;
140
 
141
 
142
        end case;
143
 
144
end process;
145
 
146
--
147
--      state machine register
148
--      and output register
149
--
150
process(clk, reset)
151
 
152
begin
153
        if (reset='1') then
154
                state <= idl;
155
                reg_rd_data <= (others => '0');
156
 
157
        elsif rising_edge(clk) then
158
 
159
                state <= next_state;
160
 
161
                case next_state is
162
 
163
                        when idl =>
164
 
165
                        when rdw =>
166
 
167
                        when rd =>
168
                                reg_rd_data <= ahbso.hrdata;
169
 
170
                        when wrw =>
171
 
172
                        when wr =>
173
 
174
                end case;
175
 
176
        end if;
177
end process;
178
 
179
--
180
--      combinatorial state machine output
181
--
182
process(next_state)
183
 
184
begin
185
 
186
        scmi.rdy_cnt <= "00";
187
        scmi.rd_data <= reg_rd_data;
188
 
189
        case next_state is
190
 
191
                when idl =>
192
 
193
                when rdw =>
194
                        scmi.rdy_cnt <= "11";
195
 
196
                when rd =>
197
                        scmi.rd_data <= ahbso.hrdata;
198
 
199
                when wrw =>
200
                        scmi.rdy_cnt <= "11";
201
 
202
                when wr =>
203
 
204
        end case;
205
 
206
end process;
207
 
208
end rtl;

powered by: WebSVN 2.1.0

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