-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipes.h
71 lines (55 loc) · 1.89 KB
/
pipes.h
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
#include <stdbool.h>
#include "consts.h"
#ifndef PIPES_H
#define PIPES_H
// Pipeline register structures
struct preg_if_id {
uint32_t inst; // Instruction value
uint32_t next_pc; // Following program counter
};
struct preg_id_exe {
bool mem_read; // Control : Memory read
bool mem_write; // Control : Memory writeback
bool reg_write; // Control : Register writeback
bool alu_src; // Control : Alu source (true = imm)
bool mem_to_reg; // Control : Write memory output to register
uint32_t rt; // RT
uint32_t rs; // Source register
uint32_t funct; // Funct value
uint32_t rs_value; // Value in rs register
uint32_t rt_value; // Value in rt register
uint32_t sign_ext_imm; // Sign extended immediate
uint32_t reg_dst; // Destination register
uint32_t shamt; // Shift amount
};
struct preg_exe_mem
{
bool mem_read; // Control : Memory read
bool mem_write; // Control : Memory writeback
bool reg_write; // Control : Register writeback
bool mem_to_reg; // Control : Write memory output to register
uint32_t rt; // RT
uint32_t rt_value; // Value in rt register
uint32_t alu_res; // Output of ALU
uint32_t reg_dst; // Destionation register
};
struct preg_mem_wb
{
bool reg_write; // Control : Register writeback
bool mem_to_reg; // Control : Write memory output to register
uint32_t rt; // RT
uint32_t read_data; // Data read from memory
uint32_t alu_res; // Output of ALU
uint32_t reg_dst; // Destionation register
};
// Pipeline steps
int interp_if();
int interp_id();
int interp_exe();
int interp_mem();
void interp_wb();
// Pipeline forwarding
int forward();
// Run MIPS cycle
int cycle();
#endif