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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [bench/] [cpp/] [memsim.h] - Blame information for rev 202

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

Line No. Rev Author Line
1 2 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 69 dgisselq
//              Gisselquist Technology, LLC
15 2 dgisselq
//
16
////////////////////////////////////////////////////////////////////////////////
17
//
18
// Copyright (C) 2015, 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
#ifndef MEMSIM_H
41
#define MEMSIM_H
42
 
43
class   MEMSIM {
44
public:
45
        typedef unsigned int    BUSW;
46
        typedef unsigned char   uchar;
47
 
48
        BUSW    *m_mem, m_len, m_mask;
49 197 dgisselq
        int     m_nxt_ack;
50
        BUSW    m_nxt_data;
51 2 dgisselq
 
52
 
53
        MEMSIM(const unsigned int nwords);
54
        ~MEMSIM(void);
55
        void    load(const char *fname);
56 36 dgisselq
        void    apply(const unsigned clk, const uchar wb_cyc, const uchar wb_stb,
57
                                const uchar wb_we,
58 2 dgisselq
                        const BUSW wb_addr, const BUSW wb_data,
59
                        uchar &o_ack, uchar &o_stall, BUSW &o_data);
60 36 dgisselq
        void    operator()(const unsigned clk, const uchar wb_cyc, const uchar wb_stb, const uchar wb_we,
61 2 dgisselq
                        const BUSW wb_addr, const BUSW wb_data,
62
                        uchar &o_ack, uchar &o_stall, BUSW &o_data) {
63 36 dgisselq
                apply(clk, wb_cyc, wb_stb, wb_we, wb_addr, wb_data, o_ack, o_stall, o_data);
64 2 dgisselq
        }
65
        BUSW &operator[](const BUSW addr) { return m_mem[addr&m_mask]; }
66
};
67
 
68
#endif

powered by: WebSVN 2.1.0

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