class SYS_REGFILE;

  //Properties for Randomizing the MOSI 
  static bit[31:0]	data[08];

  function bit[31:0] get(string reg_name);
    bit[31:0]	data_get;
    case(reg_name)
	"CHIP_ID"	:	data_get=data[0];
	"CHIP_VLD"	:	data_get=data[1];
	"CHIP_DATE"	:	data_get=data[2];
	"CHIP_VISION"	:	data_get=data[3];
	"RW_TEST"	:	data_get=data[4];
	"INT_MASK"	:	data_get=data[5];
	"INT_STATUS"	:	data_get=data[6];
	"SYS_FUNC"	:	data_get=data[7];
    endcase
    $display("@%8t(ns) INFO: reg_rfm RD_DATA: %8h <= ",$realtime,data_get,reg_name);
    return data_get;
  endfunction

  function set(string reg_name,bit[31:0] data_set);
    $display("@%8t(ns) INFO: reg_rfm WR_DATA: %8h => ",$realtime,data_set,reg_name);
    case(reg_name)
	"CHIP_ID"	:	data[0]=data_set;
	"CHIP_VLD"	:	data[1]=data_set;
	"CHIP_DATE"	:	data[2]=data_set;
	"CHIP_VISION"	:	data[3]=data_set;
	"RW_TEST"	:	data[4]=data_set;
	"INT_MASK"	:	data[5]=data_set;
	"INT_STATUS"	:	data[6]=data_set;
	"SYS_FUNC"	:	data[7]=data_set;
    endcase
  endfunction

  function new();
  endfunction

  function init();
    data[0]=32'h524F5554;
    data[1]=32'h48464E4C;
    data[2]=32'h20240701;
    data[3]=32'h01000000;
    data[4]=32'h02400012;
    data[5]=32'h00000003;
    data[6]=32'h0;
    data[7]=32'h0;
  endfunction

endclass

class DAC_REGFILE;

  static bit[31:0]	data[13];

  function bit[31:0] get(string reg_name);
    bit[31:0]	data_get;
    case(reg_name)
	"DAC_SET"	:	data_get=data[00];
	"DAC_DEM_7"	:	data_get=data[01];
	"DAC_DEM_6"	:	data_get=data[02];
	"DAC_DEM_5"	:	data_get=data[03];
	"DAC_DEM_4"	:	data_get=data[04];
	"DAC_DEM_3"	:	data_get=data[05];
	"DAC_DEM_2"	:	data_get=data[06];
	"DAC_DEM_1"	:	data_get=data[07];
	"DAC_DEM_0"	:	data_get=data[08];
	"DAC_PRBS_SET_1":	data_get=data[09];
	"DAC_PRBS_RST_1":	data_get=data[10];
	"DAC_PRBS_SET_0":	data_get=data[11];
	"DAC_PRBS_RST_0":	data_get=data[12];
    endcase
    $display("@%8t(ns) INFO: reg_rfm RD_DATA: %8h <= ",$realtime,data_get,reg_name);
    return data_get;
  endfunction

  function set(string reg_name,bit[31:0] data_set);
    $display("@%8t(ns) INFO: reg_rfm WR_DATA: %8h => ",$realtime,data_set,reg_name);
    case(reg_name)
	"DAC_SET"	:	data[00]=data_set;
	"DAC_DEM_7"	:	data[01]=data_set;
	"DAC_DEM_6"	:	data[02]=data_set;
	"DAC_DEM_5"	:	data[03]=data_set;
	"DAC_DEM_4"	:	data[04]=data_set;
	"DAC_DEM_3"	:	data[05]=data_set;
	"DAC_DEM_2"	:	data[06]=data_set;
	"DAC_DEM_1"	:	data[07]=data_set;
	"DAC_DEM_0"	:	data[08]=data_set;
	"DAC_PRBS_SET_1":	data[09]=data_set;
	"DAC_PRBS_RST_1":	data[10]=data_set;
	"DAC_PRBS_SET_0":	data[11]=data_set;
	"DAC_PRBS_RST_0":	data[12]=data_set;
    endcase
  endfunction

  function new();
  endfunction

  function init();
    data[00]=32'h0003FA20;
    data[01]=32'h171C1002;
    data[02]=32'h00E34276;
    data[03]=32'h2DB70B79;
    data[04]=32'h3E0C9513;
    data[05]=32'h29831398;
    data[06]=32'h2F6E0E81;
    data[07]=32'h114309CA;
    data[08]=32'h27972DEF;
    data[09]=32'h000000FF;
    data[10]=32'h0001FF00;
    data[11]=32'h0001FE00;
    data[12]=32'h000001FF;
  endfunction

endclass

class ADC_REGFILE;

  static bit[31:0]	data[4];

  function bit[31:0] get(string reg_name);
    bit[31:0]	data_get;
    case(reg_name)
	"ADC_ANA"	:	data_get=data[0];
	"ADC_DIG"	:	data_get=data[1];
	"CLK_SEL"	:	data_get=data[2];
	"OV_CNT"	:	data_get=data[3];
    endcase
    $display("@%8t(ns) INFO: reg_rfm RD_DATA: %8h <= ",$realtime,data_get,reg_name);
    return data_get;
  endfunction

  function set(string reg_name,bit[31:0] data_set);
    $display("@%8t(ns) INFO: reg_rfm WR_DATA: %8h => ",$realtime,data_set,reg_name);
    case(reg_name)
	"ADC_ANA"	:	data[0]=data_set;
	"ADC_DIG"	:	data[1]=data_set;
	"CLK_SEL"	:	data[2]=data_set;
	"OV_CNT"	:	data[3]=data_set;
    endcase
  endfunction

  function new();
  endfunction

  function init();
    data[0]=32'h000C6DEF;
    data[1]=32'h000C1040;
    data[2]=32'h00000001;
    data[3]=32'h0;
  endfunction

