Commit b0ddc492 authored by David Cussans's avatar David Cussans

Tidying up before copying to EUDET handshake branch

parent a0d8f423
../../../../hdl/common/TPx3_iface_rtl.vhd
\ No newline at end of file
#
# Script to exercise AIDA mini-TLU
#
# David Cussans, December 2012
#
# Hacked to only test internal triggers
from PyChipsUser import *
from FmcTluI2c import *
import sys
import time
bAddrTab = AddressTable("./aida_mini_tlu_addr_map.txt")
# Assume DIP-switch controlled address. Switches at 1
board = ChipsBusUdp(bAddrTab,"192.168.200.32",50001)
# Check the bus for I2C devices
boardi2c = FmcTluI2c(board)
numLoops = 1
for iLoop in range(0,numLoops):
preVetotriggerCount = board.read("PreVetoTriggersR")
postVetotriggerCount = board.read("PostVetoTriggersR")
print "pre , post veto triggers = " , preVetotriggerCount , postVetotriggerCount
time.sleep( 1.0 )
#
# Script to exercise AIDA mini-TLU
#
# David Cussans, December 2012
#
# Nasty hack - use both PyChips and uHAL ( for block read ... )
from PyChipsUser import *
from FmcTluI2c import *
import uhal
import sys
import time
def mean(TS):
val=0
for i in range(1,len(TS)):
val+=TS[i]-TS[i-1]
return val/(len(TS)-1)
# Point to board in uHAL
manager = uhal.ConnectionManager("file://./connection.xml")
hw = manager.getDevice("minitlu")
device_id = hw.id()
fwVersion = hw.getNode("version").read()
hw.dispatch()
print "Version (uHAL)= " , hex(fwVersion)
# Point to TLU in Pychips
bAddrTab = AddressTable("./aida_mini_tlu_addr_map.txt")
# Assume DIP-switch controlled address. Switches at 2
board = ChipsBusUdp(bAddrTab,"192.168.200.32",50001)
# Check the bus for I2C devices
boardi2c = FmcTluI2c(board)
firmwareID=board.read("FirmwareId")
print "Firmware (from PyChips) = " , hex(firmwareID)
print "Scanning I2C bus:"
scanResults = boardi2c.i2c_scan()
print scanResults
boardId = boardi2c.get_serial_number()
print "FMC-TLU serial number = " , boardId
resetClocks = 0
resetSerdes = 0
# set DACs to -200mV
print "Setting all threshold DAC to -100mV "
boardi2c.set_threshold_voltage(7, -0.1)
clockStatus = board.read("LogicClocksCSR")
print "Clock status = " , hex(clockStatus)
if resetClocks:
print "Resetting clocks"
board.write("LogicRst", 1 )
clockStatus = board.read("LogicClocksCSR")
print "Clock status after reset = " , hex(clockStatus)
inputStatus = board.read("SerdesRstR")
print "Input status = " , hex(inputStatus)
if resetSerdes:
board.write("SerdesRstW", 0x00000003 )
inputStatus = board.read("SerdesRstR")
print "Input status during reset = " , hex(inputStatus)
board.write("SerdesRstW", 0x00000000 )
inputStatus = board.read("SerdesRstR")
print "Input status after reset = " , hex(inputStatus)
board.write("SerdesRstW", 0x00000004 )
inputStatus = board.read("SerdesRstR")
print "Input status during calibration = " , hex(inputStatus)
board.write("SerdesRstW", 0x00000000 )
inputStatus = board.read("SerdesRstR")
print "Input status after calibration = " , hex(inputStatus)
inputStatus = board.read("SerdesRstR")
print "Input status = " , hex(inputStatus)
count0 = board.read("ThrCount0R")
print " Count 0 = " , count0
count1 = board.read("ThrCount1R")
print " Count 1 = " , count1
count2 = board.read("ThrCount2R")
print " Count 2 = " , count2
count3 = board.read("ThrCount3R")
print " Count 3 = " , count3
board.write("InternalTriggerIntervalW",0)
print "Setting input trigger delay to 31 160MHz clock cycles"
board.write("PulseDelayW",31)
pulseDelay = board.read("PulseDelayR")
print "Pulse delay was set to ", pulseDelay
print "Enabling DUT 0 and 1"
board.write("DUTMaskW",3)
DUTMask = board.read("DUTMaskR")
print "DUTMaskR = " , DUTMask
print "Ignore veto from shutter"
board.write("IgnoreShutterVetoW",1)
#print "Listen for veto from shutter"
#board.write("IgnoreShutterVetoW",0)
IgnoreShutterVeto = board.read("IgnoreShutterVetoR")
print "IgnoreShutterVeto = " , IgnoreShutterVeto
print "Ignore veto on DUT 0"
board.write("IgnoreDUTBusyW",1)
IgnoreDUTBusy = board.read("IgnoreDUTBusyR")
print "IgnoreDUTBusyR = " , IgnoreDUTBusy
print "Turning off software trigger veto"
board.write("TriggerVetoW",0)
print "Reseting FIFO"
board.write("EventFifoCSR",0x2)
eventFifoFillLevel = board.read("EventFifoFillLevel")
print "FIFO fill level after resetting FIFO = " , eventFifoFillLevel
print "Enabling data recording"
board.write("Enable_Record_Data",1)
#print "Disabling data recording"
#board.write("Enable_Record_Data",0)
#print "Enabling handshake: No-handshake"
#board.write("HandshakeTypeW",1)
TriggerInterval = 400000
#TriggerInterval = 0
print "Setting internal trigger interval to " , TriggerInterval
board.write("InternalTriggerIntervalW",TriggerInterval) #0->Internal pulse generator disabled. Any other value will generate pulses with a frequency of n*6.25ns
trigInterval = board.read("InternalTriggerIntervalR")
print "Trigger interval read back as ", trigInterval
loopWait = 1
numLoops = 10000000
oldEvtNumber = 0
oldPreVetotriggerCount = board.read("PreVetoTriggersR")
oldPostVetotriggerCount = board.read("PostVetoTriggersR")
for iLoop in range(0,numLoops):
preVetotriggerCount = board.read("PreVetoTriggersR")
postVetotriggerCount = board.read("PostVetoTriggersR")
preVetoFreq = (preVetotriggerCount-oldPreVetotriggerCount)/loopWait
postVetoFreq = (postVetotriggerCount-oldPostVetotriggerCount)/loopWait
print "pre , post veto triggers = " , preVetotriggerCount , postVetotriggerCount
timestampHigh = board.read("CurrentTimestampHR")
timestampLow = board.read("CurrentTimestampLR")
print "Current timestamp High,Low (hex) = " , hex(timestampHigh) , hex(timestampLow)
eventFifoFillLevel = board.read("EventFifoFillLevel")
print "FIFO fill level = " , eventFifoFillLevel
#timestampData = board.blockRead("EventFifoData", eventFifoFillLevel)
nEvents = eventFifoFillLevel//4 # only read out whole events ( 4 x 32-bit words )
wordsToRead = nEvents*4
timestampData = hw.getNode("eventBuffer.EventFifoData").readBlock(eventFifoFillLevel)
hw.dispatch()
print "number of events in FIFO = ",nEvents
# print timestampData
for evt in range (0, nEvents-1 ):
lowWord = timestampData[evt*4 + 1] + 0x100000000* timestampData[ (evt*4) + 0] # timestamp
highWord = timestampData[evt*4 + 3] + 0x100000000* timestampData[ (evt*4) + 2] # evt number
evtNumber = timestampData[evt*4 + 3]
if evtNumber != ( oldEvtNumber + 1 ):
print "***WARNING *** Non sqeuential event numbers *** , evt,oldEvt = ", evtNumber , oldEvtNumber
oldEvtNumber = evtNumber
timeStamp = lowWord & 0xFFFFFFFFFFFF
evtType = timestampData[ (evt*4) + 0] >> 28
print "bufferPos, highWord , lowWord , event-number , timestamp , evtType = %x %016x %016x %08x %012x %01x" % ( evt , highWord , lowWord, evtNumber , timeStamp , evtType)
time.sleep( loopWait)
preVetotriggerCount = board.read("PreVetoTriggersR")
postVetotriggerCount = board.read("PostVetoTriggersR")
print "\n\nPre,post trigger count at end of run " , preVetotriggerCount , postVetotriggerCount
#
# Script to exercise AIDA mini-TLU
#
# David Cussans, December 2012
#
# Hacked to only test internal triggers
from PyChipsUser import *
from FmcTluI2c import *
import sys
import time
bAddrTab = AddressTable("./aida_mini_tlu_addr_map.txt")
# Assume DIP-switch controlled address. Switches at 1
board = ChipsBusUdp(bAddrTab,"192.168.200.32",50001)
# Check the bus for I2C devices
boardi2c = FmcTluI2c(board)
firmwareID=board.read("FirmwareId")
print "Firmware = " , hex(firmwareID)
print "Enabling DUT 1"
board.write("DUTMaskW",7)
print "Turn off trigger veto"
board.write("TriggerVetoW",0)
TriggerInterval = 0xABC
print "Setting internal trigger interval to " , TriggerInterval
board.write("InternalTriggerIntervalW",TriggerInterval) #0->Internal pulse generator disabled. Any other value will generate pulses with a frequency of n*6.25ns
trigInterval = board.read("InternalTriggerIntervalR")
print "Trigger interval read back as ", trigInterval , "(should be 2 less than written)"
numLoops = 2
for iLoop in range(0,numLoops):
preVetotriggerCount = board.read("PreVetoTriggersR")
postVetotriggerCount = board.read("PostVetoTriggersR")
print "pre , post veto triggers = " , preVetotriggerCount , postVetotriggerCount
timestampHigh = board.read("CurrentTimestampHR")
timestampLow = board.read("CurrentTimestampLR")
print "Current timestamp High,Low (hex) = " , hex(timestampHigh) , hex(timestampLow)
time.sleep( 1.0 )
#
# Script to exercise AIDA mini-TLU
#
# David Cussans, December 2012
#
# Hacked to only test internal triggers
from PyChipsUser import *
from FmcTluI2c import *
import sys
import time
def mean(TS):
val=0
for i in range(1,len(TS)):
val+=TS[i]-TS[i-1]
return val/(len(TS)-1)
bAddrTab = AddressTable("./aida_mini_tlu_addr_map.txt")
# Assume DIP-switch controlled address. Switches at 1
board = ChipsBusUdp(bAddrTab,"192.168.200.32",50001)
# Check the bus for I2C devices
boardi2c = FmcTluI2c(board)
firmwareID=board.read("FirmwareId")
print "Firmware = " , hex(firmwareID)
board.write("TriggerVetoRW",0)
veto = board.read("TriggerVetoRW")
print "Trigger Veto = " , hex(veto)
board.write("TriggerPatternRW",0x1234ABCD)
triggerPattern = board.read("TriggerPatternRW")
print "Trigger Pattern = " , hex(triggerPattern)
board.write("TriggerPatternRW",0xFFFEFFFE)
triggerPattern = board.read("TriggerPatternRW")
print "Trigger Pattern = " , hex(triggerPattern)
*RegName RegAddr RegMask R W
*-------------------------------------------------------------
FirmwareId 0x00000000 0xffffffff 1 0
* DUT interfaces base = 0x010
ConfBits 0x00000011 0xffffffff 1 1
T0syncLength 0x00000012 0xffffffff 1 1
BusyMask 0x00000013 0xffffffff 1 1
ConfBitsR 0x00000019 0xffffffff 1 1
BusyMaskR 0x0000001b 0xffffffff 1 1
......@@ -105,8 +105,9 @@ NET "triggers_p_o[1]" LOC = B18; # mHDMI , J1
#NET "SPARE_N_O<1>" LOC = "A20"; ## "FMC_LA08_N" , G13 on FMC
#NET "SPARE_P_O<1>" LOC = "B20"; ## "FMC_LA08_P" , G12 on FMC
NET "shutter_to_dut_n_o[1]" LOC = "A20"; ## "FMC_LA08_N" , G13 on FMC
NET "shutter_to_dut_p_o[1]" LOC = "B20"; ## "FMC_LA08_P" , G12 on FMC
#NET "shutter_to_dut_n_o[1]" LOC = "A20"; ## "FMC_LA08_N" , G13 on FMC
#NET "shutter_to_dut_p_o[1]" LOC = "B20"; ## "FMC_LA08_P" , G12 on FMC
NET "shutter_to_dut_p_o[1]" LOC = "T12"; ## "FMC_LA18_P" , C22 on FMC # mHDMI , J1
# Connector J2 used by TPix connection
#NET "SPARE_N_O<2>" LOC = "G15"; ## "FMC_LA11_N" , H17 on FMC
......@@ -130,7 +131,8 @@ NET "dut_clk_p_o[0]" LOC = V11; # RJ45 , J3
NET "reset_or_clk_p_o[0]" LOC = V7; # RJ45 , J3
## "FMC_LA18_P" , C22 on FMC
NET "reset_or_clk_p_o[1]" LOC = T12; # mHDMI , J1
#NET "reset_or_clk_p_o[1]" LOC = T12; # mHDMI , J1
NET "reset_or_clk_p_o[1]" LOC = B20; # "FMC_LA08_P" , G12 on FMC , mHDMI , J1
## "FMC_LA07_CC_P" , H13 on FMC
# NET "reset_or_clk_p_o[2]" LOC = B2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment