summaryrefslogtreecommitdiff
path: root/uarch/core.cpp
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-11-11 16:29:22 -0800
committerJulian Blake Kongslie2022-11-11 16:29:22 -0800
commita2c9de8fcc63a954b6486846b80c402a85d956ca (patch)
treedcfffddafa0edff1d63bb4cfca5609a556ae70a6 /uarch/core.cpp
parentIgnore pipetrace files (diff)
downloadbiggolf-a2c9de8fcc63a954b6486846b80c402a85d956ca.tar.xz
Multi-word fetch bundles and icache with realistic dram latency
Diffstat (limited to 'uarch/core.cpp')
-rw-r--r--uarch/core.cpp55
1 files changed, 39 insertions, 16 deletions
diff --git a/uarch/core.cpp b/uarch/core.cpp
index 34f422a..8b2db9b 100644
--- a/uarch/core.cpp
+++ b/uarch/core.cpp
@@ -25,21 +25,38 @@ void fetch_stage::clock() {
25 gen = r.new_gen; 25 gen = r.new_gen;
26 pc = r.new_pc; 26 pc = r.new_pc;
27 didrestart = true; 27 didrestart = true;
28 outstandingfill = false;
28 c.fetch_restarto.reset(); 29 c.fetch_restarto.reset();
29 } 30 }
30 31
32 if (c.fetch_mem_responsep.can_read()) {
33 auto r = c.fetch_mem_responsep.read();
34 cache.handle_response(r);
35 }
36
31 if (c.fetch_bundlep.can_write()) { 37 if (c.fetch_bundlep.can_write()) {
32 fetch_bundle b; 38 fetch_bundle b;
33 b.tr = infra::pt::toplevel(); 39 if (auto t = cache.fetchline(b.data, pc); t.has_value()) {
34 b.gen = gen; 40 b.tr = infra::pt::toplevel();
35 b.pc = pc; 41 b.gen = gen;
36 b.word = c.mem.fetch(pc); 42 b.pc = pc;
37 if (didrestart) 43 if (didrestart)
38 infra::pt::event(b.tr, ">", now-1, ""); 44 infra::pt::event(b.tr, ">", now-1, "");
39 pte(b.tr, "F"); 45 pte(b.tr, "F", fmt::format("pc={:05o}", b.pc));
40 c.fetch_bundlep.write(std::move(b)); 46 c.fetch_bundlep.write(std::move(b));
41 pc = (pc & 070000) | ((pc + 1) & 007777); 47 pc = (pc & 070000) | (((pc & ~memory::LINE_BYTE_OFFSET_MASK) + memory::LINE_BYTES) & 007777);
42 didrestart = false; 48 didrestart = false;
49 outstandingfill = false;
50 }
51 }
52
53 if (!outstandingfill && c./*fetch_*/mem_commandp.can_write() && !cache.probe(pc)) {
54 memory::dram::command fr;
55 fr.transaction = infra::pt::toplevel();
56 fr.line_address = pc >> memory::LINE_BYTES_LOG2;
57 fr.responsep = &c.fetch_mem_responsep;
58 c./*fetch_*/mem_commandp.write(std::move(fr));
59 outstandingfill = true;
43 } 60 }
44} 61}
45 62
@@ -47,28 +64,31 @@ void decode_stage::clock() {
47 bool progress = ctlregs[HALTED]; 64 bool progress = ctlregs[HALTED];
48 65
49 if (!ctlregs[HALTED] && c.fetch_bundlep.can_read()) { 66 if (!ctlregs[HALTED] && c.fetch_bundlep.can_read()) {
50 auto b = c.fetch_bundlep.read(); 67 auto b = c.fetch_bundlep.peek();
51 68
52 if (b.gen != gen) 69 if (b.gen != gen)
53 goto bail_out; 70 goto bail_out;
54 71
55 if (b.pc != pc) { 72 if ((b.pc >> memory::LINE_BYTES_LOG2) != (pc >> memory::LINE_BYTES_LOG2)) {
56 pte(b.tr, "~"); 73 pte(b.tr, "~");
57 fetch_restart r; 74 fetch_restart r;
58 r.tr = b.tr; 75 r.tr = b.tr;
59 r.new_gen = ++gen; 76 r.new_gen = ++gen;
60 r.new_pc = pc; 77 r.new_pc = pc;
61 c.fetch_restarto = std::move(r); 78 c.fetch_restarto = std::move(r);
79 c.fetch_bundlep.discard();
62 goto bail_out; 80 goto bail_out;
63 } 81 }
64 82
65 progress = true; 83 progress = true;
66 84
67 pte(b.tr, "E"); 85 auto tr = infra::pt::child(b.tr);
86
87 pte(tr, "E");
68 88
69 inst = decode(ctlregs[FLAGS], 89 inst = decode(ctlregs[FLAGS],
70 pc, 90 pc,
71 c.mem.fetch(pc), 91 b.data[pc & memory::LINE_BYTE_OFFSET_MASK],
72 interrupt); 92 interrupt);
73 auto next_pc = inst.next_pc; 93 auto next_pc = inst.next_pc;
74 94
@@ -84,7 +104,7 @@ void decode_stage::clock() {
84 assert(!inst.need_autoinc_store); 104 assert(!inst.need_autoinc_store);
85 } 105 }
86 106
87 pte(b.tr, "", inst.disasm()); 107 pte(tr, "", inst.disasm());
88 108
89 if (inst.need_exec_load) 109 if (inst.need_exec_load)
90 inst.data = c.mem.fetch(inst.final_address.value()); 110 inst.data = c.mem.fetch(inst.final_address.value());
@@ -114,6 +134,9 @@ void decode_stage::clock() {
114 134
115 assert(inst.next_pc == next_pc || inst.possibly_redirects); 135 assert(inst.next_pc == next_pc || inst.possibly_redirects);
116 pc = inst.next_pc; 136 pc = inst.next_pc;
137
138 if ((b.pc >> memory::LINE_BYTES_LOG2) != (pc >> memory::LINE_BYTES_LOG2))
139 c.fetch_bundlep.discard();
117 } 140 }
118bail_out: 141bail_out:
119 142
@@ -125,7 +148,7 @@ bail_out:
125 148
126 c.checker.execute(); 149 c.checker.execute();
127 assert(c.checker.icount == icount); 150 assert(c.checker.icount == icount);
128 std::cerr << fmt::format("icount={:} pc={:05o} checkerpc={:05o}\n", icount, pc, c.checker.pc); 151// std::cerr << fmt::format("icount={:} pc={:05o} checkerpc={:05o}\n", icount, pc, c.checker.pc);
129 assert(pc == c.checker.pc); 152 assert(pc == c.checker.pc);
130 assert(acc == c.checker.acc); 153 assert(acc == c.checker.acc);
131 assert(link == c.checker.link); 154 assert(link == c.checker.link);