data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl/n64_deblur.v
None: at end of input
1: b'%Error: data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl/n64_deblur.v:51: Cannot find include file: vh/n64rgb_params.vh\n`include "vh/n64rgb_params.vh" \n         ^~~~~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl,data/full_repos/permissive/118480210/vh/n64rgb_params.vh\n             data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl,data/full_repos/permissive/118480210/vh/n64rgb_params.vh.v\n             data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl,data/full_repos/permissive/118480210/vh/n64rgb_params.vh.sv\n             vh/n64rgb_params.vh\n             vh/n64rgb_params.vh.v\n             vh/n64rgb_params.vh.sv\n             obj_dir/vh/n64rgb_params.vh\n             obj_dir/vh/n64rgb_params.vh.v\n             obj_dir/vh/n64rgb_params.vh.sv\n%Error: data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl/n64_deblur.v:58: Define or directive not defined: \'`VDATA_FU_SLICE\'\ninput [`VDATA_FU_SLICE] vdata_pre;         \n       ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl/n64_deblur.v:58: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\ninput [`VDATA_FU_SLICE] vdata_pre;         \n                      ^\n%Error: data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl/n64_deblur.v:78: Define or directive not defined: \'`VDATA_RE_SLICE\'\nwire [color_width-1:0] R_pre = vdata_pre[`VDATA_RE_SLICE];\n                                         ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl/n64_deblur.v:78: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\nwire [color_width-1:0] R_pre = vdata_pre[`VDATA_RE_SLICE];\n                                                        ^\n%Error: data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl/n64_deblur.v:79: Define or directive not defined: \'`VDATA_GR_SLICE\'\nwire [color_width-1:0] G_pre = vdata_pre[`VDATA_GR_SLICE];\n                                         ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl/n64_deblur.v:79: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\nwire [color_width-1:0] G_pre = vdata_pre[`VDATA_GR_SLICE];\n                                                        ^\n%Error: data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl/n64_deblur.v:80: Define or directive not defined: \'`VDATA_BL_SLICE\'\nwire [color_width-1:0] B_pre = vdata_pre[`VDATA_BL_SLICE];\n                                         ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/118480210/generalRGBmod/firmware/rtl/n64_deblur.v:80: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\nwire [color_width-1:0] B_pre = vdata_pre[`VDATA_BL_SLICE];\n                                                        ^\n%Error: Exiting due to 9 error(s)\n'
module n64_deblur (
  nCLK,
  nDSYNC,

  nRST,

  vdata_pre,
  vdata_cur,

  deblurparams_i,
  deblurparams_o
);

`include "vh/n64rgb_params.vh"

input nCLK;
input nDSYNC;

input nRST;

input [`VDATA_FU_SLICE] vdata_pre;
input [color_width-1:0] vdata_cur;

input  [6:0] deblurparams_i;
output [1:0] deblurparams_o;




wire   [1:0] data_cnt = deblurparams_i[6:5];
wire         n64_480i = deblurparams_i[  4];
wire            vmode = deblurparams_i[  3];
wire blurry_pixel_pos = deblurparams_i[  2];
wire     nForceDeBlur = deblurparams_i[  1];
wire       nDeBlurMan = deblurparams_i[  0];

wire nVSYNC_pre  = vdata_pre[3*color_width+3];
wire nHSYNC_pre  = vdata_pre[3*color_width+1];
wire nCSYNC_pre  = vdata_pre[3*color_width  ];

