summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-11 23:09:49 -0400
committerbd <bdunahu@operationnull.com>2025-04-11 23:09:49 -0400
commitdf580c5352528a4837b996a838f486d3838050a4 (patch)
tree72671b34d6baf1ea2ec4cd02f73fe51338ce0b6d /inc
parent3eeb345d673bee6d62b04fc8a8a95ab822dc1e45 (diff)
Move storage to a separate git repository.
Diffstat (limited to 'inc')
-rw-r--r--inc/cache.h84
-rw-r--r--inc/cli.h97
-rw-r--r--inc/dram.h62
-rw-r--r--inc/storage.h95
4 files changed, 0 insertions, 338 deletions
diff --git a/inc/cache.h b/inc/cache.h
deleted file mode 100644
index 88fd352..0000000
--- a/inc/cache.h
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef CACHE_H
-#define CACHE_H
-#include "definitions.h"
-#include "storage.h"
-#include <array>
-#include <ostream>
-#include <functional>
-
-class Cache : public Storage
-{
- public:
- /**
- * Constructor.
- * @param The number of `lines` contained in memory. The total number of
- * words is this number multiplied by LINE_SIZE.
- * @param The next lowest level in storage. Methods from this object are
- * called in case of a cache miss.
- * @param The number of clock cycles each access takes.
- * @return A new cache object.
- */
- Cache(Storage *lower, int delay);
- ~Cache();
-
- Response
- write_word(Accessor accessor, signed int data, int address) override;
- Response write_line(
- Accessor accessor,
- std::array<signed int, LINE_SIZE> data_line,
- int address) override;
- Response read_line(
- Accessor accessor,
- int address,
- std::array<signed int, LINE_SIZE> &data_line) override;
- Response
- read_word(Accessor accessor, int address, signed int &data) override;
-
- /**
- * Getter for the meta attribute.
- * TODO this doesn't seem like good object-oriented practice.
- * @return this->meta
- */
- std::array<std::array<int, 2>, L1_CACHE_LINES> get_meta() const;
-
- private:
- /**
- * Helper for all access methods.
- * Calls `request_handler` when `accessor` is allowed to complete its
- * request cycle.
- * @param the source making the request
- * @param the address to write to
- * @param the function to call when an access should be completed
- */
- Response process(
- Accessor accessor,
- int address,
- std::function<void(int index, int offset)> request_handler);
- /**
- * Returns OK if `accessor` is allowed to complete its request this cycle.
- * Handles cache misses, wait times, and setting the current accessor this
- * storage is serving.
- * @param the accessor asking for a resource
- * @return whether or not the access can be carried out this function call.
- */
- Response is_access_cleared(Accessor accessor, int address);
- /**
- * Helper for access_cleared.
- * Fetches `address` from a lower level of storage if it is not already
- * present. If it is not, temporarily sets the is_blocked attribute of this
- * cache level to true, and the victim line is chosen/written back.
- * @param the address that must be present in cache.
- */
- void handle_miss(int address);
- /**
- * An array of metadata about elements in `data`.
- * If the first value of an element is negative, the corresponding
- * element in `data` is invalid. If the most second value of an element
- * is nonzero, the corresponding element in `data` is dirty.
- */
- std::array<std::array<int, 2>, L1_CACHE_LINES> meta;
-};
-
-std::ostream &operator<<(std::ostream &os, const Cache &c);
-
-#endif /* CACHE_H_INCLUDED */
diff --git a/inc/cli.h b/inc/cli.h
deleted file mode 100644
index a0c698a..0000000
--- a/inc/cli.h
+++ /dev/null
@@ -1,97 +0,0 @@
-#ifndef CLI_H
-#define CLI_H
-#include "cache.h"
-#include <functional>
-#include <string>
-#include <unordered_map>
-
-class Cli
-{
- public:
- /**
- * Constructor.
- * @return A newly allocated CLI object.
- */
- Cli();
- ~Cli();
-
- /**
- * Prints all available commands to the console.
- */
- void help();
-
- /**
- * Loads data from memory from the specified memory address.
- * @param memory_address address of the memory where data needs to be loaded
- * from
- */
- void load(Accessor accessor, int memory_address);
-
- /**
- * Stores data into memory at the specified address.
- * @param accessor the pipline stage that is making this request
- * @param data data value to be written to the memory
- * @param address address of the memory where data needs to be stored
- * @return the response from the storage device
- */
- void store(Accessor accessor, int data, int address);
-
- /**
- * Resets the memory configuration and cycles to their initial state.
- * This function provides a side door reset interface to the memory system,
- * allowing the user to reset the memory configuration directly.
- */
- void reset();
-
- /**
- * Advance the clock one cycle, refreshing the storage devices.
- */
- void clock();
-
- /**
- * Displays `lines` lines of the data in `level`, starting from `base`.
- *
- *
- * This function provides a side door view into the storage system, showing
- * its current state and configuration.
- * @param level the level specifying the storage device. The first level
- * one cache is level zero, with descending levels incrementing by a factor
- * of one.
- */
- void peek(int level);
-
- /**
- * Runs the command line interface
- * This function is the main entry point for the command line interface.
- */
- void run();
-
- private:
- /**
- * Initializes the cache object.
- */
- void initialize();
- /**
- * Attempts to match string to either fetch or mem, or throws
- * std::invalid_argument otherwise.
- * @param the string to be converted accessor
- * @return the corresponding accessor
- * @throws invalid_argument if the string is not fetch or mem
- */
- Accessor match_accessor_or_die(std::string s);
- /** Map of commands and their corresponding functions.
- * This map is used to store the commands and their corresponding functions.
- */
- std::unordered_map<char, std::function<void(std::vector<std::string>)>>
- commands;
- /**
- * The cache object to interface with.
- */
- Cache *cache;
- /**
- * The current cycle.
- */
- int cycle;
-};
-
-#endif /* CLI_H_INCLUDED */
diff --git a/inc/dram.h b/inc/dram.h
deleted file mode 100644
index 102ec0f..0000000
--- a/inc/dram.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef DRAM_H
-#define DRAM_H
-#include "definitions.h"
-#include "storage.h"
-#include <ostream>
-#include <functional>
-
-class Dram : public Storage
-{
- public:
- /**
- * Constructor.
- * @param The number of clock cycles each access takes.
- * @return A new memory object.
- */
- Dram(int delay);
- ~Dram();
-
- Response
- write_word(Accessor accessor, signed int data, int address) override;
- Response read_line(
- Accessor accessor,
- int address,
- std::array<signed int, LINE_SIZE> &data_line) override;
- Response write_line(
- Accessor accessor,
- std::array<signed int, LINE_SIZE> data_line,
- int address) override;
- Response
- read_word(Accessor accessor, int address, signed int &data) override;
-
- /**
- * TODO This will accept a file at a later date.
- */
- void load(std::vector<signed int> program);
-
- private:
- /**
- * Helper for all access methods.
- * Calls `request_handler` when `accessor` is allowed to complete its
- * request cycle.
- * @param the source making the request
- * @param the address to write to
- * @param the function to call when an access should be completed
- */
- Response process(
- Accessor accessor,
- int address,
- std::function<void(int line, int word)> request_handler);
- /**
- * Returns OK if `accessor` is allowed to complete its request this cycle.
- * Handles wait times, side door, and setting the current accessor this
- * storage is serving.
- * @param the accessor asking for a resource
- * @return whether or not the access can be carried out this function call.
- */
- Response is_access_cleared(Accessor accessor);
-};
-
-std::ostream &operator<<(std::ostream &os, const Dram &d);
-
-#endif /* DRAM_H_INCLUDED */
diff --git a/inc/storage.h b/inc/storage.h
deleted file mode 100644
index d6fa094..0000000
--- a/inc/storage.h
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef STORAGE_H
-#define STORAGE_H
-#include "accessor.h"
-#include "definitions.h"
-#include "response.h"
-#include <algorithm>
-#include <array>
-#include <map>
-#include <vector>
-
-class Storage
-{
- public:
- virtual ~Storage() = default;
-
- /**
- * Write `data` word into `address`.
- * @param the source making the request.
- * @param the data (hexadecimal) to write.
- * @param the address to write to.
- * @return a status code reflecting the state of the request.
- */
- virtual Response write_word(Accessor accessor, signed int data, int address) = 0;
-
- /**
- * Write a data line to given address in this level of storage
- */
- virtual Response write_line(Accessor accessor, std::array<signed int, LINE_SIZE> data_line, int address) = 0;
-
-
- /**
- * Get the data line at `address`.
- * @param the source making the request.
- * @param the address being accessed.
- * @return a status code reflecting the state of the request, and the
- * data being returned.
- */
- virtual Response read_line(
- Accessor accessor,
- int address,
- std::array<signed int, LINE_SIZE> &data) = 0;
-
- /**
- * Read a word from given address in this level of storage
- */
- virtual Response read_word(Accessor accessor, 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.
- */
- std::vector<std::array<signed int, LINE_SIZE>>
- view(int base, int lines) const;
-
- /**
- * Getter for lower attribute.
- * TODO this doesn't seem like good object-oriented practice.
- * @return this->lower
- */
- Storage *get_lower();
-
- protected:
- /**
- * The data currently stored in this level of storage.
- */
- std::vector<std::array<signed int, LINE_SIZE>> *data;
- /**
- * A pointer to the next lowest level of storage.
- * Used in case of cache misses.
- */
- Storage *lower;
- /**
- * The number of clock cycles this level of storage takes to complete
- * requests.
- */
- int delay;
- /**
- * The accessor currently being serviced.
- */
- Accessor requester;
- /**
- * The number of cycles until the current request is completed.
- */
- int wait_time;
- /**
- * A flag indicating whether this level of storage is currently waiting for
- * a lower level.
- */
- int is_waiting;
-};
-
-#endif /* STORAGE_H_INCLUDED */