2 * Simulator of microcontrollers (cmd.src/cmdstat.cc)
4 * Copyright (C) 1999 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
28 //#include "ddconfig.h"
37 #include "cmd_statcl.h"
43 *----------------------------------------------------------------------------
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),
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
;
66 else if (cmdline
->syntax_match(uc
, MEMORY ADDRESS
)) {
67 mem
= params
[0]->value
.memory
.address_space
;
68 start
= end
= params
[1]->value
.address
;
71 else if (cmdline
->syntax_match(uc
, MEMORY
)) {
72 mem
= params
[0]->value
.memory
.address_space
;
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 "
86 "(%10lu operations)\n",
87 mem
->get_name("mem"), ww
, wr
, ww
+wr
);
94 wr
= mem
->get_nuof_reads();
95 ww
= mem
->get_nuof_writes();
97 con
->dd_printf("%s writes= %10lu "
98 "reads= %10lu\n", mem
->get_name("mem"), ww
, wr
);
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
);
115 CMDHELP(cl_statistic_cmd
,
116 "statistic [mem [startaddr [endaddr]]]",
117 "Statistic of memory accesses",
123 /* End of cmd.src/cmd_stat.cc */