wire [color_width-1:0] R_pre = vdata_pre[`VDATA_RE_SLICE];
wire [color_width-1:0] G_pre = vdata_pre[`VDATA_GR_SLICE];
wire [color_width-1:0] B_pre = vdata_pre[`VDATA_BL_SLICE];




`define CMP_RANGE 6:5

`define TREND_RANGE    8:0
`define NBLUR_TH_BIT   8

localparam init_trend = 9'h100;




reg [1:0] nblur_est_cnt     = 2'b00;
reg [1:0] nblur_est_holdoff = 2'b00;

reg run_estimation = 1'b0;

reg [1:0] gradient[2:0];



reg [1:0] gradient_changes = 2'b00;

reg [`TREND_RANGE] nblur_n64_trend = init_trend;

reg nblur_n64 = 1'b1;

always @(negedge nCLK) begin
  if (~n64_480i) begin
    if (~nDSYNC) begin
      if(~blurry_pixel_pos) begin


        if (|nblur_est_holdoff)
          nblur_est_holdoff <= nblur_est_holdoff + 1'b1;


        if (&gradient_changes) begin
          if (~nblur_est_cnt[1] & ~|nblur_est_holdoff)
            nblur_est_cnt <= nblur_est_cnt +1'b1;
          nblur_est_holdoff <= 2'b01;
        end

        gradient_changes    <= 2'b00;
      end

      if(nHSYNC_pre & ~vdata_cur[1]) begin
        nblur_est_holdoff <= 2'b00;
      end

      if(nVSYNC_pre & ~vdata_cur[3]) begin
        if (run_estimation)
          if(nblur_est_cnt[1])
              nblur_n64_trend <= &nblur_n64_trend ? nblur_n64_trend :
                                                    nblur_n64_trend + 1'b1;
          else
              nblur_n64_trend <= |nblur_n64_trend ? nblur_n64_trend - 1'b1 :
                                                    nblur_n64_trend;

        nblur_n64     <= nblur_n64_trend[`NBLUR_TH_BIT];
        nblur_est_cnt <= 2'b00;

        run_estimation <= 1'b1;
      end
    end else begin
      if (blurry_pixel_pos) begin
        case(data_cnt)
            2'b01: gradient[2] <= {R_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                   R_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]};
            2'b10: gradient[1] <= {G_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                   G_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]};
            2'b11: gradient[0] <= {B_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                   B_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]};
        endcase
      end else begin
        case(data_cnt)
            2'b01: if (&(gradient[2] ^ {R_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                        R_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]}))
                     gradient_changes <= 2'b01;
            2'b10: if (&(gradient[1] ^ {G_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                        G_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]}))
                     gradient_changes <= gradient_changes + 1'b1;
            2'b11: if (&(gradient[0] ^ {B_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                        B_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]}))
                     gradient_changes <= gradient_changes + 1'b1;
        endcase
      end
    end
  end else begin
    run_estimation <= 1'b0;
  end
  if (~nRST) begin
    nblur_n64_trend <= init_trend;
    nblur_n64       <= 1'b1;
    run_estimation  <= 1'b0;
  end
end




reg ndo_deblur = 1'b1;

reg nblank_rgb = 1'b1;

always @(negedge nCLK) begin
  if (~nDSYNC) begin
    if (nVSYNC_pre & ~vdata_cur[3]) begin
      if (nForceDeBlur)
        ndo_deblur <= n64_480i | nblur_n64;
      else
        ndo_deblur <= n64_480i | nDeBlurMan;
    end
    if(ndo_deblur)
      nblank_rgb <= 1'b1;
    else begin 
      if(~nCSYNC_pre & vdata_cur[0])
        nblank_rgb <= vmode;
      else
        nblank_rgb <= ~nblank_rgb;
    end
  end
end




assign deblurparams_o = {ndo_deblur,nblank_rgb};

endmodule
module n64_deblur (
  nCLK,
  nDSYNC,

  nRST,

  vdata_pre,
  vdata_cur,

  deblurparams_i,
  deblurparams_o
);


`include "vh/n64rgb_params.vh"

input nCLK;
input nDSYNC;

input nRST;

input [`VDATA_FU_SLICE] vdata_pre;
input [color_width-1:0] vdata_cur;

input  [6:0] deblurparams_i;
output [1:0] deblurparams_o;




wire   [1:0] data_cnt = deblurparams_i[6:5];
wire         n64_480i = deblurparams_i[  4];
wire            vmode = deblurparams_i[  3];
wire blurry_pixel_pos = deblurparams_i[  2];
wire     nForceDeBlur = deblurparams_i[  1];
wire       nDeBlurMan = deblurparams_i[  0];

wire nVSYNC_pre  = vdata_pre[3*color_width+3];
wire nHSYNC_pre  = vdata_pre[3*color_width+1];
wire nCSYNC_pre  = vdata_pre[3*color_width  ];

