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

[ExportVerilog] Add support for UnionCreate op. #5081

Merged
merged 1 commit into from
Apr 25, 2023

Commits on Apr 25, 2023

  1. [ExportVerilog] Add support for UnionCreate op.

    This adds support for `hw::UnionCreateOp` to ExportVerilog.  It works by
    emitting a bit concatenation and assigning it to a wire with a union
    type.  Each union member may have a prepadding, which is decided by the
    member's offset size, and a postpadding to ensure that each union
    element is the same size. The resulting bitconcat is `{prepadding, data,
    postpadding}`.  If there is no padding for a particular member, then
    bitconcat will not be used.
    
    The following example has no offsets, but the member `a` requires
    post-padding of `1` bit.
    
    ```mlir
    hw.module @unionCreate(%in: i1) -> (out: !hw.union<a: i1, b: i2>) {
        %0 = hw.union_create "a", %in : !hw.union<a: i1, b: i2>
        hw.output %0 : !hw.union<a: i1, b: i2>
    }
    ```
    
    ```verilog
    module unionCreate(
      input                                                                                          in,
      output union packed { struct packed {logic a; logic [0:0] __post_padding_a;} a;logic [1:0] b;} out
    );
    
      assign out = {in, 1'h0};
    endmodule
    ```
    youngar committed Apr 25, 2023
    Configuration menu
    Copy the full SHA
    a1144aa View commit details
    Browse the repository at this point in the history