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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [rtl/] [bplib/] [micron/] [mt45w8mw16b.vhd] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 wfjm
-- $Id: mt45w8mw16b.vhd 427 2011-11-19 21:04:11Z mueller $
2 2 wfjm
--
3 13 wfjm
-- Copyright 2010-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 2 wfjm
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
-- 
14
------------------------------------------------------------------------------
15
-- Module Name:    mt45w8mw16b - sim
16
-- Description:    Micron MT45W8MW16B CellularRAM model
17
--                 Currently a much simplified model
18
--                 - only async accesses
19
--                 - ignores CLK and CRE
20
--                 - simple model for response of DATA lines, but no
21
--                   check for timing violations of control lines
22
--
23
-- Dependencies:   -
24
-- Test bench:     -
25
-- Target Devices: generic
26 13 wfjm
-- Tool versions:  xst 11.4, 13.1; ghdl 0.26-0.29
27 2 wfjm
-- Revision History: 
28
-- Date         Rev Version  Comment
29 13 wfjm
-- 2011-11-19   427   1.3.2  now numeric_std clean
30 2 wfjm
-- 2010-06-03   299   1.3.1  improved timing model (WE cycle, robust T_apa)
31
-- 2010-06-03   298   1.3    add timing model again
32
-- 2010-05-28   295   1.2    drop timing (was incorrect), pure functional now
33
-- 2010-05-21   293   1.1    add BCR (only read of default so far)
34
-- 2010-05-16   291   1.0    Initial version (inspired by is61lv25616al)
35
------------------------------------------------------------------------------
36
-- Truth table accoring to data sheet:
37
--  
38
-- Asynchronous Mode (BCR(15)=1)
39
--   Operation               CLK ADV_N CE_N OE_N WE_N CRE xB_N WT  DATA
40
--   Read                     L     L    L    L    H   L    L  act data-out
41
--   Write                    L     L    L    X    L   L    L  act data-in
42
--   Standby                  L     X    H    X    X   L    X  'z' 'z'
43
--   CRE write                L     L    L    H    L   H    X  act 'z'
44
--   CRE read                 L     L    L    L    H   H    L  act conf-out
45
--
46
-- Burst Mode (BCR(15)=0)
47
--   Operation               CLK ADV_N CE_N OE_N WE_N CRE xB_N WT  DATA
48
--   Async read               L     L    L    L    H   L    L  act data-out
49
--   Async write              L     L    L    X    L   L    L  act data-in 
50
--   Standby                  L     X    H    X    X   L    X  'z' 'z'
51
--   Initial burst read      0-1    L    L    X    H   L    L  act  X
52
--   Initial burst write     0-1    L    L    H    L   L    X  act  X
53
--   Burst continue          0-1    H    L    X    X   X    X  act data-in/out
54
--   CRE write               0-1    L    L    H    L   H    X  act 'z'
55
--   CRE read                0-1    L    L    L    H   H    L  act conf-out
56
--
57
 
58
library ieee;
59
use ieee.std_logic_1164.all;
60 13 wfjm
use ieee.numeric_std.all;
61 2 wfjm
 
62
use work.slvtypes.all;
63
 
64
entity mt45w8mw16b is                   -- Micron MT45W8MW16B CellularRAM model
65
  port (
66
    CLK : in slbit;                     -- clock for synchonous operation
67
    CE_N : in slbit;                    -- chip enable        (act.low)
68
    OE_N : in slbit;                    -- output enable      (act.low)
69
    WE_N : in slbit;                    -- write enable       (act.low)
70
    UB_N : in slbit;                    -- upper byte enable  (act.low)
71
    LB_N : in slbit;                    -- lower byte enable  (act.low)
72
    ADV_N : in slbit;                   -- address valid      (act.low)
73
    CRE : in slbit;                     -- control register enable
74
    MWAIT : out slbit;                  -- wait (for burst read/write)
75
    ADDR : in slv23;                    -- address lines
76
    DATA : inout slv16                  -- data lines
77
  );
78
end mt45w8mw16b;
79
 
80
 
