diff --git a/system/system.v b/system/system.v index de26435..3842439 100644 --- a/system/system.v +++ b/system/system.v @@ -81,7 +81,7 @@ end `ifdef OTUPUT_JSON_STATISTICS reg first_json_cycle; always @(negedge clock)begin - if(HALT==0 && json_file_descriptor!=0)begin + if(finish < 2 && json_file_descriptor!=0)begin $fdisplay(json_file_descriptor,"%s{\"C\":%0d,\"L1\":%0d,\"VDI\":%0d,\"JMP\":%0d}",first_json_cycle?"":",",cycles,L1_SIZE_STAT,VALID_INSTRUCTION_STAT,jump_req); first_json_cycle <= 0; end @@ -110,6 +110,9 @@ always @(posedge HALT) begin finish<=2'd1; end +`ifdef OTUPUT_JSON_STATISTICS +reg [128:0] instruction_count_temp; +`endif always @(posedge clock) begin /* Allow some clock cycles for the waveform*/ case(finish) @@ -124,11 +127,16 @@ always @(posedge clock) begin /* verilator lint_on REALCVT */ `endif `ifdef OTUPUT_JSON_STATISTICS - if(json_file_descriptor!=0) - $fdisplay(json_file_descriptor,"],\n\"Total Cycles\":%0d,\n\"Instructions run\":%0d\n}",cycles,instruction_count); + instruction_count_temp <= instruction_count; + `endif + end + 2'd2: begin + finish <= 3; + `ifdef OTUPUT_JSON_STATISTICS + if(json_file_descriptor!=0) + $fdisplay(json_file_descriptor,"],\n\"Total Cycles\":%0d,\n\"Instructions run\":%0d\n}",cycles-1,instruction_count_temp); `endif end - 2'd2: finish <= 3; 2'd3: $finish; endcase end diff --git a/tools/plot.sh b/tools/plot.sh index 7100c8f..c5ad72a 100755 --- a/tools/plot.sh +++ b/tools/plot.sh @@ -35,6 +35,7 @@ case "$2" in parse_cache_size parse_total_cycles gnuplot -e "${BASE_GNUPLOT_OPTIONS}\ +set term svg name \"Cache_time\";\ set xlabel \"Clock cycles\";\ set ylabel \"Cache utilisation (bytes)\";\ set offsets 0, 0, 3, 1;\ @@ -44,6 +45,7 @@ unset colorbox;\ set ytics add (\"Valid\" -1);\ set grid ytics;\ set yrange [-2:${CACHE_SIZE}];\ +set xrange [-10:${TOTAL_CYCLES}+9];\ set palette model RGB defined ( 0 'red', 1 'green', 2 'dark-khaki' );\ plot\ '${CSV_FILE}' using 1:(-2):(0):("'$'"4*100):(2) with vectors nohead palette notitle,\ @@ -55,6 +57,7 @@ plot\ "cache_util_freq") parse_cache_size gnuplot -e "${BASE_GNUPLOT_OPTIONS}\ +set term svg name \"cache_util_freq\";\ set xlabel \"Utilisation (bytes)\";\ set ylabel \"Occurrences\";\ set boxwidth 0.5;\