Library of functions

From PolWiki
Jump to: navigation, search

These are the library of functions for the v1495 slave boards.

All the functions are indexed by a variable 'b' standing for board ID,

 b=0; for master board
 b=1; for slave 1
 b=2; for slave 2 
 b=3; for slave 3
 b=4; for signal generator
 b=5; for my 32 bit test board

This index is mapped to the hardware address of the corresponding v1495 boards.

v1495cpInit(b, laddr):

This function initializes the board by

  1. checking for valid board ID's
  2. printing out firmware revision number
  3. resetting all FPGA Registers

(as a first level sanity check to ensure that the board has got the correct address)

Parameter:

  • board ID
  • laddr corresponds to the local address on the VME bus that will be used to identify this board physically in the crate. This can be obtained by using the sysBusToLocalAddrs function of VxWrks

Return: nothing

v1495cpBufReset(b)

This function explicitly flushes all FPGA Registers of v1495 and can be used in the 'GO' routine of the corresponding ROC.

Parameter: board ID

Return: none

v1495cpFirmwareRevision(b) 

This function explicitly states out the firmware revision number, this information should go in each CODA run, to cover for the possibility of a subsequent change in the firmware after we start taking data.

Parameter: board ID

Return: none

v1495cpStatusPrint(b)

This function prints out

  1. the current Mask for A, B, D & E ports (default is 0xFFFFFFFF)
  2. the current pulse-width of the Trigger logic signal
  3. the current pulse-width of the Pipeline delay signal
  4. the current pulse-width of the Holdoff signaland
  5. the set Delay for Pipeline delay
  6. the no.of planes forming accumulation mode trigger (1, 2, 3 or 4)
  7. the no.of planes forming event mode trigger (1, 2, 3 or 4)
  8. the minimum pulse width being for being considering valid signal

Parameter: board ID

Return: none

v1495cpSetWidth(b, PWTL, PWDL, HoldOff, Delay)

This function sets the:

  1. pulse-width of Trigger signal => a max of 15 (equivalent to 375 ns)
  2. pulse-width of the signal in Pipeline delay => a max of 15
  3. HoldOff time of the circuit => a max of 256 (equivalent to 6.4 us)
  4. Delay induced through the Pipeline-delay => a max of 256

Parameters:

  • board ID (1, 2 or 3)
  • (integer value for) Pulse Width of Trigger Logic
  • Pulse Width of Delay Line
  • Hold-Off
  • Delay

Return: 4

v1495cpTrigChoice(b,Trig_choice_accum, Trig_choice_event)

This function sets the number of board which we use to form the trigger decision.

Parameter:

  • board ID
  • Accumulation Trigger condition: (1-4) (number of board required for forming the Trigger)
  • Event Trigger condition: (1-4)

Return: the value of Trigger choice as entered is returned.


v1495cpSetMask (b, A-MASK, B-MASK, D-MASK, E-MASK) 

This function sets the Mask for respective ports to disable any particular strip number of a particular plane.

Parameter:

  • board ID
  • Hexadecimal pattern for A-mask
  • Hexadecimal pattern for B-mask
  • Hexadecimal pattern for D-mask
  • Hexadecimal pattern for E-mask

Return: none

v1495cpMinWidth(b, Min-width)

This function sets the minimum width required for the input signal. All signals which have lesser width will be rejected. The default of this is set to 700 ns. This also adds a delay equal to the Min_width to the pipeline delay and the value of PL_delay should be according adjusted.

Parameter:

  • board ID
  • the minimum no.of clock cycles(25 ns clk) of width required by a valid pulse. (28 clk cycles=700ns)

Return: Min-width


v1495cpTrigCount(b)

This function tells the total no.of triggers received during a helicity period. This count is read on every Helicity Reversal.

Parameter: board ID

Return: number of triggers

v1495cpBufStat(b)

This function finds the number of words currently stored in the buffer, which are ready to be read. This needs to be called before every data read function is called

Parameter: board ID

Return: '0' if the Buffer status is okay and a finite number if the buffer has overflown or if there is no data while it is trying to be read.

The following functions are different in 16 bit as against 32 bit library of functions.

32 bit

v1495cpEventData(b, pointer)

This function reads out the event data. It consists of 5 words, each 32 bit long from the data buffer. The first word contains information about helicity and the no.of trigger counts in that helicity window. The next 4 words are data output from A, B, D & E ports respectively.

If the output of this function is 0x1F1F1F1F then it implies that the coincidence window is not set correctly.

Parameter

  • board ID
  • pointer of the address you want to store the event mode data.

Return: 5 (it increments the buffer pointer by 5)

v1495cpAccumData(b, pointer)

This function writes the accumulated data from A, B, D & E ports at the address of the given pointer. The accumulated data from A & B ports are clubbed to form a 32 bit word, similarly the data from D & E are clubbed to form another 32 bit word.

Since each of the A, B, D and E ports have 32 inputs, so, this function will write out 64 words each 32 bit long.

16 bit

v1495cpRdBufA(pointer bufferA)

The function v1495cpBufStat() needs to be called before calling this set of functions.

This function is called by the ROC when it gets a valid trigger.

This function reads out the 32 bit hit pattern out of the VME backplane from the buffer for the A-port of v1495 board.

In case, while trying to read out the data the buffer is found empty, a fixed hexadecimal word 0xFFFFFFF0 is put into the data stream corresponding to this trigger.

Parameter: a 32 bit pointer address of the data buffer, where you want to store this data.

Return: 1, if successfully executed.

v1495cpRdBufB(pointer bufferB)

This function reads out the 32 bit hit pattern out of the VME backplane from the buffer for the B-port of v1495 board.

In case, while trying to read out the data the buffer is found empty, a fixed hexadecimal word 0xFFFFFFF1 is put into the data stream corresponding to this trigger.

Parameter: a 32 bit pointer address of the data buffer, where you want to store this data.

Return: 1, if successfully executed.

v1495cpRdBufD(pointer bufferD)

This function reads out the 32 bit hit pattern out of the VME backplane from the buffer for the D-port of v1495 board.

In case, while trying to read out the data the buffer is found empty, a fixed hexadecimal word 0xFFFFFFF2 is put into the data stream corresponding to this trigger.

Parameter: a 32 bit pointer address of the data buffer, where you want to store this data.

Return: 1, if successfully executed.

v1495cpRdBufE(pointer bufferE)

This function reads out the 32 bit hit pattern out of the VME backplane from the buffer for the E-port of v1495 board.

In case, while trying to read out the data the buffer is found empty, a fixed hexadecimal word 0xFFFFFFF3 is put into the data stream corresponding to this trigger.

Parameter: a 32 bit pointer address of the data buffer, where you want to store this data.

Return: 1, if successfully executed.

v1495cpDatainA(pointer A)

This function reads out the accumulated counts in all of the 32 strips going into A-port. The counts accumulated, starting from the (say)0th strip of detector (say plane 1) goes at the top of the address pointed by this data buffer pointer and increments successively.

Parameter: a 32 bit pointer address of the data buffer, from where the next consecutive 31 address spaces can be occupied by the data from the next 31 strips.

Return: 1 , if executed successfully

v1495cpDatainB(pointer B)

This function reads out the accumulated counts in all of the 32 strips going into B-port. The counts that are accumulated, starting from the (say)0th strip of detector (say plane 2) goes at the top of the address pointed by this data buffer pointer and increments successively.

Parameter: a 32 bit pointer address of the data buffer, from where the next consecutive 31 address spaces can be occupied by the data from the next 31 strips.

Return: 1 , if executed successfully

v1495cpDatainD(pointer D)

This function reads out the accumulated counts in all of the 32 strips going into D-port. The counts that are accumulated, starting from the (say)0th strip of detector (say plane 3) goes at the top of the address pointed by this data buffer pointer and increments successively.

Parameter: a 32 bit pointer address of the data buffer, from where the next consecutive 31 address spaces can be occupied by the data from the next 31 strips.

Return: 1 , if executed successfully


v1495cpDatainE(pointer E)	

This function reads out the accumulated counts in all of the 32 strips going into E-port. The counts that are accumulated, starting from the (say)0th strip of detector (say plane 4) goes at the top of the address pointed by this data buffer pointer and increments successively.

Parameter: a 32 bit pointer address of the data buffer, from where the next consecutive 31 address spaces can be occupied by the data from the next 31 strips.

Return: 1 , if executed successfully