temp

`ifndef __{{ outfilename|replace('.','_')|upper }}__
`define __{{ outfilename|replace('.','_')|upper }}__

`include "s_cnps_a_no_fw_scenario_test_base.sv"
class s_cnps_a_{{ name }}_test_virtual_sequence extends s_cnps_a_no_fw_scenario_test_virtual_sequence_base;
typedef s_cnps_a_{{ name }}_test_virtual_sequence this_t;
`uvm_object_param_utils (this_t)

//---------------------------------------------------------------------------------------------
//new
//---------------------------------------------------------------------------------------------
function new (string name="s_cnps_a_{{ name }}_test_virtual_sequence");
	super.new(name);
endfunction

//reg access task files include
`include "{{ NAME }}_sys_reg.svh"
`include "{{ NAME }}_dfe_ext_reg.svh"
`include "{{ NAME }}_tg_ext_reg.svh"
`include "{{ NAME }}_vtg_ext_reg.svh"
`include "{{ NAME }}_tg_vtg_dfe_reg.svh"
`include "{{ NAME }}_hdr_reg.svh"

//---------------------------------------------------------------------------------------------
// Variables
//---------------------------------------------------------------------------------------------
string dir_name;
string command;
string linemem_exp_file_path1;
string linemem_exp_file_path2;
string linemem_exp_file_path3;
string linemem_exp_file_path4;
string linemem_exp_file_path5;
string hdr_dut_param;
string hdr_test_param;
string hdr_work_top;
string hdr_work_top_prev;
string hdr_ref_out_dfe1;
string hdr_ref_out_dfe2;
string hdr_ref_out_dfe3;
string test_dir;
string ref_work;
string scenario_name;
string gen_exp_excel_path;

int width;
int height;
int trans_num;
reg [31:0] expdata[23][32];
//---------------------------------------------------------------------------------------------
//body
//---------------------------------------------------------------------------------------------
virtual task body();
    cmn_lib_reset_sequence_item       reset_sequence_item;
    data_mon_seq_t data_mon_hdr_in_seq;
    data_mon_seq_t data_mon_hdr_out_seq;
    data_mon_seq_t data_mon_dma_seq;
    data_mon_seq_t data_mon_meta_seq;
    super.body();

    data_mon_hdr_in_seq = data_mon_seq_t::type_id::create("data_mon_hdr_in_seq");
    data_mon_hdr_out_seq = data_mon_seq_t::type_id::create("data_mon_hdr_out_seq");

    data_mon_dma_seq = data_mon_seq_t::type_id::create("data_mon_dma_seq");
    data_mon_meta_seq = data_mon_seq_t::type_id::create("data_mon_meta_seq");

    test_dir = getenv("MAYDAY_s_cnps_a_no_fw_senario_test_DIR");
    ref_work = "/ref_model_settings/";
    scenario_name = "{{ name }}_test";
    width = {{ width }};
    height = {{ height }};
    trans_num = {{ trans_num }}; // ((384+72)/8)*(280/2)
  //stg_reg_mon is off
  `uvm_info("DEBUG_MESSAGE","stg_reg_mon is off", UVM_LOW);
  no_fw_scenario_vif_.regout_mon_en = 0;

  // Make input_file and output_files dir
  dir_make(scenario_name, {{ frame_num }});

{% for FRAME in FRAME_LIST %}
  // **********************************
  // {{ FRAME.caption }} Setting Start
  // **********************************
  // Input Data Genarate
    gen_util.img_data_param_set(
      .dir_path("./input_file/{{ name }}_test"),
      .base_file_name("frame_{{ FRAME.Index }}_PIX"),
      .image_size_x(width*2),
      .image_size_y(height),
      .NLT_line(8),
      .NLE_line(0),
      .VOB_line(16),
      .VLD_line(256),
      .HOB_colm(72),
      .h_ini_val_S2({{ FRAME.h_ini_val_S2 }}),
      .h_inc_val_S2({{ FRAME.h_inc_val_S2 }}),
      .h_range_S2 (1000),
      .v_ini_val_S2({{ FRAME.v_ini_val_S2 }}),
      .v_inc_val_S2({{ FRAME.v_inc_val_S2 }}),
      .v_range_S2 (100),
      .h_ini_val_N({{ FRAME.h_ini_val_N }}),
      .h_inc_val_N({{ FRAME.h_inc_val_N }}),
      .h_range_N(64),
      .v_ini_val_N({{ FRAME.v_ini_val_N }}),
      .v_inc_val_N({{ FRAME.v_inc_val_N }}),
      .v_range_N(4),
      .rand_range_NLT_N(0),
      .rand_range_NLE_N(0),
      .rand_range_VOB_N(0),
      .rand_range_HOB_N(0),
      .rand_range_NLT_S(0),
      .rand_range_NLE_S(0),
      .rand_range_VOB_S(0),
      .rand_range_HOB_S(0)
    );

  //set_din_master_size
  gen_util.set_din_master_size(.WIDTH(width), .HEIGHT(height));

  // ******************************
  // gen_util.divide_image_data
  // ******************************
  // 1st argument: input file directory path
  // 2nd argument: input file name
  // 3rd argument: output file name for dfe1
  // 3rd argument: output file name for dfe2

  // divide_n_data for DFE1, DFE2
  gen_util.divide_image_data("./input_file/{{ name }}_test",
                             "frame_{{ FRAME.Index }}_PIX_1_N.sraw",
                             "./input_file/{{ name }}_test/frame_{{ FRAME.Index }}_din_1_N.sraw",
                             "./input_file/{{ name }}_test/frame_{{ FRAME.Index }}_din_2_N.sraw"
  );

  // // divide_s_data for DFE1, DFE2
  gen_util.divide_image_data("./input_file/{{ name }}_test",
                             "frame_{{ FRAME.Index }}_PIX_1_S2.sraw",
                             "./input_file/{{ name }}_test/frame_{{ FRAME.Index }}_din_1.sraw",
                             "./input_file/{{ name }}_test/frame_{{ FRAME.Index }}_din_2.sraw");


  // Set Image to Din master
  gen_util.set_din_master_input_file("./input_file/{{ name }}_test/frame_{{ FRAME.Index }}_din_1.sraw",
                                     "./input_file/{{ name }}_test/frame_{{ FRAME.Index }}_din_2.sraw",
                                     "./input_file/{{ name }}_test/frame_{{ FRAME.Index }}_din_1_N.sraw",
                                     "./input_file/{{ name }}_test/frame_{{ FRAME.Index }}_din_2_N.sraw"
                                     );

  // Set Parameter and RUN for Ref_MDL(DFE to HDR)
  //DFE1
  `uvm_info("DEBUG_MESSAGE","SET_PARAM_AND_RUN_FOR_DFE1_REF", UVM_LOW);
  run_dfe_ref(
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ FRAME.reg_param_sorted }}_reg_param_sorted.csv"},
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ name }}_dfe1_ref_ctrl_param.csv"},
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ name }}_dfe2hdr_dfe1_image_file.csv"}
  );
  //DFE2
  `uvm_info("DEBUG_MESSAGE","SET_PARAM_AND_RUN_FOR_DFE2_REF", UVM_LOW);
  run_dfe_ref(
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ FRAME.reg_param_sorted }}_reg_param_sorted.csv"},
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ name }}_dfe2_ref_ctrl_param.csv"},
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ name }}_dfe2hdr_dfe2_image_file.csv"}
  );

  // ****************************************************
  // Linemem REF
  // ****************************************************
  // 1st argument: input from dfe1
  // 2nd argument: input from dfe2
  // 3rd argument: output file name
  // ****************************************************
  // Run Linemem Ref_mdl
  `uvm_info("DEBUG_MESSAGE","LINEMEM_REF_RUN", UVM_LOW);
  run_linemem_ref(
        "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE1_OUT_DOUT_INT.bin",
        "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE2_OUT_DOUT_INT.bin",
        "./output_files/{{ name }}_test/linemem_ref/{{ FRAME.DirIndex }}/linemem_ref_output.bin"
  );

  // ****************************************************
  // conv to data format from linemem to hdr
  // ****************************************************
  // *** conv_dfe_to_hdr.lx ***
  // 1st argument: input_file
  // 2nd argument: output_file
  // 3rd argument: trans_num
  // ****************************************************
  `uvm_info("DEBUG_MESSAGE","CONV FROM LINEMEM TO HDR", UVM_LOW);
  dir_name = getenv("MAYDAY_s_cnps_a_data_conv_utility_DIR");
  linemem_exp_file_path{{ FRAME.IndexNext }} = "./output_files/{{ name }}_test/linemem_ref/{{ FRAME.DirIndex }}/linemem_output_conv.bin";
  command = {dir_name, "/conv_dfe_to_hdr/conv_dfe_to_hdr.lx ", "./output_files/{{ name }}_test/linemem_ref/{{ FRAME.DirIndex }}/linemem_ref_output.bin" , " ", linemem_exp_file_path{{ FRAME.IndexNext }}," 15960" };
  $system(command);
  $display(command);
  //
  //
{% if FRAME.CREATE_EXP_DATA %}
  //EXP Data Create
  `uvm_info("DEBUG_MESSAGE","CREATE EXP DATA", UVM_LOW);
  dir_name = getenv("MAYDAY_s_cnps_a_hdr_dv_common_utility_DIR");
  gen_exp_excel_path = {test_dir,"/ref_model_settings/{{ name }}_test/gen_cpu_exp.xlsx"};
  command = {dir_name, "/gen_cpu_exp.py ", gen_exp_excel_path, " {{ name }}_frame_{{ FRAME.Index }}_cpu_exp", " ./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/infiles"};
  $system(command);
  $display(command);

  //EXP_DATA_CONVERT
  `uvm_info("DEBUG_MESSAGE","CONV EXP DATA", UVM_LOW);
  dir_name = getenv("MAYDAY_s_cnps_a_hdr_dv_common_utility_DIR");
  command = {dir_name, "/convto_exp_in.py", " ./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/infiles/{{ name }}_frame_{{ FRAME.Index }}_cpu_exp.sraw", " ./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/infiles/frame_{{ FRAME.Index }}_exp.sraw"};
  $system(command);
  $display(command);

  command = {"cp ", " ./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/infiles/frame_{{ FRAME.Index }}_exp.sraw ",
                    " ./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndexNext }}/data/infiles/image_in_exp.sraw"}; // cp to next frame directory because hdr reference model uses this file in next frame.
  $system(command);
  $display(command);
{% endif %}


  // // Set Parameter for HDR Ref_MDL
  `uvm_info("DEBUG_MESSAGE","File_copy_for_HDR_REF", UVM_LOW);
  command = { "cp ",linemem_exp_file_path{{ FRAME.IndexNext }}, " ./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/infiles/image_in.sraw" };
  $system(command);
  $display(command);

  command = {"cp ", test_dir, "/ref_model_settings/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/{{ name }}_{{ FRAME.HDR_ref }}_dutparam.csv", " ./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/"};
  $system(command);
  $display(command);

  command = {"cp ", test_dir, "/ref_model_settings/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/{{ name }}_{{ FRAME.HDR_ref }}_testparam.csv", " ./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/"};
  $system(command);
  $display(command);

