systemc-clang
systemc-clang copied to clipboard
Constructor for `plane_reg` is not honoured
template<int DIM> struct plane_reg
{
bool f; //full flag.
sc_uint<bw_w(DIM)> w; //word
plane_reg(){f=false;w=0;}
plane_reg(sc_uint<bw_w(DIM)> wi){f=true;w=wi;}
plane_reg& operator=(const plane_reg<DIM>& rhs){f = rhs.f; w = rhs.w; return *this;}
bool operator==(const plane_reg<DIM>& rhs){return f == rhs.f && w == rhs.w;}
//setter pattern
public:
plane_reg& set_word(sc_uint<bw_w(DIM)> nw) { f=true; w = nw; return *this; } //"fluent" API to set word.
bool is_empty(){return f;}
};
...
// use of constructor
w[i] = plane_reg<2>((sc_uint<bw_w(2)>)(word.tdata>>(bw_w(2)*i)));
The use of constructor from sc_uint lies here
The following code is generated, notice that the assignment of f to true is missing.
for (i_zhw__decode_streamfp_t11_52_bits_t64_2__refresh_next_bs_regs_func_4_local_20 = 0;(i_zhw__decode_streamfp_t11_52_bits_t64_2__refresh_next_bs_regs_func_4_local_20) < ((64) / (32));i_zhw__decode_streamfp_t11_52_bits_t64_2__refresh_next_bs_regs_func_4_local_20++) begin
w_zhw__decode_streamfp_t11_52_bits_t64_2__refresh_next_bs_regs_func_4_local_16[i_zhw__decode_streamfp_t11_52_bits_t64_2__refresh_next_bs_regs_func_4_local_20] = (word_zhw__decode_streamfp_t11_52_bits_t64_2__refresh_next_bs_regs_func_4_local_15_tdata) >>> ((32) * (i_zhw__decode_streamfp_t11_52_bits_t64_2__refresh_next_bs_regs_func_4_local_20));
end
For now, we can circumvent this issue by manually inlining the constructor.
#329