-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignals.hpp
110 lines (99 loc) · 1.67 KB
/
signals.hpp
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
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef SIGNALS_HPP
#define SIGNALS_HPP
#include <iostream>
#include <bitset>
#include <string>
using namespace std;
#define uint8_t char
#define int16_t short
#define bit uint8_t
#define reg int16_t
#define bus int16_t
#define MAX_INT 65536
#define VCC 1
#define GND 0
#define BUS_SIZE 16
#define COMB_BIT_SIZE 8
struct ROM_SIGNALS {
bit LD_PC;
bit LD_MAR;
bit LD_MDR;
bit LD_REG;
bit LD_IR;
bit LD_BEN;
bit LD_CC;
bit GATE_PC;
bit GATE_MDR;
bit GATE_ALU;
bit GATE_MARMUX;
bit PCMUX_1;
bit PCMUX_2;
bit DRMUX_1;
bit DRMUX_2;
bit SR1MUX_1;
bit SR1MUX_2;
bit ADDR1MUX;
bit ADDR2MUX_1;
bit ADDR2MUX_2;
bit MARMUX;
bit ALUK_1;
bit ALUK_2;
bit MIO_EN;
bit R_W;
bit COND0;
bit COND1;
bit COND2;
bit IRD;
bus J;
};
struct INPUT_SIGNALS {
static bit BEN;
static bit R;
static bit JSR;
};
enum CONTROL_SIG {
LD_PC,
LD_MAR,
LD_MDR,
LD_REG,
LD_IR,
LD_BEN,
LD_CC,
GATE_PC,
GATE_MDR,
GATE_ALU,
GATE_MARMUX,
PCMUX_1,
PCMUX_2,
DRMUX_1,
DRMUX_2,
SR1MUX_1,
SR1MUX_2,
ADDR1MUX,
ADDR2MUX_1,
ADDR2MUX_2,
MARMUX,
ALUK_1,
ALUK_2,
MIO_EN,
R_W,
R,
BEN,
JSR,
IRD,
COND0,
COND1,
COND2
};
int check_index(int index);
bit get_bit(bus b, int index);
void set_bit(bus &b, int index, bit a);
bit combine_bits_three(bit a, bit b, bit c);
void combine_bits(bit &a, bit b, int index);
bit uncombine_bits(bit a, int index);
bus sign_extend(bus b, int len);
bus zero_extend(bus b, int len);
string bit_str(bit a);
string bus_str(bus b);
string bit_str_binary(bit a);
#endif