-- -*- Mode: LUA; tab-width: 2 -*-

peripheral {
	 name = "WR Softcore PLL";
	 hdl_entity = "spll_wb_slave";
	 prefix = "spll";
	 
	 reg {
			name = "SPLL Control/Status Register";
			prefix = "CSR";
			
			field {
		         align = 8;
		         name = "Unused (kept for software compatibility).";
		         prefix = "UNUSED0";
		         size = 6;
		         type = CONSTANT;
				 value = 0;
		      };


			field {
				 align = 8;
				 name = "Number of reference channels (max: 32)";
				 prefix = "N_REF";
				 type = SLV;
				 size = 6;
				 access_bus = READ_ONLY;
				 access_dev = WRITE_ONLY;
			};

			field {
				 align = 8;
				 name = "Number of output channels (max: 8)";
				 prefix = "N_OUT";
				 type = SLV;
				 size = 3;
				 access_bus = READ_ONLY;
				 access_dev = WRITE_ONLY;
			};

      field {
         name = "Debug queue supported";
         prefix = "DBG_SUPPORTED";
         type = BIT;
         access_bus = READ_ONLY;
				 access_dev = WRITE_ONLY;
      };
	 };

---------------------------------------------
-- External clock input
---------------------------------------------

   reg {
      name = "External Clock Control Register";
      prefix = "ECCR";

  field {
         name = "Enable External Clock PLL";
         prefix = "EXT_EN";
         type = BIT;
         access_bus = READ_WRITE;
				 access_dev = READ_ONLY;
      };
      field {
         name = "External Clock Input Available";
         description = "1: This instance of wr_softpll_ng supports external 10MHz clock input\
          0: no support for external 10 MHz clock input.";
         prefix = "EXT_SUPPORTED";
         type = BIT;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };

      field {
         name = "External Clock Reference Present";
         description = "1: Reference clock present on the input\
         0: reference input dead";
         prefix = "EXT_REF_LOCKED";
         type = BIT;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };

      field {
        name = "EXT_REF_STOPPED";
        description = "1: Reference 10MHz clock unplugged";
        prefix = "EXT_REF_STOPPED";
        type = BIT;
        access_bus = READ_ONLY;
        access_dev = WRITE_ONLY;
      };

      field {
        name = "EXT_PLL_RST";
        prefix = "EXT_REF_PLLRST";
        align = 31;
        type = BIT;
        access_bus = READ_WRITE;
        access_dev = READ_ONLY;
      };
   };

   reg {
      name = "Aligner Control Register";
      prefix = "AL_CR";
			
			field {
				 name = "Aligner sample valid/select on channel";
				 prefix = "VALID";
				 type = SLV;
				 size = 9;
         access_bus = READ_WRITE;
         access_dev = READ_WRITE;
				 load = LOAD_EXT;
			};

			field {
				 name = "Aligner required on channel";
				 prefix = "REQUIRED";
				 type = SLV;
				 size = 9;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
			};
   };

   reg {
      name = "Aligner Counter REF register";
      prefix = "AL_CREF";
			
			field {
				 name = "Aligner reference counter";
				 type = SLV;
				 size = 32;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
			};
   };

   reg {
      name = "Aligner Counter IN register";
      prefix = "AL_CIN";
			
			field {
				 name = "Aligner reference counter";
				 type = SLV;
				 size = 32;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
			};
   };
  
	 reg {
			name = "DMTD VCO Frequency";
			prefix = "F_DMTD";
			
			field {
				 name = "FREQ";
				 prefix = "FREQ";
				 type = SLV;
				 size = 28;
				 access_bus = READ_ONLY;
				 access_dev = WRITE_ONLY;
			};

			field {
				 name = "VALID";
				 prefix = "VALID";
				 type = BIT;
				 access_bus = READ_WRITE;
				 access_dev = READ_WRITE;
				 load = LOAD_EXT;
			};
	 };

	 reg {
			name = "REF VCO Frequency";
			prefix = "F_REF";
			
			field {
				 name = "FREQ";
				 prefix = "FREQ";
				 type = SLV;
				 size = 28;
				 access_bus = READ_ONLY;
				 access_dev = WRITE_ONLY;
			};

			field {
				 name = "VALID";
				 prefix = "VALID";
				 type = BIT;
				 access_bus = READ_WRITE;
				 access_dev = READ_WRITE;
				 load = LOAD_EXT;
			};
	 };

	 reg {
			name = "EXT VCO Frequency";
			prefix = "F_EXT";
			
			field {
				 name = "FREQ";
				 prefix = "FREQ";
				 type = SLV;
				 size = 28;
				 access_bus = READ_ONLY;
				 access_dev = WRITE_ONLY;
			};

			field {
				 name = "VALID";
				 prefix = "VALID";
				 type = BIT;
				 access_bus = READ_WRITE;
				 access_dev = READ_WRITE;
				 load = LOAD_EXT;
			};
	 };

	 reg {
			align = 4; 
			name = "Output Channel Control Register";
			prefix = "OCCR";

			field {
				 align = 8;
				 name = "Output Channel HW enable flag";
				 prefix = "OUT_EN";
				 type = SLV;
				 size = 8;
				 access_bus = READ_ONLY;
				 access_dev = WRITE_ONLY;
			};

			field {
				 name = "Output Channel locked flag";
				 prefix = "OUT_LOCK";
				 type = SLV;
				 size = 8;
				 access_bus = READ_WRITE;
				 access_dev = READ_ONLY;
			};
	 };

			reg {
				 name = "Reference Channel Tagging Enable Register";
				 prefix = "RCER";
				 
				 field {
						name = "Reference Channel Enable";
						description = "write 1: enables tag generation on the input channel corresponding to the written bit\
				 write 0: disables tag generation";
						type = SLV;
						size = 32;
						access_bus = READ_WRITE;
						access_dev = READ_WRITE;
						load = LOAD_EXT;
				 };
			};

			reg {
				 name = "Output Channel Tagging Enable Register";
				 prefix = "OCER";
				 
				 field {
						name = "Output Channel Enable";
						description = "write 1: enables tag generation on the output channel corresponding to the written bit\
				 write 0: disables tag generation";
						type = SLV;
						size = 8;
						access_bus = READ_WRITE;
						access_dev = READ_WRITE;
						load = LOAD_EXT;
				 };
			};

   reg {
			align = 8;
			name = "Helper DAC Output";
			prefix = "DAC_HPLL";
			
			field {
				 name = "DAC value";
				 type = PASS_THROUGH;
				 size = 16;
			};
	 };

	 reg {
			name = "Main DAC Output";
			prefix = "DAC_MAIN";
			
			field {
				 name = "DAC value";
				 prefix = "VALUE";
				 type = PASS_THROUGH;
				 size = 16;
			};

			field {
				 name = "DAC select";
				 prefix = "DAC_SEL";
				 description = "Selects the output DAC to be updated with VALUE";
				 type = PASS_THROUGH;
				 size = 4;
			};
	 }; 

	 reg {
			name = "DDMTD Deglitcher threshold";
			prefix = "DEGLITCH_THR";
			
			field {
				 name = "Threshold";
				 type = SLV;
				 size = 16;
				 access_bus = READ_WRITE;
				 access_dev = READ_ONLY;
			};
	 };

   reg {
      name = "Debug FIFO Register - SPLL side";
      prefix = "DFR_SPLL";
      
      field {
         name = "Debug Value";
         prefix = "VALUE";
         size = 31;
         type = PASS_THROUGH;
      };

      field {
         name = "End-of-Sample";
         prefix = "EOS";
         size = 1;
         type = PASS_THROUGH;
      };
   };


	 fifo_reg {
			name = "Debug FIFO Register - Host side";		
			prefix = "DFR_HOST";
			direction = CORE_TO_BUS;		 		 
      size = 8192;

      optional = "g_with_debug_fifo";

			flags_dev = {FIFO_FULL, FIFO_EMPTY, FIFO_COUNT};
			flags_bus = {FIFO_FULL, FIFO_EMPTY, FIFO_COUNT};

      field {
				 name = "Value";
				 prefix = "VALUE";
				 type = SLV;
				 size = 32;
      };

      field {
         name = "Seq ID";
         prefix = "SEQ_ID";
         type = SLV;
         size = 16;
      };
   };

	 fifo_reg {
			name = "Tag Readout Register";		
			prefix = "TRR";
			direction = CORE_TO_BUS;		 		 
			size = 32;

			flags_dev = {FIFO_FULL, FIFO_EMPTY};
			flags_bus = {FIFO_EMPTY};

			field {
				 name = "Tag value";
				 prefix = "VALUE";
				 type = SLV;
				 size = 24;
			};

			field {
				 name = "Channel ID";
				 description = "Tagged Channel ID: 0-31: reference tags, 32-47: output tags"; 
				 prefix = "CHAN_ID";
				 type = SLV;
				 size = 7;
			};
			field {
				 name = "Discontinuous bit";
				 prefix = "DISC";
				 description = "1: previous tag has been dropped due to FIFO overflow";
				 type = BIT;
			};
	 };


	 irq {
			name = "Got a tag";
			prefix = "TAG";
			trigger = LEVEL_1;
	 };
};