{% if FRAME.HDR_ref_run_mode == 0 %}
  //
  `uvm_info("DEBUG_MESSAGE","HDR_REF_RUN", UVM_LOW);
  hdr_work_top = "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/";
  hdr_dut_param  = {hdr_work_top, "/{{ name }}_{{ FRAME.HDR_ref }}_dutparam.csv"};
  hdr_test_param = {hdr_work_top, "/{{ name }}_{{ FRAME.HDR_ref }}_testparam.csv"};
  run_hdr_ref(
    hdr_dut_param,
    hdr_test_param,
    hdr_work_top
  );
{% else %}
  //
  `uvm_info("DEBUG_MESSAGE","HDR_REF_RUN", UVM_LOW);
  hdr_work_top = "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/";
  hdr_work_top_prev = "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndexPrev }}/";
  hdr_dut_param  = {hdr_work_top, "/{{ name }}_{{ FRAME.HDR_ref }}_dutparam.csv"};
  hdr_test_param = {hdr_work_top, "/{{ name }}_{{ FRAME.HDR_ref }}_testparam.csv"};
  run_hdr_ref_prev(
    hdr_dut_param,
    hdr_test_param,
    hdr_work_top,
    hdr_work_top_prev
  );
{% endif %}

{% if FRAME.CREATE_META_DATA %}
  //CREATE_META_DATA
  `uvm_info("DEBUG_MESSAGE","CREATE_METADATA", UVM_LOW);
  dir_name = getenv("MAYDAY_s_cnps_a_hdr_dv_common_utility_DIR");
  command = {dir_name, "/convto_meta_out.py ",
                       "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/expfiles/image_mi_out.sraw ",
                       "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/infiles/{{ name }}_frame_{{ FRAME.Index }}_cpu_exp.sraw ",
                       "./output_files/{{ name }}_test/frame_{{ FRAME.Index }}_meta.sraw"
                     };
  $system(command);
  $display(command);

  //conv metadata in hdrot
  dir_name = getenv("MAYDAY_s_cnps_a_hdr_dv_common_utility_DIR");
  command = {dir_name, "/convto_hdrot_out.py ",
             "./output_files/{{ name }}_test/frame_{{ FRAME.Index }}_meta.sraw ",
             "input_file/{{ name }}_test/frame_{{ FRAME.Index }}_META ",
             "3"
            };
  $system(command);
  $display(command);
{% endif %}

{% if FRAME.CREATE_RXHC_DATA_RAM %}
  // CREATE_RXHC_DATA_RAM
  `uvm_info("DEBUG_MESSAGE","CREATE_RXHC_DATA_RAM", UVM_LOW);
  dir_name = getenv("MAYDAY_s_cnps_a_hdr_dv_common_utility_DIR");
  command = {dir_name, "/convto_cpu_rxhc.py ",
              "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/expfiles/image_li_out.sraw ",
              "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/expfiles/image_mi_out.sraw ",
              "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/expfiles/image_chr_out.sraw ",
              "./output_files/{{ name }}_test/frame_{{ FRAME.Index }}_rxhc.sraw"
            };
  $system(command);
  $display(command);
  // CREATE_DMA_DATA
  `uvm_info("DEBUG_MESSAGE","CREATE_DMA_DATA", UVM_LOW);
  dir_name = getenv("MAYDAY_s_cnps_a_hdr_dv_common_utility_DIR");
  command = {dir_name, "/convto_cpu_dma_data.py ",
              "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/expfiles/image_ob_out.sraw ",
              "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/expfiles/image_chr_out.sraw ",
              "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/expfiles/image_mi_out.sraw ",
              "./output_files/{{ name }}_test/hdr_ref/frame_{{ FRAME.Index }}_dma_data.sraw"
  };
  $system(command);
  $display(command);
{% endif %}

  // ****************************************************
  // conv to data format from scanconv to dfe
  // ****************************************************
  // 1st argument: input_file
  // 2nd argument: output_file
  // 3rd argument: trans_num
  // ****************************************************
  // conv data format from scanconv to dfe
  `uvm_info("DEBUG_MESSAGE","DATA_CONV_FROM_SCANCONV_TO_DFE", UVM_LOW);
  dir_name = getenv("MAYDAY_s_cnps_a_data_conv_utility_DIR");
  // //DFE1
  hdr_ref_out_dfe1 = "./output_files/{{ name }}_test/scanconv_ref/{{ FRAME.DirIndex }}/scanconv_dfe1_output_conv.bin";
  command = {dir_name, "/conv_scanconv_to_dfe/conv_scanconv_to_dfe.lx ", "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/expfiles/image_dfe1_out.sraw", " ", hdr_ref_out_dfe1, " ", " 7980"};
  $system(command);
  $display(command);
  //DFE2
  hdr_ref_out_dfe2 = "./output_files/{{ name }}_test/scanconv_ref/{{ FRAME.DirIndex }}/scanconv_dfe2_output_conv.bin";
  command = {dir_name, "/conv_scanconv_to_dfe/conv_scanconv_to_dfe.lx ", "./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/expfiles/image_dfe2_out.sraw", " ", hdr_ref_out_dfe2, " ", " 7980"};
  $system(command);
  $display(command);

  // Set Parameter and RUN for Ref_MDL(HDR to DFE)
  //DFE1
  `uvm_info("DEBUG_MESSAGE","SET_PARAM_AND_RUN_FOR_DFE1_REF", UVM_LOW);
  run_dfe_ref(
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ FRAME.reg_param_sorted }}_reg_param_sorted.csv"},
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ name }}_dfe1_ref_ctrl_param.csv"},
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ name }}_hdr2dfe_dfe1_image_file.csv"}
  );
  // //DFE2
  `uvm_info("DEBUG_MESSAGE","SET_PARAM_AND_RUN_FOR_DFE2_REF", UVM_LOW);
  run_dfe_ref(
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ FRAME.reg_param_sorted }}_reg_param_sorted.csv"},
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ name }}_dfe2_ref_ctrl_param.csv"},
    {test_dir, "/ref_model_settings/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/{{ name }}_hdr2dfe_dfe2_image_file.csv"}
  );

