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
63 class cl_cell **store;
65 enum what_to_do_on_cell_change wtd;
67 cl_watched_cell(class cl_mem *amem, t_addr aaddr, class cl_cell **astore,
68 enum what_to_do_on_cell_change awtd);
70 virtual void mem_cell_changed(class cl_mem *amem, t_addr aaddr,
74 class cl_used_cell: public cl_watched_cell
77 cl_used_cell(class cl_mem *amem, t_addr aaddr, class cl_cell **astore,
78 enum what_to_do_on_cell_change awtd):
79 cl_watched_cell(amem, aaddr, astore, awtd) {}
81 /*virtual void mem_cell_changed(class cl_mem *amem, t_addr aaddr,
85 class cl_hw: public cl_guiobj
90 enum hw_cath cathegory;
94 class cl_list *partners;
95 class cl_list *watched_cells;
97 cl_hw(class cl_uc *auc, enum hw_cath cath, int aid, char *aid_string);
100 virtual void new_hw_adding(class cl_hw *new_hw);
101 virtual void new_hw_added(class cl_hw *new_hw);
102 virtual void added_to_uc(void) {}
103 virtual class cl_hw *make_partner(enum hw_cath cath, int id);
105 virtual t_mem read(class cl_cell *cell) { return(cell->get()); }
106 virtual void write(class cl_cell */*cell*/, t_mem */*val*/) {}
108 virtual void set_cmd(class cl_cmdline *cmdline, class cl_console *con) {}
109 virtual class cl_cell *register_cell(class cl_mem *mem, t_addr addr,
110 class cl_cell **store,
111 enum what_to_do_on_cell_change awtd);
112 virtual class cl_cell *use_cell(class cl_mem *mem, t_addr addr,
113 class cl_cell **store,
114 enum what_to_do_on_cell_change awtd);
115 virtual void mem_cell_changed(class cl_mem *mem, t_addr addr);
117 virtual int tick(int cycles);
118 virtual void reset(void) {}
119 virtual void happen(class cl_hw */*where*/, enum hw_event /*he*/,
121 virtual void inform_partners(enum hw_event he, void *params);
123 virtual void print_info(class cl_console *con);
126 class cl_hws: public cl_list
129 cl_hws(void): cl_list(2, 2) {}
130 virtual t_index add(void *item);
131 virtual void mem_cell_changed(class cl_mem *mem, t_addr addr);
135 class cl_partner_hw: public cl_base
139 enum hw_cath cathegory;
141 class cl_hw *partner;
143 cl_partner_hw(class cl_uc *auc, enum hw_cath cath, int aid);
145 virtual class cl_hw *get_partner(void);
146 virtual void refresh(void);
147 virtual void refresh(class cl_hw *new_hw);
149 virtual void happen(class cl_hw *where, enum hw_event he, void *params);