2 * Simulator of microcontrollers (sim.src/hwcl.h)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
10 /* This file is part of microcontroller simulator: ucsim.
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.
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.
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
28 /* Abstract hw element. It can be a timer, serial line or whatever */
30 #ifndef SIM_HWCL_HEADER
31 #define SIM_HWCL_HEADER
45 enum what_to_do_on_cell_change {
49 wtd_restore_write = 0x08
52 #define WTD_WRITE (wtd_write|wtd_restore_write)
53 #define WTD_RESTORE (wtd_restore|wtd_restore_write)
55 class cl_hw; // forward
57 class cl_watched_cell: public cl_base
60 class cl_address_space *mem;
62 class cl_memory_cell *cell;
63 class cl_memory_cell **store;
65 enum what_to_do_on_cell_change wtd;
67 cl_watched_cell(class cl_address_space *amem, t_addr aaddr,
68 class cl_memory_cell **astore,
69 enum what_to_do_on_cell_change awtd);
71 virtual void mem_cell_changed(class cl_address_space *amem, t_addr aaddr,
73 virtual void address_space_added(class cl_address_space *amem,
77 class cl_used_cell: public cl_watched_cell
80 cl_used_cell(class cl_address_space *amem, t_addr aaddr,
81 class cl_memory_cell **astore,
82 enum what_to_do_on_cell_change awtd):
83 cl_watched_cell(amem, aaddr, astore, awtd) {}
85 virtual void mem_cell_changed(class cl_address_space *amem, t_addr aaddr,
87 virtual void address_space_added(class cl_address_space *amem,
91 class cl_hw: public cl_guiobj
96 enum hw_cath cathegory;
100 class cl_list *partners;
101 class cl_list *watched_cells;
103 cl_hw(class cl_uc *auc, enum hw_cath cath, int aid, const char *aid_string);
104 virtual ~cl_hw(void);
106 virtual void new_hw_adding(class cl_hw *new_hw);
107 virtual void new_hw_added(class cl_hw *new_hw);
108 virtual void added_to_uc(void) {}
109 virtual class cl_hw *make_partner(enum hw_cath cath, int id);
111 virtual t_mem read(class cl_memory_cell *cell) { return(cell->get()); }
112 virtual void write(class cl_memory_cell * /*cell*/, t_mem * /*val*/) {}
114 virtual void set_cmd(class cl_cmdline *cmdline, class cl_console_base *con);
115 virtual class cl_memory_cell *register_cell(class cl_address_space *mem,
117 class cl_memory_cell **store,
118 enum what_to_do_on_cell_change
120 virtual class cl_memory_cell *use_cell(class cl_address_space *mem,
122 class cl_memory_cell **store,
123 enum what_to_do_on_cell_change awtd);
124 virtual void mem_cell_changed(class cl_address_space *mem, t_addr addr);
125 virtual void address_space_added(class cl_address_space *as);
127 virtual int tick(int cycles);
128 virtual void reset(void) {}
129 virtual void happen(class cl_hw * /*where*/, enum hw_event /*he*/,
130 void * /*params*/) {}
131 virtual void inform_partners(enum hw_event he, void *params);
133 virtual void print_info(class cl_console_base *con);
136 class cl_hws: public cl_list
139 cl_hws(void): cl_list(2, 2, "hws") {}
140 virtual t_index add(void *item);
141 virtual void mem_cell_changed(class cl_address_space *mem, t_addr addr);
142 virtual void address_space_added(class cl_address_space *as);
146 class cl_partner_hw: public cl_base
150 enum hw_cath cathegory;
152 class cl_hw *partner;
154 cl_partner_hw(class cl_uc *auc, enum hw_cath cath, int aid);
156 virtual class cl_hw *get_partner(void);
157 virtual void refresh(void);
158 virtual void refresh(class cl_hw *new_hw);
160 virtual void happen(class cl_hw *where, enum hw_event he, void *params);