+ {
+ while (op->get_next() &&
+ !op->get_next()->match(brk))
+ op= op->get_next();
+ if (op->get_next())
+ {
+ class cl_memory_operator *m= op->get_next();
+ op->set_next(m->get_next());;
+ delete m;
+ }
+ }
+}
+
+
+class cl_memory_cell *
+cl_memory_cell::add_hw(class cl_hw *hw, int *ith, t_addr addr)
+{
+ class cl_hw_operator *o= new cl_hw_operator(this, addr, data, mask, hw);
+ append_operator(o);
+ return(this);
+}
+
+/*class cl_hw *
+cl_memory_cell::get_hw(int ith)
+{
+ return(0);
+}*/
+
+class cl_event_handler *
+cl_memory_cell::get_event_handler(void)
+{
+ return(0);
+}
+
+
+/*
+ * Dummy cell for non-existent addresses
+ */
+
+t_mem
+cl_dummy_cell::write(t_mem val)
+{
+#ifdef STATISTIC
+ nuof_writes++;
+#endif
+ *data= rand() & mask;
+ return(*data);
+}
+
+t_mem
+cl_dummy_cell::set(t_mem val)
+{
+ *data= rand() & mask;
+ return(*data);
+}
+
+
+/*
+ * Address space
+ */
+
+cl_address_space::cl_address_space(char *id,
+ t_addr astart, t_addr asize, int awidth):
+ cl_memory(id, asize, awidth)
+{
+ start_address= astart;
+ decoders= new cl_decoder_list(2, 2, DD_FALSE);
+ cells= (class cl_memory_cell **)calloc(size, sizeof(class cl_memory_cell*));
+
+ dummy= new cl_dummy_cell();
+}
+
+cl_address_space::~cl_address_space(void)
+{
+ delete decoders;
+ int i;
+ for (i= 0; i < size; i++)
+ if (cells[i])
+ delete cells[i];
+ delete dummy;
+}
+
+
+t_mem
+cl_address_space::read(t_addr addr)
+{
+ return get_cell(addr)->read();
+}
+
+t_mem
+cl_address_space::read(t_addr addr, enum hw_cath skip)
+{
+ cl_memory_cell *cell = get_cell(addr);
+ if (cell == dummy)
+ {
+ return dummy->read();
+ }
+ return cell->read(skip);
+}
+
+t_mem
+cl_address_space::get(t_addr addr)
+{
+ return get_cell(addr)->get();
+}
+
+t_mem
+cl_address_space::write(t_addr addr, t_mem val)
+{
+ return get_cell(addr)->write(val);
+}
+
+void
+cl_address_space::set(t_addr addr, t_mem val)
+{
+ get_cell(addr)->set(val);
+}
+
+t_mem
+cl_address_space::wadd(t_addr addr, long what)
+{
+ return get_cell(addr)->wadd(what);