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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [src/] [components/] [BRAM/] [RAM.vhdl] - Blame information for rev 20

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

Line No. Rev Author Line
1 2 lcdsgmtr
-- Copyright 2015, Jürgen Defurne
2
--
3
-- This file is part of the Experimental Unstable CPU System.
4
--
5
-- The Experimental Unstable CPU System Is free software: you can redistribute
6
-- it and/or modify it under the terms of the GNU Lesser General Public License
7
-- as published by the Free Software Foundation, either version 3 of the
8
-- License, or (at your option) any later version.
9
--
10
-- The Experimental Unstable CPU System is distributed in the hope that it will
11
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
13
-- General Public License for more details.
14
--
15
-- You should have received a copy of the GNU Lesser General Public License
16
-- along with Experimental Unstable CPU System. If not, see
17
-- http://www.gnu.org/licenses/lgpl.txt.
18
 
19 15 lcdsgmtr
-- This package is the main interface to the memory. When defining
20
-- different sizes, this package generates the main component.
21
-- The components themselves are responsible for using the contents
22
-- of the passed file name to initialise the memory array.
23 2 lcdsgmtr
 
24
LIBRARY ieee;
25
USE ieee.std_logic_1164.ALL;
26
USE ieee.numeric_std.ALL;
27
 
28 15 lcdsgmtr
PACKAGE RAM IS
29 2 lcdsgmtr
 
30 15 lcdsgmtr
  COMPONENT memory IS
31 2 lcdsgmtr
 
32
    GENERIC (
33
      filename : STRING                := "";
34
      w_data   : NATURAL RANGE 1 TO 32 := 16;
35 20 lcdsgmtr
      w_addr   : NATURAL RANGE 8 TO 15 := 10);
36 2 lcdsgmtr
    PORT (
37
      clk : IN  STD_LOGIC;
38
      we  : IN  STD_LOGIC;
39
      a1  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);  -- Data port address
40
      a2  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);  -- Instruction port address
41
      d1  : IN  STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);  -- Data port input
42
      q1  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);  -- Data port output
43
      q2  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));  -- Instruction port output
44
 
45 15 lcdsgmtr
  END COMPONENT memory;
46 2 lcdsgmtr
 
47 15 lcdsgmtr
END PACKAGE RAM;
48 2 lcdsgmtr
 
49
LIBRARY ieee;
50
USE ieee.std_logic_1164.ALL;
51
USE ieee.numeric_std.ALL;
52 15 lcdsgmtr
USE work.ram_parts.ALL;
53 2 lcdsgmtr
 
54 15 lcdsgmtr
ENTITY memory IS
55 2 lcdsgmtr
 
56
  -- Memory component based upon Xilinx Spartan-6 block RAM
57
  -- Maximum capacity is 16k words
58
  -- This component can be initialised by passing a file name as a generic
59
  -- parameter.
60
 
61
  GENERIC (
62
    filename : STRING                := "";
63
    w_data   : NATURAL RANGE 1 TO 32 := 16;
64 15 lcdsgmtr
    w_addr   : NATURAL RANGE 8 TO 15 := 10);
65 2 lcdsgmtr
  PORT (
66
    clk : IN  STD_LOGIC;
67
    we  : IN  STD_LOGIC;
68
    a1  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);  -- Data port address
69
    a2  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);  -- Instruction port address
70
    d1  : IN  STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);  -- Data port input
71
    q1  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);  -- Data port output
72
    q2  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));  -- Instruction port output
73
 
74 15 lcdsgmtr
END memory;
75 2 lcdsgmtr
 
76 15 lcdsgmtr
ARCHITECTURE Structural OF memory IS
77 2 lcdsgmtr
 
78
BEGIN  -- Structural
79
 
80 15 lcdsgmtr
  SMALL_MEM : IF w_data >= 8 AND w_data <= 14 GENERATE
81
    MEM0 : RAM_GENERIC
82 2 lcdsgmtr
      GENERIC MAP (
83 15 lcdsgmtr
        filename => filename,
84 2 lcdsgmtr
        w_data   => w_data,
85 15 lcdsgmtr
        w_addr   => w_addr)
86 2 lcdsgmtr
      PORT MAP (
87
        clk => clk,
88 15 lcdsgmtr
        we  => we,
89
        a1  => a1,
90
        a2  => a2,
91 2 lcdsgmtr
        d1  => d1,
92 15 lcdsgmtr
        q1  => q1,
93
        q2  => q2);
94
  END GENERATE SMALL_MEM;
95 2 lcdsgmtr
 
96 15 lcdsgmtr
  LARGE_MEM : IF w_data = 15 GENERATE
97
    MEM1: RAM32K
98
    GENERIC MAP (
99
      filename => filename,
100
      w_data => w_data)
101
    PORT MAP (
102
      clk => clk,
103
      we  => we,
104
      a1  => a1,
105
      a2  => a2,
106
      d1  => d1,
107
      q1  => q1,
108
      q2  => q2);
109
  END GENERATE LARGE_MEM;
110 2 lcdsgmtr
 
111
END Structural;
112
 

powered by: WebSVN 2.1.0

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