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

Subversion Repositories simpcon

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 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 17 martin
--      sc2wb.vhd
24
--
25
--      SimpCon/Wishbone bridge
26
--
27
--      Author: Martin Schoeberl        martin@jopdesign.com
28
--
29
--
30
--          
31
--          WISHBONE DATA SHEET
32
--          
33
--          Revision Level: B.3, Released: September 7, 2002
34
--          Type: MASTER
35
--          
36
--          Signals: record and address size is defined in wb_pack.vhd
37
--          
38
--          Port    Width   Direction   Description
39
--          ------------------------------------------------------------------------
40
--          clk       1     Input       Master clock, see JOP top level
41
--          reset     1     Input       Reset, see JOP top level
42
--          dat_o    32     Output      Data from SimpCon
43
--          adr_o     8     Output      Address bits for the slaves, see wb_pack.vhd
44
--                                      Only addr_bits bits are actually used
45
--          we_o      1     Output      Write enable output
46
--          cyc_o     1     Output      Valid bus cycle output
47
--          stb_o     1     Output      Strobe signal output
48
--          dat_i    32     Input       Data from the slaves to JOP
49
--          ack_i     1     Input       Bus cycle acknowledge input
50
--          
51
--          Port size: 32-bit
52
--          Port granularity: 32-bit
53
--          Maximum operand size: 32-bit
54
--          Data transfer ordering: BIG/LITTLE ENDIAN
55
--          Sequence of data transfer: UNDEFINED
56
--          
57
--          
58
--      2005-12-20      first version
59
--
60
--
61
 
62
 
63
library ieee ;
64
use ieee.std_logic_1164.all ;
65
use ieee.numeric_std.all ;
66
 
67
use work.wb_pack.all;
68
 
69
entity sc2wb is
70
 
71
generic (addr_bits : integer);
72
port (
73
        clk             : in std_logic;
74
        reset   : in std_logic;
75
 
76
-- SimpCon interface
77
 
78
        address         : in std_logic_vector(addr_bits-1 downto 0);
79
        wr_data         : in std_logic_vector(31 downto 0);
80
        rd, wr          : in std_logic;
81
        rd_data         : out std_logic_vector(31 downto 0);
82
        rdy_cnt         : out unsigned(1 downto 0);
83
 
84
-- Wishbone interfac
85
 
86
        wb_out  : out wb_master_out_type;
87
        wb_in   : in wb_master_in_type
88
 
89
);
90
end sc2wb;
91
 
92
architecture rtl of sc2wb is
93
 
94
--
95
--      Wishbone specific signals
96
--
97
        signal wb_data                          : std_logic_vector(31 downto 0);         -- output of wishbone module
98
        signal wb_addr                          : std_logic_vector(7 downto 0);          -- wishbone read/write address
99
        signal wb_rd, wb_wr, wb_bsy     : std_logic;
100
        signal wb_rd_reg, wb_wr_reg     : std_logic;
101
 
102
begin
103
 
104
--
105
--      Wishbone interface
106
--
107
 
108
        -- just use the SimpCon rd/wr
109
        wb_rd <= rd;
110
        wb_wr <= wr;
111
 
112
        rd_data <= wb_data;
113
 
114
        wb_out.adr_o <= wb_addr;
115
 
116
        rdy_cnt <= "11" when wb_bsy='1' else "00";
117
 
118
--
119
--      Handle the Wishbone protocoll.
120
--      rd and wr request are registered for additional WSs.
121
--
122
process(clk, reset)
123
begin
124
        if (reset='1') then
125
 
126
                wb_addr <= (others => '0');
127
 
128
                wb_out.stb_o <= '0';
129
                wb_out.cyc_o <= '0';
130
                wb_out.we_o <= '0';
131
 
132
                wb_rd_reg <= '0';
133
                wb_wr_reg <= '0';
134
                wb_bsy <= '0';
135
 
136
        elsif rising_edge(clk) then
137
 
138
                -- read request:
139
                -- address is registered from SimpCon address and valid in the next
140
                -- cycle
141
                if wb_rd='1' then
142
                        -- store read address
143
                        wb_addr(M_ADDR_SIZE-1 downto addr_bits) <= (others => '0');
144
                        wb_addr(addr_bits-1 downto 0) <= address;
145
 
146
                        wb_out.stb_o <= '1';
147
                        wb_out.cyc_o <= '1';
148
                        wb_out.we_o <= '0';
149
                        wb_rd_reg <= '1';
150
                        wb_bsy <= '1';
151
                elsif wb_rd_reg='1' then
152
                        -- do we need a timeout???
153
                        if wb_in.ack_i='1' then
154
                                wb_out.stb_o <= '0';
155
                                wb_out.cyc_o <= '0';
156
                                wb_rd_reg <= '0';
157
                                wb_bsy <= '0';
158
                                wb_data <= wb_in.dat_i;
159
                        end if;
160
                -- write request
161
                -- address and data are stored and valid in
162
                -- the next cycle
163
                elsif wb_wr='1' then
164
                        -- store write address
165
                        wb_addr(M_ADDR_SIZE-1 downto addr_bits) <= (others => '0');
166
                        wb_addr(addr_bits-1 downto 0) <= address;
167
 
168
                        -- this keeps the write data registered,
169
                        -- but costs a latency of one cycle.
170
                        wb_out.dat_o <= wr_data;
171
 
172
                        wb_out.stb_o <= '1';
173
                        wb_out.cyc_o <= '1';
174
                        wb_out.we_o <= '1';
175
                        wb_wr_reg <= '1';
176
                        wb_bsy <= '1';
177
                elsif wb_wr_reg='1' then
178
                        -- do we need a timeout???
179
                        if wb_in.ack_i='1' then
180
                                wb_out.stb_o <= '0';
181
                                wb_out.cyc_o <= '0';
182
                                wb_out.we_o <= '0';
183
                                wb_wr_reg <= '0';
184
                                wb_bsy <= '0';
185
                        end if;
186
                end if;
187
 
188
        end if;
189
end process;
190
 
191
end rtl;

powered by: WebSVN 2.1.0

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