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

Unexpected result in insn_div when dividing by 0 when not using RISCV_FORMAL_ALTOPS #29

Closed
Zeldax64 opened this issue Aug 6, 2019 · 2 comments

Comments

@Zeldax64
Copy link

@Zeldax64 Zeldax64 commented Aug 6, 2019

When I run the insn_div test (without defining RISCV_FORMAL_ALTOPS) it always stops with an error after retiring any division by 0 instruction. After examining the counter trace I noticed that the signal rvfi_testbench.checker_inst.insn_spec.spec_rd_wdata is equal to 1 instead of -1.

I believe the problem is this line:

wire [`RISCV_FORMAL_XLEN-1:0] result = $signed(rvfi_rs1_rdata) / $signed(rvfi_rs2_rdata);

I have already read the description of RISCV_FORMAL_ALTOPS here but I think this define should also be listed in the Configuration Macros doc.

By the way, thanks for this great project. I have already caught some bugs in my implementation since I started using this framework.

@cliffordwolf
Copy link
Collaborator

@cliffordwolf cliffordwolf commented Aug 7, 2019

After examining the counter trace I noticed that the signal rvfi_testbench.checker_inst.insn_spec.spec_rd_wdata is equal to 1 instead of -1.

That's interesting. What solver did you use? Because SMT-based solvers, like the ones used by default in SymbiYosys, should interpret x/0 as -1. But of course other engines might have different definitions. I've now added explicit handling of x/0 and INT_MIN/-1 to the instruction models.

@Zeldax64
Copy link
Author

@Zeldax64 Zeldax64 commented Aug 7, 2019

I'm using Boolector Version 3.0.1-pre master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants