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

Subversion Repositories wbddr3

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

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
unsigned long PDDRSIM::operator()(int reset_n, int cke, int busoe,
47
                unsigned cmda, unsigned cmdb, unsigned long data) {
48
        int     csn, rasn, casn, wen, dqs, dm, odt, addr, ba;
49
        unsigned        hdata, ldata;
50
        unsigned long   odata;
51
 
52
        // if ((reset_n)&&(cke)) printf("PDDR: %08x/%08x/%016lx\n", cmda, cmdb, data);
53
        csn  = (cmda >> 26)&1;
54
        rasn = (cmda >> 25)&1;
55
        casn = (cmda >> 24)&1;
56
        wen  = (cmda >> 23)&1;
57
        ba   = (cmda >> 20)&0x7;        //  3 bits
58
        addr = (cmda >>  6)&0x3fff;     // 14 bits
59
        dqs  = (cmda >>  5)&0x01;       //  1 bits
60
        dm   = (cmda >>  1)&0x0f;       //  4 bits
61
        odt  = (cmda      )&0x01;       //  1 bits
62
 
63
        // if ((reset_n)&&(cke)) printf("PDDR: %s/%02x/%s\n", (dqs)?"DQS":"   ",dm,(odt)?"ODT":"   ");
64
 
65
        hdata = DDRSDRAMSIM::apply(reset_n, cke, csn, rasn, casn, wen,
66
                        dqs, dm, odt, busoe, addr, ba, (unsigned)(data>>32));
67
 
68
        csn  = (cmdb >> 26)&1;
69
        rasn = (cmdb >> 25)&1;
70
        casn = (cmdb >> 24)&1;
71
        wen  = (cmdb >> 23)&1;
72
        ba   = (cmdb >> 20)&0x7;        //  3 bits
73
        addr = (cmdb >>  6)&0x3fff;     // 14 bits
74
        dqs  = (cmdb >>  5)&0x01;       //  1 bits
75
        dm   = (cmdb >>  1)&0x0f;       //  4 bits
76
        odt  = (cmdb      )&0x01;       //  1 bits
77
 
78
        // if ((reset_n)&&(cke)) printf("PDDR: %s/%02x/%s\n", (dqs)?"DQS":"   ",dm,(odt)?"ODT":"   ");
79
 
80
        ldata = DDRSDRAMSIM::apply(reset_n, cke, csn, rasn, casn, wen,
81
                        dqs, dm, odt, busoe, addr, ba, (unsigned)(data&(~(-1l<<32))));
82
 
83
 
84
        odata = (((unsigned long)hdata)<<32)|((unsigned long)ldata);
85
        return odata;
86
}
87
 

powered by: WebSVN 2.1.0

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