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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sim/] [verilated/] [memsim.h] - Blame information for rev 58

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 58 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    memsim.h
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     This creates a memory like device to act on a WISHBONE bus.
8
//              It doesn't exercise the bus thoroughly, but does give some
9
//              exercise to the bus to see whether or not the bus master
10
//              can control it.
11
//
12
//      This particular version differs from the memsim version within the
13
//      ZipCPU project in that there is a variable delay from request to
14
//      completion.
15
//
16
//
17
// Creator:     Dan Gisselquist, Ph.D.
18
//              Gisselquist Technology, LLC
19
//
20
////////////////////////////////////////////////////////////////////////////////
21
//
22
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
23
//
24
// This program is free software (firmware): you can redistribute it and/or
25
// modify it under the terms of  the GNU General Public License as published
26
// by the Free Software Foundation, either version 3 of the License, or (at
27
// your option) any later version.
28
//
29
// This program is distributed in the hope that it will be useful, but WITHOUT
30
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
31
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
32
// for more details.
33
//
34
// You should have received a copy of the GNU General Public License along
35
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
36
// target there if the PDF file isn't present.)  If not, see
37
// <http://www.gnu.org/licenses/> for a copy.
38
//
39
// License:     GPL, v3, as defined and found on www.gnu.org,
40
//              http://www.gnu.org/licenses/gpl.html
41
//
42
//
43
////////////////////////////////////////////////////////////////////////////////
44
//
45
//
46
#ifndef MEMSIM_H
47
#define MEMSIM_H
48
 
49
class   MEMSIM {
50
public:
51
        typedef unsigned int    BUSW;
52
        typedef unsigned char   uchar;
53
 
54
        BUSW    *m_mem, m_len, m_mask, m_head, m_tail, m_delay_mask, m_delay;
55
        int     *m_fifo_ack;
56
        BUSW    *m_fifo_data;
57
 
58
 
59
        MEMSIM(const unsigned int nwords, const unsigned int delay=27);
60
        ~MEMSIM(void);
61
        void    load(const char *fname);
62
        void    load(const unsigned int addr, const char *buf,const size_t len);
63
        void    apply(const uchar wb_cyc, const uchar wb_stb,
64
                                const uchar wb_we,
65
                        const BUSW wb_addr, const BUSW wb_data,
66
                                const uchar wb_sel,
67
                        uchar &o_ack, uchar &o_stall, BUSW &o_data);
68
        void    operator()(const uchar wb_cyc, const uchar wb_stb,
69
                                const uchar wb_we,
70
                        const BUSW wb_addr, const BUSW wb_data,
71
                                const uchar wb_sel,
72
                        uchar &o_ack, uchar &o_stall, BUSW &o_data) {
73
                apply(wb_cyc, wb_stb, wb_we, wb_addr, wb_data, wb_sel, o_ack, o_stall, o_data);
74
        }
75
        BUSW &operator[](const BUSW addr) { return m_mem[addr&m_mask]; }
76
};
77
 
78
#endif

powered by: WebSVN 2.1.0

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