forked from pulp-platform/uvm-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimmem.h
81 lines (63 loc) · 2.14 KB
/
simmem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#ifndef __HTIF_SIMMEM_H
#define __HTIF_SIMMEM_H
#include "Variane_wrapped.h"
#include "verilated.h"
#include "verilated_vcd_c.h"
#include "svdpi.h"
#include "Variane_wrapped__Dpi.h"
#include <map>
#include <fesvr/htif.h>
#include <vector>
#include <string>
#include <memory>
#include <fesvr/context.h>
#include <stdio.h>
#include <queue>
class simmem_t : public htif_t
{
public:
simmem_t(int argc, char** argv, size_t b, size_t w, size_t d);
simmem_t(const std::vector<std::string>& args, size_t b, size_t w, size_t d);
void set_vcd (const char *vcd_file) { this->vcd_file = vcd_file; }
void set_label (const char *label) { this->label = label; }
int run();
addr_t get_tohost_address();
addr_t get_fromhost_address();
vluint64_t main_time; // Current simulation time
private:
size_t base;
size_t width;
size_t depth;
std::map<addr_t,std::vector<char> > mem;
std::queue<bool> flush_req;
std::queue<bool> flushing;
void flush_dcache();
const char * vcd_file;
const char * label;
void read_chunk(addr_t taddr, size_t len, void* dst);
void write_chunk(addr_t taddr, size_t len, const void* src);
size_t chunk_max_size() { return 8; }
size_t chunk_align() { return 8; }
void reset() { }
context_t* host;
context_t target;
// htif
friend void sim_thread_main(void*);
void main();
void idle();
};
#endif // __HTIF_SIMMEM_H