forked from ksriniv/ECE745_ASICVerification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controller_Pipeline.vp
142 lines (134 loc) · 9.26 KB
/
Controller_Pipeline.vp
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
`include "data_defs.vp"
module Controller_Pipeline( clock, reset, IR, bypass_alu_1, bypass_alu_2, bypass_mem_1, bypass_mem_2, complete_data, complete_instr,
Instr_dout, NZP, psr, IR_Exec,
enable_fetch, enable_decode, enable_execute, enable_writeback, enable_updatePC,
br_taken, mem_state
);
input clock, reset;
input complete_data, complete_instr;
input [15:0] IR, IR_Exec;
input [2:0] psr, NZP;
input [15:0] Instr_dout;
output bypass_alu_1, bypass_alu_2, bypass_mem_1, bypass_mem_2;
output enable_fetch, enable_decode, enable_execute, enable_writeback, enable_updatePC;
output [1:0] mem_state;
output br_taken;
reg [1:0] mem_state;
reg [4:0] enables;
reg [4:0] prev_enables;
reg [4:0] state, next_state;
reg bypass_alu_1, bypass_alu_2, bypass_mem_1, bypass_mem_2;
reg [15:0] prev_IR;
reg stall_pipe;
reg [2:0] bubble_count;
wire control_instr_dout;
wire [4:0] enables_temp;
reg inc_count, reset_count;
reg br_taken;
reg [1:0] mem_ctrl_Cstate, mem_ctrl_Nstate;
`protected
MTI!#=Q<*TrBlD*}EK[UC2$#\Ru5,UY!YqV='[I3Q=|.jmDj_0R~siYw=5A'ivmrV]C<Wz[uW??O
{OjVD#8w{v@Xv_X15A{,o~~~D2r"i_EWr+avo}}r=uj~,'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