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

Subversion Repositories wbddr3

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

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

Line No. Rev Author Line
1 16 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    pddrsim.cpp
4
//
5
// Project:     A wishbone controlled DDR3 SDRAM memory controller.
6
//
7
// Purpose:     To expand a DDR3 SDRAM controllers influence across multiple
8
//              clocks.  Hence, if the DDR3 SDRAM controller runs at half
9
//      the clock rate of the DDR3-SDRAM, this will expand it to the full
10
//      clock rate.
11
//
12
// Creator:     Dan Gisselquist, Ph.D.
13
//              Gisselquist Technology, LLC
14
//
15
////////////////////////////////////////////////////////////////////////////////
16
//
17
// Copyright (C) 2016, Gisselquist Technology, LLC
18
//
19
// This program is free software (firmware): you can redistribute it and/or
20
// modify it under the terms of  the GNU General Public License as published
21
// by the Free Software Foundation, either version 3 of the License, or (at
22
// your option) any later version.
23
//
24
// This program is distributed in the hope that it will be useful, but WITHOUT
25
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
26
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27
// for more details.
28
//
29
// You should have received a copy of the GNU General Public License along
30
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
31
// target there if the PDF file isn't present.)  If not, see
32
// <http://www.gnu.org/licenses/> for a copy.
33
//
34
// License:     GPL, v3, as defined and found on www.gnu.org,
35
//              http://www.gnu.org/licenses/gpl.html
36
//
37
//
38
////////////////////////////////////////////////////////////////////////////////
39
//
40
//
41
#include <stdio.h>
42
#include <stdlib.h>
43
#include "ddrsdramsim.h"
44
#include "pddrsim.h"
45
 
46 18 dgisselq
void PDDRSIM::operator()(int reset_n, int cke, int busoe,
47
                unsigned cmda, unsigned cmdb, unsigned cmdc, unsigned cmdd,
48
                const unsigned *data_to_sdram, unsigned *data_from_sdram) {
49 16 dgisselq
        int     csn, rasn, casn, wen, dqs, dm, odt, addr, ba;
50
 
51
        csn  = (cmda >> 26)&1;
52
        rasn = (cmda >> 25)&1;
53
        casn = (cmda >> 24)&1;
54
        wen  = (cmda >> 23)&1;
55
        ba   = (cmda >> 20)&0x7;        //  3 bits
56
        addr = (cmda >>  6)&0x3fff;     // 14 bits
57
        dqs  = (cmda >>  5)&0x01;       //  1 bits
58
        dm   = (cmda >>  1)&0x0f;       //  4 bits
59
        odt  = (cmda      )&0x01;       //  1 bits
60
 
61 18 dgisselq
        data_from_sdram[0] = DDRSDRAMSIM::apply(
62
                reset_n, cke, csn, rasn, casn, wen,
63
                        dqs, dm, odt, busoe, addr, ba, data_to_sdram[0]);
64 16 dgisselq
 
65
        csn  = (cmdb >> 26)&1;
66
        rasn = (cmdb >> 25)&1;
67
        casn = (cmdb >> 24)&1;
68
        wen  = (cmdb >> 23)&1;
69
        ba   = (cmdb >> 20)&0x7;        //  3 bits
70
        addr = (cmdb >>  6)&0x3fff;     // 14 bits
71
        dqs  = (cmdb >>  5)&0x01;       //  1 bits
72
        dm   = (cmdb >>  1)&0x0f;       //  4 bits
73
        odt  = (cmdb      )&0x01;       //  1 bits
74
 
75 18 dgisselq
        data_from_sdram[1] = DDRSDRAMSIM::apply(
76
                reset_n, cke, csn, rasn, casn, wen,
77
                        dqs, dm, odt, busoe, addr, ba, data_to_sdram[1]);
78 16 dgisselq
 
79 18 dgisselq
        csn  = (cmdc >> 26)&1;
80
        rasn = (cmdc >> 25)&1;
81
        casn = (cmdc >> 24)&1;
82
        wen  = (cmdc >> 23)&1;
83
        ba   = (cmdc >> 20)&0x7;        //  3 bits
84
        addr = (cmdc >>  6)&0x3fff;     // 14 bits
85
        dqs  = (cmdc >>  5)&0x01;       //  1 bits
86
        dm   = (cmdc >>  1)&0x0f;       //  4 bits
87
        odt  = (cmdc      )&0x01;       //  1 bits
88 16 dgisselq
 
89 18 dgisselq
        data_from_sdram[2] = DDRSDRAMSIM::apply(
90
                reset_n, cke, csn, rasn, casn, wen,
91
                        dqs, dm, odt, busoe, addr, ba, data_to_sdram[2]);
92 16 dgisselq
 
93 18 dgisselq
        csn  = (cmdd >> 26)&1;
94
        rasn = (cmdd >> 25)&1;
95
        casn = (cmdd >> 24)&1;
96
        wen  = (cmdd >> 23)&1;
97
        ba   = (cmdd >> 20)&0x7;        //  3 bits
98
        addr = (cmdd >>  6)&0x3fff;     // 14 bits
99
        dqs  = (cmdd >>  5)&0x01;       //  1 bits
100
        dm   = (cmdd >>  1)&0x0f;       //  4 bits
101
        odt  = (cmdd      )&0x01;       //  1 bits
102
 
103
        data_from_sdram[3] = DDRSDRAMSIM::apply(
104
                reset_n, cke, csn, rasn, casn, wen,
105
                        dqs, dm, odt, busoe, addr, ba, data_to_sdram[3]);
106 16 dgisselq
}
107
 

powered by: WebSVN 2.1.0

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