0x405d75 0x4035f7 0x4035f8 0x4035fb #### #!user/bin/perl #use strict; #use warnings; use bytes; $length_buffer= length(0x100) ; #buffer length print "$length_buffer, \n"; $base=length(0x00); #base address print "$base, \n"; $base_end= ($base+ $length_buffer-1); #base_end address, here it means it goes from 0 to 255 which is 256 elements in the buffer print " The end of the buffer=$base_end, \n"; #just to check if the buffer end prints correctly, in this case its 255 #$temp= 0xFFFFFFE0; $count_hit=0; #counter to calculate the number of hits $count_miss=0; #counter to calculate number of misses ################## Input and output Files#################################################################################### open(FILE1," < output_log.txt") or die "can't read the file"; #trace file input open(FILE2, "> o_hit_miss.txt") or die "can't write into the file"; #output file containing the hit and miss informaiton ############################################################################################################################### while(){ $inst_addr= $_; # read the lines and store in in inst_addr #print " $inst_addr \n"; # to check if the inst_addr is being read out correctly from the given file ###########################################calcultes the length of the address and prints the same in bytes#################### if($inst_addr) { #use bytes; # Pragma to display the string in bytes and not in characters #$len_ofinstr=length( $inst_addr); #calculates the length of string in bytes and assigns it to $len_instr #print " Length in bytes: ", $len_ofinstr, "\n"; #prints the length in bytes for my understanding if($len_ofinstr >= $base && $len_ofinstr <=$base_end) { #print" $hit, \n"; #print FILE2 $hit. "\n"; #print " The inst fits in the buffer->hit, \n"; $len_ofinstr+=$len_ofinstr; #print "Total number of bytes in the buffer=", $len_ofinstr, "\n"; $count_hit=$count_hit+1; #print " Number of hits in the buffer= $count_hit", "\n"; print FILE2 "number of hits in buffer". $count_hit. "\n"; } } else{ if($len_inst == $length_buffer) { print " it can not hold anymore, \n"; $base= $instr_addr & 0xffffffe0; } } }