Applied clang-format to my own contributions

This commit is contained in:
ZipCPU 2018-06-07 15:38:24 -04:00
parent a4f687548e
commit 4499864024
9 changed files with 831 additions and 840 deletions

View File

@ -17,20 +17,20 @@
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include "log.h"
#include "design.h"
#include "log.h"
std::vector<FILE*> log_files;
std::vector<std::ostream*> log_streams;
std::vector<FILE *> log_files;
std::vector<std::ostream *> log_streams;
FILE *log_errfile = NULL;
bool log_error_stderr = false;
@ -49,11 +49,11 @@ std::string vstringf(const char *fmt, va_list ap)
char *str = NULL;
#ifdef _WIN32
int sz = 64+strlen(fmt), rc;
int sz = 64 + strlen(fmt), rc;
while (1) {
va_list apc;
va_copy(apc, ap);
str = (char*)realloc(str, sz);
str = (char *)realloc(str, sz);
rc = vsnprintf(str, sz, fmt, apc);
va_end(apc);
if (rc >= 0 && rc < sz)
@ -210,23 +210,17 @@ void log_cmd_error(const char *format, ...)
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()
{
@ -237,12 +231,6 @@ void log_flush()
f->flush();
}
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) {}

View File

@ -21,12 +21,12 @@
#define LOG_H
#include <ostream>
#include <ostream>
#include <set>
#include <stdarg.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <ostream>
#include <stdio.h>
#include <stdarg.h>
#include "design.h"
@ -35,10 +35,12 @@
#define NXP_NORETURN
#define NXP_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
struct log_cmd_error_exception { };
struct log_cmd_error_exception
{
};
extern std::vector<FILE*> log_files;
extern std::vector<std::ostream*> log_streams;
extern std::vector<FILE *> log_files;
extern std::vector<std::ostream *> log_streams;
extern FILE *log_errfile;
extern bool log_quiet_warnings;
@ -81,16 +83,21 @@ 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_ping() \
log("-- %s:%d %s --\n", __FILE__, __LINE__, __PRETTY_FUNCTION__)
#endif

View File

@ -18,26 +18,27 @@
*/
#include <iostream>
#include <ostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <vector>
#include <list>
#include <map>
#include <ostream>
#include <set>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include "log.h"
#include "design.h"
#include "log.h"
#include "place.h"
void place_design(Design *design) {
void place_design(Design *design)
{
std::set<IdString> types_used;
std::set<IdString>::iterator not_found, element;
std::set<BelType> used_bels;
for(auto cell_entry : design->cells) {
for (auto cell_entry : design->cells) {
CellInfo *cell = cell_entry.second;
BelType bel_type;
@ -49,26 +50,27 @@ void place_design(Design *design) {
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());
"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) {
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) {
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)
if (cell->type.compare(bel_type_name) != 0)
continue;
while((bi != blist.end())
&&(design->chip.getBelType(*bi) != bel_type))
while ((bi != blist.end()) &&
(design->chip.getBelType(*bi) != bel_type))
bi++;
if (bi == blist.end())
log_error("Too many \'%s\' used in design\n",
@ -77,4 +79,3 @@ void place_design(Design *design) {
}
}
}

View File

@ -1,68 +1,72 @@
#include <string>
#include <assert.h>
#include <string>
#include "design.h"
#include "log.h"
bool check_all_nets_driven(Design *design) {
bool check_all_nets_driven(Design *design)
{
const bool debug = false;
log_info("Rule checker, Verifying pre-placed design\n");
for(auto cell_entry : design->cells) {
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) {
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\' "
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);
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",
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",
if (debug)
log_info(" Checking for a net named \'%s\'\n",
port.net->name.c_str());
assert(design->nets.count(port.net->name)>0);
assert(design->nets.count(port.net->name) > 0);
}
}
}
for(auto net_entry : design->nets) {
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)) {
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",
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);
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",
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);
assert(design->cells.count(user.cell->name) > 0);
}
}
}
if (debug) log_info(" Verified!\n");
if (debug)
log_info(" Verified!\n");
return true;
}

View File

