-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControl.h
More file actions
52 lines (47 loc) · 1.24 KB
/
Control.h
File metadata and controls
52 lines (47 loc) · 1.24 KB
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
#pragma once
#include <iostream>
#include <cmath>
using namespace std;
#define OPCODE_BITS_CTR 6
#define ALU_OP_BITS 2
#define SHAMT_BITS_CTR 5
#define RTYPE_OP "000000"
#define LW_OP "100011"
#define SW_OP "101011"
#define BEQ_OP "000100"
class Control {
private:
bool opcode_bits[OPCODE_BITS_CTR];
bool shamt_bits[SHAMT_BITS_CTR];
string function_code;
bool is_branch;
bool reg_dest;
bool reg_write;
bool alu_src;
bool alu_op[ALU_OP_BITS];
bool mem_write;
bool mem_read;
bool mem_to_reg;
bool shamt_signal;
bool shamt_right;
void initSignal();
public:
Control(string opcode, string shamtcode, string functioncode);
Control();
void init(string opcode, string shamtcode, string functioncode);
bool getBranch();
bool getRegDest();
bool getRegWrite();
bool getAluSrc();
bool* getAluOP();
bool getMemWrite();
bool getMemRead();
bool getMemToReg();
bool getShamtSignal();
bool getShamtRight();
void sign_extend(string bits, bool* ret_value);
int conv_bin_dec_idx(bool* bits, int bitidx);
void conv_dec_to_bin(int target, bool return_value[]);
string bool_to_str(bool* array, int size);
void str_to_bool(string s, int size, bool* arr);
};