summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cache.cc12
-rw-r--r--tests/utils.cc24
2 files changed, 18 insertions, 18 deletions
diff --git a/tests/cache.cc b/tests/cache.cc
index d7b3444..daaec90 100644
--- a/tests/cache.cc
+++ b/tests/cache.cc
@@ -15,7 +15,7 @@ TEST_CASE("Constructor singleton cache", "[cache]")
TEST_CASE("no delay stores instantly", "[cache]")
{
int delay = 0;
- Dram *d = new Dram(MEM_SIZE, delay);
+ Dram *d = new Dram(MEM_LINES, delay);
Cache *c = new Cache(d, delay);
std::array<signed int, LINE_SIZE> expected = {0, 0, 0, 0};
std::array<signed int, LINE_SIZE> actual = d->view(0, 1)[0];
@@ -43,7 +43,7 @@ TEST_CASE("no delay stores instantly", "[cache]")
TEST_CASE("cache takes \"forever\"", "[cache]")
{
int delay = 0;
- Dram *d = new Dram(MEM_SIZE, delay);
+ Dram *d = new Dram(MEM_LINES, delay);
Cache *c = new Cache(d, delay + 2);
std::array<signed int, LINE_SIZE> expected = {0, 0, 0, 0};
std::array<signed int, LINE_SIZE> actual = d->view(0, 1)[0];
@@ -79,7 +79,7 @@ TEST_CASE("cache takes \"forever\"", "[cache]")
TEST_CASE("dram takes \"forever\"", "[cache]")
{
int delay = 0;
- Dram *d = new Dram(MEM_SIZE, delay + 2);
+ Dram *d = new Dram(MEM_LINES, delay + 2);
Cache *c = new Cache(d, delay);
std::array<signed int, LINE_SIZE> expected = {0, 0, 0, 0};
std::array<signed int, LINE_SIZE> actual = d->view(0, 1)[0];
@@ -115,7 +115,7 @@ TEST_CASE("dram takes \"forever\"", "[cache]")
TEST_CASE("dram and cache take \"forever\"", "[cache]")
{
int delay = 2;
- Dram *d = new Dram(MEM_SIZE, delay + 2);
+ Dram *d = new Dram(MEM_LINES, delay + 2);
Cache *c = new Cache(d, delay);
std::array<signed int, LINE_SIZE> expected = {0, 0, 0, 0};
std::array<signed int, LINE_SIZE> actual = d->view(0, 1)[0];
@@ -162,7 +162,7 @@ TEST_CASE(
"dram takes \"forever\", two concurrent requests same index", "[cache]")
{
int delay = 0;
- Dram *d = new Dram(MEM_SIZE, delay + 2);
+ Dram *d = new Dram(MEM_LINES, delay + 2);
Cache *c = new Cache(d, delay);
std::array<signed int, LINE_SIZE> expected = {0, 0, 0, 0};
std::array<signed int, LINE_SIZE> actual = d->view(0, 1)[0];
@@ -217,7 +217,7 @@ TEST_CASE(
"[cache]")
{
int delay = 0;
- Dram *d = new Dram(MEM_SIZE, delay + 2);
+ Dram *d = new Dram(MEM_LINES, delay + 2);
Cache *c = new Cache(d, delay);
std::array<signed int, LINE_SIZE> expected = {0, 0, 0, 0};
std::array<signed int, LINE_SIZE> actual = d->view(0, 1)[0];
diff --git a/tests/utils.cc b/tests/utils.cc
index f0e4c24..ea1a1ed 100644
--- a/tests/utils.cc
+++ b/tests/utils.cc
@@ -5,9 +5,9 @@
TEST_CASE("Parse arbitrary fields # one", "[cache]")
{
int tag, index, offset;
- int address = 0b111110001010101;
+ int address = 0b0001010101;
get_bit_fields(address, &tag, &index, &offset);
- CHECK(tag == 0b11111000);
+ CHECK(tag == 0b000);
CHECK(index == 0b10101);
CHECK(offset == 0b01);
}
@@ -15,30 +15,30 @@ TEST_CASE("Parse arbitrary fields # one", "[cache]")
TEST_CASE("Parse arbitrary fields # two", "[cache]")
{
int tag, index, offset;
- int address = 0b000110100111011;
+ int address = 0b0100111011;
get_bit_fields(address, &tag, &index, &offset);
- CHECK(tag == 0b00011010);
+ CHECK(tag == 0b010);
CHECK(index == 0b01110);
CHECK(offset == 0b11);
}
TEST_CASE("wrap address outside upper bound", "[utils]")
{
- int address = MEM_SIZE + 25;
+ int address = MEM_WORDS + 25;
int wrapped = wrap_address(address);
REQUIRE(wrapped == 25);
}
TEST_CASE("wrap address inside upper bound", "[utils]")
{
- int address = MEM_SIZE - 25;
+ int address = MEM_WORDS - 25;
int wrapped = wrap_address(address);
- REQUIRE(wrapped == MEM_SIZE - 25);
+ REQUIRE(wrapped == MEM_WORDS - 25);
}
TEST_CASE("wrap address at upper bound", "[utils]")
{
- int address = MEM_SIZE;
+ int address = MEM_WORDS;
int wrapped = wrap_address(address);
REQUIRE(wrapped == 0);
}
@@ -47,14 +47,14 @@ TEST_CASE("wrap address lower than 0 with magnitude lesser than mem size", "[uti
{
int address = -10;
int wrapped = wrap_address(address);
- REQUIRE(wrapped == MEM_SIZE - 10);
+ REQUIRE(wrapped == MEM_WORDS - 10);
}
TEST_CASE("wrap address lower than 0 but with magnitude greater than mem size", "[utils]")
{
- int address = -(MEM_SIZE + 10);
+ int address = -(MEM_WORDS + 10);
int wrapped = wrap_address(address);
- REQUIRE(wrapped == MEM_SIZE - 10);
+ REQUIRE(wrapped == MEM_WORDS - 10);
}
TEST_CASE("wrap address at 0", "[utils]")
@@ -62,4 +62,4 @@ TEST_CASE("wrap address at 0", "[utils]")
int address = 0;
int wrapped = wrap_address(address);
REQUIRE(wrapped == 0);
-} \ No newline at end of file
+}