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;
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 (
--- /dev/null
+#!/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 = <CONFIG>) {
+ 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("<config.vhd");
+ my @a = <$fh>;
+ $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;
+}