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

ISE has issues with $clog2 #309

Open
alexforencich opened this issue Feb 18, 2025 · 2 comments
Open

ISE has issues with $clog2 #309

alexforencich opened this issue Feb 18, 2025 · 2 comments

Comments

@alexforencich
Copy link

ISE has issues with code containing $clog2. For 6-series, it is not allowed in localparam, only parameter. For parts older than 6-series, it is not supported at all. Perhaps sv2v can define a clog2 macro and substitute that for uses of $clog2, perhaps this can be configurable via a command line option or similar.

@zachjs
Copy link
Owner

zachjs commented Feb 23, 2025

$clog2 was added to Verilog in IEEE 1364-2005, released nearly 19 years in April 2006. There's certainly no reason to support it in some constant expressions but not others. Would Xilinx/AMD be receptive to a bug report in this case?

Perhaps we could have a flag to replace all $clog2 with the following constant function. Can you try this substitution in your code and confirm whether this actually works in ISE? (I don't know what other restrictions it might impose.)

function automatic integer clog2;
    input integer inp;
    clog2 = 0;
    for (inp = inp - 1; inp > 0; inp = inp >> 1)
        clog2 = clog2 + 1;
endfunction

@alexforencich
Copy link
Author

I wish, but ISE is currently no longer supported, so we're stuck with what we've got. I'll look into trying that out and report back. Hopefully that works, a macro is also a potential option, but would be decidedly less clean.

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

No branches or pull requests

2 participants