-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackPointer.v
More file actions
69 lines (47 loc) · 1.1 KB
/
Copy pathStackPointer.v
File metadata and controls
69 lines (47 loc) · 1.1 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
`include "constants.v"
module stackPointer(clock, SP, newSP, empty, full);
input wire clock;
output reg [31:0] SP;
output reg empty, full;
input wire [1:0] newSP;
// SP + 1
wire [31:0] SPPlus1;
assign SPPlus1 = SP + 32'd1;
// SP - 1
wire [31:0] SPMin1;
assign SPMin1 = SP - 32'd1;
initial begin
SP <= 32'd222;
empty = 1'b1 ;
full = 1'b0 ;
end
always @(posedge clock) begin
if (SP == 32'd222) begin
empty <= 1'b1;
end
else begin
empty <= 1'b0;
end
if (SP == 32'd256) begin
full <= 1'b1;
end
else begin
full <= 1'b0;
end
end
always @(posedge clock) begin
case (newSP)
stackPointerDef: begin
// Do nothing
end
stackPointerPop: begin
// SP = SP - 1
SP = SPMin1;
end
stackPointerPush: begin
// SP = SP + 1
SP = SPPlus1;
end
endcase
end
endmodule