diff options
author | Clifford Wolf <clifford@clifford.at> | 2019-02-28 12:15:58 -0800 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2019-02-28 12:15:58 -0800 |
commit | f570aa5e1d3ac201089da2198f8e5084185fd92f (patch) | |
tree | a4f251b930565596dd94d8726486ddc3eac9f2f4 /backends/smt2 | |
parent | 5e94a8a12777222c21c4dc70b16ede1de7f6ea99 (diff) | |
download | yosys-f570aa5e1d3ac201089da2198f8e5084185fd92f.tar.gz yosys-f570aa5e1d3ac201089da2198f8e5084185fd92f.tar.bz2 yosys-f570aa5e1d3ac201089da2198f8e5084185fd92f.zip |
Fix smt2 code generation for partially initialized memowy words, fixes #831
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'backends/smt2')
-rw-r--r-- | backends/smt2/smt2.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/backends/smt2/smt2.cc b/backends/smt2/smt2.cc index 418f8d766..7f3cc94ca 100644 --- a/backends/smt2/smt2.cc +++ b/backends/smt2/smt2.cc @@ -1103,20 +1103,27 @@ struct Smt2Worker break; Const initword = init_data.extract(i*width, width, State::Sx); + Const initmask = initword; bool gen_init_constr = false; - for (auto bit : initword.bits) - if (bit == State::S0 || bit == State::S1) + for (int k = 0; k < GetSize(initword); k++) { + if (initword[k] == State::S0 || initword[k] == State::S1) { gen_init_constr = true; + initmask[k] = State::S1; + } else { + initmask[k] = State::S0; + initword[k] = State::S0; + } + } if (gen_init_constr) { if (statebv) /* FIXME */; else - init_list.push_back(stringf("(= (select (|%s#%d#0| state) #b%s) #b%s) ; %s[%d]", + init_list.push_back(stringf("(= (bvand (select (|%s#%d#0| state) #b%s) #b%s) #b%s) ; %s[%d]", get_id(module), arrayid, Const(i, abits).as_string().c_str(), - initword.as_string().c_str(), get_id(cell), i)); + initmask.as_string().c_str(), initword.as_string().c_str(), get_id(cell), i)); } } } |