summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com>2025-03-25 12:41:38 -0400
committerGitHub <noreply@github.com>2025-03-25 12:41:38 -0400
commit9476d1355493cdab93064ec123ac13bfb78e8ed3 (patch)
treea99c2895027f22c4dbb4191fb132db36700bd0bf
parentfab7d9dcf249762eeac89a11487856e7569c66d5 (diff)
parent46c79e6e929ab784eb12417028dd43740b1a561e (diff)
Merge pull request #33 from bdunahu/dev-sid
Initial GUI Commit
-rw-r--r--CMakeLists.txt20
-rw-r--r--README.md2
-rw-r--r--inc/cache.h1
-rw-r--r--inc/dram.h1
-rw-r--r--inc/logger.h10
-rw-r--r--src/gui/gui.py0
-rw-r--r--src/logger/logger.cc20
-rw-r--r--src/main.cc84
8 files changed, 17 insertions, 121 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6a48922..9daac12 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,32 +1,34 @@
cmake_minimum_required(VERSION 3.5)
+set(CMAKE_CXX_COMPILER "g++")
project(risc_vector)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
-add_compile_options(-Wall -lstdc++)
+add_compile_options(-Wall -lstdc++ -g -O0)
add_compile_options(-Wextra -Wpedantic)
# cpp standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
-set(CMAKE_CXX_COMPILER "g++")
-
# header files
include_directories(
${PROJECT_SOURCE_DIR}/inc
)
+# add gui
+add_subdirectory(gui)
+
# gather source files
file(GLOB_RECURSE SRCS "src/*.cc")
-list(REMOVE_ITEM SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cc")
-# find python3 components
-find_package(Python3 COMPONENTS Development REQUIRED)
+# find QT components
+find_package(Qt6 COMPONENTS Widgets REQUIRED)
+qt_standard_project_setup()
# binary executable
-add_executable(${PROJECT_NAME} ${SRCS} src/main.cc)
-target_link_libraries(${PROJECT_NAME} PRIVATE Python3::Python)
+add_library(${PROJECT_NAME}_lib ${SRCS})
+target_link_libraries(${PROJECT_NAME}_lib)
find_package(Catch2 REQUIRED)
@@ -35,7 +37,7 @@ file(GLOB_RECURSE TESTS "tests/*.cc")
# test executable
add_executable(tests ${SRCS} ${TESTS})
-target_link_libraries(tests PRIVATE Catch2::Catch2WithMain PRIVATE Python3::Python)
+target_link_libraries(tests PRIVATE Catch2::Catch2WithMain PRIVATE)
# test discovery
include(CTest)
diff --git a/README.md b/README.md
index 34ae8af..a6ce662 100644
--- a/README.md
+++ b/README.md
@@ -3,8 +3,8 @@
## dependencies
- cmake
- g++ (GCC) 11.4.0
-- python 3.10 or newer
- catch2 version 3.5.3
+- Qt version 6.8.2
## to compile
Generate the build directory with
diff --git a/inc/cache.h b/inc/cache.h
index ef9c9e4..88fd352 100644
--- a/inc/cache.h
+++ b/inc/cache.h
@@ -4,6 +4,7 @@
#include "storage.h"
#include <array>
#include <ostream>
+#include <functional>
class Cache : public Storage
{
diff --git a/inc/dram.h b/inc/dram.h
index f4d175e..0799015 100644
--- a/inc/dram.h
+++ b/inc/dram.h
@@ -3,6 +3,7 @@
#include "definitions.h"
#include "storage.h"
#include <ostream>
+#include <functional>
class Dram : public Storage
{
diff --git a/inc/logger.h b/inc/logger.h
index 38527c8..88f9e30 100644
--- a/inc/logger.h
+++ b/inc/logger.h
@@ -11,7 +11,7 @@ class Logger
public:
static Logger* getInstance();
- ~Logger();
+ ~Logger() = default;
/**
* Do not allow copies.
@@ -32,15 +32,9 @@ class Logger
void log(LogLevel, const string &);
private:
- /**
- * Constructor.
- * @param The file name to log to.
- * @return A new logger object.
- */
- Logger(const string &);
+ Logger() = default;
static Logger* logger_instance;
static LogLevel level;
- static ofstream logFile;
static string level_to_string(LogLevel);
static int level_to_int(LogLevel);
};
diff --git a/src/gui/gui.py b/src/gui/gui.py
deleted file mode 100644
index e69de29..0000000
--- a/src/gui/gui.py
+++ /dev/null
diff --git a/src/logger/logger.cc b/src/logger/logger.cc
index 55d7a15..6dfaef1 100644
--- a/src/logger/logger.cc
+++ b/src/logger/logger.cc
@@ -6,21 +6,8 @@
using namespace std;
LogLevel Logger::level = INFO;
-ofstream Logger::logFile;
Logger *Logger::logger_instance;
-Logger::Logger(const string &filename)
-{
- if (!filename.empty()) {
- logFile.open(filename, ios::app);
- if (!logFile.is_open()) {
- cerr << "Error opening log file." << endl;
- }
- }
-}
-
-Logger::~Logger() { logFile.close(); }
-
void Logger::setLevel(LogLevel level) { level = level; }
void Logger::log(LogLevel level, const string &message)
@@ -39,17 +26,12 @@ void Logger::log(LogLevel level, const string &message)
<< message << endl;
cout << logEntry.str();
-
- if (logFile.is_open()) {
- logFile << logEntry.str();
- logFile.flush();
- }
}
Logger *Logger::getInstance()
{
if (logger_instance == nullptr) {
- logger_instance = new Logger("vector.log");
+ logger_instance = new Logger();
}
return logger_instance;
}
diff --git a/src/main.cc b/src/main.cc
deleted file mode 100644
index f5eecac..0000000
--- a/src/main.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "cli.h"
-#include "definitions.h"
-#include "logger.h"
-#include <getopt.h>
-#include <iostream>
-
-static Logger *global_log = Logger::getInstance();
-
-static std::string version_number = "v0.1";
-static std::string banner =
- " _/_/_/ _/_/_/ _/_/_/ _/_/_/ \n"
- " _/ _/ _/ _/ _/ \n"
- " _/_/_/ _/ _/_/ _/ \n"
- " _/ _/ _/ _/ _/ \n"
- "_/ _/ _/_/_/ _/_/_/ _/_/_/ \n"
- " \n"
- " \n"
- " _/_/ _/_/ \n"
- " _/ _/ _/ _/_/_/_/ _/_/_/ _/_/_/_/_/ _/_/ _/_/_/ _/ \n"
- " _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ \n"
- "_/ _/ _/ _/_/_/ _/ _/ _/ _/ _/_/_/ _/ \n"
- " _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ \n"
- " _/ _/ _/_/_/_/ _/_/_/ _/ _/_/ _/ _/ _/ \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--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 &memory_only)
-{
- struct option long_options[] = {
- {"debug", no_argument, 0, 'd'},
- {"memory-only", no_argument, 0, 'm'},
- {0, 0, 0, 0}};
-
- int opt;
-
- 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 'm':
- global_log->log(INFO, "Starting the storage CLI interface...");
- memory_only = true;
- break;
- default:
- err();
- exit(EXIT_FAILURE);
- }
- }
-}
-
-int main(int argc, char **argv)
-{
- print_version_number();
- global_log->log(INFO, "Initializing...");
-
- bool memory_only = false;
- parseArguments(argc, argv, memory_only);
-
- if (memory_only) {
- Cli cli;
- 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;
-}