Advertisement
tariq786

Untitled

Oct 16th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  //variables for HD calculation
  2.   reg [N-1:0]         HD [0:2**N-1][0:2**N-1];
  3.   reg [2**N-1:0]      i,j;
  4.   reg [N-1:0]         summation;
  5.  
  6.    CALC_HD:
  7.           begin
  8.             for(i=0; i < 2**N;i=i+1)
  9.               for(j=0; j < 2**N;j=j+1)
  10.                 begin
  11.                  summation = sum(i^j); //function call
  12.                  if( summation >= min_hd )
  13.                     begin
  14.                       HD[i][j] = 1;
  15.                       //     $display("sum=%b,HD[%2d][%2d]=%2d\n",summation,i,j,HD[i][j]); //for debugging
  16.                     end
  17.                   else
  18.                     HD[i][j] = 0;
  19.                 end // for (j=0; j < 2**N;j=j+1)
  20.             next_state = ONE_TIME_SETUP;
  21.              end
  22.  
  23.  
  24. function [N-1:0] sum(input [N-1:0] input_vector);
  25.     integer       k;
  26.     reg [N-1:0]   temp;
  27.    
  28.     begin
  29.       temp = 0;
  30.       for(k=0; k < N; k=k+1)
  31.         begin
  32.           temp = temp + input_vector[k];
  33.         end
  34.       sum = temp;
  35.     end
  36.        
  37.   endfunction // sum
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement