-
Notifications
You must be signed in to change notification settings - Fork 0
/
registers.v
59 lines (51 loc) · 1.03 KB
/
registers.v
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
module registers(
clk,
rst,
PC_reg,
PC_next,
IR_reg,
IR_next,
ACC_reg,
ACC_next,
MDR_reg,
MDR_next,
MAR_reg,
MAR_next,
Zflag_reg,
Zflag_next
);
input wire clk;
input wire rst;
output reg [7:0]PC_reg;
input wire [7:0]PC_next;
output reg [15:0]IR_reg;
input wire [15:0]IR_next;
output reg [15:0]ACC_reg;
input wire [15:0]ACC_next;
output reg [15:0]MDR_reg;
input wire [15:0]MDR_next;
output reg [7:0]MAR_reg;
input wire [7:0]MAR_next;
output reg Zflag_reg;
input wire Zflag_next;
always @(posedge clk)
if(rst)
begin
PC_reg <= 8'b0;
IR_reg <= 16'b0;
ACC_reg <= 16'b0;
MDR_reg <= 16'b0;
MAR_reg <= 8'b0;
Zflag_reg <= 1'b0;
end
else
begin
//set registers to next values
PC_reg <= PC_next;
IR_reg <= IR_next;
ACC_reg <= ACC_next;
MDR_reg <= MDR_next;
MAR_reg <= MAR_next;
Zflag_reg <= Zflag_next;
end
endmodule