-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Feature to share implementation #1212
Comments
#908 seems to be related too. |
I think interface inheritance / composition is better than code block approach in this case because code block provide only a feature like text macro and not special support for interface. There are some syntax ideas: interface Req {
var cmd: logic;
var cmd_accept: logic;
}
interface Resp {
var data: logic;
var data_accept: logic
}
interface Bundle inherit Req, Resp {
}
// This is the same as
// interface Bundle {
// var cmd: logic;
// var cmd_accept: logic;
// var data: logic;
// var data_accept: logic
// }
// Another inherit syntax
interface Bundle {
inherit Req;
inherit Resp;
}
// Composition style
interface Bundle {
inst req: Req;
inst resp: Resp;
} Regardless syntax style, actual member definitions becomes to be difficult to understand in case of having deep inherit depth. |
Sorry, I've mistakely closed. |
We need to consider how propagate child's generic arguments and parameters to parent interfaces. interface Bundle #(
param ADDRESS_WIDTH: u32 = 8,
param DATA_WIDTH: u32 = 8,
) {
inst Req #(ADDRESS_WIDTH, DATA_WIDTH);
inst Resp #(DATA_WIDTH);
} |
Surely, it seems to be necessary. interface Bundle #(
param ADDRESS_WIDTH: u32 = 8,
param DATA_WIDTH: u32 = 8,
) {
inherit Req #(ADDRESS_WIDTH, DATA_WIDTH);
inherit Resp #(DATA_WIDTH);
} |
Sorry, this is my miss type. |
Multiple inheritance and diamond problem should be considerd. interface Base #(
param WIDTH: u32 = 0,
) {
var x: logic<WIDTH>,
}
interface Req #(
param WIDTH: u32 = 0,
) {
inherit Base #(WIDTH);
var cmd: logic<WIDTH>;
var cmd_accept: logic;
}
interface Resp #(
param WIDTH: u32 = 0,
) {
inherit Base #(WIDTH);
var data: logic<WIDTH>;
var data_accept: logic
}
interface Bundle #(
param ADDRESS_WIDTH: u32 = 8,
param DATA_WIDTH: u32 = 8,
) {
// Base::x is inherited from both Req and Resp with the differenct parameter override
inherit Req #(ADDRESS_WIDTH);
inherit Resp #(DATA_WIDTH);
} |
When generating SV code, parent interfaces will be expanded into child interface. |
Generally, there are several ways to resolve diamond problem.
Even if we adopt checking scheme, there are some choices about what type conflict is allowed or not. |
For pzbcm, I use text macros to share implementation.
For example:
I need a new feature to share implementation between design elements to re-write these interfaces in Veryl.
Followings are idenas for this.
This is similar to #793 but no instance name is needed.
Code block will be expanded into the scope where it is instantiated.
For the above example,
pzcorebus_if
behavespzcorebus_request_if
and alsopzcorebus_response_if
.Therefore, I think
inheritance
is one of suitable ways to model the above case.Implementations of parent interfaces are expanded into the child interface.
The text was updated successfully, but these errors were encountered: