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

Subversion Repositories opb_usblite

[/] [opb_usblite/] [trunk/] [pcores/] [opb_usblite_v1_00_a/] [hdl/] [vhdl/] [opb_usblite.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 rehnmaak
--
2
--    opb_usblite - opb_uartlite replacement
3
--
4
--    opb_usblite is using components from Rudolf Usselmann see
5
--    http://www.opencores.org/cores/usb_phy/
6
--    and Joris van Rantwijk see http://www.xs4all.nl/~rjoris/fpga/usb.html
7
--
8
--    Copyright (C) 2010 Ake Rehnman
9
--
10
--    This program is free software: you can redistribute it and/or modify
11
--    it under the terms of the GNU General Public License as published by
12
--    the Free Software Foundation, either version 3 of the License, or
13
--    (at your option) any later version.
14
--
15
--    This program is distributed in the hope that it will be useful,
16
--    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
--    GNU General Public License for more details.
19
--
20
--    You should have received a copy of the GNU General Public License
21
--    along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
--
23
library IEEE;
24
use IEEE.std_logic_1164.all;
25
 
26
entity OPB_USBLITE is
27
  generic (
28
    C_OPB_AWIDTH : integer                   := 32;
29
    C_OPB_DWIDTH : integer                   := 32;
30
    C_BASEADDR   : std_logic_vector(0 to 31) := X"FFFF_0000";
31
    C_HIGHADDR   : std_logic_vector          := X"FFFF_00FF";
32
    C_SYSRST  :       std_logic := '1';
33
    C_PHYMODE :       std_logic := '1';
34
    C_VENDORID :      std_logic_vector(15 downto 0) := X"1234";
35
    C_PRODUCTID :     std_logic_vector(15 downto 0) := X"5678";
36
    C_VERSIONBCD :    std_logic_vector(15 downto 0) := X"0200";
37
    C_SELFPOWERED :   boolean := false;
38
    C_RXBUFSIZE_BITS: integer range 7 to 12 := 10;
39
    C_TXBUFSIZE_BITS: integer range 7 to 12 := 10
40
    );
41
  port (
42
    -- Global signals
43
    OPB_Clk : in std_logic;
44
    OPB_Rst : in std_logic;
45
    SYS_Rst : in std_logic;
46
    USB_Clk : in std_logic;
47
    -- OPB signals
48
    OPB_ABus    : in std_logic_vector(0 to 31);
49
    OPB_BE      : in std_logic_vector(0 to 3);
50
    OPB_RNW     : in std_logic;
51
    OPB_select  : in std_logic;
52
    OPB_seqAddr : in std_logic;
53
    OPB_DBus    : in std_logic_vector(0 to 31);
54
    Sl_DBus    : out std_logic_vector(0 to 31);
55
    Sl_errAck  : out std_logic;
56
    Sl_retry   : out std_logic;
57
    Sl_toutSup : out std_logic;
58
    Sl_xferAck : out std_logic;
59
 
60
    -- Interrupt
61
    Interrupt : out std_logic;
62
 
63
    -- USB signals
64
                txdp : out std_logic;
65
                txdn : out std_logic;
66
                txoe : out std_logic;
67
                rxd : in std_logic;
68
                rxdp : in std_logic;
69
                rxdn : in std_logic
70
    );
71
 
72
end entity OPB_USBLITE;
73
 
74
library Common_v1_00_a;
75
use Common_v1_00_a.pselect;
76
 
77
library unisim;
78
use unisim.all;
79
 
80
library opb_usblite_v1_00_a;
81
use opb_usblite_v1_00_a.opb_usblite_core;
82
 
83
architecture akre of OPB_USBLITE is
84
 
85
  component pselect is
86
    generic (
87
      C_AB  : integer;
88
      C_AW  : integer;
89
      C_BAR : std_logic_vector);
90
    port (
91
      A      : in  std_logic_vector(0 to C_AW-1);
92
      AValid : in  std_logic;
93
      ps     : out std_logic);
94
  end component pselect;
95
 
96
  component OPB_USBLITE_Core is
97
  generic (
98
    C_PHYMODE :       std_logic := '1';
99
    C_VENDORID :      std_logic_vector(15 downto 0) := X"1234";
100
    C_PRODUCTID :     std_logic_vector(15 downto 0) := X"5678";
101
    C_VERSIONBCD :    std_logic_vector(15 downto 0) := X"0200";
102
    C_SELFPOWERED :   boolean := false;
103
    C_RXBUFSIZE_BITS: integer range 7 to 12 := 10;
104
    C_TXBUFSIZE_BITS: integer range 7 to 12 := 10
105
    );
106
  port (
107
    Clk   : in std_logic;
108
    Reset : in std_logic;
109
    Usb_Clk : in std_logic;
110
    -- OPB signals
111
    OPB_CS : in std_logic;
112
    OPB_ABus : in std_logic_vector(0 to 1);
113
    OPB_RNW  : in std_logic;
114
    OPB_DBus : in std_logic_vector(7 downto 0);
115
    SIn_xferAck : out std_logic;
116
    SIn_DBus    : out std_logic_vector(7 downto 0);
117
    Interrupt : out std_logic;
118
    -- USB signals
119
                txdp : out std_logic;
120
                txdn : out std_logic;
121
                txoe : out std_logic;
122
                rxd : in std_logic;
123
                rxdp : in std_logic;
124
                rxdn : in std_logic
125
  );
126
  end component OPB_USBLITE_Core;
127
 
128
  function nbits (x, y : std_logic_vector(0 to C_OPB_AWIDTH-1)) return integer is
129
  begin
130
    for i in 0 to C_OPB_AWIDTH-1 loop
131
      if x(i) /= y(i) then
132
        return i;
133
      end if;
134
    end loop;
135
    return(C_OPB_AWIDTH);
136
  end function nbits;
137
 
138
  constant C_NBITS : integer := nbits(C_HIGHADDR, C_BASEADDR);
139
 
140
  signal OPB_CS : std_logic;
141
  signal core_rst : std_logic;
142
 
143
begin  -- architecture akre
144
 
145
 
146
  -----------------------------------------------------------------------------
147
  -- OPB bus interface
148
  -----------------------------------------------------------------------------
149
 
150
  -- Do the OPB address decoding
151
  pselect_I : pselect
152
    generic map (
153
      C_AB  => C_NBITS,
154
      C_AW  => C_OPB_AWIDTH,
155
      C_BAR => C_BASEADDR)
156
    port map (
157
      A      => OPB_ABus,
158
      AValid => OPB_select,
159
      ps     => OPB_CS);
160
 
161
 
162
  Sl_errAck                    <= '0';
163
  Sl_retry                     <= '0';
164
  Sl_toutSup                   <= '0';
165
  Sl_DBus(0 to 23)             <= (others=>'0');
166
 
167
  -----------------------------------------------------------------------------
168
  -- Instanciating the USB core
169
  -----------------------------------------------------------------------------
170
 
171
  core_rst <= SYS_Rst when C_SYSRST='1' else OPB_Rst;
172
 
173
  OPB_USBLITE_Core_inst : OPB_USBLITE_Core
174
  generic map (
175
    C_PHYMODE => C_PHYMODE,
176
    C_VENDORID => C_VENDORID,
177
    C_PRODUCTID => C_PRODUCTID,
178
    C_VERSIONBCD => C_VERSIONBCD,
179
    C_SELFPOWERED => C_SELFPOWERED,
180
    C_RXBUFSIZE_BITS => C_RXBUFSIZE_BITS,
181
    C_TXBUFSIZE_BITS => C_TXBUFSIZE_BITS
182
    )
183
  port map (
184
    Clk   => OPB_Clk,
185
    Reset => core_rst,
186
    Usb_Clk => USB_Clk,
187
    -- OPB signals
188
    OPB_CS => OPB_CS,
189
    OPB_ABus => OPB_ABus(28 to 29),
190
    OPB_RNW  => OPB_RNW,
191
    OPB_DBus => OPB_DBus(24 to 31),
192
    SIn_xferAck => Sl_xferAck,
193
    SIn_DBus    => Sl_DBus(24 to 31),
194
    Interrupt => Interrupt,
195
    -- USB signals
196
                txdp => txdp,
197
                txdn => txdn,
198
                txoe => txoe,
199
                rxd => rxd,
200
                rxdp => rxdp,
201
                rxdn => rxdn
202
                );
203
 
204
end architecture akre;

powered by: WebSVN 2.1.0

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