w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
mt45w8mw16b.vhd
Go to the documentation of this file.
1-- $Id: mt45w8mw16b.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2010-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: mt45w8mw16b - sim
7-- Description: Micron MT45W8MW16B CellularRAM model
8-- Currently a much simplified model
9-- - only async accesses
10-- - ignores CLK
11-- - simple model for response of DATA lines, but no
12-- check for timing violations of control lines
13--
14-- Dependencies: -
15-- Test bench: -
16-- Target Devices: generic
17-- Tool versions: xst 11.4-14.7; ghdl 0.26-0.33
18-- Revision History:
19-- Date Rev Version Comment
20-- 2016-08-18 799 1.4.1 remove 'assert false' from report statements
21-- 2016-07-10 786 1.4 add RCR handling; page mode by default now off !!
22-- 2015-12-26 718 1.3.3 BUGFIX: initialize L_ADDR with all '1', see comment
23-- 2011-11-19 427 1.3.2 now numeric_std clean
24-- 2010-06-03 299 1.3.1 improved timing model (WE cycle, robust T_apa)
25-- 2010-06-03 298 1.3 add timing model again
26-- 2010-05-28 295 1.2 drop timing (was incorrect), pure functional now
27-- 2010-05-21 293 1.1 add BCR (only read of default so far)
28-- 2010-05-16 291 1.0 Initial version (inspired by is61lv25616al)
29------------------------------------------------------------------------------
30-- Truth table accoring to data sheet:
31--
32-- Asynchronous Mode (BCR(15)=1)
33-- Operation CLK ADV_N CE_N OE_N WE_N CRE xB_N WT DATA
34-- Read L L L L H L L act data-out
35-- Write L L L X L L L act data-in
36-- Standby L X H X X L X 'z' 'z'
37-- CRE write L L L H L H X act 'z'
38-- CRE read L L L L H H L act conf-out
39--
40-- Burst Mode (BCR(15)=0)
41-- Operation CLK ADV_N CE_N OE_N WE_N CRE xB_N WT DATA
42-- Async read L L L L H L L act data-out
43-- Async write L L L X L L L act data-in
44-- Standby L X H X X L X 'z' 'z'
45-- Initial burst read 0-1 L L X H L L act X
46-- Initial burst write 0-1 L L H L L X act X
47-- Burst continue 0-1 H L X X X X act data-in/out
48-- CRE write 0-1 L L H L H X act 'z'
49-- CRE read 0-1 L L L H H L act conf-out
50--
51
52library ieee;
53use ieee.std_logic_1164.all;
54use ieee.numeric_std.all;
55
56use work.slvtypes.all;
57
58entity mt45w8mw16b is -- Micron MT45W8MW16B CellularRAM model
59 port (
60 CLK : in slbit; -- clock for synchonous operation
61 CE_N : in slbit; -- chip enable (act.low)
62 OE_N : in slbit; -- output enable (act.low)
63 WE_N : in slbit; -- write enable (act.low)
64 UB_N : in slbit; -- upper byte enable (act.low)
65 LB_N : in slbit; -- lower byte enable (act.low)
66 ADV_N : in slbit; -- address valid (act.low)
67 CRE : in slbit; -- control register enable
68 MWAIT : out slbit; -- wait (for burst read/write)
69 ADDR : in slv23; -- address lines
70 DATA : inout slv16 -- data lines
71 );
72end mt45w8mw16b;
73
74
75architecture sim of mt45w8mw16b is
76
77 -- timing constants for -701 speed grade (70 ns; 104 MHz)
78 constant T_aa : Delay_length := 70 ns; -- address access time (max)
79 constant T_apa : Delay_length := 20 ns; -- page access time (max)
80 constant T_oh : Delay_length := 5 ns; -- output hold from addr change (max)
81 constant T_oe : Delay_length := 20 ns; -- output enable to valid output (max)
82 constant T_ohz : Delay_length := 8 ns; -- output disable to high-z out (max)
83 constant T_olz : Delay_length := 3 ns; -- output enable to low-z output (min)
84 constant T_lz : Delay_length := 10 ns; -- chip enable to low-z output (min)
85 constant T_hz : Delay_length := 8 ns; -- chip disable to high-z output (max)
86
87 constant memsize : positive := 2**(ADDR'length);
88 constant datzero : slv(DATA'range) := (others=>'0');
89 type ram_type is array (0 to memsize-1) of slv(DATA'range);
90
91 subtype xcr_f_sel is integer range 19 downto 18; -- cre register select
92 constant xcr_sel_rcr : slv2 := "00";
93 constant xcr_sel_bcr : slv2 := "10";
94
95 constant bcr_f_mode : integer := 15; -- operating mode
96 constant bcr_f_ilat : integer := 14; -- initial latency
97 subtype bcr_f_lc is integer range 13 downto 11; -- latency counter
98 constant bcr_f_wp : integer := 10; -- wait polarity
99 constant bcr_f_wc : integer := 8; -- wait configuration
100 subtype bcr_f_drive is integer range 5 downto 4; -- drive strength
101 constant bcr_f_bw : integer := 3; -- burst wrap
102 subtype bcr_f_bl is integer range 2 downto 0; -- burst length
103
104 subtype rcr_f_res3 is integer range 22 downto 20; -- reserved - MBZ
105 subtype rcr_f_res2 is integer range 17 downto 8; -- reserved - MBZ
106 constant rcr_f_pmode : integer := 7; -- page mode (1=ena)
107 subtype rcr_f_res1 is integer range 6 downto 5; -- reserved - MBZ
108 constant rcr_f_dpd : integer := 4; -- dpd mode (1=dis)
109 constant rcr_f_res0 : integer := 3; -- reserved - MBZ
110 subtype rcr_f_par is integer range 2 downto 0; -- array conf (000=all)
111
112 subtype f_byte1 is integer range 15 downto 8;
113 subtype f_byte0 is integer range 7 downto 0;
114
115 signal CE : slbit := '0';
116 signal OE : slbit := '0';
117 signal WE : slbit := '0';
118 signal BE_L : slbit := '0';
119 signal BE_U : slbit := '0';
120 signal ADV : slbit := '0';
121 signal WE_L_EFF : slbit := '0';
122 signal WE_U_EFF : slbit := '0';
123 signal WE_C_EFF : slbit := '0';
124
125 signal R_BCR_MODE : slbit := '1'; -- mode: def: async
126 signal R_BCR_ILAT : slbit := '0'; -- ilat: def: variable
127 signal R_BCR_LC : slv3 := "011"; -- lc: def: code 3
128 signal R_BCR_WP : slbit := '1'; -- wp: def: active high
129 signal R_BCR_WC : slbit := '1'; -- wc: def: assert one before
130 signal R_BCR_DRIVE : slv2 := "01"; -- drive:def: 1/2
131 signal R_BCR_BW : slbit := '1'; -- bw: def: no wrap
132 signal R_BCR_BL : slv3 := "111"; -- bl: def: continuous
133
134 signal R_RCR_PMODE : slbit := '0'; -- pmode:def: disabled (ena=1 !)
135 signal R_RCR_DPD : slbit := '1'; -- dpd: def: disabled (ena=0 !)
136 signal R_RCR_PAR : slv3 := "000"; -- par: def: full array
137 signal R_T_APA_EFF : Delay_length := T_aa; -- page mode disabled by default
138
139 signal L_ADDR : slv23 := (others=>'1'); -- all '1' for propper 1st access
140 signal DOUT_VAL_EN : slbit := '0';
141 signal DOUT_VAL_AA : slbit := '0';
142 signal DOUT_VAL_PA : slbit := '0';
143 signal DOUT_VAL_OE : slbit := '0';
144 signal DOUT_LZ_CE : slbit := '0';
145 signal DOUT_LZ_OE : slbit := '0';
146
147 signal OEWE : slbit := '0';
148 signal DOUT : slv16 := (others=>'0');
149begin
150
151 CE <= not CE_N;
152 OE <= not OE_N;
153 WE <= not WE_N;
154 BE_L <= not LB_N;
155 BE_U <= not UB_N;
156 ADV <= not ADV_N;
157
158 WE_L_EFF <= CE and WE and BE_L and (not CRE);
159 WE_U_EFF <= CE and WE and BE_U and (not CRE);
160
161 WE_C_EFF <= CE and WE and CRE;
162
163 -- address valid logic, latch ADDR when ADV true
164 proc_adv: process (ADV, ADDR)
165 begin
166 if ADV = '1' then
167 L_ADDR <= ADDR;
168 end if;
169 end process proc_adv;
170
171 -- Notes:
172 -- 1. the row change (t_aa) and column change (t_apa) timing depends on the
173 -- recognition of address changes and of page changes. To keep the logic
174 -- simple L_ADDR and addr_last are initialized with all '1'. This gives
175 -- proper behaviour unless the very first access uses the very last
176 -- address. In w11a systems, with use only 4 MB, this can't happen, in
177 -- most other use cases this is very unlikely.
178
179 proc_dout_val: process (CE, OE, WE, BE_L, BE_U, ADV, L_ADDR)
180 variable addr_last : slv23 := (others=>'1');-- all '1' for propper 1st access
181 begin
182 if (CE'event and CE='1') or
183 (BE_L'event and BE_L='1') or
184 (BE_U'event and BE_U='1') or
185 (WE'event and WE='0') or
186 (ADV'event and ADV='1') then
187 DOUT_VAL_EN <= '0', '1' after T_aa;
188 end if;
189 if L_ADDR'event then
190 DOUT_VAL_PA <= '0', '1' after R_T_APA_EFF;
191 if L_ADDR(22 downto 4) /= addr_last(22 downto 4) then
192 DOUT_VAL_AA <= '0', '1' after T_aa;
193 end if;
194 addr_last := L_ADDR;
195 end if;
196 if rising_edge(OE) then
197 DOUT_VAL_OE <= '0', '1' after T_oe;
198 end if;
199 end process proc_dout_val;
200
201 -- to simplify things assume that OE and (not WE) have same effect on output
202 -- drivers. The timing rules are very similar indeed...
203 OEWE <= OE and (not WE);
204
205 proc_dout_lz: process (CE, OEWE)
206 begin
207 if (CE'event) then
208 if CE = '1' then
209 DOUT_LZ_CE <= '1' after T_lz;
210 else
211 DOUT_LZ_CE <= '0' after T_hz;
212 end if;
213 end if;
214 if (OEwe'event) then
215 if OEWE = '1' then
216 DOUT_LZ_OE <= '1' after T_olz;
217 else
218 DOUT_LZ_OE <= '0' after T_ohz;
219 end if;
220 end if;
221 end process proc_dout_lz;
222
223 proc_cram: process (WE_L_EFF, WE_U_EFF, L_ADDR, DATA)
224 variable ram : ram_type := (others=>datzero);
225 begin
226
227 -- end of write cycle
228 -- note: to_x01 used below to prevent that 'z' a written into mem.
229 if falling_edge(WE_L_EFF) then
230 ram(to_integer(unsigned(L_ADDR)))(f_byte0) := to_x01(DATA(f_byte0));
231 end if;
232 if falling_edge(WE_U_EFF) then
233 ram(to_integer(unsigned(L_ADDR)))(f_byte1) := to_x01(DATA(f_byte1));
234 end if;
235
236 DOUT <= ram(to_integer(unsigned(L_ADDR)));
237
238 end process proc_cram;
239
240 proc_cr: process (WE_C_EFF, L_ADDR)
241 begin
242 if falling_edge(WE_C_EFF) then
243 case L_ADDR(xcr_f_sel) is
244
245 when xcr_sel_rcr =>
247 if L_ADDR(rcr_f_pmode) = '1' then
249 else
250 R_T_APA_EFF <= T_aa;
251 end if;
252 assert L_ADDR(rcr_f_res3) = "000"
253 report "bad rcr write: 22:20 not zero" severity error;
254 assert L_ADDR(rcr_f_res2) = "0000000000"
255 report "bad rcr write: 17: 8 not zero" severity error;
256 assert L_ADDR(rcr_f_res1) = "00"
257 report "bad rcr write: 6: 5 not zero" severity error;
258 assert L_ADDR(rcr_f_dpd) = '1'
259 report "bad rcr write: dpd not '1'" severity error;
260 assert L_ADDR(rcr_f_res0) = '0'
261 report "bad rcr write: 3: 3 not zero" severity error;
262 assert L_ADDR(rcr_f_par) = "000"
263 report "bad rcr write: par not '000'" severity error;
264
265 when xcr_sel_bcr =>
266 report "bcr written - not supported" severity error;
267 when others =>
268 report "bad select field" severity error;
269 end case;
270 end if;
271 end process proc_cr;
272
275 variable idout : slv16 := (others=>'0');
276 begin
277 idout := DOUT;
278 if DOUT_VAL_EN='0' or DOUT_VAL_AA='0' or
279 DOUT_VAL_PA='0' or DOUT_VAL_OE='0' then
280 idout := (others=>'X');
281 end if;
282 if DOUT_LZ_CE='0' or DOUT_LZ_OE='0' then
283 idout := (others=>'Z');
284 end if;
285 DATA <= idout;
286 end process proc_data;
287
288 proc_mwait: process (CE)
289 begin
290 -- WT driver (just a dummy)
291 if CE = '1' then
292 MWAIT <= '1';
293 else
294 MWAIT <= 'Z';
295 end if;
296 end process proc_mwait;
297
298end sim;
slbit := '0' OEWE
slbit := '0' BE_L
slbit := '0' R_RCR_PMODE
slbit := '0' WE_U_EFF
Delay_length := 8 ns T_hz
Definition: mt45w8mw16b.vhd:85
integer := 10 bcr_f_wp
Definition: mt45w8mw16b.vhd:98
integer range 19 downto 18 xcr_f_sel
Definition: mt45w8mw16b.vhd:91
integer range 2 downto 0 bcr_f_bl
integer range 15 downto 8 f_byte1
slbit := '0' DOUT_LZ_CE
positive := 2**( ADDR'length) memsize
Definition: mt45w8mw16b.vhd:87
slv3 := "111" R_BCR_BL
integer range 7 downto 0 f_byte0
Delay_length := 3 ns T_olz
Definition: mt45w8mw16b.vhd:83
slbit := '0' DOUT_VAL_EN
slbit := '1' R_BCR_MODE
slbit := '1' R_BCR_WP
integer range 6 downto 5 rcr_f_res1
slbit := '1' R_BCR_BW
Delay_length := 8 ns T_ohz
Definition: mt45w8mw16b.vhd:82
Delay_length := 20 ns T_oe
Definition: mt45w8mw16b.vhd:81
Delay_length := 70 ns T_aa
Definition: mt45w8mw16b.vhd:78
slbit := '0' ADV
integer := 4 rcr_f_dpd
slbit := '0' CE
slbit := '0' DOUT_VAL_AA
slbit := '0' R_BCR_ILAT
integer range 5 downto 4 bcr_f_drive
Delay_length := 20 ns T_apa
Definition: mt45w8mw16b.vhd:79
integer := 14 bcr_f_ilat
Definition: mt45w8mw16b.vhd:96
Delay_length := T_aa R_T_APA_EFF
integer range 17 downto 8 rcr_f_res2
slv16 :=( others => '0') DOUT
slbit := '0' DOUT_LZ_OE
integer := 15 bcr_f_mode
Definition: mt45w8mw16b.vhd:95
slv3 := "011" R_BCR_LC
( 0 to memsize- 1) slv(DATA) ram_type
Definition: mt45w8mw16b.vhd:89
integer range 2 downto 0 rcr_f_par
integer range 13 downto 11 bcr_f_lc
Definition: mt45w8mw16b.vhd:97
integer := 8 bcr_f_wc
Definition: mt45w8mw16b.vhd:99
Delay_length := 5 ns T_oh
Definition: mt45w8mw16b.vhd:80
slbit := '0' DOUT_VAL_OE
slv23 :=( others => '1') L_ADDR
slbit := '1' R_BCR_WC
slv(DATA) :=( others => '0') datzero
Definition: mt45w8mw16b.vhd:88
integer := 3 bcr_f_bw
slv2 := "01" R_BCR_DRIVE
integer := 7 rcr_f_pmode
slbit := '0' OE
slbit := '0' DOUT_VAL_PA
Delay_length := 10 ns T_lz
Definition: mt45w8mw16b.vhd:84
integer range 22 downto 20 rcr_f_res3
slbit := '1' R_RCR_DPD
integer := 3 rcr_f_res0
slbit := '0' WE_C_EFF
slbit := '0' WE_L_EFF
slbit := '0' BE_U
slv2 := "00" xcr_sel_rcr
Definition: mt45w8mw16b.vhd:92
slv2 := "10" xcr_sel_bcr
Definition: mt45w8mw16b.vhd:93
slbit := '0' WE
slv3 := "000" R_RCR_PAR
in UB_N slbit
Definition: mt45w8mw16b.vhd:64
in CRE slbit
Definition: mt45w8mw16b.vhd:67
in WE_N slbit
Definition: mt45w8mw16b.vhd:63
in CLK slbit
Definition: mt45w8mw16b.vhd:60
out MWAIT slbit
Definition: mt45w8mw16b.vhd:68
in CE_N slbit
Definition: mt45w8mw16b.vhd:61
in OE_N slbit
Definition: mt45w8mw16b.vhd:62
in ADV_N slbit
Definition: mt45w8mw16b.vhd:66
in LB_N slbit
Definition: mt45w8mw16b.vhd:65
inout DATA slv16
Definition: mt45w8mw16b.vhd:71
in ADDR slv23
Definition: mt45w8mw16b.vhd:69
std_logic_vector( 22 downto 0) slv23
Definition: slvtypes.vhd:56
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 1 downto 0) slv2
Definition: slvtypes.vhd:34
std_logic_vector slv
Definition: slvtypes.vhd:31