打印

自己写了个NET2ASC,把Protel网表转PADS格式。

[复制链接]
2400|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
小马哥|  楼主 | 2008-8-23 23:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
收到一个Protel文件,奈何很久没用了,转PADS结果网表全乱了,一怒之下自己写了一个,下面是源程序,可执行文件见附件。

// net2asc.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <fstream>
#include <cstring>

using namespace std;

struct{
    _TCHAR des[20];
    _TCHAR part[20];
    _TCHAR foot[20];
}iComp,oComp;

int _tmain(int argc, _TCHAR* argv[])
{
    _TCHAR* pszCh;
    fstream Outfile,Con,Infile;
    int cntcmp=0,cntnet=0,cntnod=0;

    Con.open( "con", ios_base::out );

    Con<<"Protel Netlist to PADS Ascii Converter Ver 0.1\n";
    Con<<"Copyright (c) 2008 Micheal, the Wolf.\n\n";

    switch(argc){
case 2:

    argv[2]=new _TCHAR[35]; // the project must be multi-byte character set;

    strcpy(argv[2],argv[1]);
    if((pszCh=strrchr(argv[2],'.'))!=NULL)*pszCh='\0';
    strncat(argv[2],".asc",4);
    //            Con<<"\n\n"<<argv[1]<<"\n\n"<<argv[2];
case 3:
    Outfile.open( argv[2], ios_base::out | ios_base::trunc );
    //            Con<<"a";
    if(!Outfile.is_open())goto usage;
    Infile.open( argv[1], ios_base::in );
    if(!Infile.is_open())goto usage;
    break;
default:
usage:
    Con<<"Usage: Net2Asc Inputfile [Outputfile]\n\n"<<argc;
    exit(-1);
    }

    // Output the ascii header
    Outfile<<"!PADS-POWERPCB-V2005.0-MILS-250L-CP936! NETLIST FILE FROM PADS LOGIC V2005.0\n";
    Outfile<<"*REMARK* "<<argv[1]<<"\n\n";


    // pass 1: parse the componets
    pszCh=new _TCHAR[180];
    Outfile<<"*PART*       ITEMS\n";
    while(Infile.getline(pszCh,180,'\n')){
        if(!strcmp(pszCh,"[")){
            Infile.getline(iComp.des,80,'\n');
            Infile.getline(iComp.foot,80,'\n');
            Infile.getline(iComp.part,80,'\n');
            Infile.getline(pszCh,80,'\n');
            Infile.getline(pszCh,80,'\n');
            Infile.getline(pszCh,80,'\n');
            Infile.getline(pszCh,80,'\n');
            if(*pszCh!=']'){Con<<iComp.des<<'\n'<<iComp.foot<<'\n'<<iComp.part<<'\n'<<pszCh;exit(2);}

            Outfile<<iComp.des<<'\t'<<iComp.part;
            if(strlen(iComp.foot))Outfile<<'@'<<iComp.foot;
            Outfile<<'\n';
            cntcmp++;
        }
        else if(!strcmp(pszCh,"(")){
            Infile.getline(pszCh,80,'\n');
            Outfile<<"\n*SIGNAL* "<<pszCh<<'\n';
            cntnet++;
            int i=0;
            Infile.getline(pszCh,80,'\n');
            while(*pszCh!=')'){
                cntnod++;
                char* pszTemp=strchr(pszCh,'-');
                *pszTemp='.';
                Outfile<<pszCh<<' ';
                if(!(++i%5))Outfile<<'\n';
                Infile.getline(pszCh,80,'\n');
            }
        }

    }


    Outfile<<"\n*END*     OF ASCII OUTPUT FILE\n";
    Outfile.close();
    Infile.close();
    Con<<"\n"<<cntcmp<<" components, "<<cntnet<<" nets and "<<cntnod<<" nodes had been generated.\n";
    exit(0);

}

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

5

主题

19

帖子

0

粉丝