Skip to content

Commit f383952

Browse files
committed
Begin dumphist implementation into sflr menu
See also issue physical-computation#129
1 parent 1bb75c8 commit f383952

7 files changed

+22
-5
lines changed

sim/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ decode-riscv.h: latencies-riscv.h Makefile
161161
./mkdecode-riscv $(GAWK) > decode-riscv.h
162162

163163
# Either of the lex-* would suffice for generating the LaTeX / help command array.
164+
# TODO Changed to riscv for now. This should be properly implemented as a union of lex-*, considering which
165+
# parts of riscv/superh(/...) are duplicates
164166
help.h: lex-hitachi-sh.c Makefile
165167
./mkhelp $(GAWK) > help.h
166168

sim/lex-riscv.c

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ TokenTab riscv_token_table [] =
6868
{"FF", T_MODEFF}, /*+ Set simulator in fast functional mode.:none */
6969
{"MMAP", T_MMAP}, /*+ Map memory of one simulated node into another.:<source (integer)> <destination (integer)> */
7070
{"DUMPREGS", T_DUMPREGS}, /*+ Show the contents of the general purpose registers.:none */
71+
{"DUMPHIST", T_DUMPHIST}, /*+ Show the contents of a histogram register.:none */
7172
{"DUMPSYSREGS", T_DUMPSYSREGS}, /*+ Show the contents of the system registers.:none */
7273
{"DUMPMEM", T_DUMPMEM}, /*+ Show contents of memory.:<start mem address (hexadecimal)> <end mem address (hexadecimal)> */
7374
{"DUMPPIPE", T_DUMPPIPE}, /*+ Show the contents of the pipeline stages.:none */

sim/machine-riscv.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ riscvnewstate(Engine *E, double xloc, double yloc, double zloc, char *trajfilena
243243
S->riscv->uncertain = uncertainnewstate(E, "S->riscv->uncertain");
244244

245245
S->dumpregs = riscvdumpregs;
246+
S->dumphist = Histogram_PrintDist;
246247
S->dumpsysregs = riscvdumpsysregs;
247248
S->dumppipe = riscvdumppipe;
248249
S->flushpipe = riscvflushpipe;
@@ -261,7 +262,8 @@ riscvnewstate(Engine *E, double xloc, double yloc, double zloc, char *trajfilena
261262

262263

263264
// Print histogram
264-
void Histogram_PrintDist(Engine *E, State *S, Histogram *histogram){
265+
void
266+
Histogram_PrintDist(Engine *E, State *S, Histogram *histogram){
265267
mprint(E, S, nodeinfo, "tes-");
266268

267269
for (int i = 0; i < kNBINS; i++){

sim/main.h

+1
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ struct State
711711
/* Other misc machine specific actions */
712712
void (*fatalaction)(Engine *, State *S);
713713
void (*dumpregs)(Engine *, State *S);
714+
void (*dumphist)(Engine *, State *S);
714715
void (*dumpsysregs)(Engine *, State *S);
715716
void (*resetcpu)(Engine *, State *S);
716717
void (*dumppipe)(Engine *, State *S);

sim/mkhelp

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
fi
1515

1616

17+
# TODO Changed from lex-riscv.c -> lex-riscv.c
18+
# see Makefile target help.h
1719
echo 'Help Helpstrs[] =\'
1820
echo '{\'
19-
cat lex-hitachi-sh.c | grep '/\*+' | sort | $1 -F'*|_|}|{|+|,|:' '{print "\t{\n\t\t\t" $2 ",\n\t\t\t\"\tDescription:" $8 "\",\n\t\t\t\"\tArguments:\t" $9 "\",\n\t},"}'
21+
cat lex-riscv.c | grep '/\*+' | sort | $1 -F'*|_|}|{|+|,|:' '{print "\t{\n\t\t\t" $2 ",\n\t\t\t\"\tDescription:" $8 "\",\n\t\t\t\"\tArguments:\t" $9 "\",\n\t},"}'
2022
echo '};'
21-
echo 'int nHelpstrs ='`cat lex-hitachi-sh.c | grep '/\*+' | wc -l`';'
22-
echo 'int uniqHelpstrs ='`cat lex-hitachi-sh.c | grep '/\*+' | sort -t '"' -k 2 | $1 '{print $2}' | sort | uniq | wc -l`';'
23+
echo 'int nHelpstrs ='`cat lex-riscv.c | grep '/\*+' | wc -l`';'
24+
echo 'int uniqHelpstrs ='`cat lex-riscv.c | grep '/\*+' | sort -t '"' -k 2 | $1 '{print $2}' | sort | uniq | wc -l`';'

sim/regs-riscv.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ typedef union
265265
*/
266266

267267

268-
// TODO move to file containing constant declarations
269268
// TODO consider whether this should be part of the typedef, i.e. be dynamically allocated
270269
// that would be more flexible, but arguably less aligned with how a processor operating
271270
// on fixed-precision variables would work
@@ -275,6 +274,7 @@ typedef union
275274
#define kNBINS 256
276275
typedef int32_t HistogramBinDatatype;
277276

277+
// TODO Is this the best place to define this datatype?
278278
typedef struct
279279
{
280280
// TODO I chose the more familiar term "bins" rather than Alexa's "weights".

sim/sf-riscv.y

+9
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
%token T_DUMPDISTRIBUTION
105105
%token T_DUMPPWR
106106
%token T_DUMPREGS
107+
%token T_DUMPHIST
107108
%token T_DUMPSYSREGS
108109
%token T_DUMPTIME
109110
%token T_DUMPTLB
@@ -1207,6 +1208,14 @@ sf_cmd : T_QUIT '\n'
12071208
yyengine->cp->dumpregs(yyengine, yyengine->cp);
12081209
}
12091210
}
1211+
| T_DUMPHIST '\n'
1212+
{
1213+
if (!yyengine->scanning)
1214+
{
1215+
yyengine->cp->dumphist(yyengine, yyengine->cp);
1216+
}
1217+
}
1218+
12101219
| T_DUMPSYSREGS '\n'
12111220
{
12121221
if (!yyengine->scanning)

0 commit comments

Comments
 (0)