Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor for plane_reg is not honoured #343

Open
zhuanhao-wu opened this issue May 30, 2022 · 0 comments
Open

Constructor for plane_reg is not honoured #343

zhuanhao-wu opened this issue May 30, 2022 · 0 comments
Labels

Comments

@zhuanhao-wu
Copy link
Collaborator

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

@zhuanhao-wu zhuanhao-wu changed the title Constructor for plane_reg is not honored Constructor for plane_reg is not honoured May 30, 2022
@zhuanhao-wu zhuanhao-wu changed the title Constructor for plane_reg is not honoured Constructor for plane_reg is not honoured May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant