Nand Tree Script  Go Back To Script Pool
This script will generate a nand tree using the pinlst.txt file.


#
# gen_nd -- This script will generate a nand tree using the pinlst.txt
#           file.
#
#  The pin listing file is in the following format:
#
#  Pin #    Pin Name   Input/Output/Inout    Padname
#
#  If the signal is a bus, each net take the form of netname[0]. The
#  script searches for the greatest and least bit to form the
#  input [15:0] netname; format.
#

open(PINS, "pinlst.txt");
open(NAND, ">nand_tree.vs");
#
#Instantiate the module
#
print (NAND "module nand_tree (\n    ");

#
# Sort through the pin list, taking note of signals that you do not
# want included in the nand tree.
#
while($line = <PINS>) {
  ($pin, $signal, $iotype, $padtype) = split(' ', $line);
  if ($signal =~ /test_mode/) {
    print ("Skipping signal: ", $signal, "\n");
  }
  else {
    print ("Processing signal: ", $signal, "\n");
      if($line =~ /\[/) {
        print ("Signal is a bus", "\n");
        ($name, $number) = split(/\[/, $signal);
        chop($number);
        print ("This is bit #", $number, "\n");
        if($ioval{$name}) {
           ($iotype, $msb, $lsb) = split(/:/, $ioval{$name});
           if ($number > $msb) {
             print ("Current bit is greater than: ", $msb, "\n");
             $ioval{$name} = $iotype . ":" . $number . ":" . $lsb;
           }
           elsif ($number < $lsb) {
             print ("Current bit is less than: ", $lsb, "\n");
             $ioval{$name} = $iotype . ":" . $msb . ":" . $number;
           }
        }
        else {
          print ("First entry of signal in table", "\n");
          $ioval{$name} = $iotype . ":" . $number . ":" . $number;
        }
      }
      elsif(($iotype =~ /input/) || ($iotype =~ /inout/)
      || ($iotype =~ /output/) ) {
        if(! $ioval{$signal}) {
             print ("Signal is NOT a bus", "\n");
             $ioval{$signal} = $iotype . "::";
        }
      }
  }
}

foreach $value (sort keys(%ioval)) {
  if (! $first) {
    print "This is the first entry\n";
    $first = 1;
    print (NAND $value);
    $count = $count + length($value) + 2;
  }
  else {
    if ($count > 65) {
      print (NAND ",\n    $value");
      $count = 0;
    }
    else {
      print (NAND ", ", $value);
    }
    $count = $count + length($value) + 2;
  }
}

print (NAND ");\n\n");

foreach $value (sort keys(%ioval)) {
  ($iotype, $msb, $lsb) = split(/:/, $ioval{$value});
  if ($iotype =~ /output/) {
    print (NAND "output ", $value, ";\n");
  }
  elsif ($msb) {
    print (NAND "input [", $msb, ":", $lsb, "] ", $value, ";\n");
  }
  else {
    print (NAND "input ", $value, ";\n");
  }
}

print NAND "\n\n";
$count = 1;
$first = 0;

close(PINS);
open(PINS, "pinlst.txt");
while($line = <PINS>) {
    ($pin, $signal, $iotype, $padtype) = split(' ', $line);
  if ($signal =~ /test_mode/) {
    print ("Skipping signal: ", $signal, "\n");
    $skip = 1;
  }
  elsif ($signal =~ /nand_out/) {
    print ("Skipping signal: ", $signal, "\n");
    $skip = 1;
  }
  elsif (($iotype =~ /input/) || ($iotype =~ /inout/)
      || ($iotype =~ /output/) ) {
    $skip = 0;
  }
  else {
    $skip = 1;
  }
  if ($first == 2) {
    $first = 3;
  }
  elsif ($first == 3 && $skip == 0) {
    print (NAND "net", $count, "));\n");
  }
  if ($skip ==0) {
      if(! $first) {
        $first = 1;
        print (NAND "na21 na", $count, " (.A( ", $signal, "), .B( ");
      }
      elsif ($first == 1) {
        $count ++;
        print (NAND $signal, "), .Q( net", $count, "));\n");
        $first = 2;
      }
      else {
        print (NAND "na21 na", $count, " (.A( ", $signal, "), .B( net", $count,
        "), .Q(");
        $count ++;
      }
  }
}

print NAND "nand_out));\n";
print NAND "\n\nendmodule";



 

 

 

Other Scripts:

Batch Simulation
Compare Files
Convert
Def2Verilog
Gen XOR Tree
GetValue
IHEX2VHEX
nand tree
Name Instance
OnesCompSum
Preprocessor
Verilog Tag

Verilog Tag2
Verilog2DEF
VHDL2HTML
VRename
XNF2VHDL

 

Products:

Undertow Suite
Undertow
Interactive_tool
Optimizing_tool
VeriPower
Power_tool
Toggle_tool
Express_VCT
Personal_VCT
VBIT«
verilog2vhdl™
vhdl2verilogmkt
Script Pool


 

 Company    Products     News    Assistance     Download     Contact Us    Sales

Veritools, Inc.
459 Hamilton Avenue, Suite 200, Palo Alto, California 94301
(650) 462 - 5590 Main    (650) 462 - 5593 Fax
inquiry@veritools.com

For Web site information please email Webmaster