diff options
author | Clifford Wolf <clifford@clifford.at> | 2013-12-04 14:14:05 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2013-12-04 14:14:05 +0100 |
commit | 93a70959f3f67ffcee8159b18a5f68904e32a074 (patch) | |
tree | 1bf68c1a36c3d126fdb396b0ea9c06bcdc2040fb /frontends/ast/ast.cc | |
parent | a2d053694b6269bab8871a810142943fac6a3a18 (diff) | |
download | yosys-93a70959f3f67ffcee8159b18a5f68904e32a074.tar.gz yosys-93a70959f3f67ffcee8159b18a5f68904e32a074.tar.bz2 yosys-93a70959f3f67ffcee8159b18a5f68904e32a074.zip |
Replaced RTLIL::Const::str with generic decoder method
Diffstat (limited to 'frontends/ast/ast.cc')
-rw-r--r-- | frontends/ast/ast.cc | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index 9054f78ce..ec017216d 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -677,6 +677,29 @@ RTLIL::Const AstNode::bitsAsConst(int width) return bitsAsConst(width, is_signed); } +RTLIL::Const AstNode::asAttrConst() +{ + log_assert(type == AST_CONSTANT); + + RTLIL::Const val; + val.bits = bits; + + if (!str.empty()) { + val.flags |= RTLIL::CONST_FLAG_STRING; + log_assert(val.decode_string() == str); + } + + return val; +} + +RTLIL::Const AstNode::asParaConst() +{ + RTLIL::Const val = asAttrConst(); + if (is_signed) + val.flags |= RTLIL::CONST_FLAG_SIGNED; + return val; +} + // create a new AstModule from an AST_MODULE AST node static AstModule* process_module(AstNode *ast) { @@ -729,8 +752,7 @@ static AstModule* process_module(AstNode *ast) if (attr.second->type != AST_CONSTANT) log_error("Attribute `%s' with non-constant value at %s:%d!\n", attr.first.c_str(), ast->filename.c_str(), ast->linenum); - current_module->attributes[attr.first].str = attr.second->str; - current_module->attributes[attr.first].bits = attr.second->bits; + current_module->attributes[attr.first] = attr.second->asAttrConst(); } for (size_t i = 0; i < ast->children.size(); i++) { AstNode *node = ast->children[i]; |