circt icon indicating copy to clipboard operation
circt copied to clipboard

[SV] Implement support for a bit-swapping idiom

Open Schottkyc137 opened this issue 3 years ago • 2 comments

This PR implements initial support for the left streaming operator {<<{...}} to simplify bit-swap expressions. The scope of this PR is very limited and only aims at supporting a very basic subset of what the operator can do. The following is implemented

  • A new SV op: sv.reorder args... : returnType
  • A beautification in the PrettifyVerilog pass to transform expressions of the type {a[0], a[1], a[2], ..., a[n-1]} to the expression {<<{a}}

More complex transformations can be added in the future. I have created this PR with the following two in mind:

  • Enable slices for the reorder-operation so that common operations like byte-swap, nibble-swaps and swaps of arbitrary block sizes are possible
  • Enable multiple arguments, i.e. {<<{a, b}} should be infered from {b[0], b[1], ..., b[n-1], a[0], a[1], ..., a[m-1]}

I'm not quite sure about the naming of the Operation. I think it describes fairly well what it does but it doesn't have an immediate SV representation. I also thought about simply using sv.stream but that might give a wrong impression since the streaming operator is technically only the << operator. I am happy to discuss any other names.

Schottkyc137 avatar Jun 29 '22 18:06 Schottkyc137

Either that or have the 'sv.stream' op we discussed in the ODM.

On Fri, Jul 1, 2022, 12:17 PM Andrew Lenharth @.***> wrote:

@.**** requested changes on this pull request.

In include/circt/Dialect/SV/SVExpressions.td https://github.com/llvm/circt/pull/3441#discussion_r912202838:

@@ -209,3 +209,41 @@ def SampledOp : SVOp<"system.sampled", [SameOperandsAndResultType]> { let results = (outs AnyType:$sampledValue); let assemblyFormat = "$expression attr-dict : qualified(type($expression))"; }

+def ReorderOp: SVOp<"reorder", [InferTypeOpInterface, NoSideEffect]> {

I think you should do a comb operator. reorder isn't a direct verilog operation, so it probably doesn't belong in this dialect.

— Reply to this email directly, view it on GitHub https://github.com/llvm/circt/pull/3441#pullrequestreview-1026577239, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALNXYGEPLFATXHFOEVDKJDVR476FANCNFSM52GUDKYQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

teqdruid avatar Jul 01 '22 19:07 teqdruid

Either that or have the 'sv.stream' op we discussed in the ODM.

See issue #3469 where I have implemented an initial proposal for such an operator. I will revisit this PR when everything about the streaming operator is ironed out.

Schottkyc137 avatar Jul 03 '22 11:07 Schottkyc137

Converting to draft pending implementation of the stream operators (#3469 )

darthscsi avatar Apr 28 '23 18:04 darthscsi