summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--backend/regfile.h4
-rw-r--r--infra/stat.h35
-rwxr-xr-xpt8
3 files changed, 47 insertions, 0 deletions
diff --git a/backend/regfile.h b/backend/regfile.h
index 4cf328a..4ea2f31 100644
--- a/backend/regfile.h
+++ b/backend/regfile.h
@@ -4,6 +4,7 @@
4 4
5#include "frontend/decode.h" 5#include "frontend/decode.h"
6#include "infra/port.h" 6#include "infra/port.h"
7#include "infra/stat.h"
7#include "inst.h" 8#include "inst.h"
8#include "memory/dram.h" 9#include "memory/dram.h"
9 10
@@ -16,6 +17,8 @@ namespace backend {
16 infra::port<inst> writebackp; 17 infra::port<inst> writebackp;
17 infra::port<memory::dram::command> *storep = nullptr; 18 infra::port<memory::dram::command> *storep = nullptr;
18 19
20 infra::stat ipc{"ipc"};
21
19 unsigned int generation_up = 0; 22 unsigned int generation_up = 0;
20 unsigned int generation_down = 0; 23 unsigned int generation_down = 0;
21 24
@@ -33,6 +36,7 @@ namespace backend {
33 auto i = writebackp.read(); 36 auto i = writebackp.read();
34 if (i.generation == generation_down) { 37 if (i.generation == generation_down) {
35 pte(i.transaction, "W", fmt::format("writeback gen={} pc={:x}", generation_down, pc)); 38 pte(i.transaction, "W", fmt::format("writeback gen={} pc={:x}", generation_down, pc));
39 ++ipc;
36 assert(pc == i.init_pc); 40 assert(pc == i.init_pc);
37 auto old_pc = pc; 41 auto old_pc = pc;
38 pc = i.linear_next_pc; 42 pc = i.linear_next_pc;
diff --git a/infra/stat.h b/infra/stat.h
new file mode 100644
index 0000000..f1ca75a
--- /dev/null
+++ b/infra/stat.h
@@ -0,0 +1,35 @@
1#pragma once
2
3#include <fmt/format.h>
4#include <utility>
5
6#include "infra/sim.h"
7
8namespace infra {
9 struct stat : public sim {
10 std::string name;
11 std::uint64_t numerator = 0;
12 std::uint64_t denominator = 0;
13
14 stat(std::string name)
15 : name(std::move(name))
16 { }
17
18 ~stat() {
19 fmt::print("# {} {}\n", name, (double)numerator/(double)denominator);
20 }
21
22 void unclock() {
23 ++denominator;
24 }
25
26 stat & operator++() {
27 ++numerator;
28 return *this;
29 }
30
31 stat & operator++(int) {
32 return operator++();
33 }
34 };
35}
diff --git a/pt b/pt
index 489a13a..206795f 100755
--- a/pt
+++ b/pt
@@ -9,6 +9,8 @@ $data = {}
9$horiz = {} 9$horiz = {}
10$maxtime = -1 10$maxtime = -1
11 11
12$stats = false
13
12$stdin.each_line do | line | 14$stdin.each_line do | line |
13 case line 15 case line
14 16
@@ -38,11 +40,17 @@ $stdin.each_line do | line |
38 end 40 end
39 $maxtime = [$maxtime, time+1].max 41 $maxtime = [$maxtime, time+1].max
40 42
43 when /^#\s*(.*)$/
44 $stats = true
45 $stdout.write("#{$1}\n")
46
41 else 47 else
42 raise "Unexpected line: #{line}" 48 raise "Unexpected line: #{line}"
43 end 49 end
44end 50end
45 51
52$stdout.write("\n") if $stats
53
46$hier = {} 54$hier = {}
47$hier_direct = {} 55$hier_direct = {}
48 56