fix some bugs
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -4,4 +4,4 @@
 | 
			
		||||
*.wlf
 | 
			
		||||
*.mpf
 | 
			
		||||
*.mti
 | 
			
		||||
*/obj_dir/
 | 
			
		||||
**/obj_dir/
 | 
			
		||||
							
								
								
									
										15
									
								
								Crop/crop.v
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								Crop/crop.v
									
									
									
									
									
								
							@@ -11,16 +11,16 @@ module crop #(
 | 
			
		||||
    input reset,
 | 
			
		||||
 | 
			
		||||
    input in_en,
 | 
			
		||||
    output reg in_que,
 | 
			
		||||
    output in_que,
 | 
			
		||||
    input [3 * COLOR_DEPTH - 1:0] data_in,
 | 
			
		||||
 | 
			
		||||
    output reg out_en,
 | 
			
		||||
    output 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;
 | 
			
		||||
    reg fifo_en;
 | 
			
		||||
 | 
			
		||||
    async_fifo #(
 | 
			
		||||
        .DSIZE(3 * COLOR_DEPTH),
 | 
			
		||||
@@ -34,10 +34,12 @@ module crop #(
 | 
			
		||||
        .winc(fifo_en),
 | 
			
		||||
        .wdata(data_in),
 | 
			
		||||
        .wfull(fifo_full),
 | 
			
		||||
        .awfull(),
 | 
			
		||||
 | 
			
		||||
        .rinc(out_en),
 | 
			
		||||
        .rdata(data_out),
 | 
			
		||||
        .rempty(fifo_empty)
 | 
			
		||||
        .rempty(fifo_empty),
 | 
			
		||||
        .arempty()
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    assign in_que = !fifo_full;
 | 
			
		||||
@@ -45,10 +47,7 @@ module crop #(
 | 
			
		||||
 | 
			
		||||
    always @(posedge clk or posedge reset) begin
 | 
			
		||||
        if (reset) begin
 | 
			
		||||
            in_que <= 0;
 | 
			
		||||
            out_en <= 0;
 | 
			
		||||
            data_out <= 0;
 | 
			
		||||
 | 
			
		||||
            fifo_en <= 0;
 | 
			
		||||
            cnt_x <= 0;
 | 
			
		||||
            cnt_y <= 0;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,20 +13,23 @@ module chanels_to_RGB #(
 | 
			
		||||
 | 
			
		||||
    // 输出相关
 | 
			
		||||
    input data_que,                                 // 数据请求
 | 
			
		||||
    output reg out_en,
 | 
			
		||||
    output reg [3 * OUT_DEPTH - 1:0] data_out
 | 
			
		||||
    output out_en,
 | 
			
		||||
    output [3 * OUT_DEPTH - 1:0] data_out
 | 
			
		||||
);
 | 
			
		||||
    reg [31:0] data_cal [2:0]; // 用于保存运算结果,防止溢出
 | 
			
		||||
    reg fifo_en;
 | 
			
		||||
    wire [3 * OUT_DEPTH - 1:0] fifo_in; // 输入fifo中缓存
 | 
			
		||||
    reg [3 * OUT_DEPTH - 1:0] fifo_in; // 输入fifo中缓存
 | 
			
		||||
    wire fifo_empty;
 | 
			
		||||
    // wire fifo_alempty;
 | 
			
		||||
 | 
			
		||||
    always @(posedge clk or posedge reset) begin
 | 
			
		||||
        if (reset) begin
 | 
			
		||||
            // 初始化
 | 
			
		||||
            out_en <= 0;
 | 
			
		||||
            data_out <= 0;
 | 
			
		||||
            data_cal[0] <= 0;
 | 
			
		||||
            data_cal[1] <= 0;
 | 
			
		||||
            data_cal[2] <= 0;
 | 
			
		||||
            fifo_en <= 0;
 | 
			
		||||
            fifo_in <= 0;
 | 
			
		||||
        end
 | 
			
		||||
        else begin
 | 
			
		||||
            if (in_en) begin
 | 
			
		||||
