-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlineBuffer.v
50 lines (42 loc) · 835 Bytes
/
lineBuffer.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
`timescale 1ns / 1ps
module lineBuffer(
input i_clk,
input i_rst,
input [7:0] i_data,
input i_data_valid,
output [23:0] o_data,
input i_rd_data
);
reg [7:0] line [639:0]; //line buffer
reg [10:0] wrPntr;
reg [10:0] rdPntr;
always @(posedge i_clk)
begin
if(i_data_valid)
line[wrPntr] <= i_data;
end
always @(posedge i_clk) begin
if (i_rst) begin
wrPntr <= 'd0;
end else if (i_data_valid) begin
if (wrPntr == 639) begin
wrPntr <= 'd0;
end else begin
wrPntr <= wrPntr + 'd1;
end
end
end
always @(posedge i_clk) begin
if (i_rst) begin
rdPntr <= 'd0;
end
else if (i_rd_data) begin
if (rdPntr == 639) begin
rdPntr <= 'd0;
end else begin
rdPntr <= rdPntr + 'd1;
end
end
end
assign o_data = {line[rdPntr],line[rdPntr+1],line[rdPntr+2]};
endmodule