Project: Added support for json log file
This commit is contained in:
parent
99c0af752b
commit
48237ccd95
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,3 +7,5 @@ callgrind.out
|
||||
programs/cube.asm
|
||||
programs/utah_teapot.asm
|
||||
auxiliary_progs/stl_to_source_code
|
||||
|
||||
simlog.json
|
||||
|
1
cpu.c
1
cpu.c
@ -581,6 +581,7 @@ int exec(struct simdata_t *simdata){
|
||||
if(simdata->exec_data->cycles_left==0){
|
||||
simdata->fetch_data->exec_done=1;
|
||||
simdata->decode_data->exec_done=1;
|
||||
simdata->finished_instructions++;
|
||||
}
|
||||
add_to_instr_list(&simdata->cpu_gui_hints->executing_list,simdata->exec_data->address);
|
||||
return 0;
|
||||
|
24
main.c
24
main.c
@ -41,6 +41,7 @@ void help(char* progname){
|
||||
#else
|
||||
" braille\n"
|
||||
#endif
|
||||
" -o < file > Output simualtion data to specified json log file\n"
|
||||
, progname);
|
||||
}
|
||||
|
||||
@ -61,7 +62,9 @@ int main(int argc, char* argd[] ){
|
||||
char *assemble = NULL;
|
||||
enum FB_DRIVER_t fb_driver=FB_BRAILLE;
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argd, "hi:a:r:")) != -1) {
|
||||
char *json_log_filename=NULL;
|
||||
FILE *JSON_LOG_FILE;
|
||||
while ((opt = getopt(argc, argd, "hi:a:r:o:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
help(argd[0]);
|
||||
@ -88,6 +91,9 @@ int main(int argc, char* argd[] ){
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
json_log_filename=optarg;
|
||||
break;
|
||||
default:
|
||||
help(argd[0]);
|
||||
return 1;
|
||||
@ -104,6 +110,14 @@ int main(int argc, char* argd[] ){
|
||||
help(argd[0]);
|
||||
return 1;
|
||||
}
|
||||
if (json_log_filename){
|
||||
JSON_LOG_FILE=fopen(json_log_filename,"w");
|
||||
if(JSON_LOG_FILE==NULL){
|
||||
printf("Error opening file \"%s\": %s\n",json_log_filename,strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
fprintf(JSON_LOG_FILE, "{\n\"end_of_simulation_data\" : {\n");
|
||||
}
|
||||
|
||||
/// READ INPUT FILE ///
|
||||
FILE* rom=fopen(infile,"r");
|
||||
@ -275,6 +289,14 @@ int main(int argc, char* argd[] ){
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
if(json_log_filename){
|
||||
fprintf(JSON_LOG_FILE, "\"cycles_run_for\" : %lu ,\n", simdata->current_clock);
|
||||
fprintf(JSON_LOG_FILE, "\"instructions_executed\" : %lu\n", simdata->finished_instructions);
|
||||
fprintf(JSON_LOG_FILE, "}\n}\n" );
|
||||
|
||||
fclose(JSON_LOG_FILE);
|
||||
}
|
||||
|
||||
if(end_gui()){
|
||||
printf("Failed on end_gui()\n");
|
||||
cpu_simdata_free(simdata);
|
||||
|
13
parse_log.sh
Executable file
13
parse_log.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
if ! [ "$#" = 1 ]
|
||||
then
|
||||
echo $0 \<simlog json file\>
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CYCLES=$(cat "$1" | json2tsv | sed -n '/^\.end_of_simulation_data\.cycles_run_for\t/s/\.end_of_simulation_data\.cycles_run_for\tn\t//p' )
|
||||
INSTRUCTIONS=$(cat "$1" | json2tsv | sed -n '/^\.end_of_simulation_data\.instructions_executed\t/s/\.end_of_simulation_data\.instructions_executed\tn\t//p' )
|
||||
|
||||
echo executed $INSTRUCTIONS instructions with an IPC=$(echo "$INSTRUCTIONS/$CYCLES" | bc -l|grep -o '^.*\...')
|
@ -25,10 +25,11 @@
|
||||
struct simdata_t *init_simdata(){
|
||||
struct simdata_t * ret=malloc(sizeof(struct simdata_t));
|
||||
|
||||
if(!ret){
|
||||
ret->current_clock=0;
|
||||
if(!ret)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret->current_clock=0;
|
||||
ret->finished_instructions=0;
|
||||
|
||||
ret->RAM=malloc(16777216); //Maximum addressable memory
|
||||
if(!ret->RAM){
|
||||
|
Loading…
Reference in New Issue
Block a user