generated from riscv-software-src/template-riscv-code
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7120d89
commit 7f2402b
Showing
12 changed files
with
438 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
project(Lsu_test) | ||
|
||
target_link_libraries(core mss) | ||
|
||
add_executable(Lsu_test Lsu_test.cpp ${SIM_BASE}/sim/OlympiaSim.cpp) | ||
|
||
target_link_libraries (Lsu_test core common_test ${STF_LINK_LIBS} SPARTA::sparta) | ||
|
||
file(CREATE_LINK ${SIM_BASE}/mavis/json ${CMAKE_CURRENT_BINARY_DIR}/mavis_isa_files SYMBOLIC) | ||
file(CREATE_LINK ${SIM_BASE}/arches ${CMAKE_CURRENT_BINARY_DIR}/arches SYMBOLIC) | ||
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/test_cores ${CMAKE_CURRENT_BINARY_DIR}/test_cores SYMBOLIC) | ||
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/raw.json ${CMAKE_CURRENT_BINARY_DIR}/raw.json SYMBOLIC) | ||
|
||
sparta_named_test(Lsu_test_raw Lsu_test small_core.out -c test_cores/test_small_core.yaml --input-file raw.json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
|
||
#include "Dispatch.hpp" | ||
#include "MavisUnit.hpp" | ||
#include "CoreUtils.hpp" | ||
#include "Rename.hpp" | ||
#include "ExecutePipe.hpp" | ||
#include "LSU.hpp" | ||
#include "sim/OlympiaSim.hpp" | ||
#include "OlympiaAllocators.hpp" | ||
|
||
#include "test/core/common/SourceUnit.hpp" | ||
#include "test/core/common/SinkUnit.hpp" | ||
#include "test/core/rename/ROBSinkUnit.hpp" | ||
|
||
#include "sparta/app/CommandLineSimulator.hpp" | ||
#include "sparta/utils/SpartaTester.hpp" | ||
#include "sparta/resources/Buffer.hpp" | ||
#include "sparta/sparta.hpp" | ||
#include "sparta/simulation/ClockManager.hpp" | ||
#include "sparta/kernel/Scheduler.hpp" | ||
#include "sparta/utils/SpartaTester.hpp" | ||
#include "sparta/statistics/StatisticSet.hpp" | ||
#include "sparta/report/Report.hpp" | ||
#include "sparta/events/UniqueEvent.hpp" | ||
#include "sparta/app/Simulation.hpp" | ||
#include "sparta/utils/SpartaSharedPointer.hpp" | ||
|
||
#include <memory> | ||
#include <vector> | ||
#include <cinttypes> | ||
#include <sstream> | ||
#include <initializer_list> | ||
|
||
TEST_INIT | ||
|
||
class olympia::LSUTester | ||
{ | ||
public: | ||
void test_dependent_lsu_instruction(olympia::LSU & lsu){ | ||
// testing RAW dependency for LSU | ||
// we have an ADD instruction before we destination register 3 | ||
// and then a subsequent STORE instruction to register 3 | ||
// we can't STORE until the add instruction runs, so we test | ||
// while the ADD instruction is running, the STORE instruction should NOT issue | ||
EXPECT_TRUE(lsu.lsu_insts_issued_ == 0); | ||
} | ||
|
||
void test_inst_issue(olympia::LSU &lsu, int count){ | ||
EXPECT_EQUAL(lsu.lsu_insts_issued_, count); | ||
} | ||
}; | ||
|
||
const char USAGE[] = | ||
"Usage:\n" | ||
" \n" | ||
"\n"; | ||
|
||
sparta::app::DefaultValues DEFAULTS; | ||
|
||
// The main tester of Rename. The test is encapsulated in the | ||
// parameter test_type of the Source unit. | ||
void runTest(int argc, char **argv) | ||
{ | ||
DEFAULTS.auto_summary_default = "off"; | ||
std::vector<std::string> datafiles; | ||
std::string input_file; | ||
|
||
sparta::app::CommandLineSimulator cls(USAGE, DEFAULTS); | ||
auto & app_opts = cls.getApplicationOptions(); | ||
app_opts.add_options() | ||
("output_file", | ||
sparta::app::named_value<std::vector<std::string>>("output_file", &datafiles), | ||
"Specifies the output file") | ||
("input-file", | ||
sparta::app::named_value<std::string>("INPUT_FILE", &input_file)->default_value(""), | ||
"Provide a JSON instruction stream", | ||
"Provide a JSON file with instructions to run through Execute"); | ||
|
||
po::positional_options_description& pos_opts = cls.getPositionalOptions(); | ||
pos_opts.add("output_file", -1); // example, look for the <data file> at the end | ||
|
||
int err_code = 0; | ||
if(!cls.parse(argc, argv, err_code)){ | ||
sparta_assert(false, "Command line parsing failed"); // Any errors already printed to cerr | ||
} | ||
|
||
sparta_assert(false == datafiles.empty(), "Need an output file as the last argument of the test"); | ||
|
||
sparta::Scheduler scheduler; | ||
uint64_t ilimit = 0; | ||
uint32_t num_cores = 1; | ||
bool show_factories = false; | ||
OlympiaSim sim("simple", | ||
scheduler, | ||
num_cores, // cores | ||
input_file, | ||
ilimit, | ||
show_factories); | ||
|
||
cls.populateSimulation(&sim); | ||
sparta::RootTreeNode* root_node = sim.getRoot(); | ||
|
||
olympia::LSU *my_lsu = root_node->getChild("cpu.core0.lsu")->getResourceAs<olympia::LSU*>(); | ||
olympia::LSUTester lsupipe_tester; | ||
cls.runSimulator(&sim, 7); | ||
lsupipe_tester.test_inst_issue(*my_lsu, 2); | ||
cls.runSimulator(&sim); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
runTest(argc, argv); | ||
|
||
REPORT_ERROR; | ||
return (int)ERROR_CODE; | ||
} |
Oops, something went wrong.