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

Array manipulation methods #219

Open
daglem opened this issue Sep 23, 2022 · 1 comment
Open

Array manipulation methods #219

daglem opened this issue Sep 23, 2022 · 1 comment

Comments

@daglem
Copy link

daglem commented Sep 23, 2022

It seems like the following is not implemented by any open source tool: IEEE Std 1800™-2017 7.12 Array manipulation methods.

I don't know whether it is even theoretically possible to generate Verilog code for this, however perhaps it can be taken as a challenge :-)

The syntax seems quite elegant, and could considerably improve code in some cases. Here is an example, where approximately 50 lines could have been reduced to 1, if I understand correctly:

https://github.com/daglem/reDIP-SID/blob/master/gateware/sid_dac.sv

@daglem
Copy link
Author

daglem commented Oct 1, 2022

Learning some more Verilog, I realized that e.g. array reduction can be done along the lines of the following:

item_t _sum[array.size];

for (genvar i = 0; i < array.size; i++) begin
    always_comb
        _sum[i] = (i == 0 ? 0 : _sum[i - 1]) + (with_expr ? _sum[i] : 0);
end

always_comb
    res = _sum[array.size - 1];

So, I guess it may be possible to implement most, if not all, of the array manipulation methods using plain Verilog.
However since this feature is probably not used much, and workarounds like the above seem simple enough, perhaps it's not worth the trouble?

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

1 participant