endclass

class PLL_REGFILE;

  static bit[31:0]	data[11];

  function bit[31:0] get(string reg_name);
    bit[31:0]	data_get;
    case(reg_name)
	"PLL_SET0"	:	data_get=data[00];
	"PLL_SET1"	:	data_get=data[01];
	"PLL_SET2"	:	data_get=data[02];
	"PLL_SET3"	:	data_get=data[03];
	"PLL_SET4"	:	data_get=data[04];
	"PLL_SET5"	:	data_get=data[05];
	"PLL_SET6"	:	data_get=data[06];
	"PLL_SET7"	:	data_get=data[07];
	"PLL_SET8"	:	data_get=data[08];
	"PLL_SET9"	:	data_get=data[09];
	"PLL_SET10"	:	data_get=data[10];
    endcase
    $display("@%8t(ns) INFO: reg_rfm RD_DATA: %8h <= ",$realtime,data_get,reg_name);
    return data_get;
  endfunction

  function set(string reg_name,bit[31:0] data_set);
    $display("@%8t(ns) INFO: reg_rfm WR_DATA: %8h => ",$realtime,data_set,reg_name);
    case(reg_name)
	"PLL_SET0"	:	data[00]=data_set;
	"PLL_SET1"	:	data[01]=data_set;
	"PLL_SET2"	:	data[02]=data_set;
	"PLL_SET3"	:	data[03]=data_set;
	"PLL_SET4"	:	data[04]=data_set;
	"PLL_SET5"	:	data[05]=data_set;
	"PLL_SET6"	:	data[06]=data_set;
	"PLL_SET7"	:	data[07]=data_set;
	"PLL_SET8"	:	data[08]=data_set;
	"PLL_SET9"	:	data[09]=data_set;
	"PLL_SET10"	:	data[10]=data_set;
    endcase
  endfunction

  function new();
  endfunction

  function init();
    data[00]=32'h80017F2E;
    data[01]=32'h401E8010;
    data[02]=32'h05BB0884;
    data[03]=32'h00C80001;
    data[04]=32'h00001E40;
    data[05]=32'hFFFF0000;
    data[06]=32'hFE00FFFF;
    data[07]=32'h0;
    data[08]=32'h0;
    data[09]=32'h000301FF;
    data[10]=32'h00200000;
  endfunction

endclass

