#!/usr/bin/perl # $Id: pp_cfg.pl 1.6 2001/03/30 15:01:48 Administrator Exp Administrator $ # $State: Exp $ # $Source: W:/work/perls/RCS/pp_cfg.pl $ # $RCSfile: pp_cfg.pl $ # $Revision: 1.6 $ # $Date: 2001/03/30 15:01:48 $ # $Log: pp_cfg.pl $ # Revision 1.6 2001/03/30 15:01:48 Administrator # This version fixes a problem with vector generation. # # Revision 1.5 2001/03/22 14:17:36 Administrator # Initial Release # # Revision 1.4 2001/03/15 17:34:26 administrator # The code is working now, wire assignment settling was screwing it up. # # Revision 1.3 2001/03/14 23:34:18 administrator # Mostly working, possible problem with strobes. # # Revision 1.2 2001/03/14 21:11:54 administrator # All the functions seem to work. # # Revision 1.1 2001/03/13 22:17:34 administrator # Initial revision # # Revision 1.3 2000/12/12 18:22:58 Administrator # ---------------------------------------------------------------------- # ---------------------------------------------------------------------- # This Perl script reads in the specified PinPort definition file. The # file should be a delimited file, like csv. It parses the file, and # generates a Verilog module which provides an interface between the # device connected to the PinPort, and the other system simulation # models. # ---------------------------------------------------------------------- # ---------------------------------------------------------------------- # Options for this Perl script should be specified on the command line. # USAGE: # /perl /pp_cfg.pl chip_01.opt # ---------------------------------------------------------------------- # ---------------------------------------------------------------------- # OPTIONS FILE FORMAT: # # log_enable= - generates a log file 1=on 0=off # log_name= - name of log file file name # pin_definition_name= - name of pin definition file file name # verilog_name= - name of generated verilog file file name # include_name= - name of Exsent utility file file name # vector_delimiter= - vector delimiter delimiter # field_delimiter= - field delimiter delimiter # port_vectors= - generate port vectors 1=on 0=off # bidirect_pullups= - put pullups on bidirect ports 1=on 0=off # strobe_1_values= - strobe 1 parameters 6 values # strobe_2_values= - strobe 1 parameters 6 values # # OPTIONS FILE EXAMPLE: # # log_enable=1 # log_name=chip_01.log # pin_definition_name=chip_01.cvs # verilog_name=chip_01.v # include_name=test\exsent_u.v # vector_delimiter=< # field_delimiter=, # port_vectors=0 # bidirect_pullups=1 # strobe_1_values=5-5-5-5-0-0 # strobe_2_values=2-3-1-1-2-1 # # OPTION DEFAULTS: # # log_enable=1 # log_name=chip_01.log # pin_definition_name=chip_01.cvs # verilog_name=chip_01.v # include_name=exsent_u.v # vector_delimiter=[ # field_delimiter=, # port_vectors=0 # bidirect_pullups=0 # strobe_1_values=1-1-1-1-0-0 # strobe_2_values=1-1-1-1-0-0 # ---------------------------------------------------------------------- # ---------------------------------------------------------------------- # PIN DEFINITION FILE FORMAT: # # PinPort pin #, Pin Name, Pin Direction, Strobe 1, Strobe 2, Pin Drive # ------------- -------- ------------- -------- -------- --------- # # PIN DEFINITION FILE EXAMPLE: # # 1,clk,input,on,off # 2,addr,input,off,off # 3,ena,input,off,off # 4,data_i<0>,input,off,off # 5,data_i<1>,input,off,off # 6,outp<0>,output,off,off # 7,outp<1>,output,off,off # 8,bi_diwrecked,inout,off,off,~addr && ena # ---------------------------------------------------------------------- # -- SUBROUTINES ------------------------------------------------------- # -- ------------------------------------------------------------------- sub print_header { # -- print header -------------------------------------------------- # if ($print_enable == 1) { print "-sta- : print_header\n"; } print ("\n"); print ("|===================== EXSENT INC ======================|\n"); print ("|----- PERL BASED PIN INTERFACE GENERATION PROGRAM -----|\n"); print ("|----- -----|\n"); print ("|----- This Perl script generates a Verilog pin -----|\n"); print ("|----- interface module file. -----|\n"); print ("|----- -----|\n"); print ("|----- COMMAND LINE USAGE: -----|\n"); print ("|----- -----|\n"); print ("|----- /perl /pp_cfg.pl -----|\n"); print ("|----- -----|\n"); print ("|----- REQUIRED FILE TYPES AND NAMES: -----|\n"); print ("|----- -----|\n"); print ("|----- -----|\n"); print ("|----- = this text file contains the options -----|\n"); print ("|----- -----|\n"); print ("|----- = this text file contains pin definitions -----|\n"); print ("|----- -----|\n"); print ("|----- GENERATED FILE TYPES AND NAMES: -----|\n"); print ("|----- -----|\n"); print ("|----- -----|\n"); print ("|----- = generated Verilog module file -----|\n"); print ("|----- -----|\n"); print ("|----- = optional log file -----|\n"); print ("|===== =====|\n"); } # -- print header -------------------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub get_command_line_info { # -- get command line info ----------------------------------------- # if ($print_enable == 1) { print "-sta- : get_command_line\n"; } $0 =~ m:(.*)/: ; # $0 is now this program's name & path if ( $#ARGV != 0 ) # check for valid command line { print( STDERR " ERROR: Incorrect usage: USAGE: $0 /perl /pp_cfg.pl " ) ; print("\n"); print(" --T-- : Enter option file - "); $option_file = ; chop($option_file); print("\n"); } else { $option_file = shift (@ARGV); } } # -- get command line info ----------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub set_the_options { # -- read in options from option file ----------------------------- # if ($print_enable == 1) { print "-sta- : read_options_file\n"; } # -- first the defaults -------------------------------------------- $print_enable = 1; $comments_enable = 2; $log_enable = 1; $log_name = "chip_01.log"; $pin_definition_name = "chip_01.cvs"; $verilog_name = "chip_01.v"; $include_name = "exsent_u.v"; $vector_delimiter = "["; $field_delimiter = ","; $port_vectors = 0; $bidirect_pullups = 1; $strobe_1_values = 1-1-1-1-0-0; $strobe_2_values = 1-1-1-1-0-0; open OF,$option_file || die "Unable to open $option_file"; # test for option file while ( ) # read in the mandatory file { chop; if (($_ =~ /\W+/) || ($_ =~ /\w+/) || ($_ =~ /\s+/)) { # -- get the option information from the file -------------- my @option_line = split/=/,$_; if ($option_line[0] =~ "^log_enable") { $log_enable = $option_line[1]; } elsif ($option_line[0] =~ "^log_name") { $log_name = $option_line[1]; } elsif ($option_line[0] =~ "^pin_definition_name") { $pin_definition_name = $option_line[1]; } elsif ($option_line[0] =~ "^verilog_name") { $verilog_name = $option_line[1]; } elsif ($option_line[0] =~ "^include_name") { $include_name = $option_line[1]; } elsif ($option_line[0] =~ "^vector_delimiter") { $vector_delimiter = $option_line[1]; } elsif ($option_line[0] =~ "^field_delimiter") { $field_delimiter = $option_line[1]; } elsif ($option_line[0] =~ "^port_vectors") { $port_vectors = $option_line[1]; } elsif ($option_line[0] =~ "^bidirect_pullups") { $bidirect_pullups = $option_line[1]; } elsif ($option_line[0] =~ "^strobe_1_values") { $strobe_1_values = $option_line[1]; } elsif ($option_line[0] =~ "^strobe_2_values") { $strobe_2_values = $option_line[1]; } print " -----|\r"; print " = $option_line[1] \r"; print "|----- $option_line[0] \r"; print "\n"; } # -- get the option information from the file -------------- { # -- get the base name for the module ------------------------ $base_name = $verilog_name; $base_name =~ s/\.v//; } # -- get the base name for the module ------------------------ } print ("|===== =====|\n"); close( OF ) || die "Unable to close $option_file"; # test for option file } # -- read in options from option file ----------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub file_init { # -- file housekeeping --------------------------------------------- if ($print_enable > 0) { print "-sta- : file_housekeeping\n"; } open IF,$include_name || die "Unable to open $include_name"; open PF,$pin_definition_name || die "Unable to open $pin_definition_name"; if ($log_enable == 1) { open LF, "> $log_name" || die "Unable to open $log_name"; } open VF, "> $verilog_name" || die "Unable to open $verilog_name"; } # -- file housekeeping --------------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub read_in_pin_definitions { # -- read in pin definitions --------------------------------------- if ($print_enable > 0) { print "-sta- : read_pin_info\n"; } $pin_count = 0; while( ) { # -- read file ------------------------------------------------- chop; # -- check for non-lank line ----------------------------------- if (($_ =~ /\W+/) || ($_ =~ /\w+/) || ($_ =~ /\s+/)) { # -- keep track of the number of pins ---------------------- $pin_count = $pin_count + 1; # -- fix up vector delimiter ------------------------------- if ($port_vectors == 0) { if ($vector_delimiter =~ ///g; } elsif ($vector_delimiter =~ /\(/) { s/\(/_/g; s/\)//g; } elsif ($vector_delimiter =~ /\[/) { s/\[/_/g; s/\]//g; } } else { if ($vector_delimiter =~ //\]/g; } elsif ($vector_delimiter =~ /\(/) { s/\(/\[/g; s/\)/\]/g; } } my $read_line = $_; # -- split fields ------------------------------------------ my @line_read = split /$field_delimiter/,$read_line; # -- assign hash key values -------------------------------- $pin_hash[$pin_count]{pin_number} = $line_read[0]; $pin_hash[$pin_count]{pin_number} =~ s/\s*//g; $pin_hash[$pin_count]{pin_name} = $line_read[1]; $pin_hash[$pin_count]{pin_name} =~ s/\s*//g; $pin_hash[$pin_count]{pin_dir} = $line_read[2]; $pin_hash[$pin_count]{pin_dir} =~ s/\s*//g; $pin_hash[$pin_count]{pin_dir} =~ tr/[A-Z]/[a-z]/; $pin_hash[$pin_count]{strobe_1} = $line_read[3]; $pin_hash[$pin_count]{strobe_1} =~ s/\s*//g; $pin_hash[$pin_count]{strobe_1} =~ tr/[A-Z]/[a-z]/; $pin_hash[$pin_count]{strobe_2} = $line_read[4]; $pin_hash[$pin_count]{strobe_2} =~ s/\s*//g; $pin_hash[$pin_count]{strobe_2} =~ tr/[A-Z]/[a-z]/; $pin_hash[$pin_count]{pin_drive} = $line_read[5]; } } # -- read file ------------------------------------------------- } # -- read in pin definitions --------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub make_pin_definition_array { # -- make pin definition array ------------------------------------- if ($print_enable > 1) { print "-sta- : make_pin_definition_array\n"; # -- spin through all the pins --------------------------------- for $ix ( 1 .. $#pin_hash ) { print (" -----|\r"); print ("|----- "); print ("$pin_hash[$ix]{pin_number} "); print ("$pin_hash[$ix]{pin_name} "); print ("$pin_hash[$ix]{pin_dir} "); print ("$pin_hash[$ix]{strobe_1} "); print ("$pin_hash[$ix]{strobe_2} "); print ("$pin_hash[$ix]{pin_drive} \r"); print ("\n"); } } } # -- make pin definition array ------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub determine_pinport_size { # -- determine pinport size ---------------------------------------- if ($print_enable > 0) { print "-sta- : determine_pinport_size\n"; } $max_pin_number = 1; # -- spin through all the pins ------------------------------------- for $ix ( 1 .. $#pin_hash ) { if ($pin_hash[$ix]{pin_number} > $max_pin_number) { $max_pin_number = $pin_hash[$ix]{pin_number}; } } if ($max_pin_number > 64) { $max_pin_number = 192; } if ($print_enable > 1) { print (" -----|\r"); print ("|----- maximum pin number = "); print ("$max_pin_number "); print ("\n"); } } # -- determine pinport size ---------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub make_the_port_map { # -- make port list ------------------------------------------------ if ($print_enable > 0) { print "-sta- : make_port_list\n"; } print (VF "\n"); print (VF "// -- $base_name module port mapping -------------------------------------\n"); print (VF "module $base_name ("); # -- spin through all the pins ------------------------------------- for $ix ( 1 .. $#pin_hash ) { my $current_port = $pin_hash[$ix]{pin_name}; if (($current_port =~ /\[/) || ($current_port =~ /\]/)) { # -- vector port ------------------------------------------- @current_vector_name = split/\[/,$current_port; $port_name = $current_vector_name[0]; @vector_digits = split/\]/,$current_vector_name[1]; $vector_number[$port_name] = $vector_digits[0]; # -- keep track of vector name ----------------------------- if ( ($vector_flag{$port_name} > 1) || ($vector_flag{$port_name} == 1) ) { $vector_flag{$port_name} = $vector_flag{$port_name} + 1; } else { $vector_flag{$port_name} = 1; push @port_vector_names , $port_name; } # -- make the port vector hash ----------------------------- if ($vector_flag{$port_name} == 1) { $port_hash{$port_name}{min} = $vector_number[$port_name]; $port_hash{$port_name}{max} = $vector_number[$port_name]; } elsif ($vector_number[$port_name] < $port_hash{$port_name}{min}) { $port_hash{$port_name}{min} = $vector_number[$port_name]; } elsif ($vector_number[$port_name] > $port_hash{$port_name}{max}) { $port_hash{$port_name}{max} = $vector_number[$port_name]; } } # -- make the port vector hash ----------------------------- else { # -- its a scaler ------------------------------------------ $port_name = $current_port; $vector_flag{$port_name} = 0; } # -- its a scaler ------------------------------------------ if ( ($vector_flag{$port_name} == 0) || ($vector_flag{$port_name} == 1) ) { # -- print the port ---------------------------------------- if ($ix > 1) { print (VF " ,"); } else { print (VF "\n "); } print (VF "$port_name"); if ($comments_enable > 1) { print (VF " // pin $pin_hash[$ix]{pin_number}"); } print (VF "\n"); } # -- print the port ---------------------------------------- } print (VF " );\n"); } # -- make port list ------------------------------------------------ # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub make_the_port_declarations { # -- make I/O declarations ----------------------------------------- if ($print_enable > 0) { print "-sta- : make_port_declarations\n"; } print (VF "\n"); print (VF "// -- declare port types -----------------------------------------------\n"); # -- spin through all the pins ------------------------------------- for $ix ( 1 .. $#pin_hash ) { # -- print the port scaler declaration ------------------------- my $current_port = $pin_hash[$ix]{pin_name}; my $port_name = $current_port; if (($current_port =~ /\[/) || ($current_port =~ /\]/)) {} else { # -- print the port declaration ---------------------------- print (VF "$pin_hash[$ix]{pin_dir}"); print (VF " $port_name;"); if ($comments_enable > 1) { print (VF " // pin $pin_hash[$ix]{pin_number}"); } print (VF "\n"); } # -- print the port declaration ---------------------------- } # -- print the port scaler declaration ------------------------- # -- spin through all the pins ------------------------------------- for $ix ( 1 .. $#pin_hash ) { # -- print the port vector declaration ------------------------- my $current_port = $pin_hash[$ix]{pin_name}; @current_vector_name = split/\[/,$current_port; my $port_name = $current_vector_name[0]; if (($current_port =~ /\[/) || ($current_port =~ /\]/)) { # -- print the port declaration ---------------------------- if ( ($vector_hash{$port_name} > 1) || ($vector_hash{$port_name} == 1) ) { $vector_hash{$port_name} = $vector_hash{$port_name} + 1; } else { $vector_hash{$port_name} = 1; } if ($vector_hash{$port_name} == 1) { print (VF "$pin_hash[$ix]{pin_dir}"); print (VF " \[$port_hash{$port_name}{max}"); print (VF ":$port_hash{$port_name}{min}\] "); print (VF " $port_name;"); if ($comments_enable > 1) { print (VF " // pin $pin_hash[$ix]{pin_number}"); } print (VF "\n"); } } # -- print the port declaration ---------------------------- } # -- print the port vector declaration ------------------------- } # -- make I/O declarations ----------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub make_the_wire_and_register_declarations { # -- make wire and register declarations --------------------------- if ($print_enable > 0) { print "-sta- : make_wire_&_reg_declarations\n"; } print (VF "\n"); print (VF "// -- declare wires and registers --------------------------------------\n"); print (VF "reg [$max_pin_number:1] r_pin_input;"); if ($comments_enable > 1) { print (VF " // pin return values from PinPort"); } print (VF "\n"); print (VF "wire [$max_pin_number:1] w_pin_output;"); if ($comments_enable > 1) { print (VF " // pin outputs to PinPort"); } print (VF "\n"); print (VF "wire [$max_pin_number:1] w_pin_1_output;"); if ($comments_enable > 1) { print (VF " // pin outputs to PinPort, with strobe 1 gated"); } print (VF "\n"); print (VF "wire [$max_pin_number:1] w_pin_2_output;"); if ($comments_enable > 1) { print (VF " // pin outputs to PinPort, with strobe 2 gated"); } print (VF "\n"); print (VF "wire [$max_pin_number:1] w_pin_enable;"); if ($comments_enable > 1) { print (VF " // pin enables for PinPort outputs"); } print (VF "\n"); print (VF "wire [$max_pin_number:1] w_pin_drive;"); if ($comments_enable > 1) { print (VF " // pin output enables to PinPort, dynamic drive"); } print (VF "\n"); print (VF "wire [$max_pin_number:1] w_strobe_1_pin_enable;"); if ($comments_enable > 1) { print (VF " // pin strobe 1 enables"); } print (VF "\n"); print (VF "wire [$max_pin_number:1] w_strobe_2_pin_enable;"); if ($comments_enable > 1) { print (VF " // pin strobe 2 enables"); } print (VF "\n"); print (VF "wire w_strobe_1_trigger;"); if ($comments_enable > 1) { print (VF " // strobe 1 change detection"); } print (VF "\n"); print (VF "wire w_strobe_2_trigger;"); if ($comments_enable > 1) { print (VF " // strobe 2 change detection"); } print (VF "\n"); print (VF "\n"); print (VF "// -- assign strobe pin masks and triggers -----------------------------\n"); print (VF "assign w_pin_1_output = w_pin_output | w_strobe_1_pin_enable;\n"); print (VF "assign w_pin_2_output = w_pin_output | w_strobe_2_pin_enable;\n"); print (VF "assign w_strobe_1_trigger = |(w_pin_output & w_strobe_1_pin_enable);\n"); print (VF "assign w_strobe_2_trigger = |(w_pin_output & w_strobe_2_pin_enable);\n"); } # -- make wire and register declarations --------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub include_exsent_utilities { # -- include exsent routines --------------------------------------- if ($print_enable > 0) { print "-sta- : include_exsent_routines\n"; } print (VF "\n"); print (VF "// -- included file information ----------------------------------------\n"); while( ) { print VF $_; } print (VF "// -- included file information ----------------------------------------\n"); print (VF "\n"); } # -- include exsent routines --------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub assign_the_input_pins { # -- assign input pins --------------------------------------------- if ($print_enable > 0) { print "-sta- : assign_pin_inputs\n"; } print (VF "\n"); print (VF "// -- assign input ports -----------------------------------------------\n"); # -- spin through all the pins ------------------------------------- for $ix ( 1 .. $#pin_hash ) { if ( ($pin_hash[$ix]{pin_dir} =~ /input/) || ($pin_hash[$ix]{pin_dir} =~ /inout/) ) { print (VF "assign w_pin_output[$pin_hash[$ix]{pin_number}] = $pin_hash[$ix]{pin_name};"); } else { print (VF "assign w_pin_output[$pin_hash[$ix]{pin_number}] = 1'b0;"); } if ($comments_enable > 1) { print (VF " // pin $pin_hash[$ix]{pin_number}"); } print (VF "\n"); } } # -- assign input pins --------------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub assign_the_output_pins { # -- assign output pins -------------------------------------------- if ($print_enable > 0) { print "-sta- : assign_pin_outputs\n"; } print (VF "\n"); print (VF "// -- assign output ports ----------------------------------------------\n"); # -- spin through all the pins ------------------------------------- for $ix ( 1 .. $#pin_hash ) { if ($pin_hash[$ix]{pin_dir} =~ /output/) { print (VF "assign $pin_hash[$ix]{pin_name} = r_pin_input[$pin_hash[$ix]{pin_number}];"); } elsif ($pin_hash[$ix]{pin_dir} =~ /inout/) { print (VF "assign $pin_hash[$ix]{pin_name} = (w_pin_drive[$pin_hash[$ix]{pin_number}]) ? 1'bz : r_pin_input[$pin_hash[$ix]{pin_number}];"); } if ($comments_enable > 1) { print (VF " // pin $pin_hash[$ix]{pin_number}"); } print (VF "\n"); } } # -- assign output pins -------------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub assign_the_enable_pins { # -- assign enable pins -------------------------------------------- if ($print_enable > 0) { print "-sta- : assign_pin_enables\n"; } print (VF "\n"); print (VF "// -- assign pin enables -----------------------------------------------\n"); # -- spin through all the pins ------------------------------------- for $ix ( 1 .. $#pin_hash ) { if ($pin_hash[$ix]{pin_dir} =~ /output/) { print (VF "assign w_pin_enable[$pin_hash[$ix]{pin_number}] = 1'b0;"); } elsif ($pin_hash[$ix]{pin_dir} =~ /input/) { print (VF "assign w_pin_enable[$pin_hash[$ix]{pin_number}] = 1'b1;"); } elsif ($pin_hash[$ix]{pin_dir} =~ /inout/) { print (VF "assign w_pin_enable[$pin_hash[$ix]{pin_number}] = w_pin_drive[$pin_hash[$ix]{pin_number}];"); } if ($comments_enable > 1) { print (VF " // pin $pin_hash[$ix]{pin_number}"); } print (VF "\n"); } } # -- assign enable pins -------------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub assign_pin_strobe_1_enables { # -- assign pin strobe 1 enables ----------------------------------- if ($print_enable > 0) { print "-sta- : assign_pin_strobe_1_enables\n"; } $strobe_1_count = 0; print (VF "\n"); print (VF "// -- assign strobe 1 pin enables --------------------------------------\n"); # -- spin through all the pins ------------------------------------- for $ix ( 1 .. $#pin_hash ) { my $strobe_1 = $pin_hash[$ix]{strobe_1}; if ($strobe_1 =~ /on/) { print (VF "assign w_strobe_1_pin_enable[$pin_hash[$ix]{pin_number}] = 1'b1;"); $strobe_1_count = $strobe_1_count + 1; } else { print (VF "assign w_strobe_1_pin_enable[$pin_hash[$ix]{pin_number}] = 1'b0;"); } if ($comments_enable > 1) { print (VF " // pin $pin_hash[$ix]{pin_number}"); } print (VF "\n"); } } # -- assign pin strobe 1 enables ----------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub assign_pin_strobe_2_enables { # -- assign pin strobe 2 enables ----------------------------------- if ($print_enable > 0) { print "-sta- : assign_pin_strobe_2_enables\n"; } $strobe_2_count = 0; print (VF "\n"); print (VF "// -- assign strobe 2 pin enables --------------------------------------\n"); # -- spin through all the pins ------------------------------------- for $ix ( 1 .. $#pin_hash ) { my $strobe_2 = $pin_hash[$ix]{strobe_2}; if ($strobe_2 =~ /on/) { print (VF "assign w_strobe_2_pin_enable[$pin_hash[$ix]{pin_number}] = 1'b1;"); $strobe_2_count = $strobe_2_count + 1; } else { print (VF "assign w_strobe_2_pin_enable[$pin_hash[$ix]{pin_number}] = 1'b0;"); } if ($comments_enable > 1) { print (VF " // pin $pin_hash[$ix]{pin_number}"); } print (VF "\n"); } } # -- assign pin strobe 2 enables ----------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub assign_pin_drive_signals { # -- assign pin drive signals here --------------------------------- if ($print_enable > 0) { print "-sta- : assign_pin_drive\n"; } print (VF "\n"); print (VF "// -- assign pin drive signals -----------------------------------------\n"); # -- spin through all the pins ------------------------------------- for $ix ( 1 .. $#pin_hash ) { if ($pin_hash[$ix]{pin_dir} =~ /inout/) { print (VF "assign w_pin_drive[$pin_hash[$ix]{pin_number}] = $pin_hash[$ix]{pin_drive};"); } if ($comments_enable > 1) { print (VF " // pin $pin_hash[$ix]{pin_number}"); } print (VF "\n"); } } # -- assign pin drive signals here --------------------------------- sub assign_bidirect_pullups { # -- assign pullups to bidirects ----------------------------------- if ($print_enable > 0) { print "-sta- : assign_pullups\n"; } if ($bidirect_pullups == 1) { print (VF "\n"); print (VF "// -- assign pullups ---------------------------------------------------\n"); # -- spin through all the pins --------------------------------- for $ix ( 1 .. $#pin_hash ) { if ($pin_hash[$ix]{pin_dir} =~ /inout/) { print (VF "pullup($pin_hash[$ix]{pin_name});"); } if ($comments_enable > 1) { print (VF " // pin $pin_hash[$ix]{pin_number}"); } print (VF "\n"); } } } # -- assign pullups to bidirects ----------------------------------- sub make_procedural_routine { # -- make procedural routine --------------------------------------- if ($print_enable > 0) { print "-sta- : make_procedural\n"; } print (VF "\n"); print (VF "// -- strobe 1 procedure -----------------------------------------------\n"); # -- parse strobe values --------------------------------------- $strobe_1_val = $strobe_1_values; $strobe_1_val =~ tr/-/,/; @strobe_1_var = split/-/,$strobe_1_values; print (VF "always @("); if ($strobe_1_var[5] == 0) { print (VF "posedge "); } else { print (VF "negedge "); } print (VF "w_strobe_1_trigger)\n"); print (VF " begin \n"); print (VF " i_return = \$exsent_write_then_read(i_which_pinport ,r_pin_input ,w_pin_1_output ,w_pin_enable ,$max_pin_number); \n"); print (VF " if (i_return !== 0) exsent_error_trap(i_return,11);\n"); print (VF " end \n"); print (VF "\n"); print (VF "// -- strobe 2 procedure -----------------------------------------------\n"); # -- parse strobe values --------------------------------------- $strobe_2_val = $strobe_2_values; $strobe_2_val =~ tr/-/,/; @strobe_2_var = split/-/,$strobe_2_values; print (VF "always @("); if ($strobe_2_var[5] == 0) { print (VF "posedge "); } else { print (VF "negedge "); } print (VF "w_strobe_2_trigger)\n"); print (VF " begin \n"); print (VF " i_return = \$exsent_write_then_read(i_which_pinport ,r_pin_input ,w_pin_2_output ,w_pin_enable ,$max_pin_number); \n"); print (VF " if (i_return !== 0) exsent_error_trap(i_return,11);\n"); print (VF " end \n"); } # -- make procedural routine --------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub make_the_banner { # -- make banner --------------------------------------------------- if ($print_enable > 0) { print "-sta- : make_banner\n"; } print (VF "\n"); print (VF "// -- initialization ---------------------------------------------------\n"); print (VF "initial\n"); print (VF " begin\n"); print (VF " \$display(\" \");\n"); print (VF " \$display(\" ------------------------------------------------- \");\n"); print (VF " \$display(\"| VERILOG CODED BY EXSENT PIN GENERATION SCRIPT |\");\n"); print (VF " \$display(\"| Module Name - $base_name\");\n"); print (VF " \$display(\"| Instantiation - %m\");\n"); print (VF " \$display(\"| www.exsent.com |\");\n"); print (VF " \$display(\" ------------------------------------------------- \");\n"); print (VF " \$display(\" \");\n"); } # -- make banner --------------------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub make_the_strobe_init_calls { # -- make strobe init calls ---------------------------------------- if ($print_enable > 0) { print "-sta- : make_strobe_init_calls\n"; } print (VF " initialize_pinports;\n"); print (VF " // wait for wire assignments to settle before configuring strobe pin enables\n"); print (VF " \# 0;\n"); print (VF " i_return = \$exsent_size_request(i_which_pinport,$max_pin_number);\n"); print (VF " if (i_return !== 0) exsent_error_trap(i_return,5);\n"); print (VF " i_return = \$exsent_cfg_stb_1(i_which_pinport,$strobe_1_val);\n"); print (VF " if (i_return !== 0) exsent_error_trap(i_return,21);\n"); print (VF " i_return = \$exsent_cfg_stb_2(i_which_pinport,$strobe_2_val);\n"); print (VF " if (i_return !== 0) exsent_error_trap(i_return,22);\n"); print (VF " i_return = \$exsent_cfg_pin_1(i_which_pinport,w_strobe_1_pin_enable); \n"); print (VF " if (i_return !== 0) exsent_error_trap(i_return,23);\n"); print (VF " i_return = \$exsent_cfg_pin_2(i_which_pinport,w_strobe_2_pin_enable); \n"); print (VF " if (i_return !== 0) exsent_error_trap(i_return,24);\n"); print (VF " end\n\n"); print (VF "endmodule\n\n"); } # -- make strobe init calls ---------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub collect_the_stats_and_make_the_log_file { # -- make stats and log file --------------------------------------- if ($print_enable > 0) { print "-sta- : make_stats_&_log\n"; print ("|===== =====|\n"); print " -----|\r"; print " = $pin_count \r"; print "|----- pin_count \r"; print "\n"; } if ($log_enable > 0) { print LF "|===================== EXSENT INC ======================|\n"; print LF "|----- PERL BASED PIN INTERFACE GENERATION PROGRAM -----|\n"; print LF "|===== =====|\n"; print LF "|----- pin_count = $pin_count -----|\n"; print LF "|----- strobe_1_count = $strobe_1_count -----|\n"; print LF "|----- strobe_2_count = $strobe_2_count -----|\n"; print LF "|----- print_enable = $print_enable -----|\n"; print LF "|----- comments_enable = $comments_enable -----|\n"; print LF "|----- pin_definition_name = $pin_definition_name \n"; print LF "|----- verilog_name = $verilog_name \n"; print LF "|----- include_name = $include_name \n"; print LF "|----- vector_delimiter = $vector_delimiter -----|\n"; print LF "|----- field_delimiter = $field_delimiter -----|\n"; print LF "|----- port_vectors = $port_vectors -----|\n"; print LF "|----- bidirect_pullups = $bidirect_pullups -----|\n"; print LF "|----- strobe_1_values = $strobe_1_values -----|\n"; print LF "|----- strobe_2_values = $strobe_2_values -----|\n"; print LF "|===== =====|\n"; print LF "|----- PERL BASED PIN INTERFACE GENERATION PROGRAM -----|\n"; print LF "|===================== EXSENT INC ======================|\n"; } } # -- make stats and log file --------------------------------------- # -- ------------------------------------------------------------------- # -- ------------------------------------------------------------------- sub clean_up_and_finish { # -- clean up finish ----------------------------------------------- if ($print_enable > 0) { print "-sta- : clean_up_&_finish\n"; } close( VF ) || die "Unable to close $verilog_name"; close( IF ) || die "Unable to close $include_name"; close( LF ) || die "Unable to close $log_name"; close( PF ) || die "Unable to close $pin_definition_name"; print ("|===== =====|\n"); print ("|----- PERL BASED PIN INTERFACE GENERATION PROGRAM -----|\n"); print ("|===================== EXSENT INC ======================|\n"); print ("\n"); } # -- clean up finish ----------------------------------------------- # -- ------------------------------------------------------------------- # -- MAIN PROGRAM ------------------------------------------------------ { # -- main ------------------------------------------------------------ &print_header; &get_command_line_info; &set_the_options; &file_init; &read_in_pin_definitions; &make_pin_definition_array; &determine_pinport_size; &make_the_port_map; &make_the_port_declarations; &make_the_wire_and_register_declarations; &include_exsent_utilities; &assign_the_input_pins; &assign_the_output_pins; &assign_the_enable_pins; &assign_pin_strobe_1_enables; &assign_pin_strobe_2_enables; &assign_pin_drive_signals; &assign_bidirect_pullups; &make_procedural_routine; &make_the_banner; &make_the_strobe_init_calls; &collect_the_stats_and_make_the_log_file; &clean_up_and_finish; } # -- main ------------------------------------------------------------