[SOLVED] Bad handle or reference

Status
Not open for further replies.

ranayehya

Junior Member level 3
Joined
Apr 13, 2018
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
203
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;
 

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

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…