W elcome to
Fintronic USA

redball.gif (326 bytes)About Fintronic USA

redball.gif (326 bytes)Main announcements

redball.gif (326 bytes)What's new at Fintronic

redball.gif (326 bytes)What our customers are saying...

redball.gif (326 bytes)Support for SystemC

redball.gif (326 bytes)Support for Verilog 2001

redball.gif (326 bytes)Third party tools integrated with FinSim(Specman, Denali, Debussy, Undertow, Vera, VirSim, HDL Score, Comet, Meteor, NelSim, Pivot, DeskPOD, @Designer 2.1)


Inverting a 4,000,000x4,000,000 sparse matrix in Verilog

This example works on FinSim 10_07_197 and subsequent versions.

This example inverts a simple sparse matrice of 4,000,000x4,000,000 elements of type real twice, uses two norm system functions to measure it and displays all non-zero values on one line and one column.

On a laptop with Intel core i7 at 2.4GHz this example run in 1.29 seconds.

module top;
  parameter integer size = 4000000;
  real      MReal1 [size-1 : 0][size-1 : 0];
  real      MRInv [size-1 : 0][size-1 : 0];
  integer   found, lin, col, idx;
  integer   i;
  real      r, max, sum;

  initial begin
    /* declaring sparse matrices */
    /* initializing matrice to be inverted*/
    $Diag(MReal1, 2, 1, 7.0);
    /* $Diag(MReal1, 2, 1, 7.0) is a more efficient version of the code below:
    for (i = 0; i < size/2; i++)
        MReal1[2*i][i] = 7.0;
    for (i = 0; i < size; i++)
	MReal1[i][i] = 1.0;
      /*inverting matrix */
      MRInv = MReal1 **(-1); 
      MRInv = MRInv **(-1); 

      lin = 4*size/10;
      $display("displaying all non-zero values on line %d\n", lin);
      idx = -1;
      found = $SpReadNextNzElemInLine(MRInv, lin, col, idx, r);
      while (found) begin
	 $display("MRInv[%d][%d]=%e\n", lin, col, r);
	 found = $SpReadNextNzElemInLine(MRInv, lin, col, idx, r);

      col = 2*size/10;
      $display("displaying all non-zero values on column %d\n", col);
      lin = -1;
      found = $SpReadNextNzElemInCol(MRInv, lin, col, r);
      while (found) begin
	 $display("MRInv[%d][%d]=%e\n", lin, col, r);
	 found = $SpReadNextNzElemInCol(MRInv, lin, col, r);

      $display("********displaying norms and distances*********\n");
      max = $VpNormAbsMax(MRInv);
      sum = $VpNormAbsSum(MRInv);
      $display("max=%e, sum=%e\n", max, sum);
endmodule // top

Copyright 1999-2021, Fintronic USA, Inc.   All rights reserved.