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

Subversion Repositories zipcpu

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

Go to most recent revision | 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
//              exercise to the bus to see whether or not the bus master
10
//              can control it.
11
//
12
//
13
// Creator:     Dan Gisselquist, Ph.D.
14
//              Gisselquist Technology, LLC
15
//
16
////////////////////////////////////////////////////////////////////////////////
17
//
18
// Copyright (C) 2015,2017, Gisselquist Technology, LLC
19
//
20
// This program is free software (firmware): you can redistribute it and/or
21
// modify it under the terms of  the GNU General Public License as published
22
// by the Free Software Foundation, either version 3 of the License, or (at
23
// your option) any later version.
24
//
25
// This program is distributed in the hope that it will be useful, but WITHOUT
26
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
27
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28
// for more details.
29
//
30
// You should have received a copy of the GNU General Public License along
31
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
32
// target there if the PDF file isn't present.)  If not, see
33
// <http://www.gnu.org/licenses/> for a copy.
34
//
35
// License:     GPL, v3, as defined and found on www.gnu.org,
36
//              http://www.gnu.org/licenses/gpl.html
37
//
38
//
39
////////////////////////////////////////////////////////////////////////////////
40
//
41
//
42
#ifndef MEMSIM_H
43
#define MEMSIM_H
44
 
45
class   MEMSIM {
46
public:
47
        typedef unsigned int    BUSW;
48
        typedef unsigned char   uchar;
49
 
50
        BUSW    *m_mem, m_len, m_mask;
51
        int     m_nxt_ack;
52
        BUSW    m_nxt_data;
53
 
54
 
55
        MEMSIM(const unsigned int nwords);
56
        ~MEMSIM(void);
57
        void    load(const char *fname);
58
        void    load(const unsigned addr, const char *buf,const unsigned len);
59
        void    apply(const uchar wb_cyc, const uchar wb_stb,
60
                                const uchar wb_we,
61
                        const BUSW wb_addr, const BUSW wb_data,
62
                                const uchar wb_sel,
63
                        uchar &o_ack, uchar &o_stall, BUSW &o_data);
64
        void    operator()(const uchar wb_cyc, const uchar wb_stb,
65
                                const uchar wb_we,
66
                        const BUSW wb_addr, const BUSW wb_data,
67
                                const uchar wb_sel,
68
                        uchar &o_ack, uchar &o_stall, BUSW &o_data) {
69
                apply(wb_cyc, wb_stb, wb_we, wb_addr, wb_data, wb_sel, o_ack, o_stall, o_data);
70
        }
71
        BUSW &operator[](const BUSW addr) { return m_mem[addr&m_mask]; }
72
};
73
 
74
#endif

powered by: WebSVN 2.1.0

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