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

Subversion Repositories pci32tlite_oc

[/] [pci32tlite_oc/] [trunk/] [rtl/] [pcidmux.vhd] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 peio
--+-------------------------------------------------------------------------------------------------+
2
--|                                                                                                                                                                                                     |
3
--|  File:                      pcidmux.vhd                                                                             |
4
--|                                                                                                                                                                                                     |
5
--|  Project:           pci32tLite                                                                                                                                              |
6
--|                                                                                                                                                                                                     |
7
--|  Description:       Data Multiplex wb <-> regs <-> pci                                                                                              |
8
--|                                 Data Multiplex D16 whisbone <-> D32 PCI.                                            |
9
--|                                                                                                                                                                                                     |
10
--+-------------------------------------------------------------------------------------------------+
11
--+-----------------------------------------------------------------+
12
--|                                                                                                                             |
13
--|  Copyright (C) 2005-2008 Peio Azkarate, peio.azkarate@gmail.com     | 
14
--|                                                                                                                             |
15
--|  This source file may be used and distributed without               |
16
--|  restriction provided that this copyright statement is not          |
17
--|  removed from the file and that any derivative work contains        |
18
--|  the original copyright notice and the associated disclaimer.       |
19
--|                                                                     |
20
--|  This source file is free software; you can redistribute it     |
21
--|  and/or modify it under the terms of the GNU Lesser General     |
22
--|  Public License as published by the Free Software Foundation;   |
23
--|  either version 2.1 of the License, or (at your option) any     |
24
--|  later version.                                                 |
25
--|                                                                                                                             |
26
--|  This source is distributed in the hope that it will be         |
27
--|  useful, but WITHOUT ANY WARRANTY; without even the implied     |
28
--|  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR        |
29
--|  PURPOSE.  See the GNU Lesser General Public License for more   |
30
--|  details.                                                       |
31
--|                                                                                                                             |
32
--|  You should have received a copy of the GNU Lesser General      |
33
--|  Public License along with this source; if not, download it     |
34
--|  from http://www.opencores.org/lgpl.shtml                       |
35
--|                                                                                                                             |
36
--+-----------------------------------------------------------------+ 
37
 
38
 
39
--+-----------------------------------------------------------------------------+
40
--|                                                                     LIBRARIES                                                                       |
41
--+-----------------------------------------------------------------------------+
42
 
43
library ieee;
44
use ieee.std_logic_1164.all;
45
 
46
--+-----------------------------------------------------------------------------+
47
--|                                                                     ENTITY                                                                          |
48
--+-----------------------------------------------------------------------------+
49
 
50
entity pcidmux is
51
generic (
52
        BARS             : string := "1BARMEM";
53
        WBSIZE           : integer := 16;
54
        WBENDIAN         : string := "BIG"
55
);
56
port (
57
 
58
        -- General 
59
    clk_i               : in std_logic;
60
        rst_i           : in std_logic;
61
        --  
62
        d_io                    : inout std_logic_vector(31 downto 0);
63
        pcidatout_o             : out std_logic_vector(31 downto 0);
64
        --
65
        pcidOE_i                : in std_logic;
66
        wbdatLD_i       : in std_logic;
67
        rdcfg_i                 : in std_logic;
68
        cbe_i                   : in std_logic_vector(3 downto 0);
69
        --
70
        wb_dat_i                : in std_logic_vector((WBSIZE-1) downto 0);
71
        wb_dat_o                : out std_logic_vector((WBSIZE-1) downto 0);
72
        rg_dat_i                : in std_logic_vector(31 downto 0);
73
        rg_dat_o                : out std_logic_vector(31 downto 0)
74
 
75
);
76
end pcidmux;
77
 
78
 
79
architecture rtl of pcidmux is
80
 
81
 
82
--+-----------------------------------------------------------------------------+
83
--|                                                                     COMPONENTS                                                                      |
84
--+-----------------------------------------------------------------------------+
85
--+-----------------------------------------------------------------------------+
86
--|                                                                     CONSTANTS                                                                       |
87
--+-----------------------------------------------------------------------------+
88
--+-----------------------------------------------------------------------------+
89
--|                                                                     SIGNALS                                                                         |
90
--+-----------------------------------------------------------------------------+
91
 
92
        signal pcidatin         : std_logic_vector(31 downto 0);
93
        signal pcidatout        : std_logic_vector(31 downto 0);
94
        signal wb_dat_is        : std_logic_vector((WBSIZE-1) downto 0);
95
        signal wbrgdMX          : std_logic;
96
        signal wbdMX            : std_logic_vector(1 downto 0);
97
 
98
begin
99
 
100
        -- Mux control signals
101
        wbrgdMX <= not rdcfg_i;