wire [color_width-1:0] R_pre = vdata_pre[`VDATA_RE_SLICE];
wire [color_width-1:0] G_pre = vdata_pre[`VDATA_GR_SLICE];
wire [color_width-1:0] B_pre = vdata_pre[`VDATA_BL_SLICE];




`define CMP_RANGE 6:5

`define TREND_RANGE    8:0
`define NBLUR_TH_BIT   8

localparam init_trend = 9'h100;




reg [1:0] nblur_est_cnt     = 2'b00;
reg [1:0] nblur_est_holdoff = 2'b00;

reg run_estimation = 1'b0;

reg [1:0] gradient[2:0];



reg [1:0] gradient_changes = 2'b00;

reg [`TREND_RANGE] nblur_n64_trend = init_trend;

reg nblur_n64 = 1'b1;

always @(negedge nCLK) begin
  if (~n64_480i) begin
    if (~nDSYNC) begin
      if(~blurry_pixel_pos) begin


        if (|nblur_est_holdoff)
          nblur_est_holdoff <= nblur_est_holdoff + 1'b1;


        if (&gradient_changes) begin
          if (~nblur_est_cnt[1] & ~|nblur_est_holdoff)
            nblur_est_cnt <= nblur_est_cnt +1'b1;
          nblur_est_holdoff <= 2'b01;
        end

        gradient_changes    <= 2'b00;
      end

      if(nHSYNC_pre & ~vdata_cur[1]) begin
        nblur_est_holdoff <= 2'b00;
      end

      if(nVSYNC_pre & ~vdata_cur[3]) begin
        if (run_estimation)
          if(nblur_est_cnt[1])
              nblur_n64_trend <= &nblur_n64_trend ? nblur_n64_trend :
                                                    nblur_n64_trend + 1'b1;
          else
              nblur_n64_trend <= |nblur_n64_trend ? nblur_n64_trend - 1'b1 :
                                                    nblur_n64_trend;

        nblur_n64     <= nblur_n64_trend[`NBLUR_TH_BIT];
        nblur_est_cnt <= 2'b00;

        run_estimation <= 1'b1;
      end
    end else begin
      if (blurry_pixel_pos) begin
        case(data_cnt)
            2'b01: gradient[2] <= {R_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                   R_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]};
            2'b10: gradient[1] <= {G_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                   G_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]};
            2'b11: gradient[0] <= {B_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                   B_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]};
        endcase
      end else begin
        case(data_cnt)
            2'b01: if (&(gradient[2] ^ {R_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                        R_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]}))
                     gradient_changes <= 2'b01;
            2'b10: if (&(gradient[1] ^ {G_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                        G_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]}))
                     gradient_changes <= gradient_changes + 1'b1;
            2'b11: if (&(gradient[0] ^ {B_pre[`CMP_RANGE] < vdata_cur[`CMP_RANGE],
                                        B_pre[`CMP_RANGE] > vdata_cur[`CMP_RANGE]}))
                     gradient_changes <= gradient_changes + 1'b1;
        endcase
      end
    end
  end else begin
    run_estimation <= 1'b0;
  end
  if (~nRST) begin
    nblur_n64_trend <= init_trend;
    nblur_n64       <= 1'b1;
    run_estimation  <= 1'b0;
  end
end




reg ndo_deblur = 1'b1;

reg nblank_rgb = 1'b1;

always @(negedge nCLK) begin
  if (~nDSYNC) begin
    if (nVSYNC_pre & ~vdata_cur[3]) begin
      if (nForceDeBlur)
        ndo_deblur <= n64_480i | nblur_n64;
      else
        ndo_deblur <= n64_480i | nDeBlurMan;
    end
    if(ndo_deblur)
      nblank_rgb <= 1'b1;
    else begin 
      if(~nCSYNC_pre & vdata_cur[0])
        nblank_rgb <= vmode;
      else
        nblank_rgb <= ~nblank_rgb;
    end
  end
end




assign deblurparams_o = {ndo_deblur,nblank_rgb};

endmodule