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

import/export declaration #59

Closed
dalance opened this issue Jan 6, 2023 · 3 comments
Closed

import/export declaration #59

dalance opened this issue Jan 6, 2023 · 3 comments
Labels
lang Language design

Comments

@dalance
Copy link
Collaborator

dalance commented Jan 6, 2023

import PackageA::Item;
import PackageB::*;

module's import like below causes parsing and formatting complexity.

module ModuleA import PackageA::* (
) {
}

Instead of supporting module's import, is it sufficient like below?

import PackageA::*;

module ModuleA (
) {
}
@dalance dalance added the lang Language design label Jan 6, 2023
@dalance dalance changed the title import declaration import/export declaration Jan 6, 2023
dalance added a commit that referenced this issue Jan 10, 2023
@dalance dalance closed this as completed Jan 10, 2023
@taichi-ishitani
Copy link
Contributor

Visibility of items imported by import declarations outside module declarations is global.
In fact, compiling following SV files does not report a compile error.

// foo_pkg.sv
package foo_pkg;
  localparam FOO = 0;
endpackage
// foo_0.sv
import foo_pkg::*;
module foo_0;
  localparam FOO_0 = FOO;
endmodule
// foo_1.sv
module foo_1;
  localparam FOO_1 = FOO;
endmodule

Therefore, I think import declarations should be inside a module declaration.

@dalance dalance reopened this Jan 12, 2023
@dalance
Copy link
Collaborator Author

dalance commented Jan 12, 2023

There are three ideas.

  • Allow import at module declaration header like SV
  • Implement file scope import
import PackageA::*;

module ModuleA (
) {
}

module ModuleB (
) {
}

to

module ModuleA import PackageA::*;
endmodule

module ModuleB import PackageA::*;
endmodule

This case disallows global import like SV.

  • Expand import scope in module to module port declaration
module ModuleA (
) {
    import PackageA::*;
}

to

module ModuleA import PackageA::*;
endmodule

In this case all imports in a module move to the module header.

@taichi-ishitani
Copy link
Contributor

I think Implement file scope import is a better choise.

This case disallows global import like SV.

I think this is not a problem because large scope has bad influence.

dalance added a commit that referenced this issue Jan 17, 2023
@dalance dalance closed this as completed Jan 17, 2023
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