Applied clang-format to my own contributions
This commit is contained in:
parent
a4f687548e
commit
4499864024
@ -17,17 +17,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#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;
|
||||
@ -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) {}
|
||||
|
27
common/log.h
27
common/log.h
@ -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,7 +35,9 @@
|
||||
#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;
|
||||
@ -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_)
|
||||
#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
|
||||
|
@ -18,21 +18,22 @@
|
||||
*/
|
||||
|
||||
#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;
|
||||
@ -49,7 +50,8 @@ 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;
|
||||
@ -67,8 +69,8 @@ void place_design(Design *design) {
|
||||
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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
#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");
|
||||
@ -11,25 +12,28 @@ bool check_all_nets_driven(Design *design) {
|
||||
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());
|
||||
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());
|
||||
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);
|
||||
}
|
||||
@ -40,29 +44,29 @@ bool check_all_nets_driven(Design *design) {
|
||||
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);
|
||||
}
|
||||
|
||||
for (auto user : net->users) {
|
||||
if ((user.cell != NULL)
|
||||
&&(user.cell->type.compare("GND") != 0)
|
||||
&&(user.cell->type.compare("VCC") != 0)) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (debug) log_info(" Verified!\n");
|
||||
if (debug)
|
||||
log_info(" Verified!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -21,14 +21,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#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);
|
||||
|
||||
@ -40,7 +40,6 @@ namespace JsonParser {
|
||||
|
||||
template <typename T> int GetSize(const T &obj) { return obj.size(); }
|
||||
|
||||
|
||||
struct JsonNode
|
||||
{
|
||||
char type; // S=String, N=Number, A=Array, D=Dict
|
||||
@ -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,7 +294,8 @@ 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)
|
||||
@ -338,39 +320,44 @@ bool is_blackbox(JsonNode *node) {
|
||||
}
|
||||
|
||||
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)
|
||||
@ -396,8 +383,7 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
|
||||
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
|
||||
@ -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,7 +466,8 @@ 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)
|
||||
@ -497,27 +487,26 @@ void json_import_cell_ports(Design *design, string &modname, CellInfo *cell,
|
||||
|
||||
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,12 +550,13 @@ 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
|
||||
@ -573,11 +565,9 @@ void json_import_cell(Design *design, string modname, JsonNode *cell_node,
|
||||
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,33 +581,31 @@ 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
|
||||
@ -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;
|
||||
|
||||
@ -662,19 +651,17 @@ void json_import(Design *design, string modname, JsonNode *node) {
|
||||
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()
|
||||
{
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -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 *);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user