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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [bench/] [cpp/] [sdramsim.h] - Blame information for rev 98

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

Line No. Rev Author Line
1 4 dgisselq
#ifndef SDRAMSIM_H
2
 
3
#define NBANKS  4
4
#define POWERED_UP_STATE        6
5
#define CLK_RATE_HZ             100000000 // = 100 MHz = 100 * 10^6
6
#define PWRUP_WAIT_CKS          ((int)(.000200 * CLK_RATE_HZ))
7
#define MAX_BANKOPEN_TIME       ((int)(.000100 * CLK_RATE_HZ))
8
#define MAX_REFRESH_TIME        ((int)(.064 * CLK_RATE_HZ))
9 37 dgisselq
#define SDRAM_QSZ               16
10 4 dgisselq
 
11
class   SDRAMSIM {
12
        int     m_pwrup;
13
        short   *m_mem;
14
        short   m_last_value, m_qmem[4];
15
        int     m_bank_status[NBANKS];
16
        int     m_bank_row[NBANKS];
17
        int     m_bank_open_time[NBANKS];
18
        unsigned        *m_refresh_time;
19
        int             m_refresh_loc, m_nrefresh;
20 37 dgisselq
        int     m_qloc, m_qdata[SDRAM_QSZ], m_qmask, m_wr_addr;
21 4 dgisselq
        int     m_clocks_till_idle;
22
        bool    m_next_wr;
23
        unsigned        m_fail;
24
public:
25
        SDRAMSIM(void) {
26
                m_mem = new short[(1<<24)]; // 32 MB, or 16 Mshorts
27
 
28
                m_refresh_time = new unsigned[(1<<13)];
29
                for(int i=0; i<m_nrefresh; i++)
30
                        m_refresh_time[i] = 0;
31
                m_refresh_loc = 0;
32
 
33
                m_pwrup = 0;
34
                m_clocks_till_idle = 0;
35
 
36
                m_last_value = 0;
37
                m_clocks_till_idle = PWRUP_WAIT_CKS;
38
                m_wr_addr = 0;
39
 
40
                m_qloc  = 0;
41 37 dgisselq
                m_qmask = SDRAM_QSZ-1;
42 4 dgisselq
 
43
                m_next_wr = true;
44
                m_fail = 0;
45
        }
46
 
47
        ~SDRAMSIM(void) {
48
                delete m_mem;
49
        }
50
 
51
        short operator()(int clk, int cke,
52
                        int cs_n, int ras_n, int cas_n, int we_n, int bs,
53
                                unsigned addr,
54
                        int driv, short data);
55
        int     pwrup(void) const { return m_pwrup; }
56
};
57
 
58
#endif

powered by: WebSVN 2.1.0

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