-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseqfifo.v
More file actions
38 lines (29 loc) · 893 Bytes
/
seqfifo.v
File metadata and controls
38 lines (29 loc) · 893 Bytes
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
`timescale 1ns/1ps
// Sequence generator - First In First Out
module seqfifo #(
parameter BUFSIZE = 16, // buffer size
parameter STRIDE = 1'b1, // stride of range elements
parameter IWIDTH = 4, // buffer index width
parameter WWIDTH = 8 // memory word width
) (
input wire[WWIDTH-1:0] DataIn,
output reg[WWIDTH-1:0] DataOut,
input wire ClkIn,
input wire ClkOut,
output wire IsFull,
output wire IsEmpty
);
reg[WWIDTH-1:0] DataStart;
reg[IWIDTH-1:0] IndexOut = 1'b0;
assign IsFull = IndexOut == 1'b0;
assign IsEmpty = IndexOut == BUFSIZE;
always @(posedge ClkIn) DataStart <= DataIn;
always @(posedge ClkIn or posedge ClkOut) begin
if (ClkIn) begin
IndexOut <= 1'b0;
end else if (ClkOut && !IsEmpty) begin
DataOut <= IndexOut ? DataOut + STRIDE : DataStart;
IndexOut <= IndexOut + 1'b1;
end
end
endmodule