117 lines
3.3 KiB
C++
117 lines
3.3 KiB
C++
///*
|
|
// * CommandBus_test.cpp
|
|
// *
|
|
// * Created on: Mar 13, 2014
|
|
// * Author: jonny
|
|
// */
|
|
//#include <gtest/gtest.h>
|
|
//#include <gmock/gmock.h>
|
|
//#include "testUtils.h"
|
|
//#include "core/scheduling/ScheduledCommand.h"
|
|
//#include "core/Configuration.h"
|
|
//#include "core/ControllerState.h"
|
|
//#include "core/CommandBus.h"
|
|
//
|
|
//using ::testing::_;
|
|
//using ::testing::AtLeast;
|
|
//using ::testing::Expectation;
|
|
//using namespace testing;
|
|
//using namespace std;
|
|
//
|
|
//namespace core {
|
|
//
|
|
//class CommandBusTest: public Test
|
|
//{
|
|
//public:
|
|
// CommandBusTest() : config(), state(config.numberOfBanks), bus(config, state, checker), clk(config.Timings.clk){}
|
|
//
|
|
// Configuration config;
|
|
// ControllerState state;
|
|
// CommandBus bus;
|
|
//
|
|
// std::vector<ICommandChecker*> checker;
|
|
// sc_time clk;
|
|
//};
|
|
//
|
|
//TEST_F(CommandBusTest, cleanUpBusWorks)
|
|
//{
|
|
// shared_ptr<tlm::tlm_generic_payload> dummy = createDummyPayload();
|
|
// ScheduledCommand cmd1(*dummy.get(), Read, 2*clk, clk);
|
|
// ScheduledCommand cmd2(*dummy.get(), Read, 3*clk, clk);
|
|
// ScheduledCommand cmd3(*dummy.get(), Read, 5*clk, clk);
|
|
// ScheduledCommand cmd4(*dummy.get(), Read, 7*clk, clk);
|
|
//
|
|
// bus.scheduleCommand(cmd1);
|
|
// bus.scheduleCommand(cmd2);
|
|
// bus.scheduleCommand(cmd3);
|
|
// bus.scheduleCommand(cmd4);
|
|
//
|
|
// EXPECT_EQ(4, bus.getPendingBusCommands().size());
|
|
//
|
|
// bus.cleanUpBus(5*clk);
|
|
//
|
|
// EXPECT_EQ(2, bus.getPendingBusCommands().size());
|
|
//}
|
|
//
|
|
//
|
|
//TEST_F(CommandBusTest, getEarliestStartTimeWorks)
|
|
//{
|
|
// shared_ptr<tlm::tlm_generic_payload> dummy = createDummyPayload();
|
|
// ScheduledCommand cmd1(*dummy.get(), Read, 2*clk, clk);
|
|
// ScheduledCommand cmd2(*dummy.get(), Read, 3*clk, clk);
|
|
// ScheduledCommand cmd3(*dummy.get(), Read, 5*clk, clk);
|
|
// ScheduledCommand cmd4(*dummy.get(), Read, 7*clk, clk);
|
|
//
|
|
// ScheduledCommand collision(*dummy.get(), Read, 3*clk, clk);
|
|
// ScheduledCommand noCollision(*dummy.get(), Read, 6*clk, clk);
|
|
//
|
|
// bus.scheduleCommand(cmd1);
|
|
// bus.scheduleCommand(cmd2);
|
|
// bus.scheduleCommand(cmd3);
|
|
// bus.scheduleCommand(cmd4);
|
|
//
|
|
// EXPECT_EQ(4*clk, bus.getEarliestStartTime(collision));
|
|
// EXPECT_EQ(6*clk, bus.getEarliestStartTime(noCollision));
|
|
//}
|
|
//
|
|
//
|
|
//TEST_F(CommandBusTest, getESTDiesWithNotClkAligned)
|
|
//{
|
|
// shared_ptr<tlm::tlm_generic_payload> dummy = createDummyPayload();
|
|
// ScheduledCommand notAligned(*dummy.get(), Read, 2.5*clk, clk);
|
|
//
|
|
// EXPECT_DEATH(bus.getEarliestStartTime(notAligned), ".*");
|
|
//}
|
|
//
|
|
//TEST_F(CommandBusTest, getLastCommandWorks)
|
|
//{
|
|
// shared_ptr<tlm::tlm_generic_payload> dummy0 = createDummyPayload(Thread(0), Bank(0));
|
|
// shared_ptr<tlm::tlm_generic_payload> dummy2 = createDummyPayload(Thread(0), Bank(2));
|
|
//
|
|
// ScheduledCommand read0(*dummy0.get(), Read, 2*clk, clk);
|
|
// ScheduledCommand read2(*dummy2.get(), Read, 3*clk, clk);
|
|
// bus.scheduleCommand(read0);
|
|
// bus.scheduleCommand(read2);
|
|
//
|
|
// EXPECT_EQ(read0, bus.getLastCommand(Read, read0.getBank()));
|
|
// EXPECT_EQ(read2, bus.getLastCommand(Read, read2.getBank()));
|
|
// EXPECT_EQ(read2.getStart(), bus.getLastCommand(Read).getStart());
|
|
//}
|
|
//
|
|
//TEST_F(CommandBusTest, notYetScheduledWorks)
|
|
//{
|
|
// shared_ptr<tlm::tlm_generic_payload> dummy = createDummyPayload(Thread(0), Bank(0));
|
|
// ScheduledCommand read(*dummy.get(), Read, 2*clk, clk);
|
|
//
|
|
// EXPECT_TRUE(bus.notYetScheduled(Read));
|
|
// bus.scheduleCommand(read);
|
|
// EXPECT_FALSE(bus.notYetScheduled(Read));
|
|
//}
|
|
//
|
|
//
|
|
//} /* namespace controller */
|
|
//
|
|
//
|
|
//
|
|
//
|