add crop ip but not finish it

This commit is contained in:
SelfConfusion 2024-05-12 22:09:23 +08:00
parent c96e9b57b2
commit c221671804
2 changed files with 74 additions and 4 deletions

73
Crop/crop.v Normal file
View File

@ -0,0 +1,73 @@
module crop #(
parameter IN_WIDTH = 1936 - 2,
parameter IN_HEIGHT = 1088 - 2,
parameter OFFSET_X = 8,
parameter OFFSET_Y = 4,
parameter OUT_WIDTH = 640,
parameter OUT_HEIGHT = 480
parameter COLOR_DEPTH = 8;
) (
input clk,
input reset,
input in_en,
output reg in_que,
input [3 * COLOR_DEPTH - 1:0] data_in,
output reg out_en,
input out_que,
output reg [3 * COLOR_DEPTH - 1:0] data_out
);
wire fifo_en;
wire fifo_full, fifo_empty;
reg [11:0] cnt_x, cnt_y;
async_fifo #(
.DSIZE(3 * COLOR_DEPTH),
.ASIZE(128)
) fifo_image (
.wclk(clk),
.wrst_n(reset),
.rclk(clk),
.rrst_n(reset),
.winc(fifo_en),
.wdata(data_in),
.wfull(fifo_full),
.rinc(out_en),
.rdata(data_out),
.rempty(fifo_empty)
);
assign in_que = !fifo_full;
assign out_en = (out_que && !fifo_empty) ? 1 : 0;
always @(posedge clk or posedge reset) begin
if (reset) begin
in_que <= 0;
out_en <= 0;
data_out <= 0;
cnt_x <= 0;
cnt_y <= 0;
end
else begin
if (in_en) begin
cnt_x <= cnt_x + 1;
if (cnt_x >= (OFFSET_X + OUT_WIDTH)) begin
cnt_x <= 0;
if (cnt_y >= (OFFSET_Y + OUT_HEIGHT)) begin
cnt_y <= 0;
end
else begin
cnt_y <= cnt_y + 1;
end
end
end
end
end
endmodule

5
isp.v
View File

@ -57,10 +57,7 @@ module isp #(
.data_out(scale_in_data)
);
streamScaler #(
.DATA_WIDTH(COLOR_DEPTH),
.CHANNELS(3),
) scaler (
);