diff options
-rw-r--r-- | inc/definitions.h | 2 | ||||
-rw-r--r-- | inc/storage.h | 8 | ||||
-rw-r--r-- | src/storage.cc | 7 | ||||
-rw-r--r-- | tests/c11.h | 4 | ||||
-rw-r--r-- | tests/cache_1_1.cc | 14 | ||||
-rw-r--r-- | tests/cache_2_1.cc | 12 | ||||
-rw-r--r-- | tests/dram.cc | 30 |
7 files changed, 35 insertions, 42 deletions
diff --git a/inc/definitions.h b/inc/definitions.h index 020f995..f0946b8 100644 --- a/inc/definitions.h +++ b/inc/definitions.h @@ -37,7 +37,7 @@ * The number of bits to specify a memory line * The total number of lines in memory */ -#define MEM_WORD_SPEC 16 +#define MEM_WORD_SPEC 14 #define MEM_LINE_SPEC static_cast<unsigned int>(MEM_WORD_SPEC - LINE_SPEC) #define MEM_WORDS static_cast<int>(pow(2, MEM_WORD_SPEC)) #define MEM_LINES static_cast<int>(pow(2, MEM_LINE_SPEC)) diff --git a/inc/storage.h b/inc/storage.h index d7e49c8..f15dc0b 100644 --- a/inc/storage.h +++ b/inc/storage.h @@ -65,13 +65,9 @@ class Storage virtual int read_word(void *id, int address, signed int &data) = 0; /** - * Sidedoor view of `lines` of memory starting at `base`. - * @param The base line to start getting memory from. - * @param The amount of lines to fetch. - * @return A matrix of data values, where each row is a line and each column - * is a word. + * @return a copy of `this->data' */ - std::vector<std::array<signed int, LINE_SIZE>> view(int base, int lines) const; + std::vector<std::array<signed int, LINE_SIZE>> get_data() const; protected: /** diff --git a/src/storage.cc b/src/storage.cc index c13b9db..890a137 100644 --- a/src/storage.cc +++ b/src/storage.cc @@ -30,12 +30,9 @@ Storage::Storage(int delay) } std::vector<std::array<signed int, LINE_SIZE>> -Storage::view(int base, int lines) const +Storage::get_data() const { - base = (base / LINE_SIZE) * LINE_SIZE; - std::vector<std::array<signed int, LINE_SIZE>> ret(lines + 1); - std::copy(this->data->begin() + base, this->data->begin() + base + lines, ret.begin()); - return ret; + return *data; } int diff --git a/tests/c11.h b/tests/c11.h index 983d298..57a8ee1 100644 --- a/tests/c11.h +++ b/tests/c11.h @@ -23,7 +23,7 @@ class C11 this->fetch = new int(); this->c = new Cache(new Dram(this->m_delay), 5, 0, this->c_delay); this->expected = {0, 0, 0, 0}; - this->actual = this->c->view(0, 1)[0]; + this->actual = this->c->get_data()[0]; } ~C11() @@ -42,7 +42,7 @@ class C11 // check response CHECK(!r); // check for early modifications - actual = c->view(0, 1)[0]; + actual = c->get_data()[0]; REQUIRE(this->expected == this->actual); } } diff --git a/tests/cache_1_1.cc b/tests/cache_1_1.cc index 7d16f76..3cc83a0 100644 --- a/tests/cache_1_1.cc +++ b/tests/cache_1_1.cc @@ -20,7 +20,7 @@ TEST_CASE_METHOD(C11, "store 0th element in DELAY cycles", "[dram]") CHECK(r); expected.at(0) = w; - actual = c->view(0, 1)[0]; + actual = c->get_data()[0]; REQUIRE(expected == actual); } @@ -40,7 +40,7 @@ TEST_CASE_METHOD(C11, "store 0th, 1st element in DELAY cycles, with conflict", " CHECK(!r); // check for early modifications - actual = c->view(0, 1)[0]; + actual = c->get_data()[0]; REQUIRE(this->expected == this->actual); } @@ -48,7 +48,7 @@ TEST_CASE_METHOD(C11, "store 0th, 1st element in DELAY cycles, with conflict", " CHECK(r); expected.at(0) = w; - actual = c->view(0, 1)[0]; + actual = c->get_data()[0]; REQUIRE(expected == actual); // this should have been loaded already! @@ -59,7 +59,7 @@ TEST_CASE_METHOD(C11, "store 0th, 1st element in DELAY cycles, with conflict", " CHECK(r); expected.at(1) = w; - actual = c->view(0, 1)[0]; + actual = c->get_data()[0]; REQUIRE(expected == actual); } @@ -81,7 +81,7 @@ TEST_CASE_METHOD( CHECK(r); expected.at(0) = w; - actual = c->view(0, 1)[0]; + actual = c->get_data()[0]; REQUIRE(expected == actual); // write back to memory @@ -95,7 +95,7 @@ TEST_CASE_METHOD( CHECK(r); expected.at(0) = 0; - actual = c->view(0, 1)[0]; + actual = c->get_data()[0]; CHECK(expected == actual); this->wait_then_do( @@ -106,6 +106,6 @@ TEST_CASE_METHOD( expected.at(0) = 0; expected.at(1) = w; - actual = c->view(0, 1)[0]; + actual = c->get_data()[0]; REQUIRE(expected == actual); } diff --git a/tests/cache_2_1.cc b/tests/cache_2_1.cc index cb48d2a..191d5f2 100644 --- a/tests/cache_2_1.cc +++ b/tests/cache_2_1.cc @@ -43,12 +43,12 @@ TEST_CASE_METHOD(C21, "store 32th, 96th element in DELAY cycles, evict to level // check level 2 // note this is write-back == no write - actual = this->c2->view(32, 1)[0]; + actual = this->c2->get_data()[32]; REQUIRE(expected == actual); // check level 1 expected.at(0) = w; - actual = this->c->view(0, 1)[0]; + actual = this->c->get_data()[0]; REQUIRE(expected == actual); // wait = evict @@ -57,7 +57,7 @@ TEST_CASE_METHOD(C21, "store 32th, 96th element in DELAY cycles, evict to level }); // check level 2 - actual = this->c2->view(32, 1)[0]; + actual = this->c2->get_data()[32]; REQUIRE(expected == actual); // read in line @@ -75,13 +75,13 @@ TEST_CASE_METHOD(C21, "store 32th, 96th element in DELAY cycles, evict to level CHECK(r); // check level 2 - actual = this->c2->view(96, 1)[0]; + actual = this->c2->get_data()[96]; REQUIRE(expected == actual); expected.at(0) = w; - actual = this->c2->view(32, 1)[0]; + actual = this->c2->get_data()[32]; REQUIRE(expected == actual); // check level 1 - actual = this->c->view(0, 1)[0]; + actual = this->c->get_data()[0]; REQUIRE(expected == actual); } diff --git a/tests/dram.cc b/tests/dram.cc index 06a7720..5eb0316 100644 --- a/tests/dram.cc +++ b/tests/dram.cc @@ -12,7 +12,7 @@ class D this->mem = new int; this->fetch = new int; this->expected = {0, 0, 0, 0}; - this->actual = this->d->view(0, 1)[0]; + this->actual = this->d->get_data()[0]; } ~D() @@ -31,7 +31,7 @@ class D // check response CHECK(!r); // check for early modifications - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; REQUIRE(this->expected == this->actual); } } @@ -58,7 +58,7 @@ TEST_CASE_METHOD(D, "store 0th element in DELAY cycles", "[dram]") CHECK(r); expected.at(0) = w; - actual = this->d->view(0, 1)[0]; + actual = this->d->get_data()[0]; REQUIRE(expected == actual); } @@ -76,7 +76,7 @@ TEST_CASE_METHOD(D, "store 0th, 1st element in DELAY cycles, no conflict", "[dra REQUIRE(r); expected.at(0) = w; - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; REQUIRE(expected == actual); this->wait_for_storage( @@ -85,7 +85,7 @@ TEST_CASE_METHOD(D, "store 0th, 1st element in DELAY cycles, no conflict", "[dra r = d->write_word(this->fetch, w, 0x1); CHECK(r); - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; expected.at(1) = w; REQUIRE(expected == actual); } @@ -104,7 +104,7 @@ TEST_CASE_METHOD(D, "store 0th element in DELAY cycles with conflict", "[dram]") CHECK(!r); // check for early modifications - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; REQUIRE(expected == actual); } @@ -112,7 +112,7 @@ TEST_CASE_METHOD(D, "store 0th element in DELAY cycles with conflict", "[dram]") REQUIRE(r); expected.at(0) = w; - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; REQUIRE(expected == actual); this->wait_for_storage( @@ -121,7 +121,7 @@ TEST_CASE_METHOD(D, "store 0th element in DELAY cycles with conflict", "[dram]") r = d->write_word(this->fetch, w, 0x1); CHECK(r); - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; expected.at(1) = w; REQUIRE(expected == actual); } @@ -141,7 +141,7 @@ TEST_CASE_METHOD(D, "store line in DELAY cycles", "[dram]") r = d->write_line(this->mem, buffer, 0x0); CHECK(r); - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; expected = buffer; REQUIRE(expected == actual); } @@ -162,7 +162,7 @@ TEST_CASE_METHOD(D, "store line in DELAY cycles no conflict", "[dram]") REQUIRE(r); expected = buffer; - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; REQUIRE(expected == actual); buffer = {w + 4, w + 5, w + 6, w + 7}; @@ -173,7 +173,7 @@ TEST_CASE_METHOD(D, "store line in DELAY cycles no conflict", "[dram]") CHECK(r); expected = buffer; - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; REQUIRE(expected == actual); } @@ -193,14 +193,14 @@ TEST_CASE_METHOD(D, "store line in DELAY cycles with conflict", "[dram]") CHECK(!r); // check for early modifications - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; REQUIRE(expected == actual); } r = d->write_line(this->mem, buffer, 0x0); CHECK(r); - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; expected = buffer; REQUIRE(expected == actual); @@ -212,7 +212,7 @@ TEST_CASE_METHOD(D, "store line in DELAY cycles with conflict", "[dram]") CHECK(r); expected = buffer; - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; REQUIRE(expected == actual); } @@ -299,7 +299,7 @@ TEST_CASE_METHOD( r = d->write_line(this->mem, expected, addr); CHECK(r); - actual = d->view(0, 1)[0]; + actual = d->get_data()[0]; REQUIRE(expected == actual); for (i = 0; i < LINE_SIZE; ++i) { |