@ -21,33 +21,32 @@
*
*/
#include <string>
#include <iostream>
#include <fstream>
#include <assert.h>
#include <log.h>
#include "design.h"
#include "chip.h"
#include "jsonparse.h"
#include <assert.h>
#include <fstream>
#include <iostream>
#include <log.h>
#include <string>
#include "chip.h"
#include "design.h"
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<typename T> int GetSize(const T &obj) { return obj.size(); }
typedef std::string string;
template <typename T> 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<JsonNode*> data_array;
dict<string, JsonNode*> data_dict;
vector<JsonNode *> data_array;
dict<string, JsonNode *> data_dict;
vector<string> data_dict_keys;
JsonNode(std::istream &f)
@ -55,8 +54,7 @@ struct JsonNode
type = 0;
data_number = 0;
while (1)
{
while (1) {
int ch = f.get();
if (ch == EOF)
@ -65,12 +63,10 @@ struct JsonNode
if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n')
continue;
if (ch == '\"')
{
if (ch == '\"') {
type = 'S';
while (1)
{
while (1) {
ch = f.get();
if (ch == EOF)
@ -94,14 +90,12 @@ struct JsonNode
break;
}
if ('0' <= ch && ch <= '9')
{
if ('0' <= ch && ch <= '9') {
type = 'N';
data_number = ch - '0';
data_string += ch;
while (1)
{
while (1) {
ch = f.get();
if (ch == EOF)
@ -115,8 +109,7 @@ struct JsonNode
break;
}
data_number = data_number*10
+ (ch - '0');
data_number = data_number * 10 + (ch - '0');
data_string += ch;
}
@ -128,8 +121,7 @@ struct JsonNode
data_number = 0;
data_string += ch;
while (1)
{
while (1) {
ch = f.get();
if (ch == EOF)
@ -146,22 +138,18 @@ struct JsonNode
break;
}
if (ch == '[')
{
if (ch == '[') {
type = 'A';
while (1)
{
while (1) {
ch = f.get();
if (ch == EOF)
log_error("Unexpected EOF "
"in JSON file.\n");
if (ch == ' ' || ch == '\t'
|| ch == '\r'
|| ch == '\n'
|| ch == ',')
if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ||
ch == ',')
continue;
if (ch == ']')
@ -174,22 +162,18 @@ struct JsonNode
break;
}
if (ch == '{')
{
if (ch == '{') {
type = 'D';
while (1)
{
while (1) {
ch = f.get();
if (ch == EOF)
log_error("Unexpected EOF "
"in JSON file.\n");
if (ch == ' ' || ch == '\t'
|| ch == '\r'
|| ch == '\n'
|| ch == ',')
if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ||
ch == ',')
continue;
if (ch == '}')
@ -198,18 +182,15 @@ struct JsonNode
f.unget();
JsonNode key(f);
while (1)
{
while (1) {
ch = f.get();
if (ch == EOF)
log_error("Unexpected EOF "
"in JSON file.\n");
if (ch == ' ' || ch == '\t'
|| ch == '\r'
|| ch == '\n'
|| ch == ':')
if (ch == ' ' || ch == '\t' || ch == '\r' ||
ch == '\n' || ch == ':')
continue;
f.unget();
@ -224,15 +205,13 @@ struct JsonNode
"in JSON dict.\n");
data_dict[key.data_string] = value;
data_dict_keys.push_back(
key.data_string);
data_dict_keys.push_back(key.data_string);
}
break;
}
log_error("Unexpected character in JSON file: '%c'\n",
ch);
log_error("Unexpected character in JSON file: '%c'\n", ch);
}
}
@ -245,8 +224,8 @@ struct JsonNode
}
};
NetInfo *ground_net(NetInfo *net) {
NetInfo *ground_net(NetInfo *net)
{
CellInfo *cell = new CellInfo;
PortInfo port_info;
PortRef port_ref;
@ -268,7 +247,8 @@ NetInfo *ground_net(NetInfo *net) {
return net;
}
NetInfo *vcc_net(NetInfo *net) {
NetInfo *vcc_net(NetInfo *net)
{
CellInfo *cell = new CellInfo;
PortInfo port_info;
PortRef port_ref;
@ -290,7 +270,8 @@ NetInfo *vcc_net(NetInfo *net) {
return net;
}
NetInfo *floating_net(NetInfo *net) {
NetInfo *floating_net(NetInfo *net)
{
PortInfo port_info;
PortRef port_ref;
@ -313,17 +294,18 @@ 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) {
bool is_blackbox(JsonNode *node)
{
JsonNode *attr_node, *bbox_node;
if (node->data_dict.count("attributes")==0)
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)
if (GetSize(attr_node->data_dict) == 0)
return false;
if (attr_node->data_dict.count("blackbox") == 0)
return false;
@ -332,45 +314,50 @@ bool is_blackbox(JsonNode *node) {
return false;
if (bbox_node->type != 'N')
log_error("JSON module blackbox is not a number\n");
if (bbox_node->data_number==0)
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) {
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]);
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);;
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());
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\' "
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());
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)
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
assert(dir_node);
if (json_debug) log_info(" Examining port %s, node %s\n", port_name.c_str(),
if (json_debug)
log_info(" Examining port %s, node %s\n", port_name.c_str(),
cell->name.c_str());
if (!wire_group_node)
@ -387,17 +374,16 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
PortInfo port_info;
port_info.name = port_name;
if(dir_node->data_string.compare("input")==0)
if (dir_node->data_string.compare("input") == 0)
port_info.type = PORT_IN;
else if(dir_node->data_string.compare("output")==0)
else if (dir_node->data_string.compare("output") == 0)
port_info.type = PORT_OUT;
else if(dir_node->data_string.compare("inout")==0)
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(),
dir_node->data_string.c_str(), cell->name.c_str(),
modname.c_str());
//
// Find an update, or create a net to connect
@ -410,7 +396,7 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
// 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);
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) {
@ -427,10 +413,12 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
cell->ports[this_port.name] = this_port;
if (json_debug) log_info(" Port \'%s\' has no connection in \'%s\'\n",
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();
} else
for (int index = 0; index < wire_group_node->data_array.size();
index++) {
//
JsonNode *wire_node;
@ -445,8 +433,8 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
//
// Pick a name for this port
if (is_bus)
this_port.name = port_info.name + '['
+ std::to_string(index) + ']';
this_port.name =
port_info.name + '[' + std::to_string(index) + ']';
else
this_port.name = port_info.name;
this_port.type = port_info.type;
@ -463,7 +451,8 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
// The net doesn't exist in the design (yet)
// Create in now
if (json_debug) log_info(" Generating a new net, \'%d\'\n",
if (json_debug)
log_info(" Generating a new net, \'%d\'\n",
net_num);
this_net = new NetInfo;
@ -477,10 +466,11 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
// We'll connect to it
//
this_net = design->nets[net_id];
if (json_debug) log_info(" Reusing net \'%s\', id \'%s\', "
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.cell != NULL)
? this_net->driver.port.c_str()
: "NULL");
}
@ -495,29 +485,28 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
this_net->name = net_id;
const_input = (this_port.type == PORT_IN);
if (wire_node->data_string.compare(string("0"))==0) {
if (wire_node->data_string.compare(string("0")) == 0) {
if (json_debug) log_info(" Generating a constant "
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) {
} else if (wire_node->data_string.compare(string("1")) == 0) {
if (json_debug) log_info(" Generating a constant "
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) {
} 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(),
port_name.c_str(), cell->name.c_str(),
modname.c_str());
} else
@ -526,7 +515,8 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
wire_node->data_string.c_str());
}
if (json_debug) log_info(" Inserting port \'%s\' into cell \'%s\'\n",
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;
@ -545,7 +535,8 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
}
void json_import_cell(Design *design, string modname, JsonNode *cell_node,
string cell_name) {
string cell_name)
{
JsonNode *cell_type, *param_node;
cell_type = cell_node->data_dict.at("type");
@ -559,25 +550,24 @@ void json_import_cell(Design *design, string modname, JsonNode *cell_node,
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());
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());
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);
for (int paramid = 0; paramid < GetSize(param_node->data_dict_keys);
paramid++) {
json_import_cell_attributes(design, modname, cell, param_node,
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.
@ -591,38 +581,36 @@ void json_import_cell(Design *design, string modname, JsonNode *cell_node,
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());
"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());
"dictionary\n",
cell->name.c_str(), modname.c_str());
}
JsonNode *connections
= cell_node->data_dict.at("connections");
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());
"dictionary\n",
cell->name.c_str(), modname.c_str());
if (GetSize(pdir_node->data_dict_keys)
!= GetSize(connections->data_dict_keys))
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());
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);
for (int portid = 0; portid < GetSize(pdir_node->data_dict_keys);
portid++) {
//
string port_name;
@ -633,15 +621,16 @@ void json_import_cell(Design *design, string modname, JsonNode *cell_node,
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);
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) {
void json_import(Design *design, string modname, JsonNode *node)
{
if (is_blackbox(node))
return;
@ -654,27 +643,25 @@ void json_import(Design *design, string modname, JsonNode *node) {
// Loop through all of the logic elements in a flattened design
//
//
for(int cellid=0; cellid < GetSize(cell_parent->data_dict_keys);
cellid ++) {
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 {
struct JsonFrontend
{
// JsonFrontend() : Frontend("json", "read JSON file") { }
JsonFrontend(void) { }
virtual void help()
{
}
JsonFrontend(void) {}
virtual void help() {}
virtual void execute(std::istream *&f, std::string &filename,
Design *design)
{
@ -685,8 +672,7 @@ struct JsonFrontend {
if (root.type != 'D')
log_error("JSON root node is not a dictionary.\n");
if (root.data_dict.count("modules") != 0)
{
if (root.data_dict.count("modules") != 0) {
JsonNode *modules = root.data_dict.at("modules");
if (modules->type != 'D')
@ -700,7 +686,8 @@ struct JsonFrontend {
}; // End Namespace JsonParser
void parse_json_file(std::istream *&f, std::string &filename, Design *design){
void parse_json_file(std::istream *&f, std::string &filename, Design *design)
{
auto *parser = new JsonParser::JsonFrontend();
parser->execute(f, filename, design);
}

View File

@ -20,8 +20,8 @@
#ifndef JSON_PARSER
#define JSON_PARSER
#include <string>
#include <istream>
#include <string>
#include "design.h"
extern void parse_json_file(std::istream *&, std::string &, Design *);

View File

@ -173,8 +173,13 @@ struct BelIterator
{
int cursor;
BelIterator operator++() { cursor++; return *this; }
BelIterator operator++(int) {
BelIterator operator++()
{
cursor++;
return *this;
}
BelIterator operator++(int)
{
BelIterator prior(*this);
cursor++;
return prior;

View File

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