From 4499864024a5b658bf5772ed87e218bcdaedc262 Mon Sep 17 00:00:00 2001 From: ZipCPU Date: Thu, 7 Jun 2018 15:38:24 -0400 Subject: [PATCH] Applied clang-format to my own contributions --- common/log.cc | 246 ++++---- common/log.h | 59 +- common/place.cc | 91 +-- common/place.h | 8 +- common/rulecheck.cc | 108 ++-- frontend/json/jsonparse.cc | 1127 ++++++++++++++++++------------------ frontend/json/jsonparse.h | 8 +- ice40/chip.h | 17 +- ice40/main.cc | 7 +- 9 files changed, 831 insertions(+), 840 deletions(-) diff --git a/common/log.cc b/common/log.cc index 00e1765f..7a411fb2 100644 --- a/common/log.cc +++ b/common/log.cc @@ -17,27 +17,27 @@ * */ -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include -#include "log.h" #include "design.h" +#include "log.h" -std::vector log_files; -std::vector log_streams; -FILE *log_errfile = NULL; +std::vector log_files; +std::vector log_streams; +FILE *log_errfile = NULL; -bool log_error_stderr = false; -bool log_cmd_error_throw = false; -bool log_quiet_warnings = false; -int log_verbose_level; -std::string log_last_error; +bool log_error_stderr = false; +bool log_cmd_error_throw = false; +bool log_quiet_warnings = false; +int log_verbose_level; +std::string log_last_error; void (*log_error_atexit)() = NULL; static bool next_print_log = false; @@ -45,204 +45,192 @@ static int log_newline_count = 0; std::string vstringf(const char *fmt, va_list ap) { - std::string string; - char *str = NULL; + std::string string; + char *str = NULL; #ifdef _WIN32 - int sz = 64+strlen(fmt), rc; - while (1) { - va_list apc; - va_copy(apc, ap); - str = (char*)realloc(str, sz); - rc = vsnprintf(str, sz, fmt, apc); - va_end(apc); - if (rc >= 0 && rc < sz) - break; - sz *= 2; - } + int sz = 64 + strlen(fmt), rc; + while (1) { + va_list apc; + va_copy(apc, ap); + str = (char *)realloc(str, sz); + rc = vsnprintf(str, sz, fmt, apc); + va_end(apc); + if (rc >= 0 && rc < sz) + break; + sz *= 2; + } #else - if (vasprintf(&str, fmt, ap) < 0) - str = NULL; + if (vasprintf(&str, fmt, ap) < 0) + str = NULL; #endif - if (str != NULL) { - string = str; - free(str); - } + if (str != NULL) { + string = str; + free(str); + } - return string; + return string; } void logv(const char *format, va_list ap) { - // - // Trim newlines from the beginning - while (format[0] == '\n' && format[1] != 0) { - log("\n"); - format++; - } + // + // Trim newlines from the beginning + while (format[0] == '\n' && format[1] != 0) { + log("\n"); + format++; + } - std::string str = vstringf(format, ap); + std::string str = vstringf(format, ap); - if (str.empty()) - return; + if (str.empty()) + return; - size_t nnl_pos = str.find_last_not_of('\n'); - if (nnl_pos == std::string::npos) - log_newline_count += str.size(); - else - log_newline_count = str.size() - nnl_pos - 1; + size_t nnl_pos = str.find_last_not_of('\n'); + if (nnl_pos == std::string::npos) + log_newline_count += str.size(); + else + log_newline_count = str.size() - nnl_pos - 1; - for (auto f : log_files) - fputs(str.c_str(), f); + for (auto f : log_files) + fputs(str.c_str(), f); - for (auto f : log_streams) - *f << str; + for (auto f : log_streams) + *f << str; } void logv_info(const char *format, va_list ap) { - std::string message = vstringf(format, ap); + std::string message = vstringf(format, ap); - log("Info: %s", message.c_str()); - log_flush(); + log("Info: %s", message.c_str()); + log_flush(); } void logv_warning(const char *format, va_list ap) { - std::string message = vstringf(format, ap); + std::string message = vstringf(format, ap); - log("Warning: %s", message.c_str()); - log_flush(); + log("Warning: %s", message.c_str()); + log_flush(); } void logv_warning_noprefix(const char *format, va_list ap) { - std::string message = vstringf(format, ap); + std::string message = vstringf(format, ap); - log("%s", message.c_str()); + log("%s", message.c_str()); } void logv_error(const char *format, va_list ap) { #ifdef EMSCRIPTEN - auto backup_log_files = log_files; + auto backup_log_files = log_files; #endif - if (log_errfile != NULL) - log_files.push_back(log_errfile); + if (log_errfile != NULL) + log_files.push_back(log_errfile); - if (log_error_stderr) - for (auto &f : log_files) - if (f == stdout) - f = stderr; + if (log_error_stderr) + for (auto &f : log_files) + if (f == stdout) + f = stderr; - log_last_error = vstringf(format, ap); - log("ERROR: %s", log_last_error.c_str()); - log_flush(); + log_last_error = vstringf(format, ap); + log("ERROR: %s", log_last_error.c_str()); + log_flush(); - if (log_error_atexit) - log_error_atexit(); + if (log_error_atexit) + log_error_atexit(); #ifdef EMSCRIPTEN - log_files = backup_log_files; - throw 0; + log_files = backup_log_files; + throw 0; #elif defined(_MSC_VER) - _exit(EXIT_FAILURE); + _exit(EXIT_FAILURE); #else - _Exit(EXIT_FAILURE); + _Exit(EXIT_FAILURE); #endif } void log(const char *format, ...) { - va_list ap; - va_start(ap, format); - logv(format, ap); - va_end(ap); + va_list ap; + va_start(ap, format); + logv(format, ap); + va_end(ap); } void log_info(const char *format, ...) { - va_list ap; - va_start(ap, format); - logv_info(format, ap); - va_end(ap); + va_list ap; + va_start(ap, format); + logv_info(format, ap); + va_end(ap); } void log_warning(const char *format, ...) { - va_list ap; - va_start(ap, format); - logv_warning(format, ap); - va_end(ap); + va_list ap; + va_start(ap, format); + logv_warning(format, ap); + va_end(ap); } void log_warning_noprefix(const char *format, ...) { - va_list ap; - va_start(ap, format); - logv_warning_noprefix(format, ap); - va_end(ap); + va_list ap; + va_start(ap, format); + logv_warning_noprefix(format, ap); + va_end(ap); } void log_error(const char *format, ...) { - va_list ap; - va_start(ap, format); - logv_error(format, ap); + va_list ap; + va_start(ap, format); + logv_error(format, ap); } void log_cmd_error(const char *format, ...) { - va_list ap; - va_start(ap, format); + va_list ap; + va_start(ap, format); - if (log_cmd_error_throw) { - log_last_error = vstringf(format, ap); - log("ERROR: %s", log_last_error.c_str()); - log_flush(); - throw log_cmd_error_exception(); - } + if (log_cmd_error_throw) { + log_last_error = vstringf(format, ap); + log("ERROR: %s", log_last_error.c_str()); + log_flush(); + throw log_cmd_error_exception(); + } - logv_error(format, ap); + logv_error(format, ap); } void log_spacer() { - if (log_newline_count < 2) log("\n"); - if (log_newline_count < 2) log("\n"); + if (log_newline_count < 2) + log("\n"); + if (log_newline_count < 2) + log("\n"); } -void log_push() -{ -} +void log_push() {} -void log_pop() -{ - log_flush(); -} +void log_pop() { log_flush(); } -void log_reset_stack() -{ - log_flush(); -} +void log_reset_stack() { log_flush(); } void log_flush() { - for (auto f : log_files) - fflush(f); + for (auto f : log_files) + fflush(f); - for (auto f : log_streams) - f->flush(); -} - -void log_cell(CellInfo *cell, std::string indent) -{ -} - -void log_net(NetInfo *net, std::string indent) -{ + for (auto f : log_streams) + f->flush(); } +void log_cell(CellInfo *cell, std::string indent) {} +void log_net(NetInfo *net, std::string indent) {} diff --git a/common/log.h b/common/log.h index 2bf1604a..374772b3 100644 --- a/common/log.h +++ b/common/log.h @@ -21,38 +21,40 @@ #define LOG_H #include +#include +#include +#include +#include #include #include -#include -#include -#include -#include #include "design.h" // from libs/sha1/sha1.h -#define NXP_NORETURN -#define NXP_ATTRIBUTE(...) __attribute__((__VA_ARGS__)) +#define NXP_NORETURN +#define NXP_ATTRIBUTE(...) __attribute__((__VA_ARGS__)) -struct log_cmd_error_exception { }; +struct log_cmd_error_exception +{ +}; -extern std::vector log_files; -extern std::vector log_streams; -extern FILE *log_errfile; +extern std::vector log_files; +extern std::vector log_streams; +extern FILE *log_errfile; -extern bool log_quiet_warnings; -extern int log_verbose_level; -extern std::string log_last_error; -extern void (*log_error_atexit)(); +extern bool log_quiet_warnings; +extern int log_verbose_level; +extern std::string log_last_error; +extern void (*log_error_atexit)(); void logv(const char *format, va_list ap); void logv_warning(const char *format, va_list ap); void logv_warning_noprefix(const char *format, va_list ap); NXP_NORETURN void logv_error(const char *format, va_list ap) - NXP_ATTRIBUTE(noreturn); + NXP_ATTRIBUTE(noreturn); -extern std::ostream clog; +extern std::ostream clog; void log(const char *format, ...); void log_header(const char *format, ...); void log_info(const char *format, ...); @@ -73,24 +75,29 @@ void log_flush(); const char *log_id(RTLIL::IdString id); template static inline const char *log_id(T *obj) { - return log_id(obj->name); + return log_id(obj->name); } */ -void log_cell(CellInfo *cell, std::string indent = ""); -void log_net(NetInfo *net, std::string indent = ""); +void log_cell(CellInfo *cell, std::string indent = ""); +void log_net(NetInfo *net, std::string indent = ""); #ifndef NDEBUG -static inline void log_assert_worker(bool cond, const char *expr, const char *file, int line) { - if (!cond) log_error("Assert `%s' failed in %s:%d.\n", expr, file, line); +static inline void log_assert_worker(bool cond, const char *expr, + const char *file, int line) +{ + if (!cond) + log_error("Assert `%s' failed in %s:%d.\n", expr, file, line); } -# define log_assert(_assert_expr_) YOSYS_NAMESPACE_PREFIX log_assert_worker(_assert_expr_, #_assert_expr_, __FILE__, __LINE__) +#define log_assert(_assert_expr_) \ + YOSYS_NAMESPACE_PREFIX log_assert_worker(_assert_expr_, #_assert_expr_, \ + __FILE__, __LINE__) #else -# define log_assert(_assert_expr_) +#define log_assert(_assert_expr_) #endif -#define log_abort() log_error("Abort in %s:%d.\n", __FILE__, __LINE__) -#define log_ping() log("-- %s:%d %s --\n", __FILE__, __LINE__, __PRETTY_FUNCTION__) - +#define log_abort() log_error("Abort in %s:%d.\n", __FILE__, __LINE__) +#define log_ping() \ + log("-- %s:%d %s --\n", __FILE__, __LINE__, __PRETTY_FUNCTION__) #endif diff --git a/common/place.cc b/common/place.cc index 172001a6..310a75e9 100644 --- a/common/place.cc +++ b/common/place.cc @@ -18,63 +18,64 @@ */ #include -#include -#include -#include -#include -#include -#include #include #include +#include #include +#include +#include +#include +#include +#include -#include "log.h" #include "design.h" +#include "log.h" #include "place.h" -void place_design(Design *design) { - std::set types_used; - std::set::iterator not_found, element; - std::set used_bels; +void place_design(Design *design) +{ + std::set types_used; + std::set::iterator not_found, element; + std::set used_bels; - for(auto cell_entry : design->cells) { - CellInfo *cell = cell_entry.second; - BelType bel_type; + for (auto cell_entry : design->cells) { + CellInfo *cell = cell_entry.second; + BelType bel_type; - element = types_used.find(cell->type); - if (element != types_used.end()) { - continue; - } + element = types_used.find(cell->type); + if (element != types_used.end()) { + continue; + } - bel_type = belTypeFromId(cell->type); - if (bel_type == BelType()) { - log_error("No Bel of type \'%s\' defined for " - "this chip\n", cell->type.c_str()); - } - types_used.insert(cell->type); - std::cout << cell->type << std::endl; - } + bel_type = belTypeFromId(cell->type); + if (bel_type == BelType()) { + log_error("No Bel of type \'%s\' defined for " + "this chip\n", + cell->type.c_str()); + } + types_used.insert(cell->type); + std::cout << cell->type << std::endl; + } - for(auto bel_type_name : types_used) { - auto blist = design->chip.getBels(); - BelType bel_type = belTypeFromId(bel_type_name); - auto bi = blist.begin(); + for (auto bel_type_name : types_used) { + auto blist = design->chip.getBels(); + BelType bel_type = belTypeFromId(bel_type_name); + auto bi = blist.begin(); - for(auto cell_entry : design->cells) { - CellInfo *cell = cell_entry.second; + for (auto cell_entry : design->cells) { + CellInfo *cell = cell_entry.second; - // Only place one type of Bel at a time - if (cell->type.compare(bel_type_name)!=0) - continue; + // Only place one type of Bel at a time + if (cell->type.compare(bel_type_name) != 0) + continue; - while((bi != blist.end()) - &&(design->chip.getBelType(*bi) != bel_type)) - bi++; - if (bi == blist.end()) - log_error("Too many \'%s\' used in design\n", - cell->type.c_str()); - cell->bel = *bi++; - } - } + while ((bi != blist.end()) && + (design->chip.getBelType(*bi) != bel_type)) + bi++; + if (bi == blist.end()) + log_error("Too many \'%s\' used in design\n", + cell->type.c_str()); + cell->bel = *bi++; + } + } } - diff --git a/common/place.h b/common/place.h index 483f11f3..8d3b4c42 100644 --- a/common/place.h +++ b/common/place.h @@ -16,11 +16,11 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ -#ifndef PLACE_H -#define PLACE_H +#ifndef PLACE_H +#define PLACE_H #include "design.h" -extern void place_design(Design *design); +extern void place_design(Design *design); -#endif // PLACE_H +#endif // PLACE_H diff --git a/common/rulecheck.cc b/common/rulecheck.cc index 7443c636..ca0fb76c 100644 --- a/common/rulecheck.cc +++ b/common/rulecheck.cc @@ -1,68 +1,72 @@ -#include #include +#include #include "design.h" #include "log.h" -bool check_all_nets_driven(Design *design) { - const bool debug = false; +bool check_all_nets_driven(Design *design) +{ + const bool debug = false; - log_info("Rule checker, Verifying pre-placed design\n"); + log_info("Rule checker, Verifying pre-placed design\n"); - for(auto cell_entry : design->cells) { - CellInfo *cell = cell_entry.second; + for (auto cell_entry : design->cells) { + CellInfo *cell = cell_entry.second; - if (debug) log_info(" Examining cell \'%s\', of type \'%s\'\n", - cell->name.c_str(), - cell->type.c_str()); - for(auto port_entry : cell->ports) { - PortInfo &port = port_entry.second; + if (debug) + log_info(" Examining cell \'%s\', of type \'%s\'\n", + cell->name.c_str(), cell->type.c_str()); + for (auto port_entry : cell->ports) { + PortInfo &port = port_entry.second; - if (debug) log_info(" Checking name of port \'%s\' " - "against \'%s\'\n", - port_entry.first.c_str(), - port.name.c_str()); - assert(port.name.compare(port_entry.first)==0); - assert(port.name.size() > 0); + if (debug) + log_info(" Checking name of port \'%s\' " + "against \'%s\'\n", + port_entry.first.c_str(), port.name.c_str()); + assert(port.name.compare(port_entry.first) == 0); + assert(port.name.size() > 0); - if (port.net == NULL) { - if (debug) log_warning(" Port \'%s\' in cell \'%s\' is unconnected\n", - port.name.c_str(), cell->name.c_str()); - } else { - assert(port.net); - if (debug) log_info(" Checking for a net named \'%s\'\n", - port.net->name.c_str()); - assert(design->nets.count(port.net->name)>0); - } - } - } + if (port.net == NULL) { + if (debug) + log_warning( + " Port \'%s\' in cell \'%s\' is unconnected\n", + port.name.c_str(), cell->name.c_str()); + } else { + assert(port.net); + if (debug) + log_info(" Checking for a net named \'%s\'\n", + port.net->name.c_str()); + assert(design->nets.count(port.net->name) > 0); + } + } + } - for(auto net_entry : design->nets) { - NetInfo *net = net_entry.second; + for (auto net_entry : design->nets) { + NetInfo *net = net_entry.second; - assert(net->name.compare(net_entry.first) == 0); - if ((net->driver.cell != NULL) - &&(net->driver.cell->type.compare("GND") != 0) - &&(net->driver.cell->type.compare("VCC") != 0)) { + assert(net->name.compare(net_entry.first) == 0); + if ((net->driver.cell != NULL) && + (net->driver.cell->type.compare("GND") != 0) && + (net->driver.cell->type.compare("VCC") != 0)) { - if (debug) log_info(" Checking for a driver cell named \'%s\'\n", - net->driver.cell->name.c_str()); - assert(design->cells.count(net->driver.cell->name) >0); - } + if (debug) + log_info(" Checking for a driver cell named \'%s\'\n", + net->driver.cell->name.c_str()); + assert(design->cells.count(net->driver.cell->name) > 0); + } - for(auto user : net->users) { - if ((user.cell != NULL) - &&(user.cell->type.compare("GND") != 0) - &&(user.cell->type.compare("VCC") != 0)) { + for (auto user : net->users) { + if ((user.cell != NULL) && (user.cell->type.compare("GND") != 0) && + (user.cell->type.compare("VCC") != 0)) { - if (debug) log_info(" Checking for a user cell named \'%s\'\n", - user.cell->name.c_str()); - assert(design->cells.count(user.cell->name) >0); - } + if (debug) + log_info(" Checking for a user cell named \'%s\'\n", + user.cell->name.c_str()); + assert(design->cells.count(user.cell->name) > 0); + } + } + } - } - } - - if (debug) log_info(" Verified!\n"); - return true; + if (debug) + log_info(" Verified!\n"); + return true; } - diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc index d3696909..56e6b1b6 100644 --- a/frontend/json/jsonparse.cc +++ b/frontend/json/jsonparse.cc @@ -21,289 +21,270 @@ * */ -#include -#include -#include -#include -#include -#include "design.h" -#include "chip.h" #include "jsonparse.h" +#include +#include +#include +#include +#include +#include "chip.h" +#include "design.h" -extern bool check_all_nets_driven(Design *design); +extern bool check_all_nets_driven(Design *design); namespace JsonParser { - const bool json_debug = false; +const bool json_debug = false; - typedef std::string string; - - template int GetSize(const T &obj) { return obj.size(); } +typedef std::string string; +template int GetSize(const T &obj) { return obj.size(); } struct JsonNode { - char type; // S=String, N=Number, A=Array, D=Dict - string data_string; - int data_number; - vector data_array; - dict data_dict; - vector data_dict_keys; + char type; // S=String, N=Number, A=Array, D=Dict + string data_string; + int data_number; + vector data_array; + dict data_dict; + vector data_dict_keys; - JsonNode(std::istream &f) - { - type = 0; - data_number = 0; + JsonNode(std::istream &f) + { + type = 0; + data_number = 0; - while (1) - { - int ch = f.get(); + while (1) { + int ch = f.get(); - if (ch == EOF) - log_error("Unexpected EOF in JSON file.\n"); + if (ch == EOF) + log_error("Unexpected EOF in JSON file.\n"); - if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') - continue; + if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') + continue; - if (ch == '\"') - { - type = 'S'; + if (ch == '\"') { + type = 'S'; - while (1) - { - ch = f.get(); + while (1) { + ch = f.get(); - if (ch == EOF) - log_error("Unexpected EOF " - "in JSON string.\n"); + if (ch == EOF) + log_error("Unexpected EOF " + "in JSON string.\n"); - if (ch == '\"') - break; + if (ch == '\"') + break; - if (ch == '\\') { - int ch = f.get(); + if (ch == '\\') { + int ch = f.get(); - if (ch == EOF) - log_error("Unexpected EOF " - "in JSON string.\n"); - } + if (ch == EOF) + log_error("Unexpected EOF " + "in JSON string.\n"); + } - data_string += ch; - } + data_string += ch; + } - break; - } + break; + } - if ('0' <= ch && ch <= '9') - { - type = 'N'; - data_number = ch - '0'; - data_string += ch; + if ('0' <= ch && ch <= '9') { + type = 'N'; + data_number = ch - '0'; + data_string += ch; - while (1) - { - ch = f.get(); + while (1) { + ch = f.get(); - if (ch == EOF) - break; + if (ch == EOF) + break; - if (ch == '.') - goto parse_real; + if (ch == '.') + goto parse_real; - if (ch < '0' || '9' < ch) { - f.unget(); - break; - } + if (ch < '0' || '9' < ch) { + f.unget(); + break; + } - data_number = data_number*10 - + (ch - '0'); - data_string += ch; - } + data_number = data_number * 10 + (ch - '0'); + data_string += ch; + } - data_string = ""; - break; + data_string = ""; + break; - parse_real: - type = 'S'; - data_number = 0; - data_string += ch; + parse_real: + type = 'S'; + data_number = 0; + data_string += ch; - while (1) - { - ch = f.get(); + while (1) { + ch = f.get(); - if (ch == EOF) - break; + if (ch == EOF) + break; - if (ch < '0' || '9' < ch) { - f.unget(); - break; - } + if (ch < '0' || '9' < ch) { + f.unget(); + break; + } - data_string += ch; - } + data_string += ch; + } - break; - } + break; + } - if (ch == '[') - { - type = 'A'; + if (ch == '[') { + type = 'A'; - while (1) - { - ch = f.get(); + while (1) { + ch = f.get(); - if (ch == EOF) - log_error("Unexpected EOF " - "in JSON file.\n"); + if (ch == EOF) + log_error("Unexpected EOF " + "in JSON file.\n"); - if (ch == ' ' || ch == '\t' - || ch == '\r' - || ch == '\n' - || ch == ',') - continue; + if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' || + ch == ',') + continue; - if (ch == ']') - break; + if (ch == ']') + break; - f.unget(); - data_array.push_back(new JsonNode(f)); - } + f.unget(); + data_array.push_back(new JsonNode(f)); + } - break; - } + break; + } - if (ch == '{') - { - type = 'D'; + if (ch == '{') { + type = 'D'; - while (1) - { - ch = f.get(); + while (1) { + ch = f.get(); - if (ch == EOF) - log_error("Unexpected EOF " - "in JSON file.\n"); + if (ch == EOF) + log_error("Unexpected EOF " + "in JSON file.\n"); - if (ch == ' ' || ch == '\t' - || ch == '\r' - || ch == '\n' - || ch == ',') - continue; + if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' || + ch == ',') + continue; - if (ch == '}') - break; + if (ch == '}') + break; - f.unget(); - JsonNode key(f); + f.unget(); + JsonNode key(f); - while (1) - { - ch = f.get(); + while (1) { + ch = f.get(); - if (ch == EOF) - log_error("Unexpected EOF " - "in JSON file.\n"); + if (ch == EOF) + log_error("Unexpected EOF " + "in JSON file.\n"); - if (ch == ' ' || ch == '\t' - || ch == '\r' - || ch == '\n' - || ch == ':') - continue; + if (ch == ' ' || ch == '\t' || ch == '\r' || + ch == '\n' || ch == ':') + continue; - f.unget(); - break; - } + f.unget(); + break; + } - JsonNode *value = new JsonNode(f); + JsonNode *value = new JsonNode(f); - if (key.type != 'S') - log_error("Unexpected " - "non-string key " - "in JSON dict.\n"); + if (key.type != 'S') + log_error("Unexpected " + "non-string key " + "in JSON dict.\n"); - data_dict[key.data_string] = value; - data_dict_keys.push_back( - key.data_string); - } + data_dict[key.data_string] = value; + data_dict_keys.push_back(key.data_string); + } - break; - } + break; + } - log_error("Unexpected character in JSON file: '%c'\n", - ch); - } - } + log_error("Unexpected character in JSON file: '%c'\n", ch); + } + } - ~JsonNode() - { - for (auto it : data_array) - delete it; - for (auto &it : data_dict) - delete it.second; - } + ~JsonNode() + { + for (auto it : data_array) + delete it; + for (auto &it : data_dict) + delete it.second; + } }; +NetInfo *ground_net(NetInfo *net) +{ + CellInfo *cell = new CellInfo; + PortInfo port_info; + PortRef port_ref; -NetInfo *ground_net(NetInfo *net) { - CellInfo *cell = new CellInfo; - PortInfo port_info; - PortRef port_ref; + cell->name = string(net->name + ".GND"); + cell->type = string("GND"); - cell->name = string(net->name + ".GND"); - cell->type = string("GND"); + port_info.name = cell->name + "[]"; + port_info.net = net; + port_info.type = PORT_OUT; - port_info.name = cell->name + "[]"; - port_info.net = net; - port_info.type = PORT_OUT; + port_ref.cell = cell; + port_ref.port = port_info.name; - port_ref.cell = cell; - port_ref.port = port_info.name; + net->driver = port_ref; - net->driver = port_ref; + cell->ports[port_info.name] = port_info; - cell->ports[port_info.name] = port_info; - - return net; + return net; } -NetInfo *vcc_net(NetInfo *net) { - CellInfo *cell = new CellInfo; - PortInfo port_info; - PortRef port_ref; +NetInfo *vcc_net(NetInfo *net) +{ + CellInfo *cell = new CellInfo; + PortInfo port_info; + PortRef port_ref; - cell->name = string(net->name + ".VCC"); - cell->type = string("VCC"); + cell->name = string(net->name + ".VCC"); + cell->type = string("VCC"); - port_info.name = cell->name + "[]"; - port_info.net = net; - port_info.type = PORT_OUT; + port_info.name = cell->name + "[]"; + port_info.net = net; + port_info.type = PORT_OUT; - port_ref.cell = cell; - port_ref.port = port_info.name; + port_ref.cell = cell; + port_ref.port = port_info.name; - net->driver = port_ref; + net->driver = port_ref; - cell->ports[port_info.name] = port_info; + cell->ports[port_info.name] = port_info; - return net; + return net; } -NetInfo *floating_net(NetInfo *net) { - PortInfo port_info; - PortRef port_ref; +NetInfo *floating_net(NetInfo *net) +{ + PortInfo port_info; + PortRef port_ref; - port_info.name = net->name + ".floating"; - port_info.net = net; - port_info.type = PORT_OUT; + port_info.name = net->name + ".floating"; + port_info.net = net; + port_info.type = PORT_OUT; - port_ref.cell = NULL; - port_ref.port = port_info.name; + port_ref.cell = NULL; + port_ref.port = port_info.name; - net->driver = port_ref; + net->driver = port_ref; - return net; + return net; } // @@ -313,394 +294,400 @@ NetInfo *floating_net(NetInfo *net) { // An item is deemed to be a blackbox if this entry exists and if its // value is not zero. If the item is a black box, this routine will return // true, false otherwise -bool is_blackbox(JsonNode *node) { - JsonNode *attr_node, *bbox_node; - - if (node->data_dict.count("attributes")==0) - return false; - attr_node = node->data_dict.at("attributes"); - if (attr_node == NULL) - return false; - if (attr_node->type != 'D') - return false; - if (GetSize(attr_node->data_dict)==0) - return false; - if (attr_node->data_dict.count("blackbox") == 0) - return false; - bbox_node = attr_node->data_dict.at("blackbox"); - if (bbox_node == NULL) - return false; - if (bbox_node->type != 'N') - log_error("JSON module blackbox is not a number\n"); - if (bbox_node->data_number==0) - return false; - return true; -} - -void json_import_cell_attributes(Design *design, string &modname, - CellInfo *cell, JsonNode *param_node, int param_id) { - // - JsonNode *param; - IdString pId; - // - param = param_node->data_dict.at( - param_node->data_dict_keys[param_id]); - - pId = param_node->data_dict_keys[param_id]; - if (param->type == 'N') { - cell->params[pId] = std::to_string(param_node->data_number);; - } else if (param->type == 'S') - cell->params[pId] = param->data_string; - else - log_error("JSON parameter type of \"%s\' of cell \'%s\' not supported\n", - pId.c_str(), - cell->name.c_str()); - - if (json_debug) log_info(" Added parameter \'%s\'=%s to cell \'%s\' " - "of module \'%s\'\n", - pId.c_str(), cell->params[pId].c_str(), - cell->name.c_str(), modname.c_str()); -} - -void json_import_cell_ports(Design *design, string &modname, CellInfo *cell, - string &port_name, JsonNode *dir_node,JsonNode *wire_group_node) +bool is_blackbox(JsonNode *node) { - // Examine and connect a single port of the given cell to its nets, - // generating them as necessary + JsonNode *attr_node, *bbox_node; - assert(dir_node); - - if (json_debug) log_info(" Examining port %s, node %s\n", port_name.c_str(), - cell->name.c_str()); - - if (!wire_group_node) - log_error("JSON no connection match " - "for port_direction \'%s\' of node \'%s\' " - "in module \'%s\'\n", - port_name.c_str(), cell->name.c_str(), modname.c_str()); - - assert(wire_group_node); - - assert(dir_node->type == 'S'); - assert(wire_group_node->type == 'A'); - - PortInfo port_info; - - port_info.name = port_name; - if(dir_node->data_string.compare("input")==0) - port_info.type = PORT_IN; - else if(dir_node->data_string.compare("output")==0) - port_info.type = PORT_OUT; - else if(dir_node->data_string.compare("inout")==0) - port_info.type = PORT_INOUT; - else - log_error("JSON unknown port direction \'%s\' in node \'%s\' " - "of module \'%s\'\n", - dir_node->data_string.c_str(), - cell->name.c_str(), - modname.c_str()); - // - // Find an update, or create a net to connect - // to this port. - // - NetInfo *this_net; - bool is_bus; - - // - // If this port references a bus, then there will be multiple nets - // connected to it, all specified as part of an array. - // - is_bus = (wire_group_node->data_array.size()>1); - - // Now loop through all of the connections to this port. - if (wire_group_node->data_array.size() == 0) { - // - // There is/are no connections to this port. - // - // Create the port, but leave the net NULL - PortInfo this_port; - - // - this_port.name = port_info.name; - this_port.type = port_info.type; - this_port.net = NULL; - - cell->ports[this_port.name] = this_port; - - if (json_debug) log_info(" Port \'%s\' has no connection in \'%s\'\n", - this_port.name.c_str(), cell->name.c_str()); - - } else for(int index=0; index < wire_group_node->data_array.size(); - index++) { - // - JsonNode *wire_node; - PortInfo this_port; - PortRef port_ref; - bool const_input = false; - IdString net_id; - // - wire_node = wire_group_node->data_array[index]; - port_ref.cell = cell; - - // - // Pick a name for this port - if (is_bus) - this_port.name = port_info.name + '[' - + std::to_string(index) + ']'; - else - this_port.name = port_info.name; - this_port.type = port_info.type; - - port_ref.port = this_port.name; - - if (wire_node->type == 'N') { - int net_num; - - // A simple net, specified by a number - net_num = wire_node->data_number; - net_id = std::to_string(net_num); - if (design->nets.count(net_id) == 0) { - // The net doesn't exist in the design (yet) - // Create in now - - if (json_debug) log_info(" Generating a new net, \'%d\'\n", - net_num); - - this_net = new NetInfo; - this_net->name = net_id; - this_net->driver.cell = NULL; - this_net->driver.port = ""; - design->nets[net_id] = this_net; - } else { - // - // The net already exists within the design. - // We'll connect to it - // - this_net = design->nets[net_id]; - if (json_debug) log_info(" Reusing net \'%s\', id \'%s\', " - "with driver \'%s\'\n", - this_net->name.c_str(), net_id.c_str(), - (this_net->driver.cell!=NULL) - ? this_net->driver.port.c_str() - : "NULL"); - } - - } else if (wire_node->type == 'S') { - // Strings are only used to drive wires for the fixed - // values "0", "1", and "x". Handle those constant - // values here. - // - // Constants always get their own new net - this_net = new NetInfo; - this_net->name = net_id; - const_input = (this_port.type == PORT_IN); - - if (wire_node->data_string.compare(string("0"))==0) { - - if (json_debug) log_info(" Generating a constant " - "zero net\n"); - this_net = ground_net(this_net); - - } else if (wire_node->data_string.compare(string("1")) - ==0) { - - if (json_debug) log_info(" Generating a constant " - "one net\n"); - this_net = vcc_net(this_net); - - } else if (wire_node->data_string.compare(string("x")) - ==0) { - - this_net = floating_net(this_net); - log_warning(" Floating wire node value, " - "\'%s\' of port \'%s\' " - "in cell \'%s\' of module \'%s\'\n", - wire_node->data_string.c_str(), - port_name.c_str(), - cell->name.c_str(), - modname.c_str()); - - } else - log_error(" Unknown fixed type wire node " - "value, \'%s\'\n", - wire_node->data_string.c_str()); - } - - if (json_debug) log_info(" Inserting port \'%s\' into cell \'%s\'\n", - this_port.name.c_str(), cell->name.c_str()); - - this_port.net = this_net; - - cell->ports[this_port.name] = this_port; - - if (this_port.type == PORT_OUT) { - assert(this_net->driver.cell == NULL); - this_net->driver = port_ref; - } else - this_net->users.push_back(port_ref); - - if (design->nets.count(this_net->name) == 0) - design->nets[this_net->name] = this_net; - } + if (node->data_dict.count("attributes") == 0) + return false; + attr_node = node->data_dict.at("attributes"); + if (attr_node == NULL) + return false; + if (attr_node->type != 'D') + return false; + if (GetSize(attr_node->data_dict) == 0) + return false; + if (attr_node->data_dict.count("blackbox") == 0) + return false; + bbox_node = attr_node->data_dict.at("blackbox"); + if (bbox_node == NULL) + return false; + if (bbox_node->type != 'N') + log_error("JSON module blackbox is not a number\n"); + if (bbox_node->data_number == 0) + return false; + return true; } -void json_import_cell(Design *design, string modname, JsonNode *cell_node, - string cell_name) { - JsonNode *cell_type, *param_node; +void json_import_cell_attributes(Design *design, string &modname, + CellInfo *cell, JsonNode *param_node, + int param_id) +{ + // + JsonNode *param; + IdString pId; + // + param = param_node->data_dict.at(param_node->data_dict_keys[param_id]); - cell_type = cell_node->data_dict.at("type"); - if (cell_type == NULL) - return; + pId = param_node->data_dict_keys[param_id]; + if (param->type == 'N') { + cell->params[pId] = std::to_string(param_node->data_number); + ; + } else if (param->type == 'S') + cell->params[pId] = param->data_string; + else + log_error( + "JSON parameter type of \"%s\' of cell \'%s\' not supported\n", + pId.c_str(), cell->name.c_str()); - CellInfo *cell = new CellInfo; - - cell->name = cell_name; - assert(cell_type->type == 'S'); - cell->type = cell_type->data_string; - // No BEL assignment here/yet - - if (json_debug) log_info(" Processing %s $ %s\n", - modname.c_str(), cell->name.c_str()); - - param_node = cell_node->data_dict.at("parameters"); - if (param_node->type != 'D') - log_error("JSON parameter list of \'%s\' is not a data dictionary\n", cell->name.c_str()); - - // - // Loop through all parameters, adding them into the - // design to annotate the cell - // - for(int paramid = 0; paramid < GetSize(param_node->data_dict_keys); - paramid++) { - - json_import_cell_attributes(design, modname, cell, param_node, - paramid); - } - - - // - // Now connect the ports of this module. The ports are defined by - // both the port directions node as well as the connections node. - // Both should contain dictionaries having the same keys. - // - - JsonNode *pdir_node = NULL; - if (cell_node->data_dict.count("port_directions") > 0) { - - pdir_node = cell_node->data_dict.at("port_directions"); - if (pdir_node->type != 'D') - log_error("JSON port_directions node of \'%s\' " - "in module \'%s\' is not a " - "dictionary\n", cell->name.c_str(), - modname.c_str()); - - } else if (cell_node->data_dict.count("ports") > 0) { - pdir_node = cell_node->data_dict.at("ports"); - if (pdir_node->type != 'D') - log_error("JSON ports node of \'%s\' " - "in module \'%s\' is not a " - "dictionary\n", cell->name.c_str(), - modname.c_str()); - } - - JsonNode *connections - = cell_node->data_dict.at("connections"); - if (connections->type != 'D') - log_error("JSON connections node of \'%s\' " - "in module \'%s\' is not a " - "dictionary\n", cell->name.c_str(), - modname.c_str()); - - if (GetSize(pdir_node->data_dict_keys) - != GetSize(connections->data_dict_keys)) - log_error("JSON number of connections doesnt " - "match number of ports in node \'%s\' " - "of module \'%s\'\n", - cell->name.c_str(), - modname.c_str()); - - // - // Loop through all of the ports of this logic element - // - for(int portid=0; portiddata_dict_keys); - portid++) { - // - string port_name; - JsonNode *dir_node, *wire_group_node; - // - - port_name = pdir_node->data_dict_keys[portid]; - dir_node = pdir_node->data_dict.at(port_name); - wire_group_node = connections->data_dict.at(port_name); - - json_import_cell_ports(design, modname, cell, - port_name, dir_node, wire_group_node); - } - - design->cells[cell->name] = cell; - // check_all_nets_driven(design); + if (json_debug) + log_info(" Added parameter \'%s\'=%s to cell \'%s\' " + "of module \'%s\'\n", + pId.c_str(), cell->params[pId].c_str(), cell->name.c_str(), + modname.c_str()); } -void json_import(Design *design, string modname, JsonNode *node) { - if (is_blackbox(node)) - return; +void json_import_cell_ports(Design *design, string &modname, CellInfo *cell, + string &port_name, JsonNode *dir_node, + JsonNode *wire_group_node) +{ + // Examine and connect a single port of the given cell to its nets, + // generating them as necessary - log_info("Importing module %s\n", modname.c_str()); + assert(dir_node); - if (node->data_dict.count("cells")) { - JsonNode *cell_parent = node->data_dict.at("cells"); - // - // - // Loop through all of the logic elements in a flattened design - // - // - for(int cellid=0; cellid < GetSize(cell_parent->data_dict_keys); - cellid ++) { - JsonNode *cell_type, *here, *param_node; - - here = cell_parent->data_dict.at( - cell_parent->data_dict_keys[cellid]); - json_import_cell(design, modname, here, - cell_parent->data_dict_keys[cellid]); + if (json_debug) + log_info(" Examining port %s, node %s\n", port_name.c_str(), + cell->name.c_str()); - } - } + if (!wire_group_node) + log_error("JSON no connection match " + "for port_direction \'%s\' of node \'%s\' " + "in module \'%s\'\n", + port_name.c_str(), cell->name.c_str(), modname.c_str()); - check_all_nets_driven(design); + assert(wire_group_node); + + assert(dir_node->type == 'S'); + assert(wire_group_node->type == 'A'); + + PortInfo port_info; + + port_info.name = port_name; + if (dir_node->data_string.compare("input") == 0) + port_info.type = PORT_IN; + else if (dir_node->data_string.compare("output") == 0) + port_info.type = PORT_OUT; + else if (dir_node->data_string.compare("inout") == 0) + port_info.type = PORT_INOUT; + else + log_error("JSON unknown port direction \'%s\' in node \'%s\' " + "of module \'%s\'\n", + dir_node->data_string.c_str(), cell->name.c_str(), + modname.c_str()); + // + // Find an update, or create a net to connect + // to this port. + // + NetInfo *this_net; + bool is_bus; + + // + // If this port references a bus, then there will be multiple nets + // connected to it, all specified as part of an array. + // + is_bus = (wire_group_node->data_array.size() > 1); + + // Now loop through all of the connections to this port. + if (wire_group_node->data_array.size() == 0) { + // + // There is/are no connections to this port. + // + // Create the port, but leave the net NULL + PortInfo this_port; + + // + this_port.name = port_info.name; + this_port.type = port_info.type; + this_port.net = NULL; + + cell->ports[this_port.name] = this_port; + + if (json_debug) + log_info(" Port \'%s\' has no connection in \'%s\'\n", + this_port.name.c_str(), cell->name.c_str()); + + } else + for (int index = 0; index < wire_group_node->data_array.size(); + index++) { + // + JsonNode *wire_node; + PortInfo this_port; + PortRef port_ref; + bool const_input = false; + IdString net_id; + // + wire_node = wire_group_node->data_array[index]; + port_ref.cell = cell; + + // + // Pick a name for this port + if (is_bus) + this_port.name = + port_info.name + '[' + std::to_string(index) + ']'; + else + this_port.name = port_info.name; + this_port.type = port_info.type; + + port_ref.port = this_port.name; + + if (wire_node->type == 'N') { + int net_num; + + // A simple net, specified by a number + net_num = wire_node->data_number; + net_id = std::to_string(net_num); + if (design->nets.count(net_id) == 0) { + // The net doesn't exist in the design (yet) + // Create in now + + if (json_debug) + log_info(" Generating a new net, \'%d\'\n", + net_num); + + this_net = new NetInfo; + this_net->name = net_id; + this_net->driver.cell = NULL; + this_net->driver.port = ""; + design->nets[net_id] = this_net; + } else { + // + // The net already exists within the design. + // We'll connect to it + // + this_net = design->nets[net_id]; + if (json_debug) + log_info(" Reusing net \'%s\', id \'%s\', " + "with driver \'%s\'\n", + this_net->name.c_str(), net_id.c_str(), + (this_net->driver.cell != NULL) + ? this_net->driver.port.c_str() + : "NULL"); + } + + } else if (wire_node->type == 'S') { + // Strings are only used to drive wires for the fixed + // values "0", "1", and "x". Handle those constant + // values here. + // + // Constants always get their own new net + this_net = new NetInfo; + this_net->name = net_id; + const_input = (this_port.type == PORT_IN); + + if (wire_node->data_string.compare(string("0")) == 0) { + + if (json_debug) + log_info(" Generating a constant " + "zero net\n"); + this_net = ground_net(this_net); + + } else if (wire_node->data_string.compare(string("1")) == 0) { + + if (json_debug) + log_info(" Generating a constant " + "one net\n"); + this_net = vcc_net(this_net); + + } else if (wire_node->data_string.compare(string("x")) == 0) { + + this_net = floating_net(this_net); + log_warning(" Floating wire node value, " + "\'%s\' of port \'%s\' " + "in cell \'%s\' of module \'%s\'\n", + wire_node->data_string.c_str(), + port_name.c_str(), cell->name.c_str(), + modname.c_str()); + + } else + log_error(" Unknown fixed type wire node " + "value, \'%s\'\n", + wire_node->data_string.c_str()); + } + + if (json_debug) + log_info(" Inserting port \'%s\' into cell \'%s\'\n", + this_port.name.c_str(), cell->name.c_str()); + + this_port.net = this_net; + + cell->ports[this_port.name] = this_port; + + if (this_port.type == PORT_OUT) { + assert(this_net->driver.cell == NULL); + this_net->driver = port_ref; + } else + this_net->users.push_back(port_ref); + + if (design->nets.count(this_net->name) == 0) + design->nets[this_net->name] = this_net; + } } -struct JsonFrontend { - // JsonFrontend() : Frontend("json", "read JSON file") { } - JsonFrontend(void) { } - virtual void help() - { - } - virtual void execute(std::istream *&f, std::string &filename, - Design *design) - { - // log_header(design, "Executing JSON frontend.\n"); +void json_import_cell(Design *design, string modname, JsonNode *cell_node, + string cell_name) +{ + JsonNode *cell_type, *param_node; - JsonNode root(*f); + cell_type = cell_node->data_dict.at("type"); + if (cell_type == NULL) + return; - if (root.type != 'D') - log_error("JSON root node is not a dictionary.\n"); + CellInfo *cell = new CellInfo; - if (root.data_dict.count("modules") != 0) - { - JsonNode *modules = root.data_dict.at("modules"); + cell->name = cell_name; + assert(cell_type->type == 'S'); + cell->type = cell_type->data_string; + // No BEL assignment here/yet - if (modules->type != 'D') - log_error("JSON modules node is not a dictionary.\n"); + if (json_debug) + log_info(" Processing %s $ %s\n", modname.c_str(), cell->name.c_str()); - for (auto &it : modules->data_dict) - json_import(design, it.first, it.second); - } - } + param_node = cell_node->data_dict.at("parameters"); + if (param_node->type != 'D') + log_error("JSON parameter list of \'%s\' is not a data dictionary\n", + cell->name.c_str()); + + // + // Loop through all parameters, adding them into the + // design to annotate the cell + // + for (int paramid = 0; paramid < GetSize(param_node->data_dict_keys); + paramid++) { + + json_import_cell_attributes(design, modname, cell, param_node, paramid); + } + + // + // Now connect the ports of this module. The ports are defined by + // both the port directions node as well as the connections node. + // Both should contain dictionaries having the same keys. + // + + JsonNode *pdir_node = NULL; + if (cell_node->data_dict.count("port_directions") > 0) { + + pdir_node = cell_node->data_dict.at("port_directions"); + if (pdir_node->type != 'D') + log_error("JSON port_directions node of \'%s\' " + "in module \'%s\' is not a " + "dictionary\n", + cell->name.c_str(), modname.c_str()); + + } else if (cell_node->data_dict.count("ports") > 0) { + pdir_node = cell_node->data_dict.at("ports"); + if (pdir_node->type != 'D') + log_error("JSON ports node of \'%s\' " + "in module \'%s\' is not a " + "dictionary\n", + cell->name.c_str(), modname.c_str()); + } + + JsonNode *connections = cell_node->data_dict.at("connections"); + if (connections->type != 'D') + log_error("JSON connections node of \'%s\' " + "in module \'%s\' is not a " + "dictionary\n", + cell->name.c_str(), modname.c_str()); + + if (GetSize(pdir_node->data_dict_keys) != + GetSize(connections->data_dict_keys)) + log_error("JSON number of connections doesnt " + "match number of ports in node \'%s\' " + "of module \'%s\'\n", + cell->name.c_str(), modname.c_str()); + + // + // Loop through all of the ports of this logic element + // + for (int portid = 0; portid < GetSize(pdir_node->data_dict_keys); + portid++) { + // + string port_name; + JsonNode *dir_node, *wire_group_node; + // + + port_name = pdir_node->data_dict_keys[portid]; + dir_node = pdir_node->data_dict.at(port_name); + wire_group_node = connections->data_dict.at(port_name); + + json_import_cell_ports(design, modname, cell, port_name, dir_node, + wire_group_node); + } + + design->cells[cell->name] = cell; + // check_all_nets_driven(design); +} + +void json_import(Design *design, string modname, JsonNode *node) +{ + if (is_blackbox(node)) + return; + + log_info("Importing module %s\n", modname.c_str()); + + if (node->data_dict.count("cells")) { + JsonNode *cell_parent = node->data_dict.at("cells"); + // + // + // Loop through all of the logic elements in a flattened design + // + // + for (int cellid = 0; cellid < GetSize(cell_parent->data_dict_keys); + cellid++) { + JsonNode *cell_type, *here, *param_node; + + here = cell_parent->data_dict.at( + cell_parent->data_dict_keys[cellid]); + json_import_cell(design, modname, here, + cell_parent->data_dict_keys[cellid]); + } + } + + check_all_nets_driven(design); +} + +struct JsonFrontend +{ + // JsonFrontend() : Frontend("json", "read JSON file") { } + JsonFrontend(void) {} + virtual void help() {} + virtual void execute(std::istream *&f, std::string &filename, + Design *design) + { + // log_header(design, "Executing JSON frontend.\n"); + + JsonNode root(*f); + + if (root.type != 'D') + log_error("JSON root node is not a dictionary.\n"); + + if (root.data_dict.count("modules") != 0) { + JsonNode *modules = root.data_dict.at("modules"); + + if (modules->type != 'D') + log_error("JSON modules node is not a dictionary.\n"); + + for (auto &it : modules->data_dict) + json_import(design, it.first, it.second); + } + } }; // JsonFrontend; }; // End Namespace JsonParser -void parse_json_file(std::istream *&f, std::string &filename, Design *design){ - auto *parser = new JsonParser::JsonFrontend(); - parser->execute(f, filename, design); +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 index 12bf6dcd..a1c28a42 100644 --- a/frontend/json/jsonparse.h +++ b/frontend/json/jsonparse.h @@ -17,13 +17,13 @@ * */ -#ifndef JSON_PARSER -#define JSON_PARSER +#ifndef JSON_PARSER +#define JSON_PARSER -#include #include +#include #include "design.h" -extern void parse_json_file(std::istream *&, std::string &, Design *); +extern void parse_json_file(std::istream *&, std::string &, Design *); #endif diff --git a/ice40/chip.h b/ice40/chip.h index 05ef2754..3125b17f 100644 --- a/ice40/chip.h +++ b/ice40/chip.h @@ -173,12 +173,17 @@ struct BelIterator { int cursor; - BelIterator operator++() { cursor++; return *this; } - BelIterator operator++(int) { - BelIterator prior(*this); - cursor++; - return prior; - } + BelIterator operator++() + { + cursor++; + return *this; + } + BelIterator operator++(int) + { + BelIterator prior(*this); + cursor++; + return prior; + } bool operator!=(const BelIterator &other) const { diff --git a/ice40/main.cc b/ice40/main.cc index 68089ffb..d50f72e0 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -23,11 +23,11 @@ #include "design.h" #include "jsonparse.h" #include "log.h" +#include "log.h" #include "mainwindow.h" +#include "place.h" #include "pybindings.h" #include "version.h" -#include "log.h" -#include "place.h" void svg_dump_el(const GraphicElement &el) { @@ -244,7 +244,7 @@ int main(int argc, char *argv[]) std::istream *f = new std::ifstream(filename); parse_json_file(f, filename, &design); - place_design(&design); + place_design(&design); } if (vm.count("run")) { @@ -254,7 +254,6 @@ int main(int argc, char *argv[]) execute_python_file(filename.c_str()); } - if (vm.count("gui")) { QApplication a(argc, argv); MainWindow w;