The Low Level VME Interface

The functions

$ret = vmeRead( "mode", $base, $offset);
$ret = vmeRrite( "mode", $base, $offset, $data);

perform raw VME I/O. The mode parameter can be: A16D8, A16D16, A24D8, A24D16, A24D32, A32D16 and A32D32. In addition there are the control functions VmeReopen and VmeSysreset. The following example code demonstrates how the V462 gate generator of CAEN is operated by primitive VME calls.

#!/bin/perl
#
# the timer V462 is operated by primitive VME calls
# 
use Spectra; 

cls(); 

$base = 0; 
$v462_status = 0; 
$v462_ch0_msb = 2;
$v462_ch0_lsb = 4;
$v462_start_ch0 = 0x200;
$v462_gate0_open = 0x800;
$v462_local_ch0 = 0x2000;
#
# read the status
#
$status = vmeRead( A24D16, $base, $v462_status);
if( $status & $v462_local_ch0)
{
    print "\033[2;2f Channel 0 in local mode \n"; 
    return;
}
if( $status & $v462_gate0_open)
{
    print "\033[2;2f Gate is already open \n"; 
    return;
}
#
# open the gate for 1.2345678 seconds
#
$ret = vmeWrite( A24D16, $base, $v462_ch0_msb , 0x1234);
$ret = vmeWrite( A24D16, $base, $v462_ch0_lsb , 0x5678);
$ret = vmeWrite( A24D16, $base, $v462_status, $v462_start_ch0);

$status = vmeWrite( A24D16, $base, $v462_status);

$i = 0; 
while( $status & $v462_gate0_open)
{
    printf "\033[2;2f $i Waiting for the timer \n";
    Wait( 0.1); 
    $i++; 
    $status = vmeRead( A24D16, $base, $v462_status);    
}

The performance of the vme_read() function was measured with this script:

#!/bin/perl
#
# this code runs with 1560 Hz on a 333 MHz processor, 
# Linux 2.4.4, Perl 5.6.0, SIS1100
#
use Spectra;
cls(); 
#
# read the v462 status
#
$base = 0; 
$v462_status = 0; 
$time_start = Secnds(); 
$max = 10000; 
for (1 .. $max)
{
    vmeRead( A24D16, $base, $v462_status);
}
$time_total = Secnds() - $time_start; 
$res = $max / $time_total; 
print "\033[2;2f $time_total for $max iterations ($res Hz)\n";