always fix stack

This commit is contained in:
felsabbagh3
2019-10-21 11:49:10 -04:00
parent 292c792339
commit 99586279d9

View File

@@ -22,20 +22,18 @@ module VX_generic_stack
if (reset) begin if (reset) begin
ptr <= 0; ptr <= 0;
for (i = 0; i < (1 << DEPTH); i=i+1) stack[i] <= 0; for (i = 0; i < (1 << DEPTH); i=i+1) stack[i] <= 0;
end else end else if (push)
if (push)
ptr <= ptr + 2; ptr <= ptr + 2;
else if (pop) else if (pop) begin
ptr <= ptr - 1; ptr <= ptr - 1;
end end else if (push) begin
always @(posedge clk) begin
if (push) begin
stack[ptr] <= q1; stack[ptr] <= q1;
stack[ptr+1] <= q2; stack[ptr+1] <= q2;
end end
end end
assign d = stack[ptr - 1]; assign d = stack[ptr - 1];
endmodule endmodule