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

Subversion Repositories xucpu

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

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
      w_addr   : NATURAL RANGE 8 TO 14 := 10);
36
    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
USE std.textio.ALL;
53
USE ieee.std_logic_textio.ALL;
54 15 lcdsgmtr
USE work.ram_parts.ALL;
55 2 lcdsgmtr
 
56 15 lcdsgmtr
ENTITY memory IS
57 2 lcdsgmtr
 
58
  -- Memory component based upon Xilinx Spartan-6 block RAM
59
  -- Maximum capacity is 16k words
60
  -- This component can be initialised by passing a file name as a generic
61
  -- parameter.
62
 
63
  GENERIC (
64
    filename : STRING                := "";
65
    w_data   : NATURAL RANGE 1 TO 32 := 16;
66 15 lcdsgmtr
    w_addr   : NATURAL RANGE 8 TO 15 := 10);
67 2 lcdsgmtr
  PORT (
68
    clk : IN  STD_LOGIC;
69
    we  : IN  STD_LOGIC;
70
    a1  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);  -- Data port address
71
    a2  : IN  STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);  -- Instruction port address
72
    d1  : IN  STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);  -- Data port input
73
    q1  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);  -- Data port output
74
    q2  : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));  -- Instruction port output
75
 
76 15 lcdsgmtr
END memory;
77 2 lcdsgmtr
 
78 15 lcdsgmtr
ARCHITECTURE Structural OF memory IS
79 2 lcdsgmtr
 
80
BEGIN  -- Structural
81
 
82 15 lcdsgmtr
  SMALL_MEM : IF w_data >= 8 AND w_data <= 14 GENERATE
83
    MEM0 : RAM_GENERIC
84 2 lcdsgmtr
      GENERIC MAP (
85 15 lcdsgmtr
        filename => filename,
86 2 lcdsgmtr
        w_data   => w_data,
87 15 lcdsgmtr
        w_addr   => w_addr)
88 2 lcdsgmtr
      PORT MAP (
89
        clk => clk,
90 15 lcdsgmtr
        we  => we,
91
        a1  => a1,
92
        a2  => a2,
93 2 lcdsgmtr
        d1  => d1,
94 15 lcdsgmtr
        q1  => q1,
95
        q2  => q2);
96
  END GENERATE SMALL_MEM;
97 2 lcdsgmtr
 
98 15 lcdsgmtr
  LARGE_MEM : IF w_data = 15 GENERATE
99
    MEM1: RAM32K
100
    GENERIC MAP (
101
      filename => filename,
102
      w_data => w_data)
103
    PORT MAP (
104
      clk => clk,
105
      we  => we,
106
      a1  => a1,
107
      a2  => a2,
108
      d1  => d1,
109
      q1  => q1,
110
      q2  => q2);
111
  END GENERATE LARGE_MEM;
112 2 lcdsgmtr
 
113
END Structural;
114
 

powered by: WebSVN 2.1.0

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