mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-20 14:15:49 +00:00
Merge remote-tracking branch 'upstream' into merge3
This commit is contained in:
commit
3783a820ee
655 changed files with 11031 additions and 9437 deletions
|
|
@ -406,7 +406,7 @@ void AigerReader::parse_xaiger()
|
|||
module->connect(n0, State::S0);
|
||||
|
||||
int c = f.get();
|
||||
if (c != 'c')
|
||||
if (c != 'c') // 'c'omment section (used for extensions)
|
||||
log_error("Line %u: cannot interpret first character '%c'!\n", line_count, c);
|
||||
if (f.peek() == '\n')
|
||||
f.get();
|
||||
|
|
@ -415,7 +415,7 @@ void AigerReader::parse_xaiger()
|
|||
std::string s;
|
||||
for (int c = f.get(); c != EOF; c = f.get()) {
|
||||
// XAIGER extensions
|
||||
if (c == 'm') {
|
||||
if (c == 'm') { // LUT 'm'apping
|
||||
uint32_t dataSize = parse_xaiger_literal(f);
|
||||
uint32_t lutNum = parse_xaiger_literal(f);
|
||||
uint32_t lutSize = parse_xaiger_literal(f);
|
||||
|
|
@ -461,7 +461,83 @@ void AigerReader::parse_xaiger()
|
|||
module->addLut(stringf("$lut$aiger%d$%d", aiger_autoidx, rootNodeID), input_sig, output_sig, std::move(lut_mask));
|
||||
}
|
||||
}
|
||||
else if (c == 'r') {
|
||||
else if (c == 'M') { // cell 'M'apping
|
||||
struct MappingCell {
|
||||
RTLIL::IdString type;
|
||||
RTLIL::IdString out;
|
||||
std::vector<RTLIL::IdString> ins;
|
||||
};
|
||||
std::vector<MappingCell> mapping_cells;
|
||||
|
||||
/* uint32_t dataSize = */ (void)parse_xaiger_literal(f);
|
||||
uint32_t cellNum = parse_xaiger_literal(f);
|
||||
uint32_t instanceNum = parse_xaiger_literal(f);
|
||||
log_debug2("M: dataSize=%u cellNum=%u instanceNum=%u\n", dataSize, cellNum, instanceNum);
|
||||
|
||||
for (unsigned i = 0; i < cellNum; ++i) {
|
||||
MappingCell mapping_cell{};
|
||||
auto cellName = std::string{}; // name of cell
|
||||
auto outPinName = std::string{}; // name of cell output pin
|
||||
std::getline(f, cellName, '\0');
|
||||
std::getline(f, outPinName, '\0');
|
||||
uint32_t inPinNum = parse_xaiger_literal(f);
|
||||
log_debug2("M: cellID=%u cellName=%s outPinName=%s inPinNum=%u\n", i, cellName, outPinName, inPinNum);
|
||||
mapping_cell.type = RTLIL::escape_id(cellName);
|
||||
mapping_cell.out = RTLIL::escape_id(outPinName);
|
||||
|
||||
auto module = design->addModule(RTLIL::escape_id(cellName));
|
||||
module->set_bool_attribute(ID::blackbox);
|
||||
module->addWire(RTLIL::escape_id(outPinName))->port_output = true;
|
||||
|
||||
for (unsigned j = 0; j < inPinNum; ++j) {
|
||||
auto inPinName = std::string{};
|
||||
std::getline(f, inPinName, '\0');
|
||||
log_debug2("M: inPinName=%s\n", inPinName);
|
||||
mapping_cell.ins.push_back(RTLIL::escape_id(inPinName));
|
||||
module->addWire(RTLIL::escape_id(inPinName))->port_input = true;
|
||||
}
|
||||
|
||||
module->fixup_ports();
|
||||
|
||||
mapping_cells.push_back(std::move(mapping_cell));
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < instanceNum; ++i) {
|
||||
uint32_t cellID = parse_xaiger_literal(f);
|
||||
uint32_t rootNodeID = parse_xaiger_literal(f);
|
||||
|
||||
log_assert(cellID < cellNum);
|
||||
MappingCell &mapping_cell = mapping_cells.at(cellID);
|
||||
|
||||
log_debug2("M: instanceID=%u cellID=%u outPort=%s rootNodeID=%u\n", i, cellID, RTLIL::unescape_id(mapping_cell.out), rootNodeID);
|
||||
|
||||
RTLIL::Wire *output_sig = createWireIfNotExists(module, rootNodeID);
|
||||
log_assert(output_sig);
|
||||
|
||||
{
|
||||
RTLIL::IdString output_cell_name;
|
||||
if ((rootNodeID & 1) == 0) { // uninverted
|
||||
output_cell_name = stringf("$and$aiger%d$%d", aiger_autoidx, rootNodeID >> 1);
|
||||
} else { // inverted
|
||||
output_cell_name = stringf("$not$aiger%d$%d", aiger_autoidx, rootNodeID >> 1);
|
||||
}
|
||||
RTLIL::Cell *output_cell = module->cell(output_cell_name);
|
||||
log_assert(output_cell);
|
||||
module->remove(output_cell);
|
||||
}
|
||||
|
||||
RTLIL::Cell *cell = module->addCell(stringf("$sc$aiger%d$%d", aiger_autoidx, rootNodeID), mapping_cell.type);
|
||||
cell->setPort(mapping_cell.out, output_sig);
|
||||
|
||||
for (unsigned j = 0; j < mapping_cell.ins.size(); ++j) {
|
||||
auto nodeID = parse_xaiger_literal(f);
|
||||
log_debug("M: inPort=%s nodeID=%u\n", RTLIL::unescape_id(mapping_cell.ins.at(j)), nodeID);
|
||||
RTLIL::Wire *input_sig = createWireIfNotExists(module, nodeID);
|
||||
cell->setPort(mapping_cell.ins.at(j), input_sig);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c == 'r') { // 'r'egister classes
|
||||
uint32_t dataSize = parse_xaiger_literal(f);
|
||||
flopNum = parse_xaiger_literal(f);
|
||||
log_debug("flopNum = %u\n", flopNum);
|
||||
|
|
@ -470,7 +546,7 @@ void AigerReader::parse_xaiger()
|
|||
for (unsigned i = 0; i < flopNum; i++)
|
||||
mergeability.emplace_back(parse_xaiger_literal(f));
|
||||
}
|
||||
else if (c == 's') {
|
||||
else if (c == 's') { // register initial 's'tates
|
||||
uint32_t dataSize = parse_xaiger_literal(f);
|
||||
flopNum = parse_xaiger_literal(f);
|
||||
log_assert(dataSize == (flopNum+1) * sizeof(uint32_t));
|
||||
|
|
@ -478,13 +554,13 @@ void AigerReader::parse_xaiger()
|
|||
for (unsigned i = 0; i < flopNum; i++)
|
||||
initial_state.emplace_back(parse_xaiger_literal(f));
|
||||
}
|
||||
else if (c == 'n') {
|
||||
else if (c == 'n') { // 'n'ame
|
||||
parse_xaiger_literal(f);
|
||||
f >> s;
|
||||
log_debug("n: '%s'\n", s);
|
||||
}
|
||||
else if (c == 'h') {
|
||||
f.ignore(sizeof(uint32_t));
|
||||
else if (c == 'h') { // 'h'ierarchy information
|
||||
f.ignore(sizeof(uint32_t)); // length
|
||||
uint32_t version = parse_xaiger_literal(f);
|
||||
log_assert(version == 1);
|
||||
uint32_t ciNum = parse_xaiger_literal(f);
|
||||
|
|
@ -510,7 +586,7 @@ void AigerReader::parse_xaiger()
|
|||
boxes.emplace_back(cell);
|
||||
}
|
||||
}
|
||||
else if (c == 'a' || c == 'i' || c == 'o' || c == 's') {
|
||||
else if (c == 'a' /* 'a'dditional AIG */ || c == 'i' /* 'i'nput arrival times */ || c == 'o' /* 'o'utput required times */) {
|
||||
uint32_t dataSize = parse_xaiger_literal(f);
|
||||
f.ignore(dataSize);
|
||||
log_debug("ignoring '%c'\n", c);
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ struct Xaiger2Frontend : public Frontend {
|
|||
if (c == 'h') {
|
||||
uint32_t len, ci_num, co_num, pi_num, po_num, no_boxes;
|
||||
len = read_be32(*f);
|
||||
read_be32(*f);
|
||||
read_be32(*f); // version
|
||||
ci_num = read_be32(*f);
|
||||
co_num = read_be32(*f);
|
||||
pi_num = read_be32(*f);
|
||||
|
|
|
|||
|
|
@ -1079,11 +1079,7 @@ RTLIL::Const AstNode::realAsConst(int width)
|
|||
{
|
||||
double v = round(realvalue);
|
||||
RTLIL::Const result;
|
||||
#ifdef EMSCRIPTEN
|
||||
if (!isfinite(v)) {
|
||||
#else
|
||||
if (!std::isfinite(v)) {
|
||||
#endif
|
||||
result = std::vector<RTLIL::State>(width, RTLIL::State::Sx);
|
||||
} else {
|
||||
bool is_negative = v < 0;
|
||||
|
|
|
|||
|
|
@ -161,4 +161,3 @@ std::unique_ptr<AST::AstNode> AST::dpi_call(AstSrcLocType, const std::string&, c
|
|||
YOSYS_NAMESPACE_END
|
||||
|
||||
#endif /* YOSYS_ENABLE_LIBFFI */
|
||||
|
||||
|
|
|
|||
|
|
@ -1057,7 +1057,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
|||
|
||||
#if 0
|
||||
log("-------------\n");
|
||||
log("AST simplify[%d] depth %d at %s:%d on %s %p:\n", stage, recursion_counter, location.begin.filename, location.begin.line, type2str(type), this);
|
||||
log("AST simplify[%d] depth %d at %s on %s %p:\n", stage, recursion_counter, location.to_string(), type2str(type), this);
|
||||
log("const_fold=%d, stage=%d, width_hint=%d, sign_hint=%d\n",
|
||||
int(const_fold), int(stage), int(width_hint), int(sign_hint));
|
||||
// dumpAst(nullptr, "> ");
|
||||
|
|
@ -2619,21 +2619,27 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
|||
input_error("Right hand side of 1st expression of %s for-loop is not constant!\n", loop_type_str);
|
||||
|
||||
auto resolved = current_scope.at(init_ast->children[0]->str);
|
||||
if (resolved->range_valid) {
|
||||
int const_size = varbuf->range_left - varbuf->range_right;
|
||||
int resolved_size = resolved->range_left - resolved->range_right;
|
||||
if (const_size < resolved_size) {
|
||||
for (int i = const_size; i < resolved_size; i++)
|
||||
varbuf->bits.push_back(resolved->is_signed ? varbuf->bits.back() : State::S0);
|
||||
varbuf->range_left = resolved->range_left;
|
||||
varbuf->range_right = resolved->range_right;
|
||||
varbuf->range_swapped = resolved->range_swapped;
|
||||
varbuf->range_valid = resolved->range_valid;
|
||||
auto apply_loop_var_type = [&resolved](std::unique_ptr<AstNode> &value) {
|
||||
if (resolved->range_valid) {
|
||||
int const_size = value->range_left - value->range_right;
|
||||
int resolved_size = resolved->range_left - resolved->range_right;
|
||||
if (const_size < resolved_size) {
|
||||
for (int i = const_size; i < resolved_size; i++)
|
||||
value->bits.push_back(resolved->is_signed ? value->bits.back() : State::S0);
|
||||
value->range_left = resolved->range_left;
|
||||
value->range_right = resolved->range_right;
|
||||
value->range_swapped = resolved->range_swapped;
|
||||
value->range_valid = resolved->range_valid;
|
||||
}
|
||||
}
|
||||
}
|
||||
value->is_signed = resolved->is_signed;
|
||||
};
|
||||
|
||||
apply_loop_var_type(varbuf);
|
||||
|
||||
varbuf = std::make_unique<AstNode>(location, AST_LOCALPARAM, std::move(varbuf));
|
||||
varbuf->str = init_ast->children[0]->str;
|
||||
varbuf->is_signed = resolved->is_signed;
|
||||
|
||||
AstNode *backup_scope_varbuf = current_scope[varbuf->str];
|
||||
current_scope[varbuf->str] = varbuf.get();
|
||||
|
|
@ -2708,6 +2714,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
|||
if (buf->type != AST_CONSTANT)
|
||||
input_error("Right hand side of 3rd expression of %s for-loop is not constant (%s)!\n", loop_type_str, type2str(buf->type));
|
||||
|
||||
apply_loop_var_type(buf);
|
||||
varbuf->children[0] = std::move(buf);
|
||||
}
|
||||
|
||||
|
|
@ -5041,7 +5048,7 @@ void AstNode::expand_genblock(const std::string &prefix)
|
|||
if (!child->str.empty() && prefix.size() > 0) {
|
||||
bool is_resolved = false;
|
||||
std::string identifier_str = child->str;
|
||||
if (current_ast_mod != nullptr && identifier_str.compare(0, current_ast_mod->str.size(), current_ast_mod->str) == 0) {
|
||||
if (current_ast_mod != nullptr && identifier_str.size() > current_ast_mod->str.size() && identifier_str.compare(0, current_ast_mod->str.size(), current_ast_mod->str) == 0) {
|
||||
if (identifier_str.at(current_ast_mod->str.size()) == '.') {
|
||||
identifier_str = '\\' + identifier_str.substr(current_ast_mod->str.size()+1, identifier_str.size());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -836,5 +836,3 @@ skip_cell:;
|
|||
} LibertyFrontend;
|
||||
|
||||
YOSYS_NAMESPACE_END
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,4 +34,3 @@ should be something like this:
|
|||
SBY [example] summary: engine_0 (smtbmc yices) returned PASS for induction
|
||||
SBY [example] summary: successful proof by k-induction.
|
||||
SBY [example] DONE (PASS, rc=0)
|
||||
|
||||
|
|
|
|||
|
|
@ -4962,11 +4962,7 @@ struct ReadPass : public Pass {
|
|||
if (use_verific) {
|
||||
args[0] = "verific";
|
||||
} else {
|
||||
#if !defined(__wasm)
|
||||
args[0] = "read_verilog_file_list";
|
||||
#else
|
||||
cmd_error(args, 1, "Command files are not supported on this platform.\n");
|
||||
#endif
|
||||
}
|
||||
Pass::call(design, args);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#if !defined(__wasm)
|
||||
#include <filesystem>
|
||||
#endif
|
||||
|
||||
#include "verilog_frontend.h"
|
||||
#include "verilog_lexer.h"
|
||||
|
|
@ -709,8 +707,6 @@ struct VerilogDefines : public Pass {
|
|||
}
|
||||
} VerilogDefines;
|
||||
|
||||
#if !defined(__wasm)
|
||||
|
||||
static void parse_file_list(const std::string &file_list_path, RTLIL::Design *design, bool relative_to_file_list_path)
|
||||
{
|
||||
std::ifstream flist(file_list_path);
|
||||
|
|
@ -790,6 +786,4 @@ struct VerilogFileList : public Pass {
|
|||
}
|
||||
} VerilogFilelist;
|
||||
|
||||
#endif
|
||||
|
||||
YOSYS_NAMESPACE_END
|
||||
|
|
|
|||
|
|
@ -713,4 +713,3 @@ import[ \t\r\n]+\"(DPI|DPI-C)\"[ \t\r\n]+function[ \t\r\n]+ {
|
|||
<*>. { BEGIN(0); return char_tok(*YYText(), out_loc); }
|
||||
|
||||
%%
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue