1 |
3 |
mgeng |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- Synchronous static RAM ("Zero Bus Turnaround" RAM, ZBT RAM) ----
|
4 |
|
|
---- simulation model ----
|
5 |
|
|
---- ----
|
6 |
|
|
---- This file is part of the simu_mem project ----
|
7 |
|
|
---- ----
|
8 |
|
|
---- Description ----
|
9 |
|
|
---- State definition and next state calculation function for ----
|
10 |
|
|
---- the ZBT RAM model ----
|
11 |
|
|
---- ----
|
12 |
|
|
---- Authors: ----
|
13 |
|
|
---- - Michael Geng, vhdl@MichaelGeng.de ----
|
14 |
|
|
---- ----
|
15 |
|
|
----------------------------------------------------------------------
|
16 |
|
|
---- ----
|
17 |
|
|
---- Copyright (C) 2008 Authors ----
|
18 |
|
|
---- ----
|
19 |
|
|
---- This source file may be used and distributed without ----
|
20 |
|
|
---- restriction provided that this copyright statement is not ----
|
21 |
|
|
---- removed from the file and that any derivative work contains ----
|
22 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
23 |
|
|
---- ----
|
24 |
|
|
---- This source file is free software; you can redistribute it ----
|
25 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
26 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
27 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
28 |
|
|
---- later version. ----
|
29 |
|
|
---- ----
|
30 |
|
|
---- This source is distributed in the hope that it will be ----
|
31 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
32 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
33 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
34 |
|
|
---- details. ----
|
35 |
|
|
---- ----
|
36 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
37 |
|
|
---- Public License along with this source; if not, download it ----
|
38 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
39 |
|
|
---- ----
|
40 |
|
|
----------------------------------------------------------------------
|
41 |
|
|
-- CVS Revision History
|
42 |
|
|
--
|
43 |
|
|
-- $Log: not supported by cvs2svn $
|
44 |
|
|
--
|
45 |
|
|
LIBRARY IEEE;
|
46 |
|
|
USE IEEE.STD_LOGIC_1164.ALL;
|
47 |
|
|
|
48 |
|
|
PACKAGE ZBT_RAM_pkg IS
|
49 |
|
|
TYPE state_type IS (
|
50 |
|
|
sleep,
|
51 |
|
|
deselect,
|
52 |
|
|
deselect_continue,
|
53 |
|
|
read,
|
54 |
|
|
read_continue,
|
55 |
|
|
dummy_read,
|
56 |
|
|
dummy_read_continue,
|
57 |
|
|
write,
|
58 |
|
|
write_continue,
|
59 |
|
|
write_abort,
|
60 |
|
|
write_abort_continue,
|
61 |
|
|
invalid_state);
|
62 |
|
|
|
63 |
|
|
FUNCTION calc_state (
|
64 |
|
|
CS1_n : STD_LOGIC;
|
65 |
|
|
CS2 : STD_LOGIC;
|
66 |
|
|
CS2_n : STD_LOGIC;
|
67 |
|
|
WE_n : STD_LOGIC;
|
68 |
|
|
BW_n : STD_LOGIC_VECTOR;
|
69 |
|
|
OE_n : STD_LOGIC;
|
70 |
|
|
ADV : STD_LOGIC;
|
71 |
|
|
ZZ : STD_LOGIC;
|
72 |
|
|
operation : state_type) RETURN state_type;
|
73 |
|
|
|
74 |
|
|
FUNCTION calc_operation (
|
75 |
|
|
state : state_type;
|
76 |
|
|
operation : state_type) RETURN state_type;
|
77 |
|
|
END PACKAGE ZBT_RAM_pkg;
|
78 |
|
|
|
79 |
|
|
PACKAGE BODY ZBT_RAM_pkg IS
|
80 |
|
|
FUNCTION calc_state (
|
81 |
|
|
CS1_n : STD_LOGIC;
|
82 |
|
|
CS2 : STD_LOGIC;
|
83 |
|
|
CS2_n : STD_LOGIC;
|
84 |
|
|
WE_n : STD_LOGIC;
|
85 |
|
|
BW_n : STD_LOGIC_VECTOR;
|
86 |
|
|
OE_n : STD_LOGIC;
|
87 |
|
|
ADV : STD_LOGIC;
|
88 |
|
|
ZZ : STD_LOGIC;
|
89 |
|
|
operation : state_type) RETURN state_type IS
|
90 |
|
|
VARIABLE selected : BOOLEAN;
|
91 |
|
|
BEGIN
|
92 |
|
|
selected := ((CS1_n = '0') AND (CS2 = '1') AND (CS2_n = '0'));
|
93 |
|
|
|
94 |
|
|
IF (ZZ = '1') THEN
|
95 |
|
|
RETURN sleep;
|
96 |
|
|
ELSIF ((ADV = '0') AND (NOT selected)) THEN
|
97 |
|
|
RETURN deselect;
|
98 |
|
|
ELSIF ((ADV = '1') AND (operation = deselect)) THEN
|
99 |
|
|
RETURN deselect_continue;
|
100 |
|
|
ELSIF (selected AND (ADV = '0') AND (WE_n = '1') AND (OE_n = '0')) THEN
|
101 |
|
|
RETURN read;
|
102 |
|
|
ELSIF ((ADV = '1') AND (OE_n = '0') AND (operation = Read)) THEN
|
103 |
|
|
RETURN read_continue;
|
104 |
|
|
ELSIF (selected AND (ADV = '0') AND (WE_n = '1') AND (OE_n = '1')) THEN
|
105 |
|
|
RETURN dummy_read;
|
106 |
|
|
ELSIF ((ADV = '1') AND (OE_n = '1') AND (operation = Read)) THEN
|
107 |
|
|
RETURN dummy_read_continue;
|
108 |
|
|
ELSIF (selected AND (ADV = '0') AND (WE_n = '0') AND (BW_n /= (BW_n'range => '1'))) THEN
|
109 |
|
|
RETURN write;
|
110 |
|
|
ELSIF ((ADV = '1') AND (BW_n /= (BW_n'range => '1')) AND (operation = write)) THEN
|
111 |
|
|
RETURN write_continue;
|
112 |
|
|
ELSIF (selected AND (ADV = '0') AND (WE_n = '0') AND (BW_n = (BW_n'range => '1')) AND
|
113 |
|
|
(operation = Write)) THEN
|
114 |
|
|
RETURN write_abort;
|
115 |
|
|
ELSIF ((ADV = '1') AND (BW_n = (BW_n'range => '1')) AND (operation = write_abort)) THEN
|
116 |
|
|
RETURN write_abort_continue;
|
117 |
|
|
ELSE
|
118 |
|
|
RETURN invalid_state;
|
119 |
|
|
END IF;
|
120 |
|
|
END FUNCTION calc_state;
|
121 |
|
|
|
122 |
|
|
FUNCTION calc_operation (
|
123 |
|
|
state : state_type;
|
124 |
|
|
operation : state_type) RETURN state_type IS
|
125 |
|
|
BEGIN
|
126 |
|
|
CASE state IS
|
127 |
|
|
WHEN deselect | write | write_abort | read =>
|
128 |
|
|
RETURN state;
|
129 |
|
|
WHEN dummy_read =>
|
130 |
|
|
RETURN read;
|
131 |
|
|
WHEN OTHERS =>
|
132 |
|
|
RETURN operation;
|
133 |
|
|
END CASE;
|
134 |
|
|
END FUNCTION calc_operation;
|
135 |
|
|
END PACKAGE BODY ZBT_RAM_pkg;
|