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] Distinguish the index up or down on the range selection. #7280

Merged

Conversation

hailongSun2000
Copy link
Member

@hailongSun2000 hailongSun2000 commented Jul 4, 2024

For example:

  byte by;
  logic [7:0] b;
  assign by = b[7-:8];

Now:

    %by = moore.variable : <i8>
    %b = moore.variable : <l8>
    %0 = moore.read %b : l8
    %1 = moore.constant 7 : i32

    %2 = moore.constant 7 : i32
    %3 = moore.sub %1, %2 : i32

    %4 = moore.extract %0 from %3 : l8, i32 -> l8              // low bit is "0"
    %5 = moore.conversion %4 : !moore.l8 -> !moore.i8
    moore.assign %by, %5 : i8

Previous:

    %by = moore.variable : <i8>
    %b = moore.variable : <l8>
    %0 = moore.read %b : l8

    %1 = moore.constant 7 : i32
    %2 = moore.extract %0 from %1 : l8, i32 -> l8              // low bit is "7";

    %3 = moore.conversion %2 : !moore.l8 -> !moore.i8
    moore.assign %by, %3 : i8

@hailongSun2000
Copy link
Member Author

Before @fabianschuiki refactored the Moore type system, we can get the bits slice range from type, like logic<range<7:0>>, or range<0:7>, or range<2:3>... But now we cannot get this information. From my perspective, the IR after modification is more clear. If it's reasonable, I'll tweak the extract_ref.
If I misunderstand, please teach me about the big and little endian. Thanks in advance.

@hailongSun2000 hailongSun2000 force-pushed the hailong/distinguish-index-up-and-down branch from 9b3a81d to a65eeb0 Compare July 4, 2024 10:21
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! Looks great! 🥳

@hailongSun2000 hailongSun2000 force-pushed the hailong/distinguish-index-up-and-down branch from a65eeb0 to 1f57343 Compare July 10, 2024 05:19
@hailongSun2000 hailongSun2000 merged commit e2b4cb9 into llvm:main Jul 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants