-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponents.hpp
More file actions
113 lines (93 loc) · 2.15 KB
/
components.hpp
File metadata and controls
113 lines (93 loc) · 2.15 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
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
111
112
113
#ifndef COMPONENTS_HPP
#define COMPONENTS_HPP
#include "mem.hpp"
#include "gates.hpp"
#include "arithmetics.hpp"
#include "signals.hpp"
class program_counter
{
private:
Parallel_Load_Register counter;
public:
program_counter(bit state);
bus update(bit load_pc, bit set, reg x, bit clk);
bus pc_mux(bit s0, bit s1, bus main_bus, bus addr);
bus load_pc(bit ld_pc, bus set, bit clk);
bus run(bit s0, bit s1, bit ld_pc, bit clk, bus main_bus, bus addr);
};
class instruction_register
{
private:
Parallel_Load_Register ir;
public:
instruction_register(bit state);
bus get_ir();
void run(bit ld_ir, bit clk, reg instruction);
};
class memory_address_register
{
private:
Parallel_Load_Register mar;
public:
memory_address_register(bit state);
bus get_mar();
void run(bit ld_mar, bit clk, reg instruction);
};
class memory_data_register
{
private:
Parallel_Load_Register mdr;
public:
memory_data_register(bit state);
bus get_mdr();
void run(bit ld_mdr, bit clk, reg instruction);
};
class eval_addr
{
private:
bus addr2mux(bit s0, bit s1, bus ir);
bus addr1mux(bit s, bus sr1_out, bus pc);
public:
bus run(bit addr1_s, bit addr2_s0, bit addr2_s1, bus ir, bus sr1_out, bus pc);
};
bus marmux(bit select, bus ir, bus eval_addr);
bus sr2mux(bit select, bus ir, bus sr2_out);
class reg_file
{
private:
Parallel_Load_Register **registers;
const static int num_registers = 8;
public:
reg_file();
void update(bit ld_reg, bit dr_0, bit dr_1, bit dr_2, bus data, bit clk);
bus sr1_load(bit sr1_0, bit sr1_1, bit sr1_2);
bus sr2_load(bit sr2_0, bit sr2_1, bit sr2_2);
~reg_file();
};
class data_bus
{
private:
bus data;
public:
data_bus(bus init);
void update_bus(bus value);
bus read_bus();
};
class main_wiring
{
private:
bit *control_signals;
const static int num_signals = 35;
public:
main_wiring();
void write_signal(CONTROL_SIG signal, bit value);
bit read_signal(CONTROL_SIG signal);
bit& operator[](CONTROL_SIG signal);
~main_wiring();
};
class rom_wiring : main_wiring
{
private:
const static int num_signals = 25;
};
#endif