102
        wbdMX(0) <= '0' when ( cbe_i(0) = '0' or cbe_i(2) = '0' ) else '1';
103
        wbdMX(1) <= '0' when ( cbe_i(0) = '0' or cbe_i(1) = '0' ) else '1';
104
 
105
    --+-------------------------------------------------------------------------+
106
        --|  Load Whisbone Datain                                                                                                       |
107
    --+-------------------------------------------------------------------------+
108
 
109
        WBDATLD: process( rst_i, clk_i, wbdatLD_i, wb_dat_i )
110
        begin
111
 
112
                if( rst_i = '1' ) then
113
                        wb_dat_is <= ( others => '1' );
114
                elsif( rising_edge(clk_i) ) then
115
 
116
                        if ( wbdatLD_i = '1' ) then
117
                                wb_dat_is <= wb_dat_i;
118
                        end if;
119
 
120
                end if;
121
 
122
        end process WBDATLD;
123
 
124
 
125
    --+-------------------------------------------------------------------------+
126
        --|  Route PCI data in toward Registers and Whisbone                                            |
127
    --+-------------------------------------------------------------------------+
128
        rg_dat_o <= pcidatin;
129
 
130
 
131
    --+-------------------------------------------------------------------------+
132
        --|  PCI <-> WB Data route and swap                                                                                     |
133
    --+-------------------------------------------------------------------------+
134
        --+-----------------------------------------+
135
        --| PCI(Little endian) <-> WB(Little endian)|
136
        --| WB bus 32Bits                                                       |
137
    --+-----------------------------------------+
138
        dat32: if (WBSIZE = 32 and WBENDIAN = "LITTLE") generate
139
                pcidatout(31 downto 0)  <= wb_dat_is(31 downto 0) when ( wbrgdMX = '1' ) else rg_dat_i(31 downto 0);
140
                wb_dat_o(31 downto 0)   <= pcidatin(31 downto 0);
141
        end generate;
142
 
143
        --+-----------------------------------------+
144
        --| PCI(Little endian) <-> WB(Big endian)       |
145
        --| WB bus 16Bits                                                       |
146
    --+-----------------------------------------+
147
        dat16b: if (WBSIZE = 16 and WBENDIAN = "BIG") generate
148
                --pcidatout(31 downto 24) <= wb_dat_is(7 downto 0) when ( wbrgdMX_i = '1' ) else rg_dat_i(31 downto 24);
149
                --pcidatout(23 downto 16) <= wb_dat_is(15 downto 8) when ( wbrgdMX_i = '1' ) else rg_dat_i(23 downto 16);
150
                --pcidatout(15 downto 8)  <= wb_dat_is(7 downto 0) when ( wbrgdMX_i = '1' ) else rg_dat_i(15 downto 8);
151
                --pcidatout(7 downto 0)   <= wb_dat_is(15 downto 8) when ( wbrgdMX_i = '1' ) else rg_dat_i(7 downto 0);
152
                --wb_dat_o(15 downto 8)   <= pcidatin(23 downto 16) when ( wbdMX_i(1) = '1' ) else pcidatin(7 downto 0);
153
                --wb_dat_o(7 downto 0)    <= pcidatin(31 downto 24) when ( wbdMX_i(1) = '1' ) else pcidatin(15 downto 8);
154
        PCIWBMUX: process(cbe_i, pcidatin, wbrgdMX, wb_dat_is, rg_dat_i)
155
            begin
156
                case cbe_i is
157
                    when b"1100" =>
158
                        wb_dat_o(7 downto 0)  <= pcidatin(7 downto 0);
159
                        wb_dat_o(15 downto 8) <= pcidatin(15 downto 8);
160
                    when b"0011" =>
161
                        wb_dat_o(7 downto 0)  <= pcidatin(23 downto 16);
162
                        wb_dat_o(15 downto 8) <= pcidatin(31 downto 24);
163
                    when b"1110" =>
164
                        wb_dat_o(7 downto 0)  <= (others => '1');
165
                        wb_dat_o(15 downto 8) <= pcidatin(7 downto 0);
166
                    when b"1101" =>
167
                        wb_dat_o(7 downto 0)  <= pcidatin(15 downto 8);
168
                        wb_dat_o(15 downto 8) <= (others => '1');
169
                    when b"1011" =>
170
                        wb_dat_o(7 downto 0)  <= (others => '1');
171
                        wb_dat_o(15 downto 8) <= pcidatin(23 downto 16);
172
                    when b"0111" =>
173
                        wb_dat_o(7 downto 0)  <= pcidatin(31 downto 24);
174
                        wb_dat_o(15 downto 8) <= (others => '1');
175
                        when others    =>
176
                                            wb_dat_o(15 downto 0) <= pcidatin(15 downto 0);
177
                end case;
178
 
179
                if (wbrgdMX = '1') then
