SystemVerilog — cell arrays and the >> streaming operator

When connecting up array of instances of modules that have only single-bit ports (such as a flip-flop), often all you care about is that the port expressions have an equal number of bits. The types could be anything, packed or unpacked, and not necessarily the same on each port.

The generic way to write this is with an extra level of hierarchy and the >> streaming operator of 11.4.14. For example,

  DFF_array#($bits(rvalue)) 
     U( .D({>>{rvalue}}) 
      , .CLK(clock)
      , .Q({>>{lvalue}})
     );

where

  module DFF_array#(N)
  ( output [N-1:0] Q
  , input CLK
  , input [N-1:0] D
  );
    DFF U[N](.*);
  endmodule

A side-benefit of the extra level of hierarchy is that you can iterate over the output bits with a regular procedural loop (such as ‘foreach’ of 12.7.3), unlike the output bits from the individual instances, which you could only iterate over with a generate for-loop.

Advertisements

Tell me (anonymous OK)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s