1 |
6 |
mgeng |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- Single port asynchronous RAM simulation model ----
|
4 |
|
|
---- ----
|
5 |
|
|
---- This file is part of the single_port project ----
|
6 |
|
|
---- ----
|
7 |
|
|
---- Description ----
|
8 |
|
|
---- This is a single port asynchronous memory. This files ----
|
9 |
|
|
---- describes three architectures. Two architectures are ----
|
10 |
|
|
---- traditional array based memories. One describes the memory ----
|
11 |
|
|
---- as an array of STD_LOGIC_VECTOR, and the other describes ----
|
12 |
|
|
---- the ARRAY as BIT_VECTOR. ----
|
13 |
|
|
---- The third architecture describes the memory arranged as a ----
|
14 |
|
|
---- linked list in order to conserve computer memory usage. The ----
|
15 |
|
|
---- memory is organized as a linked list of BIT_VECTOR arrays ----
|
16 |
|
|
---- whose size is defined by the constant PAGEDEPTH in ----
|
17 |
|
|
---- single_port_pkg.vhd. ----
|
18 |
|
|
---- ----
|
19 |
|
|
---- Authors: ----
|
20 |
|
|
---- - Robert Paley, rpaley_yid@yahoo.com ----
|
21 |
|
|
---- - Michael Geng, vhdl@MichaelGeng.de ----
|
22 |
|
|
---- ----
|
23 |
|
|
---- References: ----
|
24 |
|
|
---- 1. The Designer's Guide to VHDL by Peter Ashenden ----
|
25 |
|
|
---- ISBN: 1-55860-270-4 (pbk.) ----
|
26 |
|
|
---- 2. Writing Testbenches - Functional Verification of HDL ----
|
27 |
|
|
---- models by Janick Bergeron | ISBN: 0-7923-7766-4 ----
|
28 |
|
|
---- ----
|
29 |
|
|
----------------------------------------------------------------------
|
30 |
|
|
---- ----
|
31 |
|
|
---- Copyright (C) 2005 Authors and OPENCORES.ORG ----
|
32 |
|
|
---- ----
|
33 |
|
|
---- This source file may be used and distributed without ----
|
34 |
|
|
---- restriction provided that this copyright statement is not ----
|
35 |
|
|
---- removed from the file and that any derivative work contains ----
|
36 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
37 |
|
|
---- ----
|
38 |
|
|
---- This source file is free software; you can redistribute it ----
|
39 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
40 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
41 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
42 |
|
|
---- later version. ----
|
43 |
|
|
---- ----
|
44 |
|
|
---- This source is distributed in the hope that it will be ----
|
45 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
46 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
47 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
48 |
|
|
---- details. ----
|
49 |
|
|
---- ----
|
50 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
51 |
|
|
---- Public License along with this source; if not, download it ----
|
52 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
53 |
|
|
---- ----
|
54 |
|
|
----------------------------------------------------------------------
|
55 |
2 |
rpaley_yid |
--
|
56 |
6 |
mgeng |
-- CVS Revision History
|
57 |
2 |
rpaley_yid |
--
|
58 |
6 |
mgeng |
-- $Log: not supported by cvs2svn $
|
59 |
|
|
-- Revision 1.1.1.1 2003/01/14 21:48:11 rpaley_yid
|
60 |
|
|
-- initial checkin
|
61 |
2 |
rpaley_yid |
--
|
62 |
6 |
mgeng |
-- Revision 1.1 2003/01/14 17:48:31 Default
|
63 |
|
|
-- Initial revision
|
64 |
|
|
--
|
65 |
|
|
-- Revision 1.1 2002/12/24 18:09:05 Default
|
66 |
|
|
-- Initial revision
|
67 |
|
|
--
|
68 |
2 |
rpaley_yid |
LIBRARY IEEE;
|
69 |
|
|
USE IEEE.STD_LOGIC_1164.ALL;
|
70 |
|
|
USE IEEE.NUMERIC_STD.ALL;
|
71 |
|
|
USE WORK.single_port_pkg.ALL;
|
72 |
|
|
USE WORK.linked_list_mem_pkg.ALL;
|
73 |
|
|
|
74 |
|
|
ENTITY single_port IS
|
75 |
|
|
GENERIC (
|
76 |
6 |
mgeng |
rnwtQ : TIME := 1 NS);
|
77 |
2 |
rpaley_yid |
PORT (
|
78 |
6 |
mgeng |
d : IN STD_LOGIC_VECTOR;
|
79 |
|
|
q : OUT STD_LOGIC_VECTOR;
|
80 |
|
|
a : IN STD_LOGIC_VECTOR;
|
81 |
|
|
rnw : IN STD_LOGIC;
|
82 |
|
|
dealloc_mem : IN BOOLEAN := FALSE);
|
83 |
2 |
rpaley_yid |
END ENTITY single_port;
|
84 |
|
|
|
85 |
|
|
ARCHITECTURE ArrayMemNoFlag OF single_port IS
|
86 |
|
|
BEGIN
|
87 |
|
|
|
88 |
6 |
mgeng |
mem_proc : PROCESS(d, a, rnw)
|
89 |
|
|
TYPE mem_typ IS ARRAY ( 0 TO PAGENUM*PAGEDEPTH-1 ) OF STD_LOGIC_VECTOR(d'RANGE);
|
90 |
2 |
rpaley_yid |
VARIABLE mem : mem_typ;
|
91 |
|
|
BEGIN
|
92 |
|
|
IF ( rnw = '0') THEN -- Write
|
93 |
|
|
mem(TO_INTEGER(unsigned(a))) := d;
|
94 |
|
|
ELSE -- Read
|
95 |
|
|
q <= mem(TO_INTEGER(unsigned(a))) AFTER rnwtQ;
|
96 |
|
|
END IF;
|
97 |
|
|
END PROCESS mem_proc;
|
98 |
|
|
|
99 |
|
|
END ArrayMemNoFlag;
|
100 |
|
|
|
101 |
|
|
ARCHITECTURE ArrayMem OF single_port IS
|
102 |
|
|
BEGIN
|
103 |
|
|
|
104 |
6 |
mgeng |
mem_proc : PROCESS(d, a, rnw)
|
105 |
|
|
TYPE mem_typ IS ARRAY ( 0 TO PAGENUM*PAGEDEPTH-1 ) OF BIT_VECTOR(d'RANGE);
|
106 |
2 |
rpaley_yid |
TYPE flag_typ IS ARRAY ( 0 TO PAGENUM*PAGEDEPTH-1 ) OF BOOLEAN;
|
107 |
6 |
mgeng |
VARIABLE mem : mem_typ;
|
108 |
2 |
rpaley_yid |
VARIABLE flag : flag_typ;
|
109 |
|
|
BEGIN
|
110 |
|
|
IF ( rnw = '0') THEN -- Write
|
111 |
|
|
mem(TO_INTEGER(unsigned(a))) := TO_BITVECTOR(d);
|
112 |
|
|
flag(TO_INTEGER(unsigned(a))) := true; -- set valid memory location flag
|
113 |
|
|
ELSE -- read data, either valid or 'U'
|
114 |
|
|
IF ( flag(TO_INTEGER(unsigned(a))) = true ) THEN
|
115 |
|
|
q <= TO_STDLOGICVECTOR(mem(TO_INTEGER(unsigned(a)))) AFTER rnwtQ;
|
116 |
|
|
ELSE -- reading invalid memory location
|
117 |
6 |
mgeng |
q <= (q'RANGE => 'U') after rnwtQ;
|
118 |
2 |
rpaley_yid |
END IF;
|
119 |
|
|
END IF;
|
120 |
|
|
END PROCESS mem_proc;
|
121 |
|
|
END ArrayMem;
|
122 |
|
|
|
123 |
|
|
ARCHITECTURE LinkedList OF single_port IS
|
124 |
6 |
mgeng |
CONSTANT WRITE_MEM : BOOLEAN := true;
|
125 |
|
|
CONSTANT READ_MEM : BOOLEAN := false;
|
126 |
|
|
BEGIN
|
127 |
2 |
rpaley_yid |
|
128 |
6 |
mgeng |
mem_proc : PROCESS(d, a, rnw, dealloc_mem)
|
129 |
|
|
VARIABLE mem_page_v : mem_page_ptr;
|
130 |
|
|
VARIABLE d_v : STD_LOGIC_VECTOR(d'RANGE);
|
131 |
|
|
VARIABLE a_v : addr_typ;
|
132 |
2 |
rpaley_yid |
BEGIN
|
133 |
|
|
IF NOT dealloc_mem THEN
|
134 |
|
|
d_v := d;
|
135 |
|
|
a_v := TO_INTEGER(unsigned(a));
|
136 |
|
|
IF ( rnw = '0' ) THEN -- write to linked list memory
|
137 |
6 |
mgeng |
rw_mem( data => d_v,
|
138 |
|
|
addr => a_v,
|
139 |
|
|
next_cell => mem_page_v,
|
140 |
|
|
write_flag => WRITE_MEM);
|
141 |
2 |
rpaley_yid |
ELSE -- read from linked list memory
|
142 |
6 |
mgeng |
rw_mem( data => d_v,
|
143 |
|
|
addr => a_v,
|
144 |
|
|
next_cell => mem_page_v,
|
145 |
|
|
write_flag => READ_MEM);
|
146 |
2 |
rpaley_yid |
q <= d_v after rnwtQ;
|
147 |
|
|
END IF;
|
148 |
|
|
ELSE -- Deallocate memory from work station memory.
|
149 |
|
|
deallocate_mem(mem_page_v);
|
150 |
|
|
END IF;
|
151 |
|
|
END PROCESS mem_proc;
|
152 |
|
|
|
153 |
|
|
END LinkedList;
|