Version 0.3.0
[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 class cl_cell: public cl_base
68 {
69 public:
70   t_mem data;
71   
72 public:
73   cl_cell(void);
74   cl_cell(t_mem idata);
75 };
76
77 /* Memory */
78
79 class cl_mem: public cl_guiobj
80 {
81 public:
82   enum mem_class type;
83   char *class_name;
84   char *addr_format, *data_format;
85   t_addr size;
86   ulong mask;
87   int width; // in bits
88   union {
89     void *mem;
90     uchar *umem8;
91   };
92   class cl_memloc_coll *read_locs, *write_locs;
93   t_addr dump_finished;
94
95 public:
96   cl_mem(enum mem_class atype, char *aclass_name, t_addr asize, int awidth);
97   ~cl_mem(void);
98   virtual int init(void);
99   virtual char *id_string(void);
100
101   virtual t_mem read(t_addr addr);
102   virtual t_mem get(t_addr addr);
103   virtual void write(t_addr addr, t_mem *val);
104   virtual void set(t_addr addr, t_mem val);
105   virtual void set_bit1(t_addr addr, t_mem bits);
106   virtual void set_bit0(t_addr addr, t_mem bits);
107   virtual t_mem add(t_addr addr, long what);
108   virtual t_addr dump(t_addr start, t_addr stop, int bpl,
109                       class cl_console *con);
110   virtual t_addr dump(class cl_console *con);
111   virtual bool search_next(bool case_sensitive,
112                            t_mem *array, int len, t_addr *addr);
113 };
114
115 /* Spec for CODE */
116
117 class cl_bitmap: public cl_base
118 {
119 public:
120   uchar *map;
121   int size;
122 public:
123   cl_bitmap(t_addr asize);
124   ~cl_bitmap(void);
125   virtual void set(t_addr pos);
126   virtual void clear(t_addr pos);
127   virtual bool get(t_addr pos);
128   virtual bool empty(void);
129 };
130
131 class cl_rom: public cl_mem
132 {
133 public:
134   class cl_bitmap *bp_map;
135   class cl_bitmap *inst_map;
136 public:
137   cl_rom(t_addr asize, int awidth);
138   ~cl_rom(void);
139 };
140
141
142 #endif
143
144 /* End of memcl.h */