81
architecture sim of mt45w8mw16b is
82
 
83
  -- timing constants for -701 speed grade (70 ns; 104 MHz)
84
  constant T_aa   : time := 70 ns;      -- address access time             (max)
85
  constant T_apa  : time := 20 ns;      -- page acess time                 (max)
86
  constant T_oh   : time :=  5 ns;      -- output hold from addr change    (max)
87
  constant T_oe   : time := 20 ns;      -- output enable to valid output   (max)
88
  constant T_ohz  : time :=  8 ns;      -- output disable to high-z output (max)
89
  constant T_olz  : time :=  3 ns;      -- output enable to low-z output   (min)
90
  constant T_lz   : time := 10 ns;      -- chip enable to low-z output     (min)
91
  constant T_hz   : time :=  8 ns;      -- chip disable to high-z output   (max)
92
 
93
  constant memsize : positive := 2**(ADDR'length);
94
  constant datzero : slv(DATA'range) := (others=>'0');
95
  type ram_type is array (0 to memsize-1) of slv(DATA'range);
96
 
97
  constant bcr_f_mode   : integer := 15;              -- operating mode 
98
  constant bcr_f_ilat   : integer := 14;              -- initial latency
99
  subtype  bcr_f_lc    is integer range 13 downto 11; -- latency counter
100
  constant bcr_f_wp     : integer := 10;              -- wait polarity
101
  constant bcr_f_wc     : integer :=  8;              -- wait configuration
102
  subtype  bcr_f_drive is integer range  5 downto  4; -- drive strength
103
  constant bcr_f_bw     : integer :=  3;              -- burst wrap
104
  subtype  bcr_f_bl    is integer range  2 downto  0; -- burst length
105
 
106
  subtype  f_byte1       is integer range 15 downto 8;
107
  subtype  f_byte0       is integer range  7 downto 0;
108
 
109
  signal CE : slbit := '0';
110
  signal OE : slbit := '0';
111
  signal WE : slbit := '0';
112
  signal BE_L : slbit := '0';
113
  signal BE_U : slbit := '0';
114
  signal ADV : slbit := '0';
115
  signal WE_L_EFF : slbit := '0';
116
  signal WE_U_EFF : slbit := '0';
117
 
118
  signal R_BCR_MODE  : slbit := '1';    -- mode: def: async
119
  signal R_BCR_ILAT  : slbit := '0';    -- ilat: def: variable
120
  signal R_BCR_LC    : slv3  := "011";  -- lc:   def: code 3
121
  signal R_BCR_WP    : slbit := '1';    -- wp:   def: active high
122
  signal R_BCR_WC    : slbit := '1';    -- wc:   def: assert one before
123
  signal R_BCR_DRIVE : slv2  := "01";   -- drive:def: 1/2
124
  signal R_BCR_BW    : slbit := '1';    -- bw:   def: no wrap
125
  signal R_BCR_BL    : slv3  := "111";  -- bl:   def: continuous
126
 
127
  signal L_ADDR : slv23 := (others=>'0');
128
  signal DOUT_VAL_EN : slbit := '0';
129
  signal DOUT_VAL_AA : slbit := '0';
130
  signal DOUT_VAL_PA : slbit := '0';
131
  signal DOUT_VAL_OE : slbit := '0';
132
  signal DOUT_LZ_CE  : slbit := '0';
133
  signal DOUT_LZ_OE  : slbit := '0';
134
 
135
  signal OEWE : slbit := '0';
136
  signal DOUT : slv16 := (others=>'0');
137
begin
138
 
139
  CE   <= not CE_N;
140
  OE   <= not OE_N;
141
  WE   <= not WE_N;
142
  BE_L <= not LB_N;
143
  BE_U <= not UB_N;
144
  ADV  <= not ADV_N;
145
 
146
  WE_L_EFF <= CE and WE and BE_L;
147
  WE_U_EFF <= CE and WE and BE_U;
148
 
149
  -- address valid logic, latch ADDR when ADV true
150
  proc_adv: process (ADV, ADDR)
151
  begin
152
    if ADV = '1' then
153
      L_ADDR <= ADDR;
154
    end if;
155
  end process proc_adv;
156
 
157
  proc_dout_val: process (CE, OE, WE, BE_L, BE_U, ADV, L_ADDR)
158
    variable addr_last : slv23 := (others=>'1');
159
  begin
160
    if (CE'event   and CE='1') or
161
       (BE_L'event and BE_L='1') or
162
       (BE_U'event and BE_U='1') or
163
       (WE'event   and WE='0') or
164
       (ADV'event  and ADV='1') then
165
      DOUT_VAL_EN <= '0', '1' after T_aa;
166
    end if;
167
    if L_ADDR'event then
168
      DOUT_VAL_PA <= '0', '1' after T_apa;
169
      if L_ADDR(22 downto 4) /= addr_last(22 downto 4) then
170
        DOUT_VAL_AA <= '0', '1' after T_aa;
171
      end if;
172
      addr_last := L_ADDR;
173
    end if;
174 13 wfjm
    if rising_edge(OE) then
175 2 wfjm
      DOUT_VAL_OE <= '0', '1' after T_oe;
176
    end if;
177
  end process proc_dout_val;
178
 
179
  -- to simplify things assume that OE and (not WE) have same effect on output
180
  -- drivers. The timing rules are very similar indeed...
181
  OEWE <= OE and (not WE);
182
 
183
  proc_dout_lz: process (CE, OEWE)
184
  begin
185
    if (CE'event) then
186
      if CE = '1' then
187
        DOUT_LZ_CE <= '1' after T_lz;
188
      else
189
        DOUT_LZ_CE <= '0' after T_hz;
190
      end if;
191
    end if;
192
    if (OEwe'event) then
193
      if OEWE = '1' then
194
        DOUT_LZ_OE <= '1' after T_olz;
195
      else
196
        DOUT_LZ_OE <= '0' after T_ohz;
197
      end if;
198
    end if;
199
  end process proc_dout_lz;
200
 
201
  proc_cram: process (CE, OE, WE, WE_L_EFF, WE_U_EFF, L_ADDR, DATA)
202
    variable ram : ram_type := (others=>datzero);
203
  begin
204
 
205
    -- end of write cycle
206
    -- note: to_x01 used below to prevent that 'z' a written into mem.
207 13 wfjm
    if falling_edge(WE_L_EFF) then
208
      ram(to_integer(unsigned(L_ADDR)))(f_byte0) := to_x01(DATA(f_byte0));
209 2 wfjm
    end if;
210 13 wfjm
    if falling_edge(WE_U_EFF) then
211
      ram(to_integer(unsigned(L_ADDR)))(f_byte1) := to_x01(DATA(f_byte1));
212 2 wfjm
    end if;
213
 
214 13 wfjm
    DOUT <= ram(to_integer(unsigned(L_ADDR)));
215 2 wfjm
 
216
  end process proc_cram;
217
 
218
  proc_data: process (DOUT, DOUT_VAL_EN, DOUT_VAL_AA, DOUT_VAL_PA, DOUT_VAL_OE,
219
                      DOUT_LZ_CE, DOUT_LZ_OE)
220
    variable idout : slv16 := (others=>'0');
221
  begin
222
    idout := DOUT;
223
    if DOUT_VAL_EN='0' or DOUT_VAL_AA='0' or
224
       DOUT_VAL_PA='0' or DOUT_VAL_OE='0' then
225
      idout := (others=>'X');
226
    end if;
227
    if DOUT_LZ_CE='0' or DOUT_LZ_OE='0' then
228
      idout := (others=>'Z');
229
    end if;
230
    DATA <= idout;
231
  end process proc_data;
232
 
233
  proc_mwait: process (CE)
234
  begin
235
    -- WT driver (just a dummy)
236
    if CE = '1' then
237
      MWAIT <= '1';
238
    else
239
      MWAIT <= 'Z';
240
    end if;
241
  end process proc_mwait;
242
 
243
end sim;

powered by: WebSVN 2.1.0

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