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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sim/] [verilator/] [memsim.h] - Blame information for rev 209

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 204 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    memsim.h
4
//
5
// Project:     Zip CPU -- a small, lightweight, RISC CPU core
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 209 dgisselq
//      exercise to the bus to see whether or not the bus master can control it.
10 204 dgisselq
//
11
//
12
// Creator:     Dan Gisselquist, Ph.D.
13
//              Gisselquist Technology, LLC
14
//
15
////////////////////////////////////////////////////////////////////////////////
16
//
17
// Copyright (C) 2015,2017, 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 209 dgisselq
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
31 204 dgisselq
// 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
#ifndef MEMSIM_H
42
#define MEMSIM_H
43
 
44
class   MEMSIM {
45
public:
46
        typedef unsigned int    BUSW;
47
        typedef unsigned char   uchar;
48
 
49
        BUSW    *m_mem, m_len, m_mask;
50
        int     m_nxt_ack;
51
        BUSW    m_nxt_data;
52
 
53
 
54
        MEMSIM(const unsigned int nwords);
55
        ~MEMSIM(void);
56
        void    load(const char *fname);
57
        void    load(const unsigned addr, const char *buf,const unsigned len);
58
        void    apply(const uchar wb_cyc, const uchar wb_stb,
59
                                const uchar wb_we,
60
                        const BUSW wb_addr, const BUSW wb_data,
61
                                const uchar wb_sel,
62
                        uchar &o_ack, uchar &o_stall, BUSW &o_data);
63
        void    operator()(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
                apply(wb_cyc, wb_stb, wb_we, wb_addr, wb_data, wb_sel, o_ack, o_stall, o_data);
69
        }
70
        BUSW &operator[](const BUSW addr) { return m_mem[addr&m_mask]; }
71
};
72
 
73
#endif

powered by: WebSVN 2.1.0

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