version 0.2.39: fix of arith insts and start of re-structure
[fw/sdcc] / sim / ucsim / sim.src / memcl.h
1 /*
2  * Simulator of microcontrollers (sim.src/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 SIM_MEMCL_HEADER
29 #define SIM_MEMCL_HEADER
30
31 #include "stypes.h"
32 #include "pobjcl.h"
33
34 #include "guiobjcl.h"
35
36
37 class cl_mem;
38
39 /* Memory location handled specially by a hw element */
40
41 class cl_memloc: public cl_base
42 {
43 public:
44   t_addr address;
45   class cl_list *hws;
46
47 public:
48   cl_memloc(t_addr addr);
49   ~cl_memloc(void);
50
51   virtual ulong read(class cl_mem *mem);
52   virtual void write(class cl_mem *mem, t_addr addr, t_mem *val);
53 };
54
55 class cl_memloc_coll: public cl_sorted_list
56 {
57 public:
58   cl_memloc_coll(void);
59
60   virtual void *key_of(void *item);
61   virtual int compare(void *key1, void *key2);
62
63   class cl_memloc *get_loc(t_addr address);
64 };
65
66
67 /* Memory */
68
69 class cl_mem: public cl_guiobj
70 {
71 public:
72   enum mem_class type;
73   char *class_name;
74   char *addr_format, *data_format;
75   t_addr size;
76   ulong mask;
77   int width; // in bits
78   union {
79     void *mem;
80     uchar *umem8;
81   };
82   class cl_memloc_coll *read_locs, *write_locs;
83   t_addr dump_finished;
84
85 public:
86   cl_mem(enum mem_class atype, char *aclass_name, t_addr asize, int awidth);
87   ~cl_mem(void);
88   virtual int init(void);
89   virtual char *id_string(void);
90
91   virtual t_mem read(t_addr addr);
92   virtual t_mem get(t_addr addr);
93   virtual void write(t_addr addr, t_mem *val);
94   virtual void set(t_addr addr, t_mem val);
95   virtual void set_bit1(t_addr addr, t_mem bits);
96   virtual void set_bit0(t_addr addr, t_mem bits);
97   virtual t_mem add(t_addr addr, long what);
98   virtual t_addr dump(t_addr start, t_addr stop, int bpl,
99                       class cl_console *con);
100   virtual t_addr dump(class cl_console *con);
101   virtual bool search_next(bool case_sensitive,
102                            t_mem *array, int len, t_addr *addr);
103 };
104
105 /* Spec for CODE */
106
107 class cl_bitmap: public cl_base
108 {
109 public:
110   uchar *map;
111   int size;
112 public:
113   cl_bitmap(t_addr asize);
114   ~cl_bitmap(void);
115   virtual void set(t_addr pos);
116   virtual void clear(t_addr pos);
117   virtual bool get(t_addr pos);
118   virtual bool empty(void);
119 };
120
121 class cl_rom: public cl_mem
122 {
123 public:
124   class cl_bitmap *bp_map;
125   class cl_bitmap *inst_map;
126 public:
127   cl_rom(t_addr asize, int awidth);
128   ~cl_rom(void);
129 };
130
131
132 #endif
133
134 /* End of memcl.h */