Forum Discussion

MamaSaru's avatar
MamaSaru
Icon for Occasional Contributor rankOccasional Contributor
1 day ago

Connection bit order between hierarchy

Hi,

I got unintended bit order of bus connection between SystemVerilog top with Block Design in lower hierarchy.

I intend to connect inst3 to out[3] but Quartus connected in reversed order.

Please see Technology map viewer screen shot and open archived project.

Is there any Quartus option to fix this problem?

This happens with (System)Verilog top only.
I already experiment bdf, tdf, vhd top instead of sv, they work as expected.
I am using Quartus Pro 23.2.

Thanks,
Masaru

2 Replies

  • Hi Masaru,
     

    Thank you for sharing the detailed description and QAR. There is no Quartus option to prevent this reversal.
     

    After review, this behavior is caused by a mismatch between SystemVerilog packed array ordering and Block Design indexing.

    • SystemVerilog buses follow a fixed MSB-to-LSB order
    • Block Design treats signals as an indexed list of bits

    Because of this difference, Quartus connects signals based on their position (index), which results in a reversed connection.
    For example:

    Block Design:

    • inst0 → index 0 
      inst1 → index 1 
      inst2 → index 2 
      inst3 → index 3

    SystemVerilog:

    • Out = [3] [2] [1] [0]   MSB to LSB

    Quartus maps by position:

    index 0 → Out[3] 
    index 1 → Out[2] 
    index 2 → Out[1] 
    index 3 → Out[0]
     

    Resulting in:

    inst0 → Out[3] 
    inst1 → Out[2] 
    inst2 → Out[1] 
    inst3 → Out[0]
     

    The recommended workaround is to explicitly reorder the bits in the top-level module: 
    assign Out = {bdf_out[0], bdf_out[1], bdf_out[2], bdf_out[3]};
     

    This manually restores the intended mapping. 
     

    I have also attached back the QAR for your reference.

    Best regards,
    Zi Ying

    • MamaSaru's avatar
      MamaSaru
      Icon for Occasional Contributor rankOccasional Contributor

      Zi Ying,

      Thank you for the information.

      .Out({<<{Out}})

      also works.

      I have checked this workaround for two-dimensional packed array.

      If the Block Design entry goes on, I am happy that altera would fix this issue.

      Masaru