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

[ILAtor] Failure to concatenate constant with specified length in systemc model generation #179

Open
LeeOHzzZ opened this issue Jun 2, 2020 · 3 comments
Assignees
Labels

Comments

@LeeOHzzZ
Copy link
Collaborator

LeeOHzzZ commented Jun 2, 2020

Describe the bug
In ILA model, concatenation with specified length of constant is often used to expand the variable's length. However, the generated systemc model fails to concatenate the specified length of constant.
e.x.
ILA code: var1 = Concat(var2, BvConst(0,4)), we should expected the var1 in systemc has a bitwidth of len(var2) + 4. However, the generated systemc code is like this:
SystemC code: var1_sc = (var2_sc, 0), which only has bitwidth of len(var2_sc) + 1

To Reproduce
Steps to reproduce the behavior:

  1. Go to ILA model and specify a variable of var1 = Concat(var2, BvConst(0, 4))
  2. Build the ILA model and generate the systemc codes
  3. Look into the var1 update function (decode_*****), and you can see the error

Environment (please complete the following information):

  • OS: [e.g. Ubuntu 18.04]
  • Compiler gcc8
@yuex1994
Copy link
Contributor

yuex1994 commented Jun 7, 2020

@LeeOHzzZ
Need more details (e.g. specific model) to reproduce the bug.

Provided example (attached) doesn't expose bugs:

    auto s1 = m.NewBvState("s1", 4);
    auto s2 = m.NewBvState("s2", 8);
    auto c1 = BvConst(0, 4);
    auto c2 = BvConst(0, 8);
    auto instr1 = m.NewInstr("i1");
    instr1.SetUpdate(s2, c2 + Concat(s1, c1));

In the generated file, the intermediate variable for Concat(s1, c1) and c2 + Concat(s1, c1)) both have length 8 -- this is as expected.

Attachment:
example.zip

@LeeOHzzZ
Copy link
Collaborator Author

LeeOHzzZ commented Jun 7, 2020

@yuex1994
The bitwidth may be correct, but the value is wrong for the intermediate result.
For example, if s1 == BvConst(1,0), and s2 = Concat(s1, BvConst(0, 4)), then s2 should be equal to 16. However, in the current version, in systemc model, s2 = (s1,0), which is equal to 2 instead, which means it only append 1 bit after s1 for the concatenation.

@yuex1994
Copy link
Contributor

yuex1994 commented Jun 8, 2020

I see. Fix -- pr#186

Bo-Yuan-Huang added a commit that referenced this issue Jun 8, 2020
Fix bug #179: miss constant bit_width in ILAtor Concat-op
@Bo-Yuan-Huang Bo-Yuan-Huang changed the title Failure to concatenate constant with specified length in systemc model generation [ILAtor] Failure to concatenate constant with specified length in systemc model generation Jun 23, 2020
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

2 participants