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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [bench/] [cpp/] [qspiflashsim.h] - Blame information for rev 15

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

Line No. Rev Author Line
1 2 dgisselq
///////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    spiflashsim.h
4
//
5
// Project:     Wishbone Controlled Quad SPI Flash Controller
6
//
7
// Purpose:     This library simulates the operation of a Quad-SPI commanded
8
//              flash, such as the S25FL032P used on the Basys-3 development
9
//              board by Digilent.  As such, it is defined by 32 Mbits of
10
//              memory (4 Mbyte).
11
//
12
// Creator:     Dan Gisselquist
13
//              Gisselquist Technology, LLC
14
//
15
///////////////////////////////////////////////////////////////////////////
16
//
17
// Copyright (C) 2015, 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
#ifndef QSPIFLASHSIM_H
40
#define QSPIFLASHSIM_H
41
 
42 10 dgisselq
#include <stdint.h>
43
 
44 2 dgisselq
#define QSPIF_WIP_FLAG                  0x0001
45
#define QSPIF_WEL_FLAG                  0x0002
46
#define QSPIF_DEEP_POWER_DOWN_FLAG      0x0200
47
class   QSPIFLASHSIM {
48
        typedef enum {
49
                QSPIF_IDLE,
50
                QSPIF_QUAD_READ_IDLE,
51
                QSPIF_RDSR,
52
                QSPIF_RDCR,
53
                QSPIF_WRSR,
54
                QSPIF_CLSR,
55
                QSPIF_RDID,
56
                QSPIF_RELEASE,
57
                QSPIF_FAST_READ,
58
                QSPIF_QUAD_READ_CMD,
59
                QSPIF_QUAD_READ,
60
                QSPIF_SECTOR_ERASE,
61
                QSPIF_PP,
62
                QSPIF_QPP,
63
                QSPIF_BULK_ERASE,
64
                QSPIF_DEEP_POWER_DOWN,
65
                QSPIF_INVALID
66
        } QSPIF_STATE;
67
 
68
        QSPIF_STATE     m_state;
69
        char            *m_mem, *m_pmem;
70
        int             m_last_sck;
71
        unsigned        m_write_count, m_ireg, m_oreg, m_sreg, m_addr,
72
                        m_count, m_config, m_mode_byte, m_creg;
73
        bool            m_quad_mode, m_debug;
74
 
75
public:
76
        QSPIFLASHSIM(void);
77
        void    load(const char *fname) { load(0, fname); }
78
        void    load(const unsigned addr, const char *fname);
79 10 dgisselq
        void    write(const unsigned addr, const unsigned len, const uint32_t *buf);
80 2 dgisselq
        void    debug(const bool dbg) { m_debug = dbg; }
81
        bool    debug(void) const { return m_debug; }
82
        int     operator()(const int csn, const int sck, const int dat);
83
};
84
 
85
#endif

powered by: WebSVN 2.1.0

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