4f3e84b5d26f5729be006c281605cdc6f6fce49c
[fw/sdcc] / sim / ucsim / sim.src / memcl.h
1 /*
2  * Simulator of microcontrollers (memcl.h)
3  *
4  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5  * 
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9
10 /* This file is part of microcontroller simulator: ucsim.
11
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING.  If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA. */
26 /*@1@*/
27
28 #ifndef MEMCL_HEADER
29 #define MEMCL_HEADER
30
31 #include "stypes.h"
32 #include "pobjcl.h"
33
34
35 class cl_mem;
36
37 /* Memory location handled specially by a hw element */
38
39 class cl_memloc: public cl_base
40 {
41 public:
42   long address;
43   class cl_list *hws;
44
45 public:
46   cl_memloc(long addr);
47   ~cl_memloc(void);
48
49   virtual ulong read(class cl_mem *mem);
50   virtual void write(class cl_mem *mem, long addr, ulong *val);
51 };
52
53 class cl_memloc_coll: public cl_sorted_list
54 {
55 public:
56   cl_memloc_coll(void);
57
58   virtual void *key_of(void *item);
59   virtual int compare(void *key1, void *key2);
60
61   class cl_memloc *get_loc(long address);
62 };
63
64
65 /* Memory */
66
67 class cl_mem: public cl_base
68 {
69 public:
70   enum mem_class type;
71   t_addr size;
72   ulong mask;
73   int width; // in bits
74   union {
75     void *mem;
76     uchar *umem8;
77   };
78   class cl_memloc_coll *read_locs, *write_locs;
79   int dump_finished;
80
81 public:
82   cl_mem(enum mem_class atype, t_addr asize, int awidth);
83   ~cl_mem(void);
84   virtual int init(void);
85   virtual char *id_string(void);
86
87   virtual ulong read(t_addr addr);
88   virtual ulong get(t_addr addr);
89   virtual void write(t_addr addr, t_mem *val);
90   virtual void set(t_addr addr, t_mem val);
91   virtual void set_bit1(t_addr addr, t_mem bits);
92   virtual void set_bit0(t_addr addr, t_mem bits);
93   virtual void dump(t_addr start, t_addr stop, int bpl, class cl_console *con);
94 };
95
96 /* Spec for CODE */
97
98 class cl_bitmap: public cl_base
99 {
100 public:
101   uchar *map;
102   int size;
103 public:
104   cl_bitmap(long asize);
105   ~cl_bitmap(void);
106   virtual void set(long pos);
107   virtual void clear(long pos);
108   virtual bool get(long pos);
109   virtual bool empty(void);
110 };
111
112 class cl_rom: public cl_mem
113 {
114 public:
115   class cl_bitmap *bp_map;
116   class cl_bitmap *inst_map;
117 public:
118   cl_rom(long asize, int awidth);
119   ~cl_rom(void);
120 };
121
122
123 #endif
124
125 /* End of memcl.h */