#!/usr/bin/perl use warnings; use strict; # 20-Aug-2006 # Keith Neufeld # version .90 # # Script to convert EAGLE netlist/partlist export files to PADS format, # for importing into FreePCB (or others). # # License terms: # # I hate huge license agreements. Please try to respect the spirit of these # terms: I wrote the script, so don't try to take credit or payment for the # work that I did. Feel free to improve the script, and send the # improvements back to me to share with others. By all means, run the script # for any purpose you desire; and if you're able to use it as part of a # money-making venture, good for you! And I'm not liable for the accuracy # or correctness of the script, nor for anything you choose to do with it. @ARGV == 1 or die "usage: $0 \n\n", "where .enet and .epart ", "will be used to create .net\n"; my $project = shift; open(ENET, "$project.enet") or die "can't open EAGLE netlist file $project.enet: $!\n"; open(EPART, "$project.epart") or die "can't open EAGLE partlist file $project.epart: $!\n"; open(NET, "> $project.net") or die "can't create netlist file $project.net: $!\n"; ############################################################################### # Set up package name translation my $fpackage = &xpackage; ############################################################################### # Write file header print NET "*PADS-PCB*\n"; ############################################################################### # Partlist section # Write partlist header print NET "*PART*\n"; # Parse EAGLE partlist file while () { next if 1 .. /^Part\b/; # skip header next if /^\s*$/; # skip blank lines # Get a line of part information chomp; my ($part, $value, $device, $epackage, $library, $sheet) = unpack("A9 A15 A13 A9 A21 A13", $_); #warn "[$part] [$value] [$device] [$epackage] [$library] [$sheet]\n"; # Optionally remove $ from part names #$part =~ s/\$//; # And write it out in PADS format #printf NET "%-7s%s\n", $part, $epackage; printf NET "%-7s%s\n", $part, exists $$fpackage{$epackage} ? $$fpackage{$epackage} : $epackage; } print NET "\n"; ############################################################################### # Netlist section # Write netlist header print NET "*NET*"; # print newlines with new signals # Parse EAGLE netlist file my $nets_this_line; while () { next if 1 .. /^Net\b/; # skip header next if /^\s*$/; # skip blank lines # Get a line of part information chomp; my ($net, $part, $pad, $pin, $sheet) = unpack("A9 A9 A9 A11 A*", $_); #warn "[$net] [$part] [$pad] [$pin] [$sheet]\n"; # Optionally remove $ from net and part names #$net =~ s/\$//; #$part =~ s/\$//; # Convert LED anode and cathode pad letters to numbers if ($part =~ /^LED/) { $pad =~ tr/AK/12/; } # If Net is non-blank, start a new signal if ($net) { print NET "\n*SIGNAL* $net\n"; $nets_this_line = 0; } # Print parts and pad numbers print NET "$part.$pad "; # print newlines with new signals if (++ $nets_this_line > 5) { print NET "\n"; # finish this line $nets_this_line = 0; } } print NET "\n"; # finish final line ############################################################################### # Write file trailer print NET "*END*\n"; sub xpackage { return { #"0207/2V" => "RC05", "0207/2V" => "RVERT-100", "1X01" => "1X1HDR-100", "1X02" => "1X2HDR-100", "1X03" => "3X1HDR-100", "1X04" => "4X1HDR-100", "1X06" => "6X1HDR-100", "1X09" => "9X1HDR-100", "DIL24-3" => "24DIP300", #LED5MM => "LED-T1.75", LED5MM => "LED-T1.75-V", } }