[sv-bc] Example of $increment() usage

From: Brad Pierce <Brad.Pierce_at_.....>
Date: Fri Mar 25 2005 - 10:35:22 PST
Clause 24.7 has no example of how to use $increment().
Here's a typical 3.0-style usage (made less necessary
by the new 'foreach' syntax).

`define FOREACH(A,I)                         \
  for (int I  = $left( A,1)                  \
      ;    I != $right(A,1)-$increment(A,1)  \
      ;    I +=            -$increment(A,1)  \
      )

module test #(parameter N = 256)
   ( input clk
   , output integer Out[1-N:N]
   , input  integer In1[1-N:N]
                  , In2[1-N:N]
   );

always_ff @(posedge clk)
   `FOREACH(Out,i) Out[i] <= In1[i] + In2[i];
   
initial begin
  int A[3:-12];
  logic [-12:3] B;
  int C[-1000:-1000];

  `FOREACH(A,I) $display("A[%d]", I);
  `FOREACH(B,I) $display("B[%d]", I);
  `FOREACH(C,I) $display("C[%d]", I);
end

endmodule:test
Received on Fri Mar 25 10:35:24 2005

This archive was generated by hypermail 2.1.8 : Fri Mar 25 2005 - 10:35:47 PST