2 * Simulator of microcontrollers (ucsim.cc)
4 * Copyright (C) 1997 Drotos Daniel
6 * To contact author send email to dr.dkdb@gmail.com
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
34 class cl_general_uc
: public cl_uc
39 cl_general_uc(cl_sim
*s
): cl_uc(s
) {}
40 virtual void make_memories(void);
41 virtual int exec_inst()
57 cl_general_uc::make_memories(void)
59 class cl_address_space
*as
;
60 class cl_memory_chip
*ch
;
61 class cl_address_decoder
*ad
;
63 rom
= as
= new cl_address_space("nas", 0, 0x100000, 8);
65 address_spaces
->add(as
);
67 ch
= new cl_chip8("chip", 0x100000, 8/*, 0*/);
71 ad
= new cl_address_decoder(as
, ch
, 0, 0x100000-1, 0);
73 as
->decoders
->add(ad
);
77 class cl_general_sim
: public cl_sim
80 cl_general_sim(cl_app
*a
): cl_sim(a
) {}
81 virtual class cl_uc
*mk_controller(void)
83 class cl_uc
*uc
= new cl_general_uc(this);
89 main(int argc
, char *argv
[])
93 volatile double fd
, id
;
99 while (++i
< 100000000) fd
+= 1.0;
100 fd
= dnow()-app_start_at
;
103 application
= new cl_app();
104 application
->set_name("ucsim");
105 application
->init(argc
, argv
);
106 sim
= new cl_general_sim(application
);
108 sim
->state
|= SIM_QUIT
;
109 application
->set_simulator(sim
);
114 while (++i < 1000000) sim->step();
117 fprintf(stderr, "\n%f MFlop ", fd);
118 fprintf(stderr, "%f kips\n", id);
121 ret
= application
->run();
126 /* End of sim.src/ucsim.cc */