[ucsim] Update email and file info, fix stm8 flash controller
[sdcc.git] / sdcc / sim / ucsim / src / core / cmd.src / cmd_stat.cc
blob90819c46873a62b02c2e6dbd884baba4e3e9f53a
1 /*
2 * Simulator of microcontrollers (cmd.src/cmdstat.cc)
4 * Copyright (C) 1999 Drotos Daniel
5 *
6 * To contact author send email to dr.dkdb@gmail.com
8 */
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
25 02111-1307, USA. */
26 /*@1@*/
28 //#include "ddconfig.h"
30 // prj
31 #include "globals.h"
33 // sim
34 //#include "simcl.h"
36 // local
37 #include "cmd_statcl.h"
40 #ifdef STATISTIC
42 * Command: statistic
43 *----------------------------------------------------------------------------
46 //int
47 //cl_stat_cmd::do_work(class cl_sim *sim,
48 // class cl_cmdline *cmdline, class cl_console *con)
49 COMMAND_DO_WORK_UC(cl_statistic_cmd)
51 class cl_address_space *mem;
52 t_addr start= 0, end= 0;
53 bool addresses= false;
54 class cl_cmd_arg *params[4]= { cmdline->param(0),
55 cmdline->param(1),
56 cmdline->param(2),
57 cmdline->param(3) };
59 mem= 0;
60 if (cmdline->syntax_match(uc, MEMORY ADDRESS ADDRESS)) {
61 mem= params[0]->value.memory.address_space;
62 start= params[1]->value.address;
63 end= params[2]->value.address;
64 addresses= true;
66 else if (cmdline->syntax_match(uc, MEMORY ADDRESS)) {
67 mem= params[0]->value.memory.address_space;
68 start= end= params[1]->value.address;
69 addresses= true;
71 else if (cmdline->syntax_match(uc, MEMORY)) {
72 mem= params[0]->value.memory.address_space;
73 addresses= false;
75 else
77 int i;
78 unsigned long wr, ww;
79 for (i= 0; i < uc->address_spaces->count; i++)
81 mem= (class cl_address_space *)(uc->address_spaces->at(i));
82 wr= mem->get_nuof_reads();
83 ww= mem->get_nuof_writes();
84 con->dd_printf("%s writes= %10lu "
85 "reads= %10lu "
86 "(%10lu operations)\n",
87 mem->get_name("mem"), ww, wr, ww+wr);
90 if (mem)
92 t_addr i;
93 unsigned long wr, ww;
94 wr= mem->get_nuof_reads();
95 ww= mem->get_nuof_writes();
96 if (!addresses)
97 con->dd_printf("%s writes= %10lu "
98 "reads= %10lu\n", mem->get_name("mem"), ww, wr);
99 else
100 for (i= start; i <= end; i++)
102 class cl_memory_cell *c= mem->get_cell(i);
103 unsigned long w= c->nuof_writes, r= c->nuof_reads;
104 double dr= wr?((double(r)*100.0)/double(wr)):0.0;
105 double dw= ww?((double(w)*100.0)/double(ww)):0.0;
106 con->dd_printf("%s[0x%06x] writes= %10lu (%6.2lf%%) "
107 "reads= %10lu (%6.2lf%%)\n",
108 mem->get_name("mem"), AU(i), w, dw, r, dr);
112 return(false);;
115 CMDHELP(cl_statistic_cmd,
116 "statistic [mem [startaddr [endaddr]]]",
117 "Statistic of memory accesses",
120 #endif
123 /* End of cmd.src/cmd_stat.cc */