class DAQ_REGFILE;

  static bit[31:0]	data[256];

  function bit[31:0] get(string reg_name);
    bit[31:0]	data_get;
    case(reg_name)
	"MCU_PARA0"		:	data_get=data[000];
	"MCU_PARA1"		:	data_get=data[001];
	"MCU_PARA2"		:	data_get=data[002];
	"MCU_PARA3"		:	data_get=data[003];
	"MCU_RST0"		:	data_get=data[004];
	"MCU_RST1"		:	data_get=data[005];
	"MCU_RST2"		:	data_get=data[006];
	"MCU_RST3"		:	data_get=data[007];
	"Timer"			:	data_get=data[008];
	"Counter"		:	data_get=data[009];
	"LOC_State"		:	data_get=data[010];
	"GLB_State"		:	data_get=data[011];
	"FEED_Data"		:	data_get=data[012];
	"SEND_Data"		:	data_get=data[013];
	"Frequency"		:	data_get=data[014];
	"Phase"			:	data_get=data[015];
	"command"		:	data_get=data[016];
	"function"		:	data_get=data[017];
	"wave_sample_depth"	:	data_get=data[018];
	"demod_win_width"	:	data_get=data[019];
	"read_threshold"	:	data_get=data[020];
	"qubit_state"		:	data_get=data[021];
	"demod_width_q0"	:	data_get=data[032];
	"demod_width_q1"	:	data_get=data[033];
	"demod_width_q2"	:	data_get=data[034];
	"demod_width_q3"	:	data_get=data[035];
	"demod_width_q4"	:	data_get=data[036];
	"demod_width_q5"	:	data_get=data[037];
	"demod_width_q6"	:	data_get=data[038];
	"demod_width_q7"	:	data_get=data[039];
	"demod_width_q8"	:	data_get=data[040];
	"demod_width_q9"	:	data_get=data[041];
	"demod_width_q10"	:	data_get=data[042];
	"demod_width_q11"	:	data_get=data[043];
	"demod_width_q12"	:	data_get=data[044];
	"demod_width_q13"	:	data_get=data[045];
	"demod_width_q14"	:	data_get=data[046];
	"demod_width_q15"	:	data_get=data[047];
	"Q0_state0_statistics"	:	data_get=data[064];
	"Q0_state1_statistics"	:	data_get=data[065];
	"Q0_state2_statistics"	:	data_get=data[066];
	"Q0_state3_statistics"	:	data_get=data[067];
	"Q1_state0_statistics"	:	data_get=data[068];
	"Q1_state1_statistics"	:	data_get=data[069];
	"Q1_state2_statistics"	:	data_get=data[070];
	"Q1_state3_statistics"	:	data_get=data[071];
	"Q2_state0_statistics"	:	data_get=data[072];
	"Q2_state1_statistics"	:	data_get=data[073];
	"Q2_state2_statistics"	:	data_get=data[074];
	"Q2_state3_statistics"	:	data_get=data[075];
	"Q3_state0_statistics"	:	data_get=data[076];
	"Q3_state1_statistics"	:	data_get=data[077];
	"Q3_state2_statistics"	:	data_get=data[078];
	"Q3_state3_statistics"	:	data_get=data[079];
	"Q4_state0_statistics"	:	data_get=data[080];
	"Q4_state1_statistics"	:	data_get=data[081];
	"Q4_state2_statistics"	:	data_get=data[082];
	"Q4_state3_statistics"	:	data_get=data[083];
	"Q5_state0_statistics"	:	data_get=data[084];
	"Q5_state1_statistics"	:	data_get=data[085];
	"Q5_state2_statistics"	:	data_get=data[086];
	"Q5_state3_statistics"	:	data_get=data[087];
	"Q6_state0_statistics"	:	data_get=data[088];
	"Q6_state1_statistics"	:	data_get=data[089];
	"Q6_state2_statistics"	:	data_get=data[090];
	"Q6_state3_statistics"	:	data_get=data[091];
	"Q7_state0_statistics"	:	data_get=data[092];
	"Q7_state1_statistics"	:	data_get=data[093];
	"Q7_state2_statistics"	:	data_get=data[094];
	"Q7_state3_statistics"	:	data_get=data[095];
	"Q8_state0_statistics"	:	data_get=data[096];
	"Q8_state1_statistics"	:	data_get=data[097];
	"Q8_state2_statistics"	:	data_get=data[098];
	"Q8_state3_statistics"	:	data_get=data[099];
	"Q9_state0_statistics"	:	data_get=data[100];
	"Q9_state1_statistics"	:	data_get=data[101];
	"Q9_state2_statistics"	:	data_get=data[102];
	"Q9_state3_statistics"	:	data_get=data[103];
	"Q10_state0_statistics"	:	data_get=data[104];
	"Q10_state1_statistics"	:	data_get=data[105];
	"Q10_state2_statistics"	:	data_get=data[106];
	"Q10_state3_statistics"	:	data_get=data[107];
	"Q11_state0_statistics"	:	data_get=data[108];
	"Q11_state1_statistics"	:	data_get=data[109];
	"Q11_state2_statistics"	:	data_get=data[110];
	"Q11_state3_statistics"	:	data_get=data[111];
	"Q12_state0_statistics"	:	data_get=data[112];
	"Q12_state1_statistics"	:	data_get=data[113];
	"Q12_state2_statistics"	:	data_get=data[114];
	"Q12_state3_statistics"	:	data_get=data[115];
	"Q13_state0_statistics"	:	data_get=data[116];
	"Q13_state1_statistics"	:	data_get=data[117];
	"Q13_state2_statistics"	:	data_get=data[118];
	"Q13_state3_statistics"	:	data_get=data[119];
	"Q14_state0_statistics"	:	data_get=data[120];
	"Q14_state1_statistics"	:	data_get=data[121];
	"Q14_state2_statistics"	:	data_get=data[122];
	"Q14_state3_statistics"	:	data_get=data[123];
	"Q15_state0_statistics"	:	data_get=data[124];
	"Q15_state1_statistics"	:	data_get=data[125];
	"Q15_state2_statistics"	:	data_get=data[126];
	"Q15_state3_statistics"	:	data_get=data[127];
	"Q0_state_est_ab_0"	:	data_get=data[128];
	"Q0_state_est_c_0"	:	data_get=data[129];
	"Q0_state_est_ab_1"	:	data_get=data[130];
	"Q0_state_est_c_1"	:	data_get=data[131];
	"Q0_state_est_ab_2"	:	data_get=data[132];
	"Q0_state_est_c_2"	:	data_get=data[133];
	"Q0_i_sum"		:	data_get=data[134];
	"Q0_q_sum"		:	data_get=data[135];
	"Q1_state_est_ab_0"	:	data_get=data[136];
	"Q1_state_est_c_0"	:	data_get=data[137];
	"Q1_state_est_ab_1"	:	data_get=data[138];
	"Q1_state_est_c_1"	:	data_get=data[139];
	"Q1_state_est_ab_2"	:	data_get=data[140];
	"Q1_state_est_c_2"	:	data_get=data[141];
	"Q1_i_sum"		:	data_get=data[142];
	"Q1_q_sum"		:	data_get=data[143];
	"Q2_state_est_ab_0"	:	data_get=data[144];
	"Q2_state_est_c_0"	:	data_get=data[145];
	"Q2_state_est_ab_1"	:	data_get=data[146];
	"Q2_state_est_c_1"	:	data_get=data[147];
	"Q2_state_est_ab_2"	:	data_get=data[148];
	"Q2_state_est_c_2"	:	data_get=data[149];
	"Q2_i_sum"		:	data_get=data[150];
	"Q2_q_sum"		:	data_get=data[151];
	"Q3_state_est_ab_0"	:	data_get=data[152];
	"Q3_state_est_c_0"	:	data_get=data[153];
	"Q3_state_est_ab_1"	:	data_get=data[154];
	"Q3_state_est_c_1"	:	data_get=data[155];
	"Q3_state_est_ab_2"	:	data_get=data[156];
	"Q3_state_est_c_2"	:	data_get=data[157];
	"Q3_i_sum"		:	data_get=data[158];
	"Q3_q_sum"		:	data_get=data[159];
	"Q4_state_est_ab_0"	:	data_get=data[160];
	"Q4_state_est_c_0"	:	data_get=data[161];
	"Q4_state_est_ab_1"	:	data_get=data[162];
	"Q4_state_est_c_1"	:	data_get=data[163];
	"Q4_state_est_ab_2"	:	data_get=data[164];
	"Q4_state_est_c_2"	:	data_get=data[165];
	"Q4_i_sum"		:	data_get=data[166];
	"Q4_q_sum"		:	data_get=data[167];
	"Q5_state_est_ab_0"	:	data_get=data[168];
	"Q5_state_est_c_0"	:	data_get=data[169];
	"Q5_state_est_ab_1"	:	data_get=data[170];
	"Q5_state_est_c_1"	:	data_get=data[171];
	"Q5_state_est_ab_2"	:	data_get=data[172];
	"Q5_state_est_c_2"	:	data_get=data[173];
	"Q5_i_sum"		:	data_get=data[174];
	"Q5_q_sum"		:	data_get=data[175];
	"Q6_state_est_ab_0"	:	data_get=data[176];
	"Q6_state_est_c_0"	:	data_get=data[177];
	"Q6_state_est_ab_1"	:	data_get=data[178];
	"Q6_state_est_c_1"	:	data_get=data[179];
	"Q6_state_est_ab_2"	:	data_get=data[180];
	"Q6_state_est_c_2"	:	data_get=data[181];
	"Q6_i_sum"		:	data_get=data[182];
	"Q6_q_sum"		:	data_get=data[183];
	"Q7_state_est_ab_0"	:	data_get=data[184];
	"Q7_state_est_c_0"	:	data_get=data[185];
	"Q7_state_est_ab_1"	:	data_get=data[186];
	"Q7_state_est_c_1"	:	data_get=data[187];
	"Q7_state_est_ab_2"	:	data_get=data[188];
	"Q7_state_est_c_2"	:	data_get=data[189];
	"Q7_i_sum"		:	data_get=data[190];
	"Q7_q_sum"		:	data_get=data[191];
	"Q8_state_est_ab_0"	:	data_get=data[192];
	"Q8_state_est_c_0"	:	data_get=data[193];
	"Q8_state_est_ab_1"	:	data_get=data[194];
	"Q8_state_est_c_1"	:	data_get=data[195];
	"Q8_state_est_ab_2"	:	data_get=data[196];
	"Q8_state_est_c_2"	:	data_get=data[197];
	"Q8_i_sum"		:	data_get=data[198];
	"Q8_q_sum"		:	data_get=data[199];
	"Q9_state_est_ab_0"	:	data_get=data[200];
	"Q9_state_est_c_0"	:	data_get=data[201];
	"Q9_state_est_ab_1"	:	data_get=data[202];
	"Q9_state_est_c_1"	:	data_get=data[203];
	"Q9_state_est_ab_2"	:	data_get=data[204];
	"Q9_state_est_c_2"	:	data_get=data[205];
	"Q9_i_sum"		:	data_get=data[206];
	"Q9_q_sum"		:	data_get=data[207];
	"Q10_state_est_ab_0"	:	data_get=data[208];
	"Q10_state_est_c_0"	:	data_get=data[209];
	"Q10_state_est_ab_1"	:	data_get=data[210];
	"Q10_state_est_c_1"	:	data_get=data[211];
	"Q10_state_est_ab_2"	:	data_get=data[212];
	"Q10_state_est_c_2"	:	data_get=data[213];
	"Q10_i_sum"		:	data_get=data[214];
	"Q10_q_sum"		:	data_get=data[215];
	"Q11_state_est_ab_0"	:	data_get=data[216];
	"Q11_state_est_c_0"	:	data_get=data[217];
	"Q11_state_est_ab_1"	:	data_get=data[218];
	"Q11_state_est_c_1"	:	data_get=data[219];
	"Q11_state_est_ab_2"	:	data_get=data[220];
	"Q11_state_est_c_2"	:	data_get=data[221];
	"Q11_i_sum"		:	data_get=data[222];
	"Q11_q_sum"		:	data_get=data[223];
	"Q12_state_est_ab_0"	:	data_get=data[224];
	"Q12_state_est_c_0"	:	data_get=data[225];
	"Q12_state_est_ab_1"	:	data_get=data[226];
	"Q12_state_est_c_1"	:	data_get=data[227];
	"Q12_state_est_ab_2"	:	data_get=data[228];
	"Q12_state_est_c_2"	:	data_get=data[229];
	"Q12_i_sum"		:	data_get=data[230];
	"Q12_q_sum"		:	data_get=data[231];
	"Q13_state_est_ab_0"	:	data_get=data[232];
	"Q13_state_est_c_0"	:	data_get=data[233];
	"Q13_state_est_ab_1"	:	data_get=data[234];
	"Q13_state_est_c_1"	:	data_get=data[235];
	"Q13_state_est_ab_2"	:	data_get=data[236];
	"Q13_state_est_c_2"	:	data_get=data[237];
	"Q13_i_sum"		:	data_get=data[238];
	"Q13_q_sum"		:	data_get=data[239];
	"Q14_state_est_ab_0"	:	data_get=data[240];
	"Q14_state_est_c_0"	:	data_get=data[241];
	"Q14_state_est_ab_1"	:	data_get=data[242];
	"Q14_state_est_c_1"	:	data_get=data[243];
	"Q14_state_est_ab_2"	:	data_get=data[244];
	"Q14_state_est_c_2"	:	data_get=data[245];
	"Q14_i_sum"		:	data_get=data[246];
	"Q14_q_sum"		:	data_get=data[247];
	"Q15_state_est_ab_0"	:	data_get=data[248];
	"Q15_state_est_c_0"	:	data_get=data[249];
	"Q15_state_est_ab_1"	:	data_get=data[250];
	"Q15_state_est_c_1"	:	data_get=data[251];
	"Q15_state_est_ab_2"	:	data_get=data[252];
	"Q15_state_est_c_2"	:	data_get=data[253];
	"Q15_i_sum"		:	data_get=data[254];
	"Q15_q_sum"		:	data_get=data[255];
    endcase
    $display("@%8t(ns) INFO: reg_rfm RD_DATA: %8h <= ",$realtime,data_get,reg_name);
    return data_get;
  endfunction

  function set(string reg_name,bit[31:0] data_set);
    $display("@%8t(ns) INFO: reg_rfm WR_DATA: %8h => ",$realtime,data_set,reg_name);
    case(reg_name)
	"MCU_PARA0"		:	data[000]=data_set;
	"MCU_PARA1"		:	data[001]=data_set;
	"MCU_PARA2"		:	data[002]=data_set;
	"MCU_PARA3"		:	data[003]=data_set;
	"MCU_RST0"		:	data[004]=data_set;
	"MCU_RST1"		:	data[005]=data_set;
	"MCU_RST2"		:	data[006]=data_set;
	"MCU_RST3"		:	data[007]=data_set;
	"Timer"			:	data[008]=data_set;
	"Counter"		:	data[009]=data_set;
	"LOC_State"		:	data[010]=data_set;
	"GLB_State"		:	data[011]=data_set;
	"FEED_Data"		:	data[012]=data_set;
	"SEND_Data"		:	data[013]=data_set;
	"Frequency"		:	data[014]=data_set;
	"Phase"			:	data[015]=data_set;
	"command"		:	data[016]=data_set;
	"function"		:	data[017]=data_set;
	"wave_sample_depth"	:	data[018]=data_set;
	"demod_win_width"	:	data[019]=data_set;
	"read_threshold"	:	data[020]=data_set;
	"qubit_state"		:	data[021]=data_set;
	"demod_width_q0"	:	data[032]=data_set;
	"demod_width_q1"	:	data[033]=data_set;
	"demod_width_q2"	:	data[034]=data_set;
	"demod_width_q3"	:	data[035]=data_set;
	"demod_width_q4"	:	data[036]=data_set;
	"demod_width_q5"	:	data[037]=data_set;
	"demod_width_q6"	:	data[038]=data_set;
	"demod_width_q7"	:	data[039]=data_set;
	"demod_width_q8"	:	data[040]=data_set;
	"demod_width_q9"	:	data[041]=data_set;
	"demod_width_q10"	:	data[042]=data_set;
	"demod_width_q11"	:	data[043]=data_set;
	"demod_width_q12"	:	data[044]=data_set;
	"demod_width_q13"	:	data[045]=data_set;
	"demod_width_q14"	:	data[046]=data_set;
	"demod_width_q15"	:	data[047]=data_set;
	"Q0_state0_statistics"	:	data[064]=data_set;
	"Q0_state1_statistics"	:	data[065]=data_set;
	"Q0_state2_statistics"	:	data[066]=data_set;
	"Q0_state3_statistics"	:	data[067]=data_set;
	"Q1_state0_statistics"	:	data[068]=data_set;
	"Q1_state1_statistics"	:	data[069]=data_set;
	"Q1_state2_statistics"	:	data[070]=data_set;
	"Q1_state3_statistics"	:	data[071]=data_set;
	"Q2_state0_statistics"	:	data[072]=data_set;
	"Q2_state1_statistics"	:	data[073]=data_set;
	"Q2_state2_statistics"	:	data[074]=data_set;
	"Q2_state3_statistics"	:	data[075]=data_set;
	"Q3_state0_statistics"	:	data[076]=data_set;
	"Q3_state1_statistics"	:	data[077]=data_set;
	"Q3_state2_statistics"	:	data[078]=data_set;
	"Q3_state3_statistics"	:	data[079]=data_set;
	"Q4_state0_statistics"	:	data[080]=data_set;
	"Q4_state1_statistics"	:	data[081]=data_set;
	"Q4_state2_statistics"	:	data[082]=data_set;
	"Q4_state3_statistics"	:	data[083]=data_set;
	"Q5_state0_statistics"	:	data[084]=data_set;
	"Q5_state1_statistics"	:	data[085]=data_set;
	"Q5_state2_statistics"	:	data[086]=data_set;
	"Q5_state3_statistics"	:	data[087]=data_set;
	"Q6_state0_statistics"	:	data[088]=data_set;
	"Q6_state1_statistics"	:	data[089]=data_set;
	"Q6_state2_statistics"	:	data[090]=data_set;
	"Q6_state3_statistics"	:	data[091]=data_set;
	"Q7_state0_statistics"	:	data[092]=data_set;
	"Q7_state1_statistics"	:	data[093]=data_set;
	"Q7_state2_statistics"	:	data[094]=data_set;
	"Q7_state3_statistics"	:	data[095]=data_set;
	"Q8_state0_statistics"	:	data[096]=data_set;
	"Q8_state1_statistics"	:	data[097]=data_set;
	"Q8_state2_statistics"	:	data[098]=data_set;
	"Q8_state3_statistics"	:	data[099]=data_set;
	"Q9_state0_statistics"	:	data[100]=data_set;
	"Q9_state1_statistics"	:	data[101]=data_set;
	"Q9_state2_statistics"	:	data[102]=data_set;
	"Q9_state3_statistics"	:	data[103]=data_set;
	"Q10_state0_statistics"	:	data[104]=data_set;
	"Q10_state1_statistics"	:	data[105]=data_set;
	"Q10_state2_statistics"	:	data[106]=data_set;
	"Q10_state3_statistics"	:	data[107]=data_set;
	"Q11_state0_statistics"	:	data[108]=data_set;
	"Q11_state1_statistics"	:	data[109]=data_set;
	"Q11_state2_statistics"	:	data[110]=data_set;
	"Q11_state3_statistics"	:	data[111]=data_set;
	"Q12_state0_statistics"	:	data[112]=data_set;
	"Q12_state1_statistics"	:	data[113]=data_set;
	"Q12_state2_statistics"	:	data[114]=data_set;
	"Q12_state3_statistics"	:	data[115]=data_set;
	"Q13_state0_statistics"	:	data[116]=data_set;
	"Q13_state1_statistics"	:	data[117]=data_set;
	"Q13_state2_statistics"	:	data[118]=data_set;
	"Q13_state3_statistics"	:	data[119]=data_set;
	"Q14_state0_statistics"	:	data[120]=data_set;
	"Q14_state1_statistics"	:	data[121]=data_set;
	"Q14_state2_statistics"	:	data[122]=data_set;
	"Q14_state3_statistics"	:	data[123]=data_set;
	"Q15_state0_statistics"	:	data[124]=data_set;
	"Q15_state1_statistics"	:	data[125]=data_set;
	"Q15_state2_statistics"	:	data[126]=data_set;
	"Q15_state3_statistics"	:	data[127]=data_set;
	"Q0_state_est_ab_0"	:	data[128]=data_set;
	"Q0_state_est_c_0"	:	data[129]=data_set;
	"Q0_state_est_ab_1"	:	data[130]=data_set;
	"Q0_state_est_c_1"	:	data[131]=data_set;
	"Q0_state_est_ab_2"	:	data[132]=data_set;
	"Q0_state_est_c_2"	:	data[133]=data_set;
	"Q0_i_sum"		:	data[134]=data_set;
	"Q0_q_sum"		:	data[135]=data_set;
	"Q1_state_est_ab_0"	:	data[136]=data_set;
	"Q1_state_est_c_0"	:	data[137]=data_set;
	"Q1_state_est_ab_1"	:	data[138]=data_set;
	"Q1_state_est_c_1"	:	data[139]=data_set;
	"Q1_state_est_ab_2"	:	data[140]=data_set;
	"Q1_state_est_c_2"	:	data[141]=data_set;
	"Q1_i_sum"		:	data[142]=data_set;
	"Q1_q_sum"		:	data[143]=data_set;
	"Q2_state_est_ab_0"	:	data[144]=data_set;
	"Q2_state_est_c_0"	:	data[145]=data_set;
	"Q2_state_est_ab_1"	:	data[146]=data_set;
	"Q2_state_est_c_1"	:	data[147]=data_set;
	"Q2_state_est_ab_2"	:	data[148]=data_set;
	"Q2_state_est_c_2"	:	data[149]=data_set;
	"Q2_i_sum"		:	data[150]=data_set;
	"Q2_q_sum"		:	data[151]=data_set;
	"Q3_state_est_ab_0"	:	data[152]=data_set;
	"Q3_state_est_c_0"	:	data[153]=data_set;
	"Q3_state_est_ab_1"	:	data[154]=data_set;
	"Q3_state_est_c_1"	:	data[155]=data_set;
	"Q3_state_est_ab_2"	:	data[156]=data_set;
	"Q3_state_est_c_2"	:	data[157]=data_set;
	"Q3_i_sum"		:	data[158]=data_set;
	"Q3_q_sum"		:	data[159]=data_set;
	"Q4_state_est_ab_0"	:	data[160]=data_set;
	"Q4_state_est_c_0"	:	data[161]=data_set;
	"Q4_state_est_ab_1"	:	data[162]=data_set;
	"Q4_state_est_c_1"	:	data[163]=data_set;
	"Q4_state_est_ab_2"	:	data[164]=data_set;
	"Q4_state_est_c_2"	:	data[165]=data_set;
	"Q4_i_sum"		:	data[166]=data_set;
	"Q4_q_sum"		:	data[167]=data_set;
	"Q5_state_est_ab_0"	:	data[168]=data_set;
	"Q5_state_est_c_0"	:	data[169]=data_set;
	"Q5_state_est_ab_1"	:	data[170]=data_set;
	"Q5_state_est_c_1"	:	data[171]=data_set;
	"Q5_state_est_ab_2"	:	data[172]=data_set;
	"Q5_state_est_c_2"	:	data[173]=data_set;
	"Q5_i_sum"		:	data[174]=data_set;
	"Q5_q_sum"		:	data[175]=data_set;
	"Q6_state_est_ab_0"	:	data[176]=data_set;
	"Q6_state_est_c_0"	:	data[177]=data_set;
	"Q6_state_est_ab_1"	:	data[178]=data_set;
	"Q6_state_est_c_1"	:	data[179]=data_set;
	"Q6_state_est_ab_2"	:	data[180]=data_set;
	"Q6_state_est_c_2"	:	data[181]=data_set;
	"Q6_i_sum"		:	data[182]=data_set;
	"Q6_q_sum"		:	data[183]=data_set;
	"Q7_state_est_ab_0"	:	data[184]=data_set;
	"Q7_state_est_c_0"	:	data[185]=data_set;
	"Q7_state_est_ab_1"	:	data[186]=data_set;
	"Q7_state_est_c_1"	:	data[187]=data_set;
	"Q7_state_est_ab_2"	:	data[188]=data_set;
	"Q7_state_est_c_2"	:	data[189]=data_set;
	"Q7_i_sum"		:	data[190]=data_set;
	"Q7_q_sum"		:	data[191]=data_set;
	"Q8_state_est_ab_0"	:	data[192]=data_set;
	"Q8_state_est_c_0"	:	data[193]=data_set;
	"Q8_state_est_ab_1"	:	data[194]=data_set;
	"Q8_state_est_c_1"	:	data[195]=data_set;
	"Q8_state_est_ab_2"	:	data[196]=data_set;
	"Q8_state_est_c_2"	:	data[197]=data_set;
	"Q8_i_sum"		:	data[198]=data_set;
	"Q8_q_sum"		:	data[199]=data_set;
	"Q9_state_est_ab_0"	:	data[200]=data_set;
	"Q9_state_est_c_0"	:	data[201]=data_set;
	"Q9_state_est_ab_1"	:	data[202]=data_set;
	"Q9_state_est_c_1"	:	data[203]=data_set;
	"Q9_state_est_ab_2"	:	data[204]=data_set;
	"Q9_state_est_c_2"	:	data[205]=data_set;
	"Q9_i_sum"		:	data[206]=data_set;
	"Q9_q_sum"		:	data[207]=data_set;
	"Q10_state_est_ab_0"	:	data[208]=data_set;
	"Q10_state_est_c_0"	:	data[209]=data_set;
	"Q10_state_est_ab_1"	:	data[210]=data_set;
	"Q10_state_est_c_1"	:	data[211]=data_set;
	"Q10_state_est_ab_2"	:	data[212]=data_set;
	"Q10_state_est_c_2"	:	data[213]=data_set;
	"Q10_i_sum"		:	data[214]=data_set;
	"Q10_q_sum"		:	data[215]=data_set;
	"Q11_state_est_ab_0"	:	data[216]=data_set;
	"Q11_state_est_c_0"	:	data[217]=data_set;
	"Q11_state_est_ab_1"	:	data[218]=data_set;
	"Q11_state_est_c_1"	:	data[219]=data_set;
	"Q11_state_est_ab_2"	:	data[220]=data_set;
	"Q11_state_est_c_2"	:	data[221]=data_set;
	"Q11_i_sum"		:	data[222]=data_set;
	"Q11_q_sum"		:	data[223]=data_set;
	"Q12_state_est_ab_0"	:	data[224]=data_set;
	"Q12_state_est_c_0"	:	data[225]=data_set;
	"Q12_state_est_ab_1"	:	data[226]=data_set;
	"Q12_state_est_c_1"	:	data[227]=data_set;
	"Q12_state_est_ab_2"	:	data[228]=data_set;
	"Q12_state_est_c_2"	:	data[229]=data_set;
	"Q12_i_sum"		:	data[230]=data_set;
	"Q12_q_sum"		:	data[231]=data_set;
	"Q13_state_est_ab_0"	:	data[232]=data_set;
	"Q13_state_est_c_0"	:	data[233]=data_set;
	"Q13_state_est_ab_1"	:	data[234]=data_set;
	"Q13_state_est_c_1"	:	data[235]=data_set;
	"Q13_state_est_ab_2"	:	data[236]=data_set;
	"Q13_state_est_c_2"	:	data[237]=data_set;
	"Q13_i_sum"		:	data[238]=data_set;
	"Q13_q_sum"		:	data[239]=data_set;
	"Q14_state_est_ab_0"	:	data[240]=data_set;
	"Q14_state_est_c_0"	:	data[241]=data_set;
	"Q14_state_est_ab_1"	:	data[242]=data_set;
	"Q14_state_est_c_1"	:	data[243]=data_set;
	"Q14_state_est_ab_2"	:	data[244]=data_set;
	"Q14_state_est_c_2"	:	data[245]=data_set;
	"Q14_i_sum"		:	data[246]=data_set;
	"Q14_q_sum"		:	data[247]=data_set;
	"Q15_state_est_ab_0"	:	data[248]=data_set;
	"Q15_state_est_c_0"	:	data[249]=data_set;
	"Q15_state_est_ab_1"	:	data[250]=data_set;
	"Q15_state_est_c_1"	:	data[251]=data_set;
	"Q15_state_est_ab_2"	:	data[252]=data_set;
	"Q15_state_est_c_2"	:	data[253]=data_set;
	"Q15_i_sum"		:	data[254]=data_set;
	"Q15_q_sum"		:	data[255]=data_set;
    endcase
  endfunction

  function new();
  endfunction

  function init();
    int j=0;
    foreach(data[i]) data[i]=32'b0;
    data[18]=32'h100;
    data[19]=32'h100;
    data[20]=32'h80;
    for(j=32;j<48;j++) data[j]=32'h100;
  endfunction

