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

Subversion Repositories wbddr3

[/] [wbddr3/] [trunk/] [bench/] [cpp/] [ddrsdramsim.h] - Blame information for rev 20

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    ddrsdramsim.h
4
//
5
// Project:     A wishbone controlled DDR3 SDRAM memory controller.
6
//
7
// Purpose:     
8
//
9
// Creator:     Dan Gisselquist, Ph.D.
10
//              Gisselquist Technology, LLC
11
//
12
////////////////////////////////////////////////////////////////////////////////
13
//
14
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
15
//
16
// This program is free software (firmware): you can redistribute it and/or
17
// modify it under the terms of  the GNU General Public License as published
18
// by the Free Software Foundation, either version 3 of the License, or (at
19
// your option) any later version.
20
//
21
// This program is distributed in the hope that it will be useful, but WITHOUT
22
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
// for more details.
25
//
26
// You should have received a copy of the GNU General Public License along
27
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
28
// target there if the PDF file isn't present.)  If not, see
29
// <http://www.gnu.org/licenses/> for a copy.
30
//
31
// License:     GPL, v3, as defined and found on www.gnu.org,
32
//              http://www.gnu.org/licenses/gpl.html
33
//
34
//
35
////////////////////////////////////////////////////////////////////////////////
36
//
37
//
38
#ifndef DDRSDRAMSIM_H
39
#define DDRSDRAMSIM_H
40
 
41
#define DDR_MRSET       0
42
#define DDR_REFRESH     1
43
#define DDR_PRECHARGE   2
44
#define DDR_ACTIVATE    3
45
#define DDR_WRITE       4
46
#define DDR_READ        5
47
#define DDR_ZQS         6
48
#define DDR_NOOP        7
49 18 dgisselq
#define DDR_DESELECT    8
50 4 dgisselq
 
51
#define NBANKS          8
52 13 dgisselq
#define NTIMESLOTS      32
53 18 dgisselq
#define NWIDTH          1
54 4 dgisselq
 
55
class   BANKINFO {
56
public:
57
        int             m_state;
58 14 dgisselq
        unsigned        m_row, m_wcounter, m_min_time_before_precharge,
59
                        m_min_time_before_activate;
60
        BANKINFO(void);
61 4 dgisselq
        void    tick(int cmd, unsigned addr=0);
62
};
63
 
64
class   BUSTIMESLOT     {
65
public:
66 13 dgisselq
        int     m_used, m_read, m_data, m_rtt;
67 4 dgisselq
        unsigned        m_addr;
68
};
69
 
70
class   DDRSDRAMSIM     {
71 6 dgisselq
        int             m_reset_state, m_reset_counts, m_memlen, m_busloc,
72 13 dgisselq
                        m_clocks_since_refresh, m_nrefresh_issued,
73
                        m_last_dqs, m_last_rtt;
74 4 dgisselq
        unsigned        *m_mem;
75
        BUSTIMESLOT     *m_bus;
76
        int     cmd(int,int,int,int);
77
public:
78 14 dgisselq
        BANKINFO        m_bank[8];
79 4 dgisselq
        DDRSDRAMSIM(int lglen);
80 16 dgisselq
        unsigned apply(int, int,
81 4 dgisselq
                        int, int, int, int,
82
                        int, int, int, int,
83
                        int, int, int);
84 16 dgisselq
        unsigned operator()(int reset_n, int cke,
85
                        int csn, int rasn, int casn, int wen,
86
                        int dqs, int dm, int odt, int busoe,
87
                        int addr, int ba, int data) {
88
                return apply(reset_n, cke, csn, rasn, casn, wen, dqs, dm, odt,
89
                        busoe, addr, ba, data);
90
        }
91
        unsigned &mem(unsigned addr) { return m_mem[addr]; };
92
        unsigned &operator[](unsigned addr) { return mem(addr); };
93 4 dgisselq
};
94
 
95
#endif

powered by: WebSVN 2.1.0

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