//*** Set Parameter for DOUT ****
  // DFE1
  gen_util.set_dout_slave_size(
  s_cnps_a_no_fw_scenario_test_data_generation_util::DFE1, width, height
  );
  gen_util.set_dout_slave_ref_files(
            s_cnps_a_no_fw_scenario_test_data_generation_util::DFE1,
            "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE1_DOUT_CH1.bin",
            "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE1_DOUT_CH2.bin",
            "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE1_DOUT_CH3.bin",
            "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE1_DOUT_CH4.bin",
            "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE1_DOUT_CH5.bin",
            "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE1_DOUT_CH6.bin",
            "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE1_DOUT_CH7.bin",
            "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE1_DOUT_CH8.bin"
        );
  gen_util.enable_dout_slave_data_compare(
      s_cnps_a_no_fw_scenario_test_data_generation_util::DFE1
  );
  gen_util.disable_dout_slave_scode_num_check(
      s_cnps_a_no_fw_scenario_test_data_generation_util::DFE1
  );
  // DFE2
  gen_util.set_dout_slave_size(
      s_cnps_a_no_fw_scenario_test_data_generation_util::DFE2, width, height
  );

  gen_util.set_dout_slave_ref_files(
      s_cnps_a_no_fw_scenario_test_data_generation_util::DFE2,
      "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE2_DOUT_CH1.bin",
      "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE2_DOUT_CH2.bin",
      "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE2_DOUT_CH3.bin",
      "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE2_DOUT_CH4.bin",
      "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE2_DOUT_CH5.bin",
      "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE2_DOUT_CH6.bin",
      "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE2_DOUT_CH7.bin",
      "./output_files/{{ name }}_test/dfe_ref/{{ FRAME.DirIndex }}/output/DFE2_DOUT_CH8.bin"
  );

  gen_util.enable_dout_slave_data_compare(
      s_cnps_a_no_fw_scenario_test_data_generation_util::DFE2
  );

  gen_util.disable_dout_slave_scode_num_check(
      s_cnps_a_no_fw_scenario_test_data_generation_util::DFE2
  );
{% endfor %}


