diff options
author | Siddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com> | 2025-03-29 22:14:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-29 22:14:42 -0400 |
commit | b3566a17da8081147dba3711d415385450ed6019 (patch) | |
tree | cf5d6872eec0cf50d1831137a337bbbdfbee0ff1 | |
parent | 495a8af3a90257e491c063730bccf86e34e153fa (diff) | |
parent | d8e33f871bfb8dbfbad3fa0d7e1e13af5bcde830 (diff) |
Merge pull request #37 from bdunahu/bdunahu
Instr, InstrDTO gets/sets, other structures required for decode
-- tests as we move forward
-- base classes
-- decode stage implemented
-rw-r--r-- | inc/accessor.h | 3 | ||||
-rw-r--r-- | inc/definitions.h | 32 | ||||
-rw-r--r-- | inc/response.h | 1 | ||||
-rw-r--r-- | inc/storage.h | 2 | ||||
-rw-r--r-- | inc/utils.h | 2 | ||||
-rw-r--r-- | src/cli/cli.cc | 3 | ||||
-rw-r--r-- | src/storage/cache.cc | 4 | ||||
-rw-r--r-- | src/utils/accessor.cc | 4 | ||||
-rw-r--r-- | src/utils/response.cc | 2 | ||||
-rw-r--r-- | src/utils/utils.cc | 10 | ||||
-rw-r--r-- | tests/utils.cc | 8 |
11 files changed, 55 insertions, 16 deletions
diff --git a/inc/accessor.h b/inc/accessor.h index fb4999d..eb56785 100644 --- a/inc/accessor.h +++ b/inc/accessor.h @@ -4,7 +4,10 @@ enum Accessor { IDLE, + WRITE, MEM, + EXEC, + DCDE, FETCH, L1CACHE, SIDE, diff --git a/inc/definitions.h b/inc/definitions.h index ff2f7c6..3238a8b 100644 --- a/inc/definitions.h +++ b/inc/definitions.h @@ -11,6 +11,10 @@ * The total number of words in a line */ #define LINE_SIZE static_cast<int>(pow(2, 2)) +/** + * Number of bits in a word + */ +#define WORD_SPEC 32 /** * The number of bits to specify a memory word @@ -28,7 +32,8 @@ * The total number of lines in l1 cache */ #define L1_CACHE_WORD_SPEC 7 -#define L1_CACHE_LINE_SPEC static_cast<unsigned int>(L1_CACHE_WORD_SPEC - LINE_SPEC) +#define L1_CACHE_LINE_SPEC \ + static_cast<unsigned int>(L1_CACHE_WORD_SPEC - LINE_SPEC) #define L1_CACHE_LINES static_cast<int>(pow(2, L1_CACHE_LINE_SPEC)) /** @@ -47,6 +52,31 @@ #define GPR_NUM 16 /** + * The number of vector registers + */ +#define V_NUM 8 + +/** + * The number of bits to specify an instruction type + */ +#define TYPE_SIZE 2 + +/** + * The number of bits to specify a register + */ +#define REG_SIZE 5 + +/** + * The number of bits to specify an R-Type opcode. + */ +#define R_OPCODE_SIZE 5 + +/** + * The number of bits to specify an opcode. + */ +#define OPCODE_SIZE 4 + +/** * Return the N least-significant bits from integer K using a bit mask * @param the integer to be parsed * @param the number of bits to be parsed diff --git a/inc/response.h b/inc/response.h index 6cd6678..05e9352 100644 --- a/inc/response.h +++ b/inc/response.h @@ -6,6 +6,7 @@ enum Response { OK, WAIT, BLOCKED, + STALLED, }; std::ostream &operator<<(std::ostream &os, Response r); diff --git a/inc/storage.h b/inc/storage.h index ff1fbcb..d6fa094 100644 --- a/inc/storage.h +++ b/inc/storage.h @@ -80,7 +80,7 @@ class Storage /** * The accessor currently being serviced. */ - enum Accessor requester; + Accessor requester; /** * The number of cycles until the current request is completed. */ diff --git a/inc/utils.h b/inc/utils.h index df8d374..a375b68 100644 --- a/inc/utils.h +++ b/inc/utils.h @@ -10,7 +10,7 @@ * @param the resulting index * @param the resulting offset */ -void get_bit_fields(int address, int *tag, int *index, int *offset); +void get_cache_fields(int address, int *tag, int *index, int *offset); /** * Formats a string using snprintf. diff --git a/src/cli/cli.cc b/src/cli/cli.cc index 022b266..58575cb 100644 --- a/src/cli/cli.cc +++ b/src/cli/cli.cc @@ -3,6 +3,7 @@ #include "definitions.h" #include "dram.h" #include "response.h" +#include "accessor.h" #include "utils.h" #include <iostream> @@ -43,6 +44,7 @@ Cli::Cli() }; commands['r'] = [this](std::vector<std::string> args) { + (void)args; reset(); return; }; @@ -61,6 +63,7 @@ Cli::Cli() }; commands['h'] = [this](std::vector<std::string> args) { + (void)args; help(); return; }; diff --git a/src/storage/cache.cc b/src/storage/cache.cc index dccab47..80f59ef 100644 --- a/src/storage/cache.cc +++ b/src/storage/cache.cc @@ -69,7 +69,7 @@ Response Cache::process( Response r = this->is_access_cleared(accessor, address); if (r == OK) { int tag, index, offset; - get_bit_fields(address, &tag, &index, &offset); + get_cache_fields(address, &tag, &index, &offset); request_handler(index, offset); } return r; @@ -104,7 +104,7 @@ void Cache::handle_miss(int expected) std::array<signed int, LINE_SIZE> *actual; std::array<int, 2> *meta; - get_bit_fields(expected, &tag, &index, &offset); + get_cache_fields(expected, &tag, &index, &offset); r = OK; meta = &this->meta.at(index); actual = &this->data->at(index); diff --git a/src/utils/accessor.cc b/src/utils/accessor.cc index 86484c5..99347ed 100644 --- a/src/utils/accessor.cc +++ b/src/utils/accessor.cc @@ -3,6 +3,8 @@ std::ostream &operator<<(std::ostream &os, Accessor a) { - const std::string nameA[] = {"IDLE", "MEM", "FETCH", "L1CACHE", "SIDE"}; + const std::string nameA[] = { + "IDLE", "WRITE", "MEM", "EXEC", "DCDE", "FETCH", "L1CACHE", "SIDE", + }; return os << nameA[a]; } diff --git a/src/utils/response.cc b/src/utils/response.cc index def6578..3d6e439 100644 --- a/src/utils/response.cc +++ b/src/utils/response.cc @@ -3,6 +3,6 @@ std::ostream &operator<<(std::ostream &os, Response r) { - const std::string nameR[] = {"OK", "WAIT", "BLOCKED"}; + const std::string nameR[] = {"OK", "WAIT", "BLOCKED", "STALLED"}; return os << nameR[r]; } diff --git a/src/utils/utils.cc b/src/utils/utils.cc index 3a11c2c..e12a0e0 100644 --- a/src/utils/utils.cc +++ b/src/utils/utils.cc @@ -4,10 +4,9 @@ #include <string> #include <vector> -void get_bit_fields(int address, int *tag, int *index, int *offset) +void get_cache_fields(int address, int *tag, int *index, int *offset) { - *tag = GET_MID_BITS( - address, L1_CACHE_LINE_SPEC + LINE_SPEC, MEM_WORD_SPEC); + *tag = GET_MID_BITS(address, L1_CACHE_LINE_SPEC + LINE_SPEC, MEM_WORD_SPEC); *index = GET_MID_BITS(address, LINE_SPEC, L1_CACHE_LINE_SPEC + LINE_SPEC); *offset = GET_LS_BITS(address, LINE_SPEC); } @@ -28,8 +27,9 @@ const std::string string_format(const char *const zcFormat, ...) return std::string(zc.data(), iLen); } -int wrap_address(int address) { - if (address < 0){ +int wrap_address(int address) +{ + if (address < 0) { return ((address % MEM_WORDS) + MEM_WORDS) % MEM_WORDS; } return address % MEM_WORDS; diff --git a/tests/utils.cc b/tests/utils.cc index ea1a1ed..2e0e934 100644 --- a/tests/utils.cc +++ b/tests/utils.cc @@ -2,21 +2,21 @@ #include "definitions.h" #include <catch2/catch_test_macros.hpp> -TEST_CASE("Parse arbitrary fields # one", "[cache]") +TEST_CASE("Parse arbitrary fields # one", "[utils]") { int tag, index, offset; int address = 0b0001010101; - get_bit_fields(address, &tag, &index, &offset); + get_cache_fields(address, &tag, &index, &offset); CHECK(tag == 0b000); CHECK(index == 0b10101); CHECK(offset == 0b01); } -TEST_CASE("Parse arbitrary fields # two", "[cache]") +TEST_CASE("Parse arbitrary fields # two", "[utils]") { int tag, index, offset; int address = 0b0100111011; - get_bit_fields(address, &tag, &index, &offset); + get_cache_fields(address, &tag, &index, &offset); CHECK(tag == 0b010); CHECK(index == 0b01110); CHECK(offset == 0b11); |