Applied clang-format to my own contributions
This commit is contained in:
parent
a4f687548e
commit
4499864024
246
common/log.cc
246
common/log.cc
@ -17,27 +17,27 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "log.h"
|
|
||||||
#include "design.h"
|
#include "design.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
std::vector<FILE*> log_files;
|
std::vector<FILE *> log_files;
|
||||||
std::vector<std::ostream*> log_streams;
|
std::vector<std::ostream *> log_streams;
|
||||||
FILE *log_errfile = NULL;
|
FILE *log_errfile = NULL;
|
||||||
|
|
||||||
bool log_error_stderr = false;
|
bool log_error_stderr = false;
|
||||||
bool log_cmd_error_throw = false;
|
bool log_cmd_error_throw = false;
|
||||||
bool log_quiet_warnings = false;
|
bool log_quiet_warnings = false;
|
||||||
int log_verbose_level;
|
int log_verbose_level;
|
||||||
std::string log_last_error;
|
std::string log_last_error;
|
||||||
void (*log_error_atexit)() = NULL;
|
void (*log_error_atexit)() = NULL;
|
||||||
|
|
||||||
static bool next_print_log = false;
|
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 vstringf(const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
std::string string;
|
std::string string;
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int sz = 64+strlen(fmt), rc;
|
int sz = 64 + strlen(fmt), rc;
|
||||||
while (1) {
|
while (1) {
|
||||||
va_list apc;
|
va_list apc;
|
||||||
va_copy(apc, ap);
|
va_copy(apc, ap);
|
||||||
str = (char*)realloc(str, sz);
|
str = (char *)realloc(str, sz);
|
||||||
rc = vsnprintf(str, sz, fmt, apc);
|
rc = vsnprintf(str, sz, fmt, apc);
|
||||||
va_end(apc);
|
va_end(apc);
|
||||||
if (rc >= 0 && rc < sz)
|
if (rc >= 0 && rc < sz)
|
||||||
break;
|
break;
|
||||||
sz *= 2;
|
sz *= 2;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (vasprintf(&str, fmt, ap) < 0)
|
if (vasprintf(&str, fmt, ap) < 0)
|
||||||
str = NULL;
|
str = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
string = str;
|
string = str;
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void logv(const char *format, va_list ap)
|
void logv(const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Trim newlines from the beginning
|
// Trim newlines from the beginning
|
||||||
while (format[0] == '\n' && format[1] != 0) {
|
while (format[0] == '\n' && format[1] != 0) {
|
||||||
log("\n");
|
log("\n");
|
||||||
format++;
|
format++;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string str = vstringf(format, ap);
|
std::string str = vstringf(format, ap);
|
||||||
|
|
||||||
if (str.empty())
|
if (str.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
size_t nnl_pos = str.find_last_not_of('\n');
|
size_t nnl_pos = str.find_last_not_of('\n');
|
||||||
if (nnl_pos == std::string::npos)
|
if (nnl_pos == std::string::npos)
|
||||||
log_newline_count += str.size();
|
log_newline_count += str.size();
|
||||||
else
|
else
|
||||||
log_newline_count = str.size() - nnl_pos - 1;
|
log_newline_count = str.size() - nnl_pos - 1;
|
||||||
|
|
||||||
for (auto f : log_files)
|
for (auto f : log_files)
|
||||||
fputs(str.c_str(), f);
|
fputs(str.c_str(), f);
|
||||||
|
|
||||||
for (auto f : log_streams)
|
for (auto f : log_streams)
|
||||||
*f << str;
|
*f << str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void logv_info(const char *format, va_list ap)
|
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("Info: %s", message.c_str());
|
||||||
log_flush();
|
log_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void logv_warning(const char *format, va_list ap)
|
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("Warning: %s", message.c_str());
|
||||||
log_flush();
|
log_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void logv_warning_noprefix(const char *format, va_list ap)
|
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)
|
void logv_error(const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
auto backup_log_files = log_files;
|
auto backup_log_files = log_files;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (log_errfile != NULL)
|
if (log_errfile != NULL)
|
||||||
log_files.push_back(log_errfile);
|
log_files.push_back(log_errfile);
|
||||||
|
|
||||||
if (log_error_stderr)
|
if (log_error_stderr)
|
||||||
for (auto &f : log_files)
|
for (auto &f : log_files)
|
||||||
if (f == stdout)
|
if (f == stdout)
|
||||||
f = stderr;
|
f = stderr;
|
||||||
|
|
||||||
log_last_error = vstringf(format, ap);
|
log_last_error = vstringf(format, ap);
|
||||||
log("ERROR: %s", log_last_error.c_str());
|
log("ERROR: %s", log_last_error.c_str());
|
||||||
log_flush();
|
log_flush();
|
||||||
|
|
||||||
if (log_error_atexit)
|
if (log_error_atexit)
|
||||||
log_error_atexit();
|
log_error_atexit();
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
log_files = backup_log_files;
|
log_files = backup_log_files;
|
||||||
throw 0;
|
throw 0;
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
#else
|
#else
|
||||||
_Exit(EXIT_FAILURE);
|
_Exit(EXIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(const char *format, ...)
|
void log(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
logv(format, ap);
|
logv(format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_info(const char *format, ...)
|
void log_info(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
logv_info(format, ap);
|
logv_info(format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_warning(const char *format, ...)
|
void log_warning(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
logv_warning(format, ap);
|
logv_warning(format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_warning_noprefix(const char *format, ...)
|
void log_warning_noprefix(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
logv_warning_noprefix(format, ap);
|
logv_warning_noprefix(format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_error(const char *format, ...)
|
void log_error(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
logv_error(format, ap);
|
logv_error(format, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_cmd_error(const char *format, ...)
|
void log_cmd_error(const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
|
||||||
if (log_cmd_error_throw) {
|
if (log_cmd_error_throw) {
|
||||||
log_last_error = vstringf(format, ap);
|
log_last_error = vstringf(format, ap);
|
||||||
log("ERROR: %s", log_last_error.c_str());
|
log("ERROR: %s", log_last_error.c_str());
|
||||||
log_flush();
|
log_flush();
|
||||||
throw log_cmd_error_exception();
|
throw log_cmd_error_exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
logv_error(format, ap);
|
logv_error(format, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_spacer()
|
void log_spacer()
|
||||||
{
|
{
|
||||||
if (log_newline_count < 2) log("\n");
|
if (log_newline_count < 2)
|
||||||
if (log_newline_count < 2) log("\n");
|
log("\n");
|
||||||
|
if (log_newline_count < 2)
|
||||||
|
log("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_push()
|
void log_push() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_pop()
|
void log_pop() { log_flush(); }
|
||||||
{
|
|
||||||
log_flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_reset_stack()
|
void log_reset_stack() { log_flush(); }
|
||||||
{
|
|
||||||
log_flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_flush()
|
void log_flush()
|
||||||
{
|
{
|
||||||
for (auto f : log_files)
|
for (auto f : log_files)
|
||||||
fflush(f);
|
fflush(f);
|
||||||
|
|
||||||
for (auto f : log_streams)
|
for (auto f : log_streams)
|
||||||
f->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) {}
|
||||||
|
59
common/log.h
59
common/log.h
@ -21,38 +21,40 @@
|
|||||||
#define LOG_H
|
#define LOG_H
|
||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <ostream>
|
||||||
|
#include <set>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
|
||||||
#include <ostream>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include "design.h"
|
#include "design.h"
|
||||||
|
|
||||||
// from libs/sha1/sha1.h
|
// from libs/sha1/sha1.h
|
||||||
|
|
||||||
#define NXP_NORETURN
|
#define NXP_NORETURN
|
||||||
#define NXP_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
|
#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<FILE *> log_files;
|
||||||
extern std::vector<std::ostream*> log_streams;
|
extern std::vector<std::ostream *> log_streams;
|
||||||
extern FILE *log_errfile;
|
extern FILE *log_errfile;
|
||||||
|
|
||||||
extern bool log_quiet_warnings;
|
extern bool log_quiet_warnings;
|
||||||
extern int log_verbose_level;
|
extern int log_verbose_level;
|
||||||
extern std::string log_last_error;
|
extern std::string log_last_error;
|
||||||
extern void (*log_error_atexit)();
|
extern void (*log_error_atexit)();
|
||||||
|
|
||||||
void logv(const char *format, va_list ap);
|
void logv(const char *format, va_list ap);
|
||||||
void logv_warning(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);
|
void logv_warning_noprefix(const char *format, va_list ap);
|
||||||
NXP_NORETURN void logv_error(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(const char *format, ...);
|
||||||
void log_header(const char *format, ...);
|
void log_header(const char *format, ...);
|
||||||
void log_info(const char *format, ...);
|
void log_info(const char *format, ...);
|
||||||
@ -73,24 +75,29 @@ void log_flush();
|
|||||||
const char *log_id(RTLIL::IdString id);
|
const char *log_id(RTLIL::IdString id);
|
||||||
|
|
||||||
template<typename T> static inline const char *log_id(T *obj) {
|
template<typename T> 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_cell(CellInfo *cell, std::string indent = "");
|
||||||
void log_net(NetInfo *net, std::string indent = "");
|
void log_net(NetInfo *net, std::string indent = "");
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
static inline void log_assert_worker(bool cond, const char *expr, const char *file, int line) {
|
static inline void log_assert_worker(bool cond, const char *expr,
|
||||||
if (!cond) log_error("Assert `%s' failed in %s:%d.\n", expr, file, line);
|
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
|
#else
|
||||||
# define log_assert(_assert_expr_)
|
#define log_assert(_assert_expr_)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define log_abort() log_error("Abort in %s:%d.\n", __FILE__, __LINE__)
|
#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
|
#endif
|
||||||
|
@ -18,63 +18,64 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ostream>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <ostream>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "log.h"
|
|
||||||
#include "design.h"
|
#include "design.h"
|
||||||
|
#include "log.h"
|
||||||
#include "place.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<IdString> types_used;
|
||||||
std::set<BelType> used_bels;
|
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;
|
CellInfo *cell = cell_entry.second;
|
||||||
BelType bel_type;
|
BelType bel_type;
|
||||||
|
|
||||||
element = types_used.find(cell->type);
|
element = types_used.find(cell->type);
|
||||||
if (element != types_used.end()) {
|
if (element != types_used.end()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bel_type = belTypeFromId(cell->type);
|
bel_type = belTypeFromId(cell->type);
|
||||||
if (bel_type == BelType()) {
|
if (bel_type == BelType()) {
|
||||||
log_error("No Bel of type \'%s\' defined for "
|
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;
|
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();
|
auto blist = design->chip.getBels();
|
||||||
BelType bel_type = belTypeFromId(bel_type_name);
|
BelType bel_type = belTypeFromId(bel_type_name);
|
||||||
auto bi = blist.begin();
|
auto bi = blist.begin();
|
||||||
|
|
||||||
for(auto cell_entry : design->cells) {
|
for (auto cell_entry : design->cells) {
|
||||||
CellInfo *cell = cell_entry.second;
|
CellInfo *cell = cell_entry.second;
|
||||||
|
|
||||||
// Only place one type of Bel at a time
|
// 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;
|
continue;
|
||||||
|
|
||||||
while((bi != blist.end())
|
while ((bi != blist.end()) &&
|
||||||
&&(design->chip.getBelType(*bi) != bel_type))
|
(design->chip.getBelType(*bi) != bel_type))
|
||||||
bi++;
|
bi++;
|
||||||
if (bi == blist.end())
|
if (bi == blist.end())
|
||||||
log_error("Too many \'%s\' used in design\n",
|
log_error("Too many \'%s\' used in design\n",
|
||||||
cell->type.c_str());
|
cell->type.c_str());
|
||||||
cell->bel = *bi++;
|
cell->bel = *bi++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef PLACE_H
|
#ifndef PLACE_H
|
||||||
#define PLACE_H
|
#define PLACE_H
|
||||||
|
|
||||||
#include "design.h"
|
#include "design.h"
|
||||||
|
|
||||||
extern void place_design(Design *design);
|
extern void place_design(Design *design);
|
||||||
|
|
||||||
#endif // PLACE_H
|
#endif // PLACE_H
|
||||||
|
@ -1,68 +1,72 @@
|
|||||||
#include <string>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <string>
|
||||||
#include "design.h"
|
#include "design.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
bool check_all_nets_driven(Design *design) {
|
bool check_all_nets_driven(Design *design)
|
||||||
const bool debug = false;
|
{
|
||||||
|
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) {
|
for (auto cell_entry : design->cells) {
|
||||||
CellInfo *cell = cell_entry.second;
|
CellInfo *cell = cell_entry.second;
|
||||||
|
|
||||||
if (debug) log_info(" Examining cell \'%s\', of type \'%s\'\n",
|
if (debug)
|
||||||
cell->name.c_str(),
|
log_info(" Examining cell \'%s\', of type \'%s\'\n",
|
||||||
cell->type.c_str());
|
cell->name.c_str(), cell->type.c_str());
|
||||||
for(auto port_entry : cell->ports) {
|
for (auto port_entry : cell->ports) {
|
||||||
PortInfo &port = port_entry.second;
|
PortInfo &port = port_entry.second;
|
||||||
|
|
||||||
if (debug) log_info(" Checking name of port \'%s\' "
|
if (debug)
|
||||||
"against \'%s\'\n",
|
log_info(" Checking name of port \'%s\' "
|
||||||
port_entry.first.c_str(),
|
"against \'%s\'\n",
|
||||||
port.name.c_str());
|
port_entry.first.c_str(), port.name.c_str());
|
||||||
assert(port.name.compare(port_entry.first)==0);
|
assert(port.name.compare(port_entry.first) == 0);
|
||||||
assert(port.name.size() > 0);
|
assert(port.name.size() > 0);
|
||||||
|
|
||||||
if (port.net == NULL) {
|
if (port.net == NULL) {
|
||||||
if (debug) log_warning(" Port \'%s\' in cell \'%s\' is unconnected\n",
|
if (debug)
|
||||||
port.name.c_str(), cell->name.c_str());
|
log_warning(
|
||||||
} else {
|
" Port \'%s\' in cell \'%s\' is unconnected\n",
|
||||||
assert(port.net);
|
port.name.c_str(), cell->name.c_str());
|
||||||
if (debug) log_info(" Checking for a net named \'%s\'\n",
|
} else {
|
||||||
port.net->name.c_str());
|
assert(port.net);
|
||||||
assert(design->nets.count(port.net->name)>0);
|
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) {
|
for (auto net_entry : design->nets) {
|
||||||
NetInfo *net = net_entry.second;
|
NetInfo *net = net_entry.second;
|
||||||
|
|
||||||
assert(net->name.compare(net_entry.first) == 0);
|
assert(net->name.compare(net_entry.first) == 0);
|
||||||
if ((net->driver.cell != NULL)
|
if ((net->driver.cell != NULL) &&
|
||||||
&&(net->driver.cell->type.compare("GND") != 0)
|
(net->driver.cell->type.compare("GND") != 0) &&
|
||||||
&&(net->driver.cell->type.compare("VCC") != 0)) {
|
(net->driver.cell->type.compare("VCC") != 0)) {
|
||||||
|
|
||||||
if (debug) log_info(" Checking for a driver cell named \'%s\'\n",
|
if (debug)
|
||||||
net->driver.cell->name.c_str());
|
log_info(" Checking for a driver cell named \'%s\'\n",
|
||||||
assert(design->cells.count(net->driver.cell->name) >0);
|
net->driver.cell->name.c_str());
|
||||||
}
|
assert(design->cells.count(net->driver.cell->name) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
for(auto user : net->users) {
|
for (auto user : net->users) {
|
||||||
if ((user.cell != NULL)
|
if ((user.cell != NULL) && (user.cell->type.compare("GND") != 0) &&
|
||||||
&&(user.cell->type.compare("GND") != 0)
|
(user.cell->type.compare("VCC") != 0)) {
|
||||||
&&(user.cell->type.compare("VCC") != 0)) {
|
|
||||||
|
|
||||||
if (debug) log_info(" Checking for a user cell named \'%s\'\n",
|
if (debug)
|
||||||
user.cell->name.c_str());
|
log_info(" Checking for a user cell named \'%s\'\n",
|
||||||
assert(design->cells.count(user.cell->name) >0);
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -17,13 +17,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef JSON_PARSER
|
#ifndef JSON_PARSER
|
||||||
#define JSON_PARSER
|
#define JSON_PARSER
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
#include <string>
|
||||||
#include "design.h"
|
#include "design.h"
|
||||||
|
|
||||||
extern void parse_json_file(std::istream *&, std::string &, Design *);
|
extern void parse_json_file(std::istream *&, std::string &, Design *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
17
ice40/chip.h
17
ice40/chip.h
@ -173,12 +173,17 @@ struct BelIterator
|
|||||||
{
|
{
|
||||||
int cursor;
|
int cursor;
|
||||||
|
|
||||||
BelIterator operator++() { cursor++; return *this; }
|
BelIterator operator++()
|
||||||
BelIterator operator++(int) {
|
{
|
||||||
BelIterator prior(*this);
|
cursor++;
|
||||||
cursor++;
|
return *this;
|
||||||
return prior;
|
}
|
||||||
}
|
BelIterator operator++(int)
|
||||||
|
{
|
||||||
|
BelIterator prior(*this);
|
||||||
|
cursor++;
|
||||||
|
return prior;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator!=(const BelIterator &other) const
|
bool operator!=(const BelIterator &other) const
|
||||||
{
|
{
|
||||||
|
@ -23,11 +23,11 @@
|
|||||||
#include "design.h"
|
#include "design.h"
|
||||||
#include "jsonparse.h"
|
#include "jsonparse.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "log.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "place.h"
|
||||||
#include "pybindings.h"
|
#include "pybindings.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "log.h"
|
|
||||||
#include "place.h"
|
|
||||||
|
|
||||||
void svg_dump_el(const GraphicElement &el)
|
void svg_dump_el(const GraphicElement &el)
|
||||||
{
|
{
|
||||||
@ -244,7 +244,7 @@ int main(int argc, char *argv[])
|
|||||||
std::istream *f = new std::ifstream(filename);
|
std::istream *f = new std::ifstream(filename);
|
||||||
|
|
||||||
parse_json_file(f, filename, &design);
|
parse_json_file(f, filename, &design);
|
||||||
place_design(&design);
|
place_design(&design);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("run")) {
|
if (vm.count("run")) {
|
||||||
@ -254,7 +254,6 @@ int main(int argc, char *argv[])
|
|||||||
execute_python_file(filename.c_str());
|
execute_python_file(filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (vm.count("gui")) {
|
if (vm.count("gui")) {
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
Loading…
Reference in New Issue
Block a user