@@ -55,10 +58,10 @@ module chanels_to_RGB #(
 | 
			
		||||
 | 
			
		||||
        .winc(fifo_en),
 | 
			
		||||
        .wdata(fifo_in),
 | 
			
		||||
        // .wfull(),
 | 
			
		||||
        // .awfull(),
 | 
			
		||||
        .wfull(),
 | 
			
		||||
        .awfull(),
 | 
			
		||||
        
 | 
			
		||||
        // .arempty(fifo_alempty)
 | 
			
		||||
        .arempty(),
 | 
			
		||||
        .rempty(fifo_empty),
 | 
			
		||||
        .rdata(data_out),
 | 
			
		||||
        .rinc(out_en)
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ module RGB_to_RAM #(
 | 
			
		||||
    input reset,
 | 
			
		||||
 | 
			
		||||
    // 数据输入
 | 
			
		||||
    output in_que,
 | 
			
		||||
    output reg in_que,
 | 
			
		||||
    input in_en,
 | 
			
		||||
    input [3 * COLOR_DEPTH - 1:0] data_in,
 | 
			
		||||
 | 
			
		||||
@@ -39,10 +39,12 @@ module RGB_to_RAM #(
 | 
			
		||||
        .winc(in_en),
 | 
			
		||||
        .wdata(fifo_data),
 | 
			
		||||
        .wfull(fifo_full),
 | 
			
		||||
        .awfull(),
 | 
			
		||||
 | 
			
		||||
        .rinc(write_en),
 | 
			
		||||
        .rdata(data_write),
 | 
			
		||||
        .rempty(fifo_empty)
 | 
			
		||||
        .rempty(fifo_empty),
 | 
			
		||||
        .arempty()
 | 
			
		||||
    );
 | 
			
		||||
    
 | 
			
		||||
    // 当有数据请求且FIFO不为空时,输出数据
 | 
			
		||||
@@ -57,8 +59,6 @@ module RGB_to_RAM #(
 | 
			
		||||
 | 
			
		||||
    always @(posedge clk or posedge reset) begin
 | 
			
		||||
        if (reset) begin
 | 
			
		||||
            write_en <= 0;
 | 
			
		||||
            data_write <= 0;
 | 
			
		||||
            fifo_data <= 0;
 | 
			
		||||
            data_cache <= 0;
 | 
			
		||||
        end
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								isp.v
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								isp.v
									
									
									
									
									
								
							@@ -27,9 +27,9 @@ module isp #(
 | 
			
		||||
    wire [15:0] im_red, im_green, im_blue;
 | 
			
		||||
 | 
			
		||||
    // 任意比例缩放图像
 | 
			
		||||
    wire scale_in_en;
 | 
			
		||||
    reg scale_in_en;
 | 
			
		||||
    wire scale_in_que;        // scaler 请求数据
 | 
			
		||||
    wire [3 * COLOR_DEPTH - 1:0] scale_in_data;
 | 
			
		||||
    reg [3 * COLOR_DEPTH - 1:0] scale_in_data;
 | 
			
		||||
 | 
			
		||||
    // 写入RAM
 | 
			
		||||
    wire RAM_in_en;
 | 
			
		||||
@@ -70,8 +70,8 @@ module isp #(
 | 
			
		||||
        .clk(clk),
 | 
			
		||||
        .reset(reset),
 | 
			
		||||
 | 
			
		||||
        .in_en(scale_en),
 | 
			
		||||
        .in_que(scale_que),
 | 
			
		||||
        .in_en(scale_in_en),
 | 
			
		||||
        .in_que(scale_in_que),
 | 
			
		||||
        .data_in(scale_in_data),
 | 
			
		||||
 | 
			
		||||
        .out_en(RAM_in_en),
 | 
			
		||||
@@ -83,9 +83,9 @@ module isp #(
 | 
			
		||||
        .clk(clk),
 | 
			
		||||
        .reset(reset),
 | 
			
		||||
 | 
			
		||||
        .in_en(scale_in_en),
 | 
			
		||||
        .in_que(scale_in_que),
 | 
			
		||||
        .data_in(scale_in_data),
 | 
			
		||||
        .in_en(RAM_in_en),
 | 
			
		||||
        .in_que(RAM_in_que),
 | 
			
		||||
        .data_in(RAM_in_data),
 | 
			
		||||
 | 
			
		||||
        .write_que(out_que),
 | 
			
		||||
        .write_en(out_en),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user