blob: a0c698adf6eb5926a2d20a7e745f3df997897e44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#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 */
|