//************************* MODEL SETTINGS END ***********+++++++++++++

  `uvm_info("DEBUG_MESSAGE","REG_SETTING_START_IN_IDLE",UVM_LOW);


  // **********************************
  // IDLE Frame Reg Set
  // **********************************
  //RX Reset
  wrW(cmd_seqr[2], `R_RELAX0_RST_REG, 32'h0000_0000,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_RELAX1_RST_REG, 32'h0000_0000,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_RELAX2_RST_REG, 32'h0000_0000,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_RELAX3_RST_REG, 32'h0000_0000,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_RELAX4_RST_REG, 32'h0000_0000,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_RELAX5_RST_REG, 32'h0000_0000,, CMN_LIB_CMD_FRONTDOOR);

  // S9_HDR_sys_reg_default_1_axi();
  // -> This task has some step reg_val. So, it is necessary to divide and write
  //HDR-1~HDR-3
  wrW(cmd_seqr[2], `R_SCKGENGATECFG, 32'h0000_0100,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_HDRRIGHTGATECFG, 32'h0011_1111,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_SCKGENGATECFG, 32'h0000_0001,, CMN_LIB_CMD_FRONTDOOR);
  // wrW(cmd_seqr[2], `R_CPUGATECFG, 32'h0010_0000,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_CPUGATECFG, 32'h0011_1111,, CMN_LIB_CMD_FRONTDOOR);// -> Setting is necessary to operate cpu

  //HDR-5
  wrW(cmd_seqr[2], `MCMDR, 32'h0017_0020,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `OPCR, 32'h0000_0002,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_SRST, 32'h0000_0111,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `CGDISR, 32'h0000_7FFF,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `CGDISR, 32'h0000_0000,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_SRST, 32'h0000_0222,, CMN_LIB_CMD_FRONTDOOR);

  {{ NAME }}_hdr_reg_HDR_5_1_axi();
  {{ NAME }}_hdr_reg_HDR_5_4_axi();
  {{ NAME }}_hdr_reg_HDR_6_axi();
  {{ NAME }}_tg_vtg_dfe_reg_HDR_6_sio();
  {{ NAME }}_vtg_ext_reg_HDR_6_axi();
  {{ NAME }}_dfe_ext_reg_HDR_6_axi();
  //HDR-6
  wrW(cmd_seqr[2], `OPMR_COMMON, 32'h0000_0000,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `PIXSIZER, 32'h0118_01C8,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_BUF_INTERVAL, 32'h0000_01F0,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `R_BLKNUM, 32'h0000_0003,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `MSKCTRLMODER, 32'h0000_0000,, CMN_LIB_CMD_FRONTDOOR);
  wrW(cmd_seqr[2], `MSKCTRLHIDXR, 32'h0000_0003,, CMN_LIB_CMD_FRONTDOOR);

  {{ NAME }}_tg_vtg_dfe_reg_HDR_8_sio();

  sio_vif_.sio_if.set_ssg(50,30,0,0,0,0);
  sio_vif_.sio_if.set_vd_enable(1);

{% for FRAME in FRAME_LIST %}
  // **********************************
  // {{ FRAME.caption }} Start
  // **********************************
  `uvm_info("DEBUG_MESSAGE","{{ FRAME.caption }}_start",UVM_LOW);
  sio_vif_.sio_if.wait_until_vd(1);
  gen_util.load_din_master_input_file();
  gen_util.emit_dout_slave_reffile_load_req(
      s_cnps_a_no_fw_scenario_test_data_generation_util::DFE1
  );
  gen_util.emit_dout_slave_reffile_load_req(
      s_cnps_a_no_fw_scenario_test_data_generation_util::DFE2
  );

  data_mon_hdr_in_seq.set_expected_file_path(linemem_exp_file_path{{ FRAME.IndexNext }});
  data_mon_hdr_out_seq.set_expected_file_path("./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/expfiles/NLRTOUT_out.sraw");
{% if not FRAME.is_null_frame %}
  data_mon_dma_seq.set_expected_file_path("./output_files/{{ name }}_test/hdr_ref/frame_{{ FRAME.Index }}_dma_data.sraw");
  data_mon_meta_seq.set_expected_file_path("./output_files/{{ name }}_test/frame_{{ FRAME.Index }}_meta.sraw");
  //load exp file
  gen_util.get_exp_data("./output_files/{{ name }}_test/hdr_ref/{{ FRAME.DirIndex }}/data/infiles/{{ name }}_frame_{{ FRAME.Index }}_cpu_exp.sraw",
                        expdata,
                        1,
                        3,
                        0,
                        1);
{% endif %}
{% if FRAME.use_mask_mon %}
  //If you use msk_mon, It is necessary below task.
  `ifdef MSK_TEST
    for(int i=0;i<23;i++)begin
      for(int j=0;j<32;j++)begin
        set_val_for_msk_mdl(
          expdata
        );
      end
    end
  `endif
  `uvm_info("DEBUG_MESSAGE","{{ FRAME.caption }} monitor_settings_end",UVM_LOW);
{% endif %}

  fork
    begin
      `uvm_info("DEBUG_MESSAGE","DATA_MON_HDR_IN_START",UVM_LOW);
      data_mon_hdr_in_seq.start(shp_data_mon_hdr_in_agent_.SEQUENCER);
      `uvm_info("DEBUG_MESSAGE","DATA_MON_HDR_IN_END",UVM_LOW);
    end
    begin
      `uvm_info("DEBUG_MESSAGE","DATA_MON_HDR_OUT_START",UVM_LOW);
      data_mon_hdr_out_seq.start(shp_data_mon_hdr_out_agent_.SEQUENCER);
      `uvm_info("DEBUG_MESSAGE","DATA_MON_HDR_OUT_END",UVM_LOW);
    end
{% if not FRAME.is_null_frame %}
    begin
      `uvm_info("DEBUG_MESSAGE","DATA_MON_DMA_START",UVM_LOW);
      data_mon_dma_seq.start(shp_data_mon_dma_agent_.SEQUENCER);
      `uvm_info("DEBUG_MESSAGE","DATA_MON_DMA_END",UVM_LOW);
    end
    begin
      `uvm_info("DEBUG_MESSAGE","DATA_MON_META_START",UVM_LOW);
      data_mon_meta_seq.start(shp_data_mon_meta_agent_.SEQUENCER);
      `uvm_info("DEBUG_MESSAGE","DATA_MON_META_END",UVM_LOW);
    end
{% endif %}
    begin
      `uvm_info("DEBUG_MESSAGE","REG_SETTING_START_IN {{ FRAME.caption }}",UVM_LOW);
      sio_vif_.sio_if.set_ssg(570,220,0,22,72,0);
      sio_vif_.sio_if.wait_until_ihd(5);
      {% for reg_setting in FRAME.reg_setting_list %}
      {{ NAME }}_{{ reg_setting }}();{% endfor %}
      `uvm_info("DEBUG_MESSAGE","REG_SETTING_END_IN {{ FRAME.caption }}",UVM_LOW);
    end

{% if not FRAME.is_null_frame %}
    begin
      wait(no_fw_scenario_vif_.tie_outq_pushreq_hc0 == 1)
        sio_vif_.sio_if.wait_until_ihd(4);
      `uvm_info("DEBUG_MESSAGE","TRANS_EXP_1st",UVM_LOW);
        for (int j=1;j<4;j++) begin
          fork
              tie_wire_ctrl_agent_.pulse("tie_qin_hg_empty" , 1'h0 , 1, 1);
              tie_wire_ctrl_agent_.pulse("tie_qin_hg" , expdata[0][j], 1, 1);
              repeat(24) @ (posedge no_fw_scenario_vif_.rxhc0_clk);
          join
        end
      wait(no_fw_scenario_vif_.tie_outq_pushreq_hc0 == 1)
        sio_vif_.sio_if.wait_until_ihd(4);
      `uvm_info("DEBUG_MESSAGE","TRANS_EXP_2nd",UVM_LOW);
        for (int j=1;j<4;j++) begin
          fork
              tie_wire_ctrl_agent_.pulse("tie_qin_hg_empty" , 1'h0 , 1, 1);
              tie_wire_ctrl_agent_.pulse("tie_qin_hg" , expdata[1][j], 1, 1);
              repeat(24) @ (posedge no_fw_scenario_vif_.rxhc0_clk);
          join
        end
      `uvm_info("DEBUG_MESSAGE","TRANS_EXP_END",UVM_LOW);
    end
    begin
      repeat(2) @ (negedge no_fw_scenario_vif_.tie_outq_pushreq_hc0);
      no_fw_scenario_vif_.comp_hc_dram(
        "./output_files/{{ name }}_test/frame_{{ FRAME.Index }}_rxhc.sraw",
        0,
        1,
        3,
        0,
        1);
    end
  join
{% endif %}
{% endfor %}

  // **********************************
  // end_sequence
  // **********************************
  sio_vif_.sio_if.wait_until_vd(1);
  sio_vif_.sio_if.set_ssg(50,30,0,0,0,0);
  sio_vif_.sio_if.wait_until_ihd(5);
  sio_vif_.sio_if.wait_until_vd(1);

endtask : body

task run_hdr_ref(input string dut_param, input string test_param, input string work_top);
  string dir;
  `uvm_info("DEBUG_MESSAGE","HDR_PARAM_SET_FOR_REF",UVM_HIGH);
  dir = getenv("MAYDAY_s_cnps_a_hdr_ref_DIR");
  command = {dir, $sformatf("/s_cnps_a_hdr_ref.py %s %s %s", dut_param, test_param, work_top)};
  $display(command);
  $system(command);
endtask

task run_hdr_ref_prev(input string dut_param, input string test_param, input string work_top, input string work_top_prev);
  string dir;
  `uvm_info("DEBUG_MESSAGE","HDR_PARAM_SET_FOR_REF",UVM_HIGH);
  dir = getenv("MAYDAY_s_cnps_a_hdr_ref_DIR");
  command = {dir, $sformatf("/s_cnps_a_hdr_ref.py %s %s %s %s", dut_param, test_param, work_top, work_top_prev)};
  $display(command);
  $system(command);
endtask


task run_dfe_ref(input string reg_param, input string ref_ctrl, input string image_file);
  string dir;
  dir= getenv("MAYDAY_s_cnps_a_dfe_ref_DIR");
  command = {dir, "/cnps_dfe_ref ", reg_param, " ", ref_ctrl, " ", image_file};
  $display(command);
  $system(command);
endtask

task run_linemem_ref(input string dfe1_ref_output, input string dfe2_ref_output, input string linemem_ref_output_path);
  string dir;
  `uvm_info("DEBUG_MESSAGE","LINEME_REF_RUN", UVM_HIGH);
  dir = getenv("MAYDAY_s_cnps_a_linemem_ref_DIR");
  command = $sformatf("python3 %s/linemem_ref.py %s %s %s",dir, dfe1_ref_output, dfe2_ref_output, linemem_ref_output_path);
  $display(command);
  $system(command);
endtask

endclass

class s_cnps_a_{{ name }}_test extends s_cnps_a_no_fw_scenario_test_base;
	//---------------------------------------------------------
	// component_util_macro
	//---------------------------------------------------------
	`uvm_component_utils(s_cnps_a_{{ name }}_test)
    s_cnps_a_no_fw_scenario_test_env    no_fw_scenario_test_env;
	//---------------------------------------------------------
	// new
	//---------------------------------------------------------
	function new(string name="s_cnps_a_no_fw_scenario_test", uvm_component parent=null);
		super.new(name, parent);
	endfunction

	//---------------------------------------------------------
	// build_phase
	//---------------------------------------------------------
	virtual function void build_phase(uvm_phase phase);
		super.build_phase(phase);
		`uvm_info(get_type_name(), $sformatf("{{ name }} test build pahse start"), UVM_LOW)
		uvm_config_db#(uvm_object_wrapper)::set(this, "no_fw_scenario_test_env.main_sequencer_.run_phase", "default_sequence",
    	s_cnps_a_{{ name }}_test_virtual_sequence::get_type());
		`uvm_info(get_type_name(), $sformatf("no_fw_scenario test build pahsestart"), UVM_LOW)
	endfunction
endclass

`endif