2 * Simulator of microcontrollers (cmd.src/cmdstat.cc)
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
37 #include "cmdstatcl.h"
43 *----------------------------------------------------------------------------
47 //cl_stat_cmd::do_work(class cl_sim *sim,
48 // class cl_cmdline *cmdline, class cl_console_base *con)
49 COMMAND_DO_WORK_UC(cl_statistic_cmd)
52 class cl_address_space *mem;
53 t_addr start= 0, end= 0;
54 bool addresses= DD_FALSE;
55 class cl_cmd_arg *params[4]= { cmdline->param(0),
60 if (cmdline->syntax_match(uc, HW)) {
61 hw= params[0]->value.hw;
65 if (cmdline->syntax_match(uc, MEMORY ADDRESS ADDRESS)) {
66 mem= params[0]->value.memory.address_space;
67 start= params[1]->value.address;
68 end= params[2]->value.address;
71 else if (cmdline->syntax_match(uc, MEMORY ADDRESS)) {
72 mem= params[0]->value.memory.address_space;
73 start= end= params[1]->value.address;
76 else if (cmdline->syntax_match(uc, MEMORY)) {
77 mem= params[0]->value.memory.address_space;
82 /*con->dd_printf("Error: wrong syntax\n"
83 "%s\n", short_help?short_help:"no help");*/
86 for (i= 0; i < uc->address_spaces->count; i++)
88 mem= (class cl_address_space *)(uc->address_spaces->at(i));
89 wr= mem->get_nuof_reads();
90 ww= mem->get_nuof_writes();
91 con->dd_printf("%s writes= %10lu "
93 "(%10lu operations)\n",
94 mem->get_name("mem"), ww, wr, ww+wr);
100 unsigned long wr, ww;
101 wr= mem->get_nuof_reads();
102 ww= mem->get_nuof_writes();
104 con->dd_printf("%s writes= %10lu "
105 "reads= %10lu\n", mem->get_name("mem"), ww, wr);
107 for (i= start; i <= end; i++)
109 class cl_memory_cell *c= mem->get_cell(i);
110 unsigned long w= c->nuof_writes, r= c->nuof_reads;
111 double dr= wr?((double(r)*100.0)/double(wr)):0.0;
112 double dw= ww?((double(w)*100.0)/double(ww)):0.0;
113 con->dd_printf("%s[0x%06x] writes= %10lu (%6.2lf%%) "
114 "reads= %10lu (%6.2lf%%)\n",
115 mem->get_name("mem"), i, w, dw, r, dr);
125 /* End of cmd.src/cmdstat.cc */