mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Merge branch 'win32'
This commit is contained in:
commit
8cea352a6a
8
frontends/ilang/.gitignore
vendored
8
frontends/ilang/.gitignore
vendored
|
@ -1,4 +1,4 @@
|
||||||
lexer.cc
|
ilang_lexer.cc
|
||||||
parser.output
|
ilang_parser.output
|
||||||
parser.tab.cc
|
ilang_parser.tab.cc
|
||||||
parser.tab.h
|
ilang_parser.tab.h
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
|
|
||||||
GENFILES += frontends/ilang/parser.tab.cc
|
GENFILES += frontends/ilang/ilang_parser.tab.cc
|
||||||
GENFILES += frontends/ilang/parser.tab.h
|
GENFILES += frontends/ilang/ilang_parser.tab.h
|
||||||
GENFILES += frontends/ilang/parser.output
|
GENFILES += frontends/ilang/ilang_parser.output
|
||||||
GENFILES += frontends/ilang/lexer.cc
|
GENFILES += frontends/ilang/ilang_lexer.cc
|
||||||
|
|
||||||
frontends/ilang/parser.tab.cc: frontends/ilang/parser.y
|
frontends/ilang/ilang_parser.tab.cc: frontends/ilang/ilang_parser.y
|
||||||
$(P) bison -d -r all -b frontends/ilang/parser frontends/ilang/parser.y
|
$(P) bison -d -r all -b frontends/ilang/ilang_parser frontends/ilang/ilang_parser.y
|
||||||
$(Q) mv frontends/ilang/parser.tab.c frontends/ilang/parser.tab.cc
|
$(Q) mv frontends/ilang/ilang_parser.tab.c frontends/ilang/ilang_parser.tab.cc
|
||||||
|
|
||||||
frontends/ilang/parser.tab.h: frontends/ilang/parser.tab.cc
|
frontends/ilang/ilang_parser.tab.h: frontends/ilang/ilang_parser.tab.cc
|
||||||
|
|
||||||
frontends/ilang/lexer.cc: frontends/ilang/lexer.l
|
frontends/ilang/ilang_lexer.cc: frontends/ilang/ilang_lexer.l
|
||||||
$(P) flex -o frontends/ilang/lexer.cc frontends/ilang/lexer.l
|
$(P) flex -o frontends/ilang/ilang_lexer.cc frontends/ilang/ilang_lexer.l
|
||||||
|
|
||||||
OBJS += frontends/ilang/parser.tab.o frontends/ilang/lexer.o
|
OBJS += frontends/ilang/ilang_parser.tab.o frontends/ilang/ilang_lexer.o
|
||||||
OBJS += frontends/ilang/ilang_frontend.o
|
OBJS += frontends/ilang/ilang_frontend.o
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,16 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ilang_frontend.h"
|
#include "ilang_frontend.h"
|
||||||
#include "parser.tab.h"
|
#include "ilang_parser.tab.h"
|
||||||
|
|
||||||
USING_YOSYS_NAMESPACE
|
USING_YOSYS_NAMESPACE
|
||||||
|
|
||||||
#define YY_INPUT(buf,result,max_size) \
|
#define YY_INPUT(buf,result,max_size) \
|
||||||
result = readsome(*ILANG_FRONTEND::lexin, buf, max_size);
|
do { \
|
||||||
|
ILANG_FRONTEND::lexin->read(buf, max_size-1); \
|
||||||
|
result = ILANG_FRONTEND::lexin->gcount(); \
|
||||||
|
if (result >= 0) buf[result] = '\0'; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
8
frontends/verilog/.gitignore
vendored
8
frontends/verilog/.gitignore
vendored
|
@ -1,4 +1,4 @@
|
||||||
lexer.cc
|
verilog_lexer.cc
|
||||||
parser.output
|
verilog_parser.output
|
||||||
parser.tab.cc
|
verilog_parser.tab.cc
|
||||||
parser.tab.h
|
verilog_parser.tab.h
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
|
|
||||||
GENFILES += frontends/verilog/parser.tab.cc
|
GENFILES += frontends/verilog/verilog_parser.tab.cc
|
||||||
GENFILES += frontends/verilog/parser.tab.h
|
GENFILES += frontends/verilog/verilog_parser.tab.h
|
||||||
GENFILES += frontends/verilog/parser.output
|
GENFILES += frontends/verilog/verilog_parser.output
|
||||||
GENFILES += frontends/verilog/lexer.cc
|
GENFILES += frontends/verilog/verilog_lexer.cc
|
||||||
|
|
||||||
frontends/verilog/parser.tab.cc: frontends/verilog/parser.y
|
frontends/verilog/verilog_parser.tab.cc: frontends/verilog/verilog_parser.y
|
||||||
$(P) bison -d -r all -b frontends/verilog/parser frontends/verilog/parser.y
|
$(P) bison -d -r all -b frontends/verilog/verilog_parser frontends/verilog/verilog_parser.y
|
||||||
$(Q) mv frontends/verilog/parser.tab.c frontends/verilog/parser.tab.cc
|
$(Q) mv frontends/verilog/verilog_parser.tab.c frontends/verilog/verilog_parser.tab.cc
|
||||||
|
|
||||||
frontends/verilog/parser.tab.h: frontends/verilog/parser.tab.cc
|
frontends/verilog/verilog_parser.tab.h: frontends/verilog/verilog_parser.tab.cc
|
||||||
|
|
||||||
frontends/verilog/lexer.cc: frontends/verilog/lexer.l
|
frontends/verilog/verilog_lexer.cc: frontends/verilog/verilog_lexer.l
|
||||||
$(P) flex -o frontends/verilog/lexer.cc frontends/verilog/lexer.l
|
$(P) flex -o frontends/verilog/verilog_lexer.cc frontends/verilog/verilog_lexer.l
|
||||||
|
|
||||||
OBJS += frontends/verilog/parser.tab.o
|
OBJS += frontends/verilog/verilog_parser.tab.o
|
||||||
OBJS += frontends/verilog/lexer.o
|
OBJS += frontends/verilog/verilog_lexer.o
|
||||||
OBJS += frontends/verilog/preproc.o
|
OBJS += frontends/verilog/preproc.o
|
||||||
OBJS += frontends/verilog/verilog_frontend.o
|
OBJS += frontends/verilog/verilog_frontend.o
|
||||||
OBJS += frontends/verilog/const2ast.o
|
OBJS += frontends/verilog/const2ast.o
|
||||||
|
|
|
@ -196,14 +196,16 @@ static std::string next_token(bool pass_newline = false)
|
||||||
static void input_file(std::istream &f, std::string filename)
|
static void input_file(std::istream &f, std::string filename)
|
||||||
{
|
{
|
||||||
char buffer[513];
|
char buffer[513];
|
||||||
int rc;
|
|
||||||
|
|
||||||
insert_input("");
|
insert_input("");
|
||||||
auto it = input_buffer.begin();
|
auto it = input_buffer.begin();
|
||||||
|
|
||||||
input_buffer.insert(it, "`file_push " + filename + "\n");
|
input_buffer.insert(it, "`file_push " + filename + "\n");
|
||||||
while ((rc = readsome(f, buffer, sizeof(buffer)-1)) > 0) {
|
while (1) {
|
||||||
buffer[rc] = 0;
|
f.read(buffer, sizeof(buffer)-1);
|
||||||
|
if (f.gcount() <= 0)
|
||||||
|
break;
|
||||||
|
buffer[f.gcount()] = 0;
|
||||||
input_buffer.insert(it, buffer);
|
input_buffer.insert(it, buffer);
|
||||||
}
|
}
|
||||||
input_buffer.insert(it, "\n`file_pop\n");
|
input_buffer.insert(it, "\n`file_pop\n");
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "kernel/log.h"
|
#include "kernel/log.h"
|
||||||
#include "verilog_frontend.h"
|
#include "verilog_frontend.h"
|
||||||
#include "frontends/ast/ast.h"
|
#include "frontends/ast/ast.h"
|
||||||
#include "parser.tab.h"
|
#include "verilog_parser.tab.h"
|
||||||
|
|
||||||
USING_YOSYS_NAMESPACE
|
USING_YOSYS_NAMESPACE
|
||||||
using namespace AST;
|
using namespace AST;
|
||||||
|
@ -64,7 +64,11 @@ YOSYS_NAMESPACE_END
|
||||||
return TOK_ID;
|
return TOK_ID;
|
||||||
|
|
||||||
#define YY_INPUT(buf,result,max_size) \
|
#define YY_INPUT(buf,result,max_size) \
|
||||||
result = readsome(*lexin, buf, max_size);
|
do { \
|
||||||
|
lexin->read(buf, max_size-1); \
|
||||||
|
result = lexin->gcount(); \
|
||||||
|
if (result >= 0) buf[result] = '\0'; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -21,7 +21,10 @@
|
||||||
#include "libs/sha1/sha1.h"
|
#include "libs/sha1/sha1.h"
|
||||||
#include "backends/ilang/ilang_backend.h"
|
#include "backends/ilang/ilang_backend.h"
|
||||||
|
|
||||||
#include <sys/time.h>
|
#ifndef _WIN32
|
||||||
|
# include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -48,6 +51,26 @@ static struct timeval initial_tv = { 0, 0 };
|
||||||
static bool next_print_log = false;
|
static bool next_print_log = false;
|
||||||
static int log_newline_count = 0;
|
static int log_newline_count = 0;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// this will get time information and return it in timeval, simulating gettimeofday()
|
||||||
|
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER counter;
|
||||||
|
LARGE_INTEGER freq;
|
||||||
|
|
||||||
|
QueryPerformanceFrequency(&freq);
|
||||||
|
QueryPerformanceCounter(&counter);
|
||||||
|
|
||||||
|
counter.QuadPart *= 1000000;
|
||||||
|
counter.QuadPart /= freq.QuadPart;
|
||||||
|
|
||||||
|
tv->tv_sec = counter.QuadPart / 1000000;
|
||||||
|
tv->tv_usec = counter.QuadPart % 1000000;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void logv(const char *format, va_list ap)
|
void logv(const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
while (format[0] == '\n' && format[1] != 0) {
|
while (format[0] == '\n' && format[1] != 0) {
|
||||||
|
|
12
kernel/log.h
12
kernel/log.h
|
@ -23,9 +23,9 @@
|
||||||
#define LOG_H
|
#define LOG_H
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
# include <sys/time.h>
|
||||||
# include <sys/resource.h>
|
# include <sys/resource.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ extern int log_verbose_level;
|
||||||
|
|
||||||
void logv(const char *format, va_list ap);
|
void logv(const char *format, va_list ap);
|
||||||
void logv_header(const char *format, va_list ap);
|
void logv_header(const char *format, va_list ap);
|
||||||
void logv_error(const char *format, va_list ap) __attribute__ ((noreturn));
|
|
||||||
|
|
||||||
void log(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
|
void logv_error(const char *format, va_list ap) __attribute__((noreturn));
|
||||||
void log_header(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
|
void log(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
||||||
void log_error(const char *format, ...) __attribute__ ((format (printf, 1, 2))) __attribute__ ((noreturn));
|
void log_header(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
||||||
void log_cmd_error(const char *format, ...) __attribute__ ((format (printf, 1, 2))) __attribute__ ((noreturn));
|
void log_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn));
|
||||||
|
void log_cmd_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn));
|
||||||
|
|
||||||
void log_spacer();
|
void log_spacer();
|
||||||
void log_push();
|
void log_push();
|
||||||
|
|
|
@ -920,23 +920,25 @@ struct RTLIL::SigBit
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RTLIL::SigSpecIterator
|
struct RTLIL::SigSpecIterator : public std::iterator<std::input_iterator_tag, RTLIL::SigSpec>
|
||||||
{
|
{
|
||||||
RTLIL::SigSpec *sig_p;
|
RTLIL::SigSpec *sig_p;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
inline RTLIL::SigBit &operator*() const;
|
inline RTLIL::SigBit &operator*() const;
|
||||||
inline bool operator!=(const RTLIL::SigSpecIterator &other) const { return index != other.index; }
|
inline bool operator!=(const RTLIL::SigSpecIterator &other) const { return index != other.index; }
|
||||||
|
inline bool operator==(const RTLIL::SigSpecIterator &other) const { return index == other.index; }
|
||||||
inline void operator++() { index++; }
|
inline void operator++() { index++; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RTLIL::SigSpecConstIterator
|
struct RTLIL::SigSpecConstIterator : public std::iterator<std::input_iterator_tag, RTLIL::SigSpec>
|
||||||
{
|
{
|
||||||
const RTLIL::SigSpec *sig_p;
|
const RTLIL::SigSpec *sig_p;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
inline const RTLIL::SigBit &operator*() const;
|
inline const RTLIL::SigBit &operator*() const;
|
||||||
inline bool operator!=(const RTLIL::SigSpecConstIterator &other) const { return index != other.index; }
|
inline bool operator!=(const RTLIL::SigSpecConstIterator &other) const { return index != other.index; }
|
||||||
|
inline bool operator==(const RTLIL::SigSpecIterator &other) const { return index == other.index; }
|
||||||
inline void operator++() { index++; }
|
inline void operator++() { index++; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -172,22 +172,6 @@ bool patmatch(const char *pattern, const char *string)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int readsome(std::istream &f, char *s, int n)
|
|
||||||
{
|
|
||||||
int rc = f.readsome(s, n);
|
|
||||||
|
|
||||||
// win32 sometimes returns 0 on a non-empty stream..
|
|
||||||
if (rc == 0) {
|
|
||||||
int c = f.get();
|
|
||||||
if (c != EOF) {
|
|
||||||
*s = c;
|
|
||||||
rc = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
int run_command(const std::string &command, std::function<void(const std::string&)> process_line)
|
int run_command(const std::string &command, std::function<void(const std::string&)> process_line)
|
||||||
{
|
{
|
||||||
if (!process_line)
|
if (!process_line)
|
||||||
|
|
|
@ -58,6 +58,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef _YOSYS_
|
||||||
|
# error It looks like you are trying to build Yosys with the config defines set. \
|
||||||
|
When building Yosys with a custom make system, make sure you set all the \
|
||||||
|
defines the Yosys Makefile would set for your build configuration.
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef YOSYS_ENABLE_TCL
|
#ifdef YOSYS_ENABLE_TCL
|
||||||
# include <tcl.h>
|
# include <tcl.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -77,6 +83,10 @@
|
||||||
# define FINAL
|
# define FINAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__GNUC__) && !defined(__clang__)
|
||||||
|
# define __attribute__(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
YOSYS_NAMESPACE_BEGIN
|
YOSYS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
namespace RTLIL {
|
namespace RTLIL {
|
||||||
|
@ -90,7 +100,6 @@ std::string stringf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))
|
||||||
std::string vstringf(const char *fmt, va_list ap);
|
std::string vstringf(const char *fmt, va_list ap);
|
||||||
std::string next_token(std::string &text, const char *sep);
|
std::string next_token(std::string &text, const char *sep);
|
||||||
bool patmatch(const char *pattern, const char *string);
|
bool patmatch(const char *pattern, const char *string);
|
||||||
int readsome(std::istream &f, char *s, int n);
|
|
||||||
int run_command(const std::string &command, std::function<void(const std::string&)> process_line = std::function<void(const std::string&)>());
|
int run_command(const std::string &command, std::function<void(const std::string&)> process_line = std::function<void(const std::string&)>());
|
||||||
std::string make_temp_file(std::string template_str = "/tmp/yosys_XXXXXX");
|
std::string make_temp_file(std::string template_str = "/tmp/yosys_XXXXXX");
|
||||||
std::string make_temp_dir(std::string template_str = "/tmp/yosys_XXXXXX");
|
std::string make_temp_dir(std::string template_str = "/tmp/yosys_XXXXXX");
|
||||||
|
|
|
@ -256,9 +256,12 @@ void SHA1::buffer_to_block(const std::string &buffer, uint32 block[BLOCK_BYTES])
|
||||||
|
|
||||||
void SHA1::read(std::istream &is, std::string &s, int max)
|
void SHA1::read(std::istream &is, std::string &s, int max)
|
||||||
{
|
{
|
||||||
char sbuf[max];
|
char* sbuf = new char[max];
|
||||||
|
|
||||||
is.read(sbuf, max);
|
is.read(sbuf, max);
|
||||||
s.assign(sbuf, is.gcount());
|
s.assign(sbuf, is.gcount());
|
||||||
|
|
||||||
|
delete[] sbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,10 +68,13 @@ struct WriteFileFrontend : public Frontend {
|
||||||
|
|
||||||
FILE *of = fopen(output_filename.c_str(), append_mode ? "a" : "w");
|
FILE *of = fopen(output_filename.c_str(), append_mode ? "a" : "w");
|
||||||
char buffer[64 * 1024];
|
char buffer[64 * 1024];
|
||||||
size_t bytes;
|
|
||||||
|
|
||||||
while (0 < (bytes = readsome(*f, buffer, sizeof(buffer))))
|
while (1) {
|
||||||
fwrite(buffer, bytes, 1, of);
|
f->read(buffer, sizeof(buffer));
|
||||||
|
if (f->gcount() <= 0)
|
||||||
|
break;
|
||||||
|
fwrite(buffer, f->gcount(), 1, of);
|
||||||
|
}
|
||||||
|
|
||||||
fclose(of);
|
fclose(of);
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,7 +342,7 @@ struct FsmOptPass : public Pass {
|
||||||
for (auto &mod_it : design->modules_) {
|
for (auto &mod_it : design->modules_) {
|
||||||
if (design->selected(mod_it.second))
|
if (design->selected(mod_it.second))
|
||||||
for (auto &cell_it : mod_it.second->cells_)
|
for (auto &cell_it : mod_it.second->cells_)
|
||||||
if (cell_it.second->type == "$fsm" and design->selected(mod_it.second, cell_it.second))
|
if (cell_it.second->type == "$fsm" && design->selected(mod_it.second, cell_it.second))
|
||||||
FsmData::optimize_fsm(cell_it.second, mod_it.second);
|
FsmData::optimize_fsm(cell_it.second, mod_it.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ struct WreduceConfig
|
||||||
|
|
||||||
WreduceConfig()
|
WreduceConfig()
|
||||||
{
|
{
|
||||||
supported_cell_types = {
|
supported_cell_types = std::set<IdString>({
|
||||||
"$not", "$pos", "$neg",
|
"$not", "$pos", "$neg",
|
||||||
"$and", "$or", "$xor", "$xnor",
|
"$and", "$or", "$xor", "$xnor",
|
||||||
"$shl", "$shr", "$sshl", "$sshr", "$shift", "$shiftx",
|
"$shl", "$shr", "$sshl", "$sshr", "$shift", "$shiftx",
|
||||||
"$lt", "$le", "$eq", "$ne", "$eqx", "$nex", "$ge", "$gt",
|
"$lt", "$le", "$eq", "$ne", "$eqx", "$nex", "$ge", "$gt",
|
||||||
"$add", "$sub", // "$mul", "$div", "$mod", "$pow",
|
"$add", "$sub", // "$mul", "$div", "$mod", "$pow",
|
||||||
"$mux", "$pmux"
|
"$mux", "$pmux"
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue