From 3ef3f86a29651428ea9cc67c11059c0c9465d3c7 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Fri, 1 Apr 2016 10:59:55 +0200 Subject: [PATCH] adding missing compile script for TDC --- releases/tdc_v2.3/TDC_record.vhd | 11 ++++- scripts/compile_tdc.pl | 84 ++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100755 scripts/compile_tdc.pl diff --git a/releases/tdc_v2.3/TDC_record.vhd b/releases/tdc_v2.3/TDC_record.vhd index 8b7f5bc..1498936 100644 --- a/releases/tdc_v2.3/TDC_record.vhd +++ b/releases/tdc_v2.3/TDC_record.vhd @@ -152,6 +152,9 @@ architecture TDC_record of TDC_record is signal bushit_tx, busstat_tx, buschdebug_tx, busctrl_tx : CTRLBUS_TX; signal busreadout_rx : READOUT_RX; signal busreadout_tx : READOUT_TX; + + signal hit_in_reg : std_logic_vector(CHANNEL_NUMBER-1 downto 1); + signal ref_in_reg : std_logic; attribute syn_keep : boolean; @@ -650,13 +653,17 @@ begin DATA_IN => ch_level_hit_number, DATA_OUT => open); - ch_level_hit_number(0)(31) <= REFERENCE_TIME when rising_edge(CLK_READOUT); + ch_level_hit_number(0)(31) <= ref_in_reg when rising_edge(CLK_READOUT); ch_level_hit_number(0)(30 downto 0) <= std_logic_vector(ch_hit_detect_cntr(0)) when rising_edge(CLK_READOUT); GenHitDetectNumber : for i in 1 to CHANNEL_NUMBER-1 generate - ch_level_hit_number(i)(31) <= HIT_IN(i) when rising_edge(CLK_READOUT); + ch_level_hit_number(i)(31) <= hit_in_reg(i) when rising_edge(CLK_READOUT); ch_level_hit_number(i)(30 downto 0) <= std_logic_vector(ch_hit_detect_cntr(i)) when rising_edge(CLK_READOUT); end generate GenHitDetectNumber; + hit_in_reg <= HIT_IN when rising_edge(CLK_READOUT); + ref_in_reg <= REFERENCE_TIME when rising_edge(CLK_READOUT); + + -- Status register TheStatusRegisterBus : entity work.BusHandler_record generic map ( diff --git a/scripts/compile_tdc.pl b/scripts/compile_tdc.pl new file mode 100755 index 0000000..cfe9fa0 --- /dev/null +++ b/scripts/compile_tdc.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl +use warnings; +use strict; +use FileHandle; + +my $WORKDIR = $ARGV[0]; +my $TOPNAME = $ARGV[1]; +my $OPTION = $ARGV[2]; + +edit_config() if $OPTION eq "config"; +edit_prj() if $OPTION eq "prj"; + + +sub edit_prj { + #edit the prj file according to tdc data format + my %configSettings = (); + open(CONFIG, '../config.vhd'); + my $config = "#!!! This file was compiled using compile_contraints.pl.\n#!!! DO NOT EDIT AS ALL CHANGES WILL BE OVERRIDEN\n\n"; + print "The following module configuration was derived from config.vhd:\n"; + + while (my $line = ) { + if ($line =~ /(TDC_DATA_FORMAT).*:=\s*(\d+).*;/i) { + my $mod = uc $1; + my $type = $2; + $configSettings{$mod} = $type; + my $conf = "set $mod $type\n"; + print ' ' . $conf; + $config .= $conf; + } + } + close(CONFIG); + open TCLCONF, '>', $TOPNAME . '_prjconfig.tcl'; + print TCLCONF $config; + close TCLCONF; +} + +sub edit_config { + #change the Ring buffer name in the constraints file according to the config.vhd + my $fh = new FileHandle("; + $fh -> close; + my $ringbuffersize; + my $chNumber; + + foreach (@a) { + $ringbuffersize = $1 if $_ =~ /constant\s+RING_BUFFER_SIZE\s*:.*:=\s*(\d+);/; + $chNumber = $1 if $_ =~ /constant\s+NUM_TDC_CHANNELS\s*:.*:=\s*(\d+);/; + } + # print "$ringbuffersize\n"; + # print "$chNumber\n"; + + my @newline; + $fh = new FileHandle("<$WORKDIR/$TOPNAME".".lpf"); + @a = <$fh>; + $fh -> close; + + foreach (@a) { + if ($ringbuffersize == 0) { + $_ =~ s/Buffer_128.The_Buffer/Buffer_32.The_Buffer/g; + } elsif ($ringbuffersize == 1 || $ringbuffersize == 5) { + $_ =~ s/Buffer_128.The_Buffer/Buffer_64.The_Buffer/g; + } elsif ($ringbuffersize == 2) { + $_ =~ s/Buffer_128.The_Buffer/Buffer_96.The_Buffer/g; + } elsif ($ringbuffersize == 3 || $ringbuffersize == 7) { + $_ =~ s/Buffer_128.The_Buffer/Buffer_128.The_Buffer/g; + } else { + print "unknown ringbuffer size... \n"; + exit 129; + } + + my $ch = 1; + $ch = $1 if $_ =~ /.*[]BLKNAME|PROHIBIT].*[GEN_Channels|GEN_hit_mux]\.(\d+).*/; + if ($ch >= $chNumber) { + # print "Channel $ch doesn't exist.\nold line $_"; + $_ =~ s/$_/#$_/; + # print GREEN "new line $_\n\n\n", RESET; + } + + push(@newline,$_); + } + $fh = new FileHandle(">$WORKDIR/$TOPNAME".".lpf"); + print $fh @newline; + $fh -> close; +} -- 2.43.0