diff options
| -rw-r--r-- | CMakeLists.txt | 6 | ||||
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | common/rulecheck.cc | 2 | ||||
| -rw-r--r-- | frontend/json/jsonparse.cc | 25 | ||||
| -rw-r--r-- | frontend/json/jsonparse.h | 29 | ||||
| -rw-r--r-- | ice40/main.cc | 38 | 
6 files changed, 68 insertions, 35 deletions
| diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b50e1d8..dfc33e90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,8 +70,10 @@ if (NOT Boost_PYTHON_FOUND )  endif ()  include(gui/gui.cmake) -include_directories(common/ gui/ ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}) -aux_source_directory(common/ COMMON_FILES) +include_directories(common/ gui/ frontend/json ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}) +aux_source_directory(common/ COMMON_SRC_FILES) +aux_source_directory(frontend/json/ JSON_PARSER_FILES) +set(COMMON_FILES ${COMMON_SRC_FILES} ${JSON_PARSER_FILES})  foreach (family ${FAMILIES})      string(TOUPPER ${family} ufamily) @@ -11,8 +11,9 @@ Prequisites   - CMake 3.3 or later   - Modern C++11 compiler, clang recommended + - Qt5 or later (`qt5-default` for Ubuntu 16.04)   - Python 3.5 or later, including development libraries (`python3-dev` for Ubuntu) - - Boost libraries (`libboost-all-dev` for Ubuntu) + - Boost libraries (`libboost-dev` or `libboost-all-dev` for Ubuntu)   - Icestorm, with chipdbs installed in `/usr/local/share/icebox`  Building diff --git a/common/rulecheck.cc b/common/rulecheck.cc index 4b355368..b81695b9 100644 --- a/common/rulecheck.cc +++ b/common/rulecheck.cc @@ -1,6 +1,6 @@  #include <string>  #include <assert.h> -#include "common/design.h" +#include "design.h"  #include "log.h"  bool	check_all_nets_driven(Design *design) { diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc index 4d0fc1b1..45edabad 100644 --- a/frontend/json/jsonparse.cc +++ b/frontend/json/jsonparse.cc @@ -26,8 +26,9 @@  #include <fstream>  #include <assert.h>  #include <log.h> -#include "common/design.h" -#include "ice40/chip.h" +#include "design.h" +#include "chip.h" +#include "jsonparse.h"  extern	bool	check_all_nets_driven(Design *design); @@ -670,21 +671,7 @@ struct JsonFrontend {  }; // End Namespace JsonParser -#warning "Main routine should be removed from jsonparse.cc before production" - -int	main(int argc, char **argv) { -	JsonParser::JsonFrontend *parser = new JsonParser::JsonFrontend; -	ChipArgs	chip_args; -	chip_args.type = ChipArgs::LP384; - -	log_files.push_back(stderr); - -	Design	*design = new Design(chip_args); -	// std::string	fname = "../../ice40/blinky.json"; -	std::string	fname = "/home/dan/work/rnd/opencores/icozip/trunk/rtl/icozip/icozip.json"; -	std::istream	*f = new std::ifstream(fname); -	parser->execute(f, fname, design); - -	printf("Successful exit\n"); +void	parse_json_file(std::istream *&f, std::string filename, Design *design){ +	auto *parser = new JsonParser::JsonFrontend(); +	parser->execute(f, filename, design);  } - diff --git a/frontend/json/jsonparse.h b/frontend/json/jsonparse.h new file mode 100644 index 00000000..12bf6dcd --- /dev/null +++ b/frontend/json/jsonparse.h @@ -0,0 +1,29 @@ +/* + *  nextpnr -- Next Generation Place and Route + * + *  Copyright (C) 2018  SymbioticEDA + * + *  Permission to use, copy, modify, and/or distribute this software for any + *  purpose with or without fee is hereby granted, provided that the above + *  copyright notice and this permission notice appear in all copies. + * + *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + *  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + *  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + *  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + *  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + *  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifndef	JSON_PARSER +#define	JSON_PARSER + +#include <string> +#include <istream> +#include "design.h" + +extern	void	parse_json_file(std::istream *&, std::string &, Design *); + +#endif diff --git a/ice40/main.cc b/ice40/main.cc index 185c7f53..9295bde4 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -20,9 +20,11 @@  #include "mainwindow.h"  #include <QApplication>  #include <iostream> +#include <fstream>  #include "version.h"  #include <boost/program_options.hpp>  #include "pybindings.h" +#include "jsonparse.h"  void svg_dump_el(const GraphicElement &el)  { @@ -52,6 +54,7 @@ int main(int argc, char *argv[])  	options.add_options()("gui","start gui");  	options.add_options()("svg","dump SVG file");  	options.add_options()("file", po::value<std::string>(), "python file to execute"); +	options.add_options()("json", po::value<std::string>(), "JSON design file to ingest");  	options.add_options()("version,v","show version");	  	options.add_options()("lp384","set device type to iCE40LP384");  	options.add_options()("lp1k","set device type to iCE40LP1K"); @@ -66,19 +69,20 @@ int main(int argc, char *argv[])  	po::variables_map vm;  	try {  		po::parsed_options parsed = po::command_line_parser(argc, argv). -        	options(options). -        	positional(pos). -        	run(); +		options(options). +		positional(pos). +		run(); -    	po::store(parsed, vm); +		po::store(parsed, vm); -		po::notify(vm);     +		po::notify(vm);    +	} + +	catch(std::exception& e) +	{ +		std::cout << e.what() << "\n"; +		return 1;  	} -    catch(std::exception& e) -    { -        std::cout << e.what() << "\n"; -        return 1; -    }  	if (vm.count("help") || argc == 1)  	{ @@ -90,7 +94,9 @@ int main(int argc, char *argv[])  	if (vm.count("version"))  	{ -		std::cout << basename(argv[0]) << " -- Next Generation Place and Route (git sha1 " GIT_COMMIT_HASH_STR ")\n"; +		std::cout << basename(argv[0]) +			<< " -- Next Generation Place and Route (git sha1 " +					GIT_COMMIT_HASH_STR ")\n";  		return 1;  	} @@ -199,11 +205,19 @@ int main(int argc, char *argv[])  		std::cout << "</svg>\n";  	} +	if (vm.count("json"))  +	{ +		std::string filename = vm["json"].as<std::string>(); +		std::istream *f = new std::ifstream(filename); +		 +		parse_json_file(f, filename, &design); +	}	 +	  	if (vm.count("file"))   	{  		std::string filename = vm["file"].as<std::string>();  		execute_python_file(argv[0],filename.c_str()); -    }	 +	}	  	return 0;  } | 
