-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLIFO_Simple.v
52 lines (49 loc) · 1.16 KB
/
LIFO_Simple.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 11:55:23 07/06/2021
// Design Name:
// Module Name: LIFO_Simple
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module LIFO_Simple(in, full, empty, clk, rst, wn, rn, out);
input [7:0] in;
input clk, rst, wn, rn;
output reg [7:0] out;
output full, empty;
reg [3:0] sp;
reg [7:0] memory [7:0];
assign full = (sp == 4'b1000) ? 1 : 0;
assign empty = (sp == 4'b0000) ? 1 : 0;
always @(posedge clk)
begin
if (rst)
begin
memory[0] <= 0; memory[1] <= 0; memory[2] <= 0; memory[3] <= 0;
memory[4] <= 0; memory[5] <= 0; memory[6] <= 0; memory[7] <= 0;
out <= 0; sp <= 1;
end
else if (wn & !full)
begin
memory[sp] <= in;
sp <= sp + 1;
end
else if (rn & !empty)
begin
sp <= sp - 1;
out <= memory[sp];
end
end
endmodule