Attempt to add JSON parser--not working yet w/ build system

This commit is contained in:
ZipCPU 2018-06-06 14:44:54 -04:00
parent 5e463b8543
commit 16b9a2f1b5
6 changed files with 68 additions and 35 deletions

View File

@ -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)

View File

@ -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

View File

@ -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) {

View File

@ -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);
}

29
frontend/json/jsonparse.h Normal file
View File

@ -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

View File

@ -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");
@ -74,6 +77,7 @@ int main(int argc, char *argv[])
po::notify(vm);
}
catch(std::exception& e)
{
std::cout << e.what() << "\n";
@ -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,6 +205,14 @@ 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>();