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

Interface prototype #963

Open
dalance opened this issue Sep 13, 2024 · 3 comments
Open

Interface prototype #963

dalance opened this issue Sep 13, 2024 · 3 comments
Labels
lang Language design

Comments

@dalance
Copy link
Collaborator

dalance commented Sep 13, 2024

No description provided.

@dalance dalance added the lang Language design label Sep 13, 2024
@dalance
Copy link
Collaborator Author

dalance commented Sep 20, 2024

Interface prototype may be the same as concrete interface in almost cases.

proto interface ProtoA #(
    param X: u32,
) {
    var a: logic;

    modport A {
        a: input,
    }
}

interface InterfaceA for ProtoA #(
    param X: u32,
) {
    var a: logic;

    modport A {
        a: input,
    }
}

So generic bound by interface may be sufficient instead of adding interface prototype.

block rggen_connect_bit_field_if::<RIF: InterfaceA, FIF: InterfaceA, LSB: const, WIDTH: const> {
    assign  FIF.valid                 = RIF.valid;
    assign  FIF.read_mask             = RIF.read_mask[LSB+:WIDTH];
    assign  FIF.write_mask            = RIF.write_mask[LSB+:WIDTH];
    assign  FIF.write_data            = RIF.write_data[LSB+:WIDTH];
    assign  RIF.read_data[LSB+:WIDTH] = FIF.read_data;
    assign  RIF.value[LSB+:WIDTH]     = FIF.value;
}

@taichi-ishitani
Copy link
Contributor

taichi-ishitani commented Jan 7, 2025

The prototype generics boundary is to specify a module name which will be instantiated.
This notation may be confusable because its appearance is similar with the prototype boundary but thier functionality are different.
Therefore, I think other notation is needed like below.

block rggen_connect_bit_field_if::<RIF: inst InterfaceA, FIF: inst InterfaceA, LSB: const, WIDTH: const> {
    assign  FIF.valid                 = RIF.valid;
    assign  FIF.read_mask             = RIF.read_mask[LSB+:WIDTH];
    assign  FIF.write_mask            = RIF.write_mask[LSB+:WIDTH];
    assign  FIF.write_data            = RIF.write_data[LSB+:WIDTH];
    assign  RIF.read_data[LSB+:WIDTH] = FIF.read_data;
    assign  RIF.value[LSB+:WIDTH]     = FIF.value;
}

@taichi-ishitani
Copy link
Contributor

interface can have functions so I think interface prototype is meaningful.

proto interface InterfaceA {
  function FuncA(a: input logic, b: input logic) -> logic;

  modport mp {
    FuncA: import,
  }
}

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

No branches or pull requests

2 participants