File tree Expand file tree Collapse file tree 5 files changed +62
-1
lines changed Expand file tree Collapse file tree 5 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ set(TESTS_CPPS
6262 func_sim/traps/t/unit_test.cpp
6363 func_sim/driver/t/unit_test.cpp
6464 func_sim/t/unit_test.cpp
65+ func_sim/ooo_window/t/unit_test.cpp
6566 modules/fetch/bpu/t/unit_test.cpp
6667 modules/core/t/unit_test.cpp
6768 export /gdb/t/unit_test.cpp
@@ -187,6 +188,7 @@ add_library(mipt-mips-src OBJECT
187188 func_sim/func_sim.cpp
188189 func_sim/driver/driver.cpp
189190 func_sim/traps/trap.cpp
191+ func_sim/ooo_window/ooo_window.cpp
190192 mips/mips_instr.cpp
191193 mips/mips_register/mips_register.cpp
192194 mips/mips_driver.cpp
Original file line number Diff line number Diff line change 55
66#include " driver/driver.h"
77#include " func_sim.h"
8+
89#include < kernel/kernel.h>
10+ #include < infra/config/config.h>
911
1012#include < iostream>
1113#include < sstream>
1214#include < stdexcept>
1315
16+ namespace config {
17+ static Value<uint32> ooo_window_size = { " ooo_window_size" , 0 , " size of OOO window (ROB)" };
18+ } // namespace config
19+
1420template <typename ISA>
1521FuncSim<ISA>::FuncSim( Endian endian, bool log, std::string_view isa)
1622 : BasicFuncSim( isa)
23+ , ooo_window( config::ooo_window_size)
1724 , imem( endian)
1825 , driver( ISA::create_driver( this ))
1926{
@@ -91,6 +98,7 @@ Trap FuncSim<ISA>::run( uint64 instrs_to_run)
9198 auto result_trap = driver_step ( instr);
9299 if ( result_trap != Trap::NO_TRAP)
93100 return result_trap;
101+ ooo_window.write_instruction ( instr);
94102 }
95103 return Trap (Trap::BREAKPOINT);
96104}
Original file line number Diff line number Diff line change 1414#include < infra/exception.h>
1515#include < memory/memory.h>
1616#include < simulator.h>
17+ #include < func_sim/ooo_window/ooo_window.h>
1718
1819#include < memory>
1920#include < string>
@@ -35,6 +36,7 @@ class FuncSim : public BasicFuncSim
3536 using RegisterUInt = typename ISA::RegisterUInt;
3637
3738 private:
39+ OOOWindow<FuncInstr> ooo_window;
3840 RF<FuncInstr> rf;
3941 uint64 sequence_id = 0 ;
4042 std::shared_ptr<FuncMemory> mem;
Original file line number Diff line number Diff line change 1+
2+ #include < catch.hpp>
3+
4+ #include < func_sim/ooo_window/ooo_window.h>
5+ #include < risc_v/riscv_instr.h>
6+
7+ TEST_CASE ( " OOO_Window: zero size" )
8+ {
9+ OOOWindow<RISCVInstr<uint32>> w ( 0 );
10+ RISCVInstr<uint32> nop (0x0001 );
11+ w.write_instruction ( nop);
12+ w.write_instruction ( nop);
13+ w.write_instruction ( nop);
14+
15+ CHECK ( w.get_avg_independent_instructions () == 0 );
16+ }
17+
18+ TEST_CASE ( " OOO_Window: all independent" )
19+ {
20+ OOOWindow<RISCVInstr<uint32>> w ( 5 );
21+ RISCVInstr<uint32> instr (0x48fd ); // c_li $a7, 31
22+
23+ for ( int i = 0 ; i < 1000 ; i++)
24+ w.write_instruction ( instr);
25+
26+ CHECK ( w.get_avg_independent_instructions () == 5.0 );
27+ }
28+
29+ TEST_CASE ( " OOO_Window: all dependent" )
30+ {
31+ OOOWindow<RISCVInstr<uint32>> w ( 10 );
32+ RISCVInstr<uint32> instr (0x8df1 ); // c_and $a1, $a2
33+
34+ for ( int i = 0 ; i < 1000 ; i++)
35+ w.write_instruction ( instr);
36+
37+ CHECK ( w.get_avg_independent_instructions () == 1.0 ); // the last instr. in the window is always independent
38+ }
Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ class BaseInstruction : public Datapath<T>
234234 using MyDatapath = Datapath<T>;
235235 using Register = R;
236236 using RegisterUInt = T;
237- R get_src_num ( size_t index) const { return ( index == 0 ) ? src1 : src2; }
237+ R get_src_num ( size_t index) const ;
238238 R get_dst_num () const { return dst; }
239239 R get_dst2_num () const { return dst2; }
240240
@@ -251,6 +251,17 @@ class BaseInstruction : public Datapath<T>
251251 R dst2 = R::zero();
252252};
253253
254+ template <typename T, typename R>
255+ R BaseInstruction<T, R>::get_src_num( size_t index) const
256+ {
257+ if ( index == 0 )
258+ return src1;
259+ else if ( index == 1 )
260+ return src2;
261+ else
262+ return src3;
263+ }
264+
254265template <typename T, typename R>
255266std::string BaseInstruction<T, R>::generate_disasm() const
256267{
You can’t perform that action at this time.
0 commit comments