+ Post New Thread
Results 1 to 2 of 2
  1. #1
    Junior Member level 2
    Points: 196, Level: 2

    Join Date
    Apr 2018
    Posts
    20
    Helped
    0 / 0
    Points
    196
    Level
    2

    Bad handle or reference

    I got this fatal in simulation at this line
    Code:
    A.KeyExpansion();
    in TEST.sv file
    TEST.sv file
    Code:
    import uvm_pkg::*;
    `include "uvm_macros.svh"
    import code_pkg::*;
    module test();
    	AES_do A;
    int i;
    initial 
    begin
     A.nonce      [8 ]={8'h00,8'h00,8'h00,8'h00,8'h00,8'h00,8'h00,8'h00};
    A.key        [16]={ 8'h2b ,8'h7e,8'h15,8'h16,8'h28,8'hae,8'hd2,8'ha6,8'hab,8'hf7,8'h15,8'h88,8'h09,8'hcf,8'h4f,8'h3c} ;
    A.message[16]={ 8'h6b ,8'hc1,8'hbe,8'he2,8'h2e,8'h40,8'h9f,8'h96,8'he9,8'h3d,8'h7e,8'h11,8'h73,8'h93,8'h17,8'h2a}; 
        A.Nr = 128 ;  
        A.Nk = A.Nr / 32;
        A.Nr = A.Nk + 6;
        A.temp = {A.nonce[0]  ,A.nonce[1]  ,A.nonce[2]  ,A.nonce[3]  ,A.nonce[4]  ,A.nonce[5]  ,A.nonce[6]  ,A.nonce[7]  ,8'h00  ,8'h00  ,8'h00  ,8'h00  ,8'h00  ,8'h00  ,8'h00  ,8'h00};
    
        for(i=0;i<A.Nk*4;i++)
        begin
            A.in[i] =A.temp[i];
            A.Key[i]=A.key[i];
       end
    
      A.KeyExpansion();
        A.Cipher;
    $display("Cipher %p",A.ciphertext);
       end
       
    endmodule
    package.sv file
    Code:
    package code_pkg;
    	import uvm_pkg::*;
    	`include "uvm_macros.svh"
    	`include "code.sv"
    endpackage: code_pkg
    code,sv
    Code:
    import uvm_pkg::*;
    `include "uvm_macros.svh"
    import code_pkg::*;
    class code ; 
      
      byte nonce      [8 ]; 
      byte message    [16];
      byte key        [16];
      byte ciphertext [16];
    //...
     virtual function void KeyExpansion();
    //...
    endfunction : KeyExpansion;
    //...
    endclass: code;

    •   AltAdvertisment

        
       

  2. #2
    Junior Member level 2
    Points: 196, Level: 2

    Join Date
    Apr 2018
    Posts
    20
    Helped
    0 / 0
    Points
    196
    Level
    2

    Re: Bad handle or reference

    I just solved my issue.
    I should add this line to my initial block in code.sv
    // A = new;



--[[ ]]--