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

[ImportVerilog]Support the delay control. #8259

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hailongSun2000
Copy link
Member

No description provided.

@hailongSun2000
Copy link
Member Author

It's just a simple attempt. And I have a question about the timeUnit. Slang has calculated the truth time, but we cannot distinguish which is the correct timeUnit from s, ms, us, etc. For example:
(Is there a way to get the time unit 🤔 ?)

`timescale 10 ns/1 ns
assign #1.49 a = 1'b1;
assign #1.50 a = 1'b0;

assign #1us a = 1'b0;

AST:

delay": {
              "kind": "Delay",
              "expr": {
                "kind": "RealLiteral",
                "type": "realtime",
                "value": 0.1,
                "constant": "0.1"
              }

-----------------------------------------------
"delay": {
              "kind": "Delay",
              "expr": {
                "kind": "RealLiteral",
                "type": "realtime",
                "value": 0.2,
                "constant": "0.2"
              }

----------------------------------------------
"delay": {
              "kind": "Delay",
              "expr": {
                "kind": "TimeLiteral",
                "type": "realtime",
                "value": 100,
                "constant": "100"
              }

@likeamahoney
Copy link
Contributor

`timescale 10 ns/1 ns
assign #1.49 a = 1'b1;
assign #1.50 a = 1'b0;

assign #1us a = 1'b0;

Hi! timeUnit from timescale directive is module defined property according to LRM (which should be specified outside the module definition). It can be founded at module definition slang json ast section :

  "definitions": [
    {
      "name": "m",
      "kind": "Definition",
      "addr": 5723682596352,
      "defaultNetType": "5723682914720 wire",
      "definitionKind": "Module",
      "defaultLifetime": "Static",
      "unconnectedDrive": "None",
      "timeScale": "10ns / 1ns"
    },
    {
      "name": "n",
      "kind": "Definition",
      "addr": 5723682587136,
      "defaultNetType": "5723682914720 wire",
      "definitionKind": "Module",
      "defaultLifetime": "Static",
      "unconnectedDrive": "None",
      "timeScale": "100ns / 1ns"
    }
  ]

from sv like this:

`timescale 10 ns/1 ns
module m();
endmodule

`timescale 100 ns/1 ns
module n();
endmodule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants