From: Andreas Neiser Date: Tue, 2 Dec 2014 08:24:07 +0000 (+0100) Subject: CTS: Compile scripts updated, syncing config.vhd X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=669f0c52e1a8e006842e2c2b13216f6ca89a1c8a;p=trb3.git CTS: Compile scripts updated, syncing config.vhd --- diff --git a/cts/compile_central_frankfurt_proposal.pl b/cts/compile_central_frankfurt_proposal.pl new file mode 100755 index 0000000..8251466 --- /dev/null +++ b/cts/compile_central_frankfurt_proposal.pl @@ -0,0 +1,171 @@ +#!/usr/bin/perl +use Data::Dumper; +use warnings; +use strict; +use Term::ANSIColor; +use File::stat; +use POSIX; +use FileHandle; + + +################################################################################### +#Settings for this project +my $TOPNAME = "trb3_central"; #Name of top-level entity +my $BasePath = "../base/"; #path to "base" directory +my $CbmNetPath = "../../cbmnet"; +my $lm_license_file_for_synplify = "27000\@lxcad01.gsi.de"; +my $lm_license_file_for_par = "1702\@hadeb05.gsi.de"; + +my $lattice_path = '/d/jspc29/lattice/diamond/3.2_x64'; +my $synplify_path = '/d/jspc29/lattice/synplify/I-2013.09-SP1/'; +my $lattice_bin_path = "$lattice_path/bin/lin64"; # note the lin or lin64 at the end, no isfgpa needed +my $config_vhd = 'config_default.vhd'; +################################################################################### + +system("./compile_constraints.pl"); + +symlink($CbmNetPath, '../cbmnet/cbmnet') unless (-e '../cbmnet/cbmnet'); + +# source the standard lattice environment +$ENV{bindir}="$lattice_bin_path"; +open my $SOURCE, "bash -c '. $lattice_bin_path/diamond_env >& /dev/null; env'|" or + die "Can't fork: $!"; +while (<$SOURCE>) { + if (/^(.*)=(.*)/) { + $ENV{$1} = ${2} ; + } +} +close $SOURCE; + +$ENV{'SYNPLIFY'}=$synplify_path; +$ENV{'SYN_DISABLE_RAINBOW_DONGLE'}=1; +$ENV{'LM_LICENSE_FILE'}=$lm_license_file_for_synplify; + + +my $FAMILYNAME="LatticeECP3"; +my $DEVICENAME="LFE3-150EA"; +my $PACKAGE="FPBGA1156"; +my $SPEEDGRADE="8"; + +my $WORKDIR = "workdir"; +unless(-d $WORKDIR) { + mkdir $WORKDIR or die "can't create workdir '$WORKDIR': $!"; + system ("cd workdir; ../../base/linkdesignfiles.sh; cd ..;"); + system ("ln -sfT ../tdc_release/Adder_304.ngo $WORKDIR/Adder_304.ngo"); + system ("cp ../base/mulipar_nodelist_example.txt $WORKDIR/nodelist.txt"); +} + +system("ln -sfT $lattice_path $WORKDIR/lattice-diamond"); +system("ln -f -s $config_vhd config.vhd"); + +#generate timestamp +my $t=time; +my $fh = new FileHandle(">version.vhd"); +die "could not open file" if (! defined $fh); +print $fh <close; + +system("env| grep LM_"); +my $r = ""; + +my $c="$synplify_path/bin/synplify_premier_dp -batch $TOPNAME.prj"; +$r=execute($c, "do_not_exit" ); + + +chdir $WORKDIR; +$fh = new FileHandle("<$TOPNAME".".srr"); +my @a = <$fh>; +$fh -> close; + + + +foreach (@a) +{ + if(/\@E:/) + { + print "\n"; + $c="cat $TOPNAME.srr | grep \"\@E\""; + system($c); + print "\n\n"; + exit 129; + } +} + + +$ENV{'LM_LICENSE_FILE'}=$lm_license_file_for_par; + +$c=qq|edif2ngd -l $FAMILYNAME -d $DEVICENAME "$TOPNAME.edf" "$TOPNAME.ngo" |; +execute($c); + +$c=qq|edfupdate -t "$TOPNAME.tcy" -w "$TOPNAME.ngo" -m "$TOPNAME.ngo" "$TOPNAME.ngx"|; +execute($c); + +$c=qq'ngdbuild -a $FAMILYNAME -d $DEVICENAME -p "$lattice_path/ispfpga/ep5c00/data" -dt "$TOPNAME.ngo" "$TOPNAME.ngd" | grep -v -e "^WARNING.*has no load"'; +execute($c); + +my $tpmap = $TOPNAME . "_map" ; + +$c=qq|map -retime -split_node -a $FAMILYNAME -p $DEVICENAME -t $PACKAGE -s $SPEEDGRADE "$TOPNAME.ngd" -o "$tpmap.ncd" -mp "$TOPNAME.mrp" "$TOPNAME.lpf"|; +execute($c); + +system("rm $TOPNAME.ncd"); + +#$c=qq|multipar -pr "$TOPNAME.prf" -o "mpar_$TOPNAME.rpt" -log "mpar_$TOPNAME.log" -p "../$TOPNAME.p2t" "$tpmap.ncd" "$TOPNAME.ncd"|; +#$c=qq|par -f "../$TOPNAME.p2t" "$tpmap.ncd" "$TOPNAME.ncd" "$TOPNAME.prf"|; +#$c=qq|par -f "../$TOPNAME.p2t" "$tpmap.ncd" "$TOPNAME.dir" "$TOPNAME.prf"|; +$c=qq|mpartrce -p "../$TOPNAME.p2t" -f "../$TOPNAME.p3t" -tf "$TOPNAME.pt" "|.$TOPNAME.qq|_map.ncd" "$TOPNAME.ncd"|; +execute($c); + +# IOR IO Timing Report +$c=qq|iotiming -s "$TOPNAME.ncd" "$TOPNAME.prf"|; +execute($c); + +# TWR Timing Report +$c=qq|trce -c -v 15 -o "$TOPNAME.twr.setup" "$TOPNAME.ncd" "$TOPNAME.prf"|; +execute($c); + +$c=qq|trce -hld -c -v 5 -o "$TOPNAME.twr.hold" "$TOPNAME.ncd" "$TOPNAME.prf"|; +execute($c); + +$c=qq|ltxt2ptxt $TOPNAME.ncd|; +execute($c); + +$c=qq|$lattice_path/ispfpga/bin/lin/bitgen -w "$TOPNAME.ncd" "$TOPNAME.prf"|; +execute($c); + +chdir ".."; + + +sub execute { + my ($c, $op) = @_; + #print "option: $op \n"; + $op = "" if(!$op); + print color 'blue bold'; + print "\n\ncommand to execute: $c \n"; + print color 'reset'; + $r=system($c); + if($r) { + print "$!"; + if($op ne "do_not_exit") { + wait; + } + } + + return $r; + +} + diff --git a/cts/compile_central_gsi.pl b/cts/compile_central_gsi.pl index b808f34..860b8be 100755 --- a/cts/compile_central_gsi.pl +++ b/cts/compile_central_gsi.pl @@ -2,22 +2,29 @@ use Data::Dumper; use warnings; use strict; +use Term::ANSIColor; +use File::stat; +use POSIX; use FileHandle; - - ################################################################################### #Settings for this project my $TOPNAME = "trb3_central"; #Name of top-level entity -my $lattice_path = '/opt/lattice/diamond/2.1_x64'; -my $lattice_bin_path = "$lattice_path/bin/lin64"; # note the lin/lin64 at the end, no isfgpa needed -my $synplify_path = '/opt/synplicity/F-2012.03-SP1'; -my $lm_license_file_for_synplify = '27000@lxcad01.gsi.de'; -my $lm_license_file_for_par = '1702@hadeb05.gsi.de'; +my $BasePath = "../base/"; #path to "base" directory +my $CbmNetPath = "../../cbmnet"; +my $lm_license_file_for_synplify = "27000\@lxcad01.gsi.de"; +my $lm_license_file_for_par = "1702\@hadeb05.gsi.de"; + +my $lattice_path = '/opt/lattice/diamond/3.2_x64/'; +my $synplify_path = '/opt/synplicity/I-2013.09-SP1/'; +my $lattice_bin_path = "$lattice_path/bin/lin64"; # note the lin or lin64 at the end, no isfgpa needed +my $config_vhd = 'config_mainz_a2.vhd'; ################################################################################### +system("./compile_constraints.pl"); +symlink($CbmNetPath, '../cbmnet/cbmnet') unless (-e '../cbmnet/cbmnet'); # source the standard lattice environment $ENV{bindir}="$lattice_bin_path"; @@ -35,8 +42,6 @@ $ENV{'SYN_DISABLE_RAINBOW_DONGLE'}=1; $ENV{'LM_LICENSE_FILE'}=$lm_license_file_for_synplify; - - my $FAMILYNAME="LatticeECP3"; my $DEVICENAME="LFE3-150EA"; my $PACKAGE="FPBGA1156"; @@ -51,19 +56,7 @@ unless(-d $WORKDIR) { } system("ln -sfT $lattice_path $WORKDIR/lattice-diamond"); - -#create full lpf file -system("cp ../base/trb3_central_cts.lpf $WORKDIR/$TOPNAME.lpf"); -system("cat tdc_release/tdc_constraints.lpf >> $WORKDIR/$TOPNAME.lpf"); -system("cat ".$TOPNAME."_constraints.lpf >> $WORKDIR/$TOPNAME.lpf"); -system("sed -i 's#THE_TDC/#gen_TDC_THE_TDC/#g' $WORKDIR/$TOPNAME.lpf"); - -system("ln -f -s config_mainz_a2.vhd config.vhd"); - -if(defined $ENV{'LPF_ONLY'} and $ENV{'LPF_ONLY'} == 1) {exit;} - -#set -e -#set -o errexit +system("ln -f -s $config_vhd config.vhd"); #generate timestamp my $t=time; @@ -81,12 +74,12 @@ use ieee.numeric_std.all; package version is constant VERSION_NUMBER_TIME : integer := $t; - + end package version; EOF $fh->close; -#system("env| grep LM_"); +system("env| grep LM_"); my $r = ""; my $c="$synplify_path/bin/synplify_premier_dp -batch $TOPNAME.prj"; @@ -115,19 +108,18 @@ foreach (@a) $ENV{'LM_LICENSE_FILE'}=$lm_license_file_for_par; - -$c=qq| edif2ngd -path "../" -path "." -l $FAMILYNAME -d $DEVICENAME "$TOPNAME.edf" "$TOPNAME.ngo" |; +$c=qq|edif2ngd -l $FAMILYNAME -d $DEVICENAME "$TOPNAME.edf" "$TOPNAME.ngo" |; execute($c); $c=qq|edfupdate -t "$TOPNAME.tcy" -w "$TOPNAME.ngo" -m "$TOPNAME.ngo" "$TOPNAME.ngx"|; execute($c); -$c=qq|ngdbuild -a $FAMILYNAME -d $DEVICENAME -p "$lattice_path/ispfpga/ep5c00/data" -dt "$TOPNAME.ngo" "$TOPNAME.ngd"|; +$c=qq'ngdbuild -a $FAMILYNAME -d $DEVICENAME -p "$lattice_path/ispfpga/ep5c00/data" -dt "$TOPNAME.ngo" "$TOPNAME.ngd" | grep -v -e "^WARNING.*has no load"'; execute($c); my $tpmap = $TOPNAME . "_map" ; -$c=qq|map -retime -split_node -a $FAMILYNAME -p $DEVICENAME -t $PACKAGE -s $SPEEDGRADE "$TOPNAME.ngd" -pr "$TOPNAME.prf" -o "$tpmap.ncd" -mp "$TOPNAME.mrp" "$TOPNAME.lpf"|; +$c=qq|map -retime -split_node -a $FAMILYNAME -p $DEVICENAME -t $PACKAGE -s $SPEEDGRADE "$TOPNAME.ngd" -o "$tpmap.ncd" -mp "$TOPNAME.mrp" "$TOPNAME.lpf"|; execute($c); system("rm $TOPNAME.ncd"); @@ -140,7 +132,7 @@ execute($c); # IOR IO Timing Report $c=qq|iotiming -s "$TOPNAME.ncd" "$TOPNAME.prf"|; -#execute($c); +execute($c); # TWR Timing Report $c=qq|trce -c -v 15 -o "$TOPNAME.twr.setup" "$TOPNAME.ncd" "$TOPNAME.prf"|; @@ -152,27 +144,28 @@ execute($c); $c=qq|ltxt2ptxt $TOPNAME.ncd|; execute($c); -$c=qq|bitgen -w -g CfgMode:Disable -g RamCfg:Reset -g ES:No $TOPNAME.ncd $TOPNAME.bit $TOPNAME.prf|; -# $c=qq|$lattice_path/ispfpga/bin/lin/bitgen -w "$TOPNAME.ncd" "$TOPNAME.prf"|; +$c=qq|$lattice_path/ispfpga/bin/lin/bitgen -w "$TOPNAME.ncd" "$TOPNAME.prf"|; execute($c); chdir ".."; -exit; sub execute { my ($c, $op) = @_; #print "option: $op \n"; $op = "" if(!$op); + print color 'blue bold'; print "\n\ncommand to execute: $c \n"; + print color 'reset'; $r=system($c); if($r) { - print "$!"; - if($op ne "do_not_exit") { - exit; - } + print "$!"; + if($op ne "do_not_exit") { + wait; + } } return $r; } + diff --git a/cts/config_mainz_a2.vhd b/cts/config_mainz_a2.vhd index 96a10b2..5a75a41 100644 --- a/cts/config_mainz_a2.vhd +++ b/cts/config_mainz_a2.vhd @@ -4,32 +4,43 @@ use ieee.numeric_std.all; use work.trb_net_std.all; package config is - - ------------------------------------------------------------------------------ --Begin of configuration ------------------------------------------------------------------------------ + constant INCLUDE_CTS : integer range c_NO to c_YES := c_YES; + constant INCLUDE_CBMNET : integer range c_NO to c_YES := c_NO; + --include TDC for all four trigger input lines constant INCLUDE_TDC : integer range c_NO to c_YES := c_YES; + constant TDC_CHANNEL_NUMBER : integer := 5; + +--Use 64 word ringbuffer instead of 128 word ringbuffer in TDC channels + constant USE_64_FIFO : integer := c_YES; + +--Define ringbuffer size for TDC channels: 32-64-128 + constant RING_BUFFER_SIZE : integer range 0 to 128 := 1; ---use all four SFP (1-4) as downlink to other boards. +--use all four SFP (1-4) as downlink to other boards (only w/o CBMNET) constant USE_4_SFP : integer range c_NO to c_YES := c_NO; --Run wih 125 MHz instead of 100 MHz constant USE_125_MHZ : integer range c_NO to c_YES := c_NO; +--Run external 200 MHz clock source + constant USE_EXTERNAL_CLOCK : integer range c_NO to c_YES := c_NO; + --Which external trigger module (ETM) to use? - type ETM_CHOICE_type is (ETM_CHOICE_MBS_VULOM, ETM_CHOICE_MAINZ_A2); + constant INCLUDE_ETM : integer range c_NO to c_YES := c_NO; + type ETM_CHOICE_type is (ETM_CHOICE_MBS_VULOM, ETM_CHOICE_MAINZ_A2, ETM_CHOICE_CBMNET); constant ETM_CHOICE : ETM_CHOICE_type := ETM_CHOICE_MAINZ_A2; + constant ETM_ID : std_logic_vector(7 downto 0); + ------------------------------------------------------------------------------ --End of configuration ------------------------------------------------------------------------------ - - - --Ports: -- LVL1/IPU SCtrl @@ -41,10 +52,6 @@ package config is -- 5-7 SFP 2-4 -- 5(8) CTS read-out internal 0 1 - X X O --downlink only -- 6(9) CTS TRG Sctrl GbE 2 3 4 X X X --uplink only - - - - ------------------------------------------------------------------------------ --Hub configuration @@ -62,6 +69,7 @@ package config is --slow-control is accepted on SFP1 only, triggers are sent to all used SFP constant INTERNAL_NUM_ARR : hub_mii_t := (5,5); constant INTERFACE_NUM_ARR : hub_mii_t := (5,8); +-- 0 1 2 3 4 5 6 7 8 9 a b c d e f constant IS_UPLINK_ARR : hub_cfg_t := ((0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0), (0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0)); constant IS_DOWNLINK_ARR : hub_cfg_t := ((1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0), @@ -108,7 +116,7 @@ end; package body config is --compute correct configuration mode constant CFG_MODE : integer := USE_4_SFP; - constant cts_rdo_additional_ports : integer := 1 + INCLUDE_TDC; + constant cts_rdo_additional_ports : integer := 1 + INCLUDE_TDC + INCLUDE_CBMNET; constant HARDWARE_INFO : std_logic_vector (31 downto 0) := HARDWARE_INFO_ARR(INCLUDE_TDC); constant INTERNAL_NUM : integer := INTERNAL_NUM_ARR(CFG_MODE); @@ -117,5 +125,17 @@ package body config is constant IS_DOWNLINK : hub_ct := IS_DOWNLINK_ARR(CFG_MODE); constant IS_UPLINK_ONLY : hub_ct := IS_UPLINK_ONLY_ARR(CFG_MODE); + function etm_id_func return std_logic_vector is + variable res : unsigned(7 downto 0); + begin + res := x"00"; + if INCLUDE_ETM=c_YES then + res := x"60"; + res := res + TO_UNSIGNED(ETM_CHOICE_type'pos(ETM_CHOICE), 4); + end if; + return std_logic_vector(res); + end function; + + constant ETM_ID : std_logic_vector(7 downto 0) := etm_id_func; end package body;