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

Generics support #191

Closed
dalance opened this issue Mar 15, 2023 · 0 comments · Fixed by #679
Closed

Generics support #191

dalance opened this issue Mar 15, 2023 · 0 comments · Fixed by #679
Labels
lang Language design

Comments

@dalance
Copy link
Collaborator

dalance commented Mar 15, 2023

This is a syntax idea for generics support.
Generics is not the same as "parameter override", it provide more flexibility than SystemVerilog.
This is because the generics code will be expanded by transpiler.

I think this resolves #39, #58 and #178 in a unified way.

In this idea, ::<> is used for generics because <> is used as packed array currently.
::<> comes from "turbofish" which is used in Rust's generics function call.

  • module
module A::<T> #(
    parameter a: u32 = 1,
) (
    a: input logic,
) {
    inst u: T ();
}

module B {
    inst u: A::<ModuleC> ();
}
  • struct
struct A::<T> {
    a: T,
}

var a: A::<logic<10>><10>;
  • function
function FuncA::<N> (
    a: input logic<N>
) -> logic<N> {
    return a;
}

assign x = FuncA::<10>(a);
  • package
package PackageA::<N> {
    localparam A: u32 = N;
}

import PackageA::<10>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang Language design
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant