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

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [core/] [ds_dma64/] [pcie_src/] [pcie_core64_m1/] [source_s6/] [pcie_bram_s6.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dsmv
-------------------------------------------------------------------------------
2
--
3
-- (c) Copyright 2008, 2009 Xilinx, Inc. All rights reserved.
4
--
5
-- This file contains confidential and proprietary information
6
-- of Xilinx, Inc. and is protected under U.S. and
7
-- international copyright and other intellectual property
8
-- laws.
9
--
10
-- DISCLAIMER
11
-- This disclaimer is not a license and does not grant any
12
-- rights to the materials distributed herewith. Except as
13
-- otherwise provided in a valid license issued to you by
14
-- Xilinx, and to the maximum extent permitted by applicable
15
-- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
16
-- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
17
-- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
18
-- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
19
-- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
20
-- (2) Xilinx shall not be liable (whether in contract or tort,
21
-- including negligence, or under any other theory of
22
-- liability) for any loss or damage of any kind or nature
23
-- related to, arising under or in connection with these
24
-- materials, including for any direct, or any indirect,
25
-- special, incidental, or consequential loss or damage
26
-- (including loss of data, profits, goodwill, or any type of
27
-- loss or damage suffered as a result of any action brought
28
-- by a third party) even if such damage or loss was
29
-- reasonably foreseeable or Xilinx had been advised of the
30
-- possibility of the same.
31
--
32
-- CRITICAL APPLICATIONS
33
-- Xilinx products are not designed or intended to be fail-
34
-- safe, or for use in any application requiring fail-safe
35
-- performance, such as life-support or safety devices or
36
-- systems, Class III medical devices, nuclear facilities,
37
-- applications related to the deployment of airbags, or any
38
-- other applications that could lead to death, personal
39
-- injury, or severe property or environmental damage
40
-- (individually and collectively, "Critical
41
-- Applications"). Customer assumes the sole risk and
42
-- liability of any use of Xilinx products in Critical
43
-- Applications, subject only to applicable laws and
44
-- regulations governing limitations on product liability.
45
--
46
-- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
47
-- PART OF THIS FILE AT ALL TIMES.
48
--
49
-------------------------------------------------------------------------------
50
-- Project    : Spartan-6 Integrated Block for PCI Express
51
-- File       : pcie_bram_s6.vhd
52
-- Description: BlockRAM module for Spartan-6 PCIe Block
53
--              The BRAM A port is the write port.
54
--              The BRAM B port is the read port.
55
--
56
-------------------------------------------------------------------------------
57
 
58
library ieee;
59
use ieee.std_logic_1164.all;
60
use ieee.std_logic_unsigned.all;
61
 
62
library unisim;
63
use unisim.vcomponents.all;
64
 
65
entity pcie_bram_s6 is
66
  generic (
67
    DOB_REG   : integer := 0; --  1 use output register, 0 don't use output register
68
    WIDTH     : integer := 0  --  supported WIDTH values are: 4, 9, 18, 36
69
  );
70
  port (
71
    user_clk_i   : in  std_logic; --  user clock
72
    reset_i      : in  std_logic; --  bram reset
73
 
74
    wen_i        : in  std_logic; --  write enable
75
    waddr_i      : in  std_logic_vector(11 downto 0); --  write address
76
    wdata_i      : in  std_logic_vector(WIDTH-1 downto 0); --  write data
77
 
78
    ren_i        : in  std_logic; --  read enable
79
    rce_i        : in  std_logic; --  output register clock enable
80
    raddr_i      : in  std_logic_vector(11 downto 0); --  read address
81
 
82
    rdata_o      : out std_logic_vector(WIDTH-1 downto 0) --  read data
83
  );
84
end pcie_bram_s6;
85
 
86
architecture rtl of pcie_bram_s6 is
87
 
88
  function CALC_ADDR(constant WIDTH : in integer;
89
                     constant addr_in : in std_logic_vector(11 downto 0)
90
                    ) return std_logic_vector is
91
    variable ADDR : std_logic_vector(13 downto 0);
92
  begin
93
    if    WIDTH = 4 then  ADDR := addr_in(11 downto 0) & "00";
94
    elsif WIDTH = 9 then  ADDR := addr_in(10 downto 0) & "000";
95
    elsif WIDTH = 18 then ADDR := addr_in(9  downto 0) & "0000";
96
    else                  ADDR := addr_in(8  downto 0) & "00000"; -- WIDTH=36
97
    end if;
98
    return ADDR;
99
  end function CALC_ADDR;
100
 
101
  signal di_int     : std_logic_vector(31 downto 0);
102
  signal dip_int    : std_logic_vector(3 downto 0);
103
  signal do_int     : std_logic_vector(31 downto 0);
104
  signal dop_int    : std_logic_vector(3 downto 0);
105
  signal waddr_int  : std_logic_vector(13 downto 0);
106
  signal raddr_int  : std_logic_vector(13 downto 0);
107
  signal wen_int    : std_logic_vector(3 downto 0);
108
 
109
begin
110
 
111
  --synthesis translate_off
112
  process
113
  begin
114
    case WIDTH is
115
      when 4 | 9 | 18 | 36 =>
116
        null;
117
      when others =>
118
        report "ERROR: WIDTH size " & integer'image(WIDTH) & " is not supported."
119
          severity failure;
120
    end case;
121
    wait;
122
  end process;
123
  --synthesis translate_on
124
 
125
  -- Wire up BRAM I/Os to module I/Os - map data & parity bits appropriately
126
  width_36 : if (WIDTH = 36) generate
127
    di_int                <= wdata_i(31 downto 0);
128
    dip_int               <= wdata_i(35 downto 32);
129
    rdata_o(35 downto 32) <= dop_int;
130
    rdata_o(31 downto 0)  <= do_int;
131
  end generate width_36;
132
 
133
  width_18 : if (WIDTH = 18) generate
134
    di_int(31 downto 16)  <= (OTHERS => '0');
135
    di_int(15 downto 0)   <= wdata_i(15 downto 0);
136
    dip_int(3 downto 2)   <= (OTHERS => '0');
137
    dip_int(1 downto 0)   <= wdata_i(17 downto 16);
138
    rdata_o(17 downto 16) <= dop_int(1 downto 0);
139
    rdata_o(15 downto 0)  <= do_int(15 downto 0);
140
  end generate width_18;
141
 
142
  width_9 : if (WIDTH = 9) generate
143
    di_int(31 downto 8)   <= (OTHERS => '0');
144
    di_int(7 downto 0)    <= wdata_i(7 downto 0);
145
    dip_int(3 downto 1)   <= (OTHERS => '0');
146
    dip_int(0)            <= wdata_i(8);
147
    rdata_o(8)            <= dop_int(0);
148
    rdata_o(7 downto 0)   <= do_int(7 downto 0);
149
  end generate width_9;
150
 
151
  width_4 : if (WIDTH = 4) generate
152
    di_int(31 downto 4)   <= (OTHERS => '0');
153
    di_int(3 downto 0)    <= wdata_i(3 downto 0);
154
    dip_int               <= (OTHERS => '0');
155
    rdata_o               <= do_int(3 downto 0);
156
  end generate width_4;
157
 
158
  waddr_int <= CALC_ADDR(WIDTH, waddr_i);
159
  raddr_int <= CALC_ADDR(WIDTH, raddr_i);
160
  wen_int   <= wen_i & wen_i & wen_i & wen_i;
161
 
162
  ramb16 : RAMB16BWER
163
  generic map (
164
    DATA_WIDTH_A  => WIDTH,
165
    DATA_WIDTH_B  => WIDTH,
166
    DOA_REG       => 0,
167
    DOB_REG       => DOB_REG,
168
    WRITE_MODE_A  => "NO_CHANGE",
169
    WRITE_MODE_B  => "NO_CHANGE"
170
  )
171
  port map (
172
    CLKA           => user_clk_i,
173
    RSTA           => reset_i,
174
    DOA            => open,
175
    DOPA           => open,
176
    ADDRA          => waddr_int,
177
    DIA            => di_int,
178
    DIPA           => dip_int,
179
    ENA            => wen_i,
180
    WEA            => wen_int,
181
    REGCEA         => '0',
182
 
183
    CLKB           => user_clk_i,
184
    RSTB           => reset_i,
185
    WEB            => "0000",
186
    DIB            => x"00000000",
187
    DIPB           => "0000",
188
    ADDRB          => raddr_int,
189
    DOB            => do_int,
190
    DOPB           => dop_int,
191
    ENB            => ren_i,
192
    REGCEB         => rce_i
193
  );
194
 
195
end rtl;
196
 

powered by: WebSVN 2.1.0

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