⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 对于研究FPGA结构的人来说
💻 C
字号:
/*------------------------------------------------------------------------** Copyright 1998 by Paul Leventis, Jonathan Rose and the University of    ** Toronto.  Use is permitted, provided that this attribution is retained  ** and no part of the code is re-distributed or included in any commercial ** product except by written agreement with the above parties.             **                                                                         ** For more information, contact us directly:                              **    Paul Leventis (leventi@eecg.utoronto.ca)                             **    Jonathan Rose  (jayar@eecg.toronto.edu)                              **    Department of Electrical and Computer Engineering                    **    University of Toronto, 10 King's College Rd.,                        **    Toronto, Ontario, CANADA M5S 1A4                                     **    Phone: (416) 978-6992  Fax: (416) 971-2286                           **------------------------------------------------------------------------*/#include <stdio.h>#include <string.h>#include "e_graph.h"#include "e_parse.h"#include "e_table.h"#include "e_shared.h"/* Routine defined in e_table.c to parse the TAB file */extern int read_table(char *, LIBRARY *);/* Routine defined in e_blif.c to write the BLIF file */extern int blif_write(char *, CELL *);/* Holds the current options */Options opt;/* * Initialize the options structure */static void _init_options(void){	opt.edif_info = 1;	opt.edif_warn = 1;	opt.edif_verbose = 0;	opt.edif_warn_once = 1;	opt.blif_info = 1;	opt.blif_warn = 1;	opt.blif_verbose = 0;	opt.tab_info = 1;	opt.tab_warn = 1;	opt.tab_verbose = 0;	opt.func = 1;	opt.quiet = 0;	opt.tab_filename = NULL;	opt.edif_filename = NULL;	opt.blif_filename = NULL;	return;}static void_print_header(void){	printf(		"\n"		"EDIF2BLIF  EDIF to BLIF Conversion Utility  Version 1.00 by Paul Leventis\n"		"Source completed May 18, 1998; compiled " __DATE__ " at " __TIME__ ".\n"	);}static void_print_usage(void){	printf(		"Usage:\n"		"\tedif2blif [flags] <edif_file> <blif_file> [tab_file]\n"		"\n"		"Flags: (+flag to turn on, -flag to turn off; default in [])\n"		"\tfunc\t\tInclude gate functions (i.e. with truth tables) [on]\n"		"\n"		"\tquiet\t\tSuppresses all non-critical messages [off]\n"		"\n"		"\twarn\t\tTurn on all warning messages [on]\n"		"\tinfo\t\tTurn on all info messages [on]\n"		"\tverbose\t\tTurn on all verbose messages [off]\n"		"\n"		"\tedif_warn_once\tPrint EDIF warnings only once each [on]\n"		"\tedif_warn\tPrint warning messages during EDIF parsing [on]\n"		"\tedif_info\tPrint info messages during EDIF parsing [on]\n"		"\tedif_verbose\tPrint verbose messages during EDIF parsing [off]\n"		"\n"		"\ttab_warn\tPrint warning messages during TAB parsing [on]\n"		"\ttab_info\tPrint info messages during TAB parsing [on]\n"		"\ttab_verbose\tPrint verbose messages during TAB parsing [off]\n"		"\n"		"\tblif_warn\tPrint warning messages during BLIF output [on]\n"		"\tblif_info\tPrint info messages during BLIF output [on]\n"		"\tblif_verbose\tPrint verbose messages durring BLIF output [off]\n" 		"\n"		"Example:\n"		"\tedif2blif -warn +edif_warn +verbose circuit.edif circuit.blif mcnc.tab\n"		"\n"	);}/* * MAIN SUBROUTINE*/int main(int argc, char *argv[]){	FILE *infile;	int i;	/* Initialize the option structure */	_init_options();	/* Process all command line flags */	for(i=1; i<argc; i++) {		if(argv[i][0] == '+' || argv[i][0] == '-') {			int val = (argv[i][0] == '+') ? 1 : 0;			if(!strcasecmp(&argv[i][1], "func")) {				opt.func = val;			} else if(!strcasecmp(&argv[i][1], "quiet")) {				opt.quiet = val;			} else if(!strcasecmp(&argv[i][1], "warn")) {				opt.edif_warn = val;				opt.tab_warn = val;				opt.blif_warn = val;			} else if(!strcasecmp(&argv[i][1], "info")) {				opt.edif_info = val;				opt.tab_info = val;				opt.blif_info = val;			} else if(!strcasecmp(&argv[i][1], "verbose")) {				opt.edif_verbose = val;				opt.tab_verbose = val;				opt.blif_verbose = val;			} else if(!strcasecmp(&argv[i][1], "edif_warn_once")) {				opt.edif_warn_once = val;			} else if(!strcasecmp(&argv[i][1], "edif_warn")) {				opt.edif_warn = val;			} else if(!strcasecmp(&argv[i][1], "edif_info")) {				opt.edif_info = val;			} else if(!strcasecmp(&argv[i][1], "edif_verbose")) {				opt.edif_verbose = val;			} else if(!strcasecmp(&argv[i][1], "tab_warn")) {				opt.tab_warn = val;			} else if(!strcasecmp(&argv[i][1], "tab_info")) {				opt.tab_info = val;			} else if(!strcasecmp(&argv[i][1], "tab_verbose")) {				opt.tab_verbose = val;			} else if(!strcasecmp(&argv[i][1], "blif_warn")) {				opt.blif_warn = val;			} else if(!strcasecmp(&argv[i][1], "blif_info")) {				opt.blif_info = val;			} else if(!strcasecmp(&argv[i][1], "blif_verbose")) {				opt.blif_verbose = val;			} else {				_print_header();				_print_usage();				printf("Error: unknown flag '%s'\n", &argv[i][1]);				return -1;			}		} else break;	}	if(opt.quiet) {		opt.edif_warn = 0;		opt.edif_info = 0;		opt.edif_verbose = 0;		opt.tab_warn = 0;		opt.tab_info = 0;		opt.tab_verbose = 0;		opt.blif_warn = 0;		opt.blif_info = 0;		opt.blif_verbose = 0;	} else {		_print_header();	}	/* Get the EDIF filename */	if(i<argc) {		opt.edif_filename = argv[i++];	} else {		_print_usage();		if(argc>=2) {			printf("Error: No EDIF file specified.\n");		}		return -1;	}	/* Get the BLIF filename */	if(i<argc) {		opt.blif_filename = argv[i++];	} else {		_print_usage();		printf("Error: No BLIF file specified.\n");		return -1;	}	/* Get the TAB filename (if it exists) and parse it */	if(i<argc) {		opt.tab_filename = argv[i++];	} else if(opt.func) {		_print_usage();		printf("Error: Translation table required for functional BLIF output.\n");		return -1;	} else {		opt.tab_filename = 0;	}			/* Check for extraneous command line arguments */	if(i<argc) {		_print_usage();		printf("Error: Extraneous command line arguments found.\n");		return -1;	}	/* Allocate and initialize the default library */	defaultLib = (LIBRARY *) malloc(sizeof(LIBRARY));	mem_assert(defaultLib);	defaultLib->name = strdup("defaultLib");	defaultLib->pCellHT = hash_alloc(DEFAULT_LIBRARIES, hash_hashfunc1, free_LIBRARY);	/* Parse the TAB file (if necessary) */	if(opt.tab_filename) {		if(read_table(opt.tab_filename, defaultLib))			return -1;	}	/* Open the EDIF file */    EPyyin = fopen(opt.edif_filename, "rt");	if(!EPyyin) {		printf("Error opening edif file '%s' for reading.\n", opt.edif_filename);		return -1;	}	/* Parse the EDIF file */    EPyyparse();    if(pTopCell==NULL) {        printf("Error parsing EDIF file. Empty or unparsable.\n");		return 1;    }	fclose(EPyyin);	/* Write the BLIF file */	if(blif_write(opt.blif_filename, pTopCell)) {		printf("Error writing BLIF file.\n");		return 1;	}	if(!opt.quiet) {		printf("\n** Conversion Successfully Completed **\n\n");	}	// hash_free(pLibraryHT);	// free_LIBRARY(defaultLib);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -