Saturday 27 June 2015

Insertion of Pragmas in Source Code using Cshell Script

Their was a requirement to develop a script to add pragma to the code in order to encrypt the source code.We need to add `protect begin and `protect end between module and end module of .v files.



Original .v file:

 module chip( MINUS,PLUS );

  output wreal PLUS;
  input wreal MINUS;

  parameter elite  = 0;
   parameter coffee = 1;
   parameter club   = 1;

  always@(*) 
   begin 
    $display("elite  = %d" , elite );
    $display("coffee = %d" , coffee);
    $display("club   = %d" , club  );
   end

endmodule 
// comments 
// parameter

Output .v file:

 module chip( MINUS,PLUS );

  output wreal PLUS;
  input wreal MINUS;

  parameter elite  = 0;
   parameter coffee = 1;
   parameter club   = 1; 

  `protect begin

  always@(*) 
   begin 

    $display("elite  = %d" , elite );
    $display("coffee = %d" , coffee);
    $display("club   = %d" , club  );
   end

 `protect end

endmodule
// comments 
// parameter



The script was written in cshell as stated below

#! /bin/csh -fx

setenv RUN_DIR $PWD

set filename = $RUN_DIR/test_list.txt  # test_list.txt gives list of all .v files
set temp = temp                        # temp variable
set file = file                        # file variable

foreach filelocal (`cat $filename`)    # foreach is reading each file in test_list

  echo $filelocal

  # Removing Tempfiles
  rm -rf $file$temp                    # Removing temporary in between generated files
  rm -rf $file

  # Removing comments in the file
  cat $filelocal | sed 's/\/\/.*$//' > $file  # Making sure to remove all comment " // " lines from the orginal .v file ($filelocal) and piping to a temporary file ($file)

  #Counting total lines of the file
  set count = `cat $file | wc -l`             # counting the entire lines of the file ($file)

  # Finding the last line for the grep item
  set final = `grep -n "input\|output\|parameter\|inout" $file | sed 's/:/ /g' | awk '{print $1}' | tail -n 1 `  # Here we are greping the various fields as stated , here up to parameter and finding the line number


  echo $final

  head -$final $file > $file$temp # Then we are sending the contents of the lines up to the parameter to a new file

  echo \`protect begin >> $file$temp # Then printing the `protect begin to the new file

  # Finding the last line for the grep item
  set end = `grep -n "endmodule" $file | sed 's/:/ /g' | awk '{print $1}' | tail -n 1 ` # Finding the endmodule line here
  echo $end

  # printing between Lines
  set final = `expr $final + 1`
  set end = `expr $end - 1`

  sed -n $final,{$end}p $file >> $file$temp # Printing all the lines between after parameter last line to endmoule before line

  echo \`protect end >> $file$temp # Printing the `protect end
  echo endmodule >> $file$temp # Printing endmodule

   #printing end lines
  set end = `grep -n "endmodule" $file | sed 's/:/ /g' | awk '{print $1}' | tail -n 1 `
  set rem = `expr $count - $end`
  tail -$rem $file >> $file$temp # Printing the ending lines after endmdule

  # Copying the local file to orginal file
  cp -rf $file$temp $filelocal  # Copying the temporary file back to original file

end

Thanks for reading this post ..!

Saturday 13 June 2015

DAC-15 Highlights

Design Automation Conference got an outstanding response, around 800 papers were submitted this year in which 200 papers were finalized.  All keynote presentations were very interesting especially the smart lens  speech by Brain Otis ,Director from Google was really amazing. Vivek Singh speech on Moore’s law at fifty was another highlight , his presentation was outstanding especially the ending slide which shows the Moore Photograph.


My Interaction with Cliff Cummings ( Sunburst Design) , Dave Rich ( Verification Academy) helped me in understanding UVM concepts in depth.



My presentation was satisfactory received positive response from the audience , heard the next big turn in verification is simAccel ( Simulation + Acceleration) and  VIP vendors are about to start this in full-swing.



At last it was a satisfactory trip with thought provoking discussions.