endclass


class AWG_REGFILE;

  static bit[31:0]	data[20];

  function bit[31:0] get(string reg_name);
    bit[31:0]	data_get;
    case(reg_name)
	"MCU_PARA0"	:	data_get=data[00];
	"MCU_PARA1"	:	data_get=data[01];
	"MCU_PARA2"	:	data_get=data[02];
	"MCU_PARA3"	:	data_get=data[03];
	"MCU_RST0"	:	data_get=data[04];
	"MCU_RST1"	:	data_get=data[05];
	"MCU_RST2"	:	data_get=data[06];
	"MCU_RST3"	:	data_get=data[07];
	"Timer"		:	data_get=data[08];
	"Counter"	:	data_get=data[09];
	"LOC_State"	:	data_get=data[10];
	"GLB_State"	:	data_get=data[11];
	"FEED_Data"	:	data_get=data[12];
	"Amplitude"	:	data_get=data[13];
	"Frequency"	:	data_get=data[14];
	"Phase"		:	data_get=data[15];
	"Command"	:	data_get=data[16];
	"Function"	:	data_get=data[17];
	"pump_ctrl"	:	data_get=data[18];
	"maker_ctrl"	:	data_get=data[19];
    endcase
    $display("@%8t(ns) INFO: reg_rfm RD_DATA: %8h <= ",$realtime,data_get,reg_name);
    return data_get;
  endfunction

  function set(string reg_name,bit[31:0] data_set);
    $display("@%8t(ns) INFO: reg_rfm WR_DATA: %8h => ",$realtime,data_set,reg_name);
    case(reg_name)
	"MCU_PARA0"	:	data[00]=data_set;
	"MCU_PARA1"	:	data[01]=data_set;
	"MCU_PARA2"	:	data[02]=data_set;
	"MCU_PARA3"	:	data[03]=data_set;
	"MCU_RST0"	:	data[04]=data_set;
	"MCU_RST1"	:	data[05]=data_set;
	"MCU_RST2"	:	data[06]=data_set;
	"MCU_RST3"	:	data[07]=data_set;
	"Timer"		:	data[08]=data_set;
	"Counter"	:	data[09]=data_set;
	"LOC_State"	:	data[10]=data_set;
	"GLB_State"	:	data[11]=data_set;
	"FEED_Data"	:	data[12]=data_set;
	"Amplitude"	:	data[13]=data_set;
	"Frequency"	:	data[14]=data_set;
	"Phase"		:	data[15]=data_set;
	"Command"	:	data[16]=data_set;
	"Function"	:	data[17]=data_set;
	"pump_ctrl"	:	data[18]=data_set;
	"maker_ctrl"	:	data[19]=data_set;
    endcase
  endfunction

  function new();
  endfunction

  function init();
    foreach(data[i]) data[i]=32'b0;
    data[13]=32'h40000000;
    data[14]=32'h10000000;
    data[18]=32'h300;
    data[19]=32'h300;
  endfunction

endclass

class CLK_REGFILE;

  static bit[31:0]	data[4];

  function bit[31:0] get(string reg_name);
    bit[31:0]	data_get;
    case(reg_name)
	"CLK_SET0"	:	data_get=data[0];
	"CLK_SET1"	:	data_get=data[1];
	"CLK_SET2"	:	data_get=data[2];
	"CLK_SET3"	:	data_get=data[3];
    endcase
    $display("@%8t(ns) INFO: reg_rfm RD_DATA: %8h <= ",$realtime,data_get,reg_name);
    return data_get;
  endfunction

  function set(string reg_name,bit[31:0] data_set);
    $display("@%8t(ns) INFO: reg_rfm WR_DATA: %8h => ",$realtime,data_set,reg_name);
    case(reg_name)
	"CLK_SET0"	:	data[0]=data_set;
	"CLK_SET1"	:	data[1]=data_set;
	"CLK_SET2"	:	data[2]=data_set;
	"CLK_SET3"	:	data[3]=data_set;
    endcase
  endfunction

  function new();
  endfunction

  function init();
    data[0]=32'h4E189866;
    data[1]=32'h0081FFC0;
    data[2]=32'h01E40190;
    data[3]=32'h0;
  endfunction

endclass

class RAM #(int size=32768);

  static bit[7:0]	data[size];

  function new();
  endfunction

  function get32bit(bit[24:0] start, ref  bit[31:0] get_data[$]);
    int i=0,j=0,len=0;
    bit[31:0] temp;
    len = get_data.size();
    get_data.delete();
    if(len >= size/4) begin
	$display("Warnning: address outnumber!");
    end
    for(i=0;i<len;i++) begin
      for(j=0;j<4;j++) begin
	temp[8*j+7 -: 8] = data[(int'(start[19:0])+4*i+j)%size];
      end
      get_data.push_back(temp);
    end
  endfunction

  function get8bit(bit[24:0] start, ref  bit[7:0] get_data[$]);
    int i=0,j=0,len=0;
    len = get_data.size();
    get_data.delete();
    if(len >= size) begin
	$display("Warnning: address outnumber!");
    end
    for(i=0;i<len;i++) begin
      get_data.push_back(data[(int'(start[19:0])+i)%size]);
    end
  endfunction

  function set32bit(bit[24:0] start, bit[31:0] set_data[$]);
    int i=0,j=0,len=0;
    bit[31:0] temp;
    len = set_data.size();
    if(len >= size/4) begin
	$display("Warnning: address outnumber!");
    end
    for(i=0;i<len;i++) begin
      temp = set_data[i];
      for(j=0;j<4;j++) begin
	 data[(int'(start[19:0])+4*i+j)%size] = temp[8*j+7 -: 8];
      end
    end
  endfunction

  function set8bit(bit[24:0] start, bit[7:0] set_data[$]);
    int i=0,j=0,len=0;
    len = set_data.size();
    if(len >= size) begin
	$display("Warnning: address outnumber!");
    end
    for(i=0;i<len;i++) begin
      data[(int'(start[19:0])+i)%size] = set_data[i];
    end
  endfunction
    
endclass


class reg_mems;

  static SYS_REGFILE sys_regfile;
  static DAC_REGFILE dac_regfile;
  static ADC_REGFILE adc_regfile;
  static PLL_REGFILE pll_regfile;
  static DAQ_REGFILE daq_regfile;
  static AWG_REGFILE awg_regfile;
  static CLK_REGFILE clk_regfile;
  static RAM#( 32768) daq_inst_ram;
  static RAM#( 32768) daq_data_ram;
  static RAM#(524288) match_filter;
  static RAM#(524288) read_out_ram;
  static RAM#( 32768) awg_inst_ram;
  static RAM#( 32768) awg_data_ram;
  static RAM#(  1024) env_indx_ram;
  static RAM#(262144) env_data_ram;

  function new();
  endfunction : new

  function init();
   sys_regfile=new();
   dac_regfile=new();
   adc_regfile=new();
   pll_regfile=new();
   daq_regfile=new();
   awg_regfile=new();
   clk_regfile=new();
   daq_inst_ram=new();
   daq_data_ram=new();
   match_filter=new();
   read_out_ram=new();
   awg_inst_ram=new();
   awg_data_ram=new();
   env_indx_ram=new();
   env_data_ram=new();
   sys_regfile.init();
   dac_regfile.init();
   adc_regfile.init();
   pll_regfile.init();
   daq_regfile.init();
   awg_regfile.init();
   clk_regfile.init();
  endfunction : init

endclass