180
                    case cbe_i is
181
                        when b"1100" =>
182
                            pcidatout(31 downto 16) <= (others => '1');
183
                            pcidatout(15 downto 0) <= wb_dat_is(15 downto 0);
184
                        when b"0011" =>
185
                            pcidatout(31 downto 16) <= wb_dat_is(15 downto 0);
186
                            pcidatout(15 downto 0) <= (others => '1');
187
                        when b"1110" =>
188
                            pcidatout(31 downto 8) <= (others => '1');
189
                            pcidatout(7 downto 0) <= wb_dat_is(15 downto 8);
190
                        when b"1101" =>
191
                            pcidatout(31 downto 16) <= (others => '1');
192
                            pcidatout(15 downto 8) <= wb_dat_is(7 downto 0);
193
                            pcidatout(7 downto 0) <= (others => '1');
194
                        when b"1011" =>
195
                            pcidatout(31 downto 24) <= (others => '1');
196
                            pcidatout(23 downto 16) <= wb_dat_is(15 downto 8);
197
                            pcidatout(15 downto 0) <= (others => '1');
198
                        when b"0111" =>
199
                            pcidatout(31 downto 24) <= wb_dat_is(7 downto 0);
200
                            pcidatout(23 downto 0) <= (others => '1');
201
                            when others    =>
202
                            pcidatout(15 downto 0) <= wb_dat_is(15 downto 0);
203
                            pcidatout(31 downto 16) <= (others => '1');
204
                    end case;
205
                else
206
                    pcidatout(31 downto 0) <= rg_dat_i(31 downto 0);
207
                end if;
208
 
209
        end process PCIWBMUX;
210
 
211
        end generate;
212
 
213
        --+-----------------------------------------+
214
        --| PCI(Little endian) <-> WB(Little endian)|
215
        --| WB bus 16Bits                                                       |
216
    --+-----------------------------------------+
217
        dat16l: if (WBSIZE = 16 and WBENDIAN = "LITTLE") generate
218
                pcidatout(31 downto 16) <= wb_dat_is when ( wbrgdMX = '1' ) else rg_dat_i(31 downto 16);
219
                pcidatout(15 downto 0)  <= wb_dat_is when ( wbrgdMX = '1' ) else rg_dat_i(15 downto 0);
220
                wb_dat_o(15 downto 0)   <= pcidatin(31 downto 16) when ( wbdMX(1) = '1' ) else pcidatin(15 downto 0);
221
        end generate;
222
 
223
        --+-----------------------------------------+
224
        --| PCI(Little endian) <-> WB(Little endian)|
225
        --| WB bus 8Bits                                                        |
226
    --+-----------------------------------------+
227
        dat8l: if (WBSIZE = 8 and WBENDIAN = "LITTLE") generate
228
                --pcidatout(31 downto 24) <= wb_dat_is(7 downto 0);
229
                --pcidatout(23 downto 16) <= wb_dat_is(7 downto 0);
230
                --pcidatout(15 downto 8)  <= wb_dat_is(7 downto 0);
231
                --pcidatout(7 downto 0)   <= wb_dat_is(7 downto 0);
232
                pcidatout(31 downto 24) <= wb_dat_is(7 downto 0) when ( wbrgdMX = '1' ) else rg_dat_i(31 downto 24);
233
                pcidatout(23 downto 16) <= wb_dat_is(7 downto 0) when ( wbrgdMX = '1' ) else rg_dat_i(23 downto 16);
234
                pcidatout(15 downto 8)  <= wb_dat_is(7 downto 0) when ( wbrgdMX = '1' ) else rg_dat_i(15 downto 8);
235
                pcidatout(7 downto 0)   <= wb_dat_is(7 downto 0) when ( wbrgdMX = '1' ) else rg_dat_i(7 downto 0);
236
                with wbdMX select
237
                        wb_dat_o(7 downto 0) <= pcidatin(7 downto 0)   when "00",
238
                                                                        pcidatin(15 downto 8)  when "01",
239
                                                                        pcidatin(23 downto 16) when "10",
240
                                                                        pcidatin(31 downto 24) when "11",
241
                                                                        (others => '0')        when others;
242
        end generate;
243
 
244
 
245
        --+-----------------------------------------+
246
        --| Data out for parity generation                      |
247
    --+-----------------------------------------+
248
        pcidatout_o <= pcidatout;
249
 
250
    --+-------------------------------------------------------------------------+
251
        --|  PCI data in/out with Triestate                                                                                     |
252
    --+-------------------------------------------------------------------------+
253
        pcidatin <= d_io;
254
        d_io <= pcidatout when ( pcidOE_i = '1' ) else ( others => 'Z' );
255
 
256
end rtl;

powered by: WebSVN 2.1.0

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