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

Subversion Repositories xucpu

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

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

powered by: WebSVN 2.1.0

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