diff --git a/Crop/crop.v b/Crop/crop.v new file mode 100644 index 0000000..91cd862 --- /dev/null +++ b/Crop/crop.v @@ -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 \ No newline at end of file diff --git a/isp.v b/isp.v index 0d1cd05..b70fc75 100644 --- a/isp.v +++ b/isp.v @@ -57,10 +57,7 @@ module isp #( .data_out(scale_in_data) ); - streamScaler #( - .DATA_WIDTH(COLOR_DEPTH), - .CHANNELS(3), - ) scaler ( + );