diff options
author | Siddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com> | 2025-03-21 14:21:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-21 14:21:06 -0400 |
commit | 24e8a72b40cb185de04821f31be65b0ec8768fb7 (patch) | |
tree | ffd8e0bd2b112180251804a096f601f745f9af1b /src | |
parent | 89b9d1e4592d11cd6146b1bc3b3c12e241e574d3 (diff) | |
parent | cf3ac49639bef5082489068e2d92a4d86f42080b (diff) |
Merge pull request #27 from bdunahu/bdunahu
Make memory simulator an optional command, switch to test fixtures
Changes look good
Diffstat (limited to 'src')
-rw-r--r-- | src/cli/cli.cc | 2 | ||||
-rw-r--r-- | src/main.cc | 43 | ||||
-rw-r--r-- | src/storage/dram.cc | 4 |
3 files changed, 25 insertions, 24 deletions
diff --git a/src/cli/cli.cc b/src/cli/cli.cc index 41ac57c..e25b316 100644 --- a/src/cli/cli.cc +++ b/src/cli/cli.cc @@ -211,7 +211,7 @@ void Cli::initialize() if (this->cache != nullptr) delete this->cache; - Dram *d = new Dram(MEM_LINES, MEM_DELAY); + Dram *d = new Dram(MEM_DELAY); this->cache = new Cache(d, L1_CACHE_DELAY); this->cycle = 1; } diff --git a/src/main.cc b/src/main.cc index 08b38e6..f5eecac 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ #include "cli.h" -#include "logger.h" #include "definitions.h" +#include "logger.h" #include <getopt.h> #include <iostream> @@ -22,36 +22,39 @@ static std::string banner = " _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ \n" " _/ _/ _/_/_/_/ _/_/_/ _/ _/_/ _/ _/ _/ \n" " _/_/ _/_/ "; -static void print_version_number() { std::cout << banner << version_number << '\n'; } +static void print_version_number() +{ + std::cout << banner << version_number << '\n'; +} static void err() { std::cerr << "Usage:\n\trisc_vector [OPTIONS]\nOptions:\n\t--debug,\t-d: " - "turn on verbose output\n\t--no-python,\t-p: run without " - "GUI\n\t--version,\t-v: print the version information and exit\n" + "turn on verbose output\n\t--memory-only,\t-m: run the memory " + "simulator only, without a GUI.\n\t--version,\t-v: print the " + "version information and exit\n" << std::endl; } -static void parseArguments(int argc, char **argv, bool &python) +static void +parseArguments(int argc, char **argv, bool &memory_only) { struct option long_options[] = { {"debug", no_argument, 0, 'd'}, - {"no-python", no_argument, 0, 'p'}, + {"memory-only", no_argument, 0, 'm'}, {0, 0, 0, 0}}; - python = true; - int opt; - while ((opt = getopt_long(argc, argv, "d:p", long_options, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "d:m", long_options, NULL)) != -1) { switch (opt) { case 'd': global_log->setLevel(DEBUG); global_log->log(DEBUG, "DEBUG output enabled."); break; - case 'p': - global_log->log(INFO, "Python will NOT be started!"); - python = false; + case 'm': + global_log->log(INFO, "Starting the storage CLI interface..."); + memory_only = true; break; default: err(); @@ -63,20 +66,18 @@ static void parseArguments(int argc, char **argv, bool &python) int main(int argc, char **argv) { print_version_number(); - Cli cli; global_log->log(INFO, "Initializing..."); - bool python = true; - parseArguments(argc, argv, python); + bool memory_only = false; + parseArguments(argc, argv, memory_only); - if (python) { - // fork off python here - ; - global_log->log(INFO, "Python started."); + if (memory_only) { + Cli cli; + cli.run(); } - cli.run(); - + // fork off python here + global_log->log(INFO, "Python started."); global_log->log(INFO, "Cleaning up..."); global_log->log(INFO, "Goodbye!"); return EXIT_SUCCESS; diff --git a/src/storage/dram.cc b/src/storage/dram.cc index 56eec47..20db47e 100644 --- a/src/storage/dram.cc +++ b/src/storage/dram.cc @@ -8,10 +8,10 @@ #include <iterator> #include <utils.h> -Dram::Dram(int lines, int delay) +Dram::Dram(int delay) { this->data = new std::vector<std::array<signed int, LINE_SIZE>>; - this->data->resize(lines); + this->data->resize(MEM_LINES); this->delay = delay; this->is_waiting = false; this->lower = nullptr; |