summaryrefslogtreecommitdiff
path: root/inc/stage.h
blob: 04de475d5d3224e228dcbb0a1bd273293463a5d4 (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
#ifndef STAGE_H
#define STAGE_H
#include "definitions.h"
#include "instrDTO.h"
#include "response.h"
#include "storage.h"
#include "accessor.h"
#include <array>

class Stage
{
  public:
	/**
	 * Constructor.
	 * @param The next stage in the pipeline.
	 * @return A newly allocated stage object.
	 */
	Stage(Stage *next);
	virtual ~Stage() = default;
	/**
	 * Advances this stage by a single clock cycle.
	 * @param a DTO object containing various information about an instruction
	 * moving through the pipeline.
	 * @return a response, indicating whether this pipeline stage is stalled,
	 * busy, or done.
	 */
	virtual Response advance(InstrDTO &i) = 0;

  protected:
	/**
	 * The name of the pipeline stage.
	 */
	Accessor id;
	/**
	 * The shared pool of general-purpose integer registers.
	 */
	static std::array<signed int, GPR_NUM> gprs;
	/**
	 * The address of the currently executing instruction.
	 */
	static unsigned int pc;
	/**
	 * A pointer to the next stage in the pipeline.
	 */
	Stage *next;
	/**
	 * A pointer to the top-level storage device.
	 */
	static Storage *storage;
	/**
	 * A flag indicating whether pipelining should be used.
	 */
	static bool is_pipelined;
	/**
	 * The current clock cycle.
	 */
	static int clock_cycle;
};

#endif /* STAGE_H_INCLUDED */