otis
Member level 3
- Joined
- Sep 21, 2010
- Messages
- 60
- Helped
- 4
- Reputation
- 8
- Reaction score
- 3
- Trophy points
- 1,288
- Activity points
- 1,711
Hi,
I have a question in the copy method. I hope this is the correct forum
Here is the code
I am getting error (questasim) at t1 = t.one.copy(); .
** FatalSIGSEGV) Bad handle or reference
#Fatal error in Function test_pkg/packet::copy at .......
What is wrong with the copy class.
Thanks a lot!
I have a question in the copy method. I hope this is the correct forum
Here is the code
Code:
package test_pkg;
typedef enum bit {rd, wr} typ_dir;
typedef logic [15:0] typ_data;
typedef logic [15:0] typ_addr;
typedef class stream;
class packet;
static int next_ID;
const int ID;
rand typ_data data;
rand typ_addr addr;
rand typ_dir dir;
function new();
ID = next_ID++;
endfunction
function packet copy();
packet clone;
clone.dir = dir;
clone.addr = addr;
clone.data = data;
return clone;
endfunction
function bit compare(packet other);
if (other.dir !== dir) return 0;
if (other.addr !== addr) return 0;
if (other.data !== data) return 0;
return 1;
endfunction
function string psprint();
string kind;
kind = (dir==rd) ? "Read" : "Write";;
$sformat (psprint, "%s packet %0d: a=%h, D=%h...id=%h",kind,data,addr,dir,ID );
endfunction
endclass
class stream;
string name;
packet history [$];
function packet get_trans(bit print = 1'b0);
packet t;
t = new();
void'(t.randomize());
history.push_back(t);
if (print)
$display ("Stream %s generated %s\n", name, t.psprint());
return t;
endfunction : get_trans
function new(string name = "default");
this.name = name;
endfunction
endclass
endpackage
module top;
import test_pkg::*;
stream one = new ();
packet t, t1, t2;
initial begin
repeat (10)
begin
t = one.get_trans(1);
#1000;
$display ("%t.....",$time);
end
for (int i=0; i<one.history.size(); i++)
$display( "%d: %s", i, one.history[i].psprint() );
t = one.get_trans();
t1 = t.one.copy();
t2 = one.get_trans();
end
endmodule
I am getting error (questasim) at t1 = t.one.copy(); .
** FatalSIGSEGV) Bad handle or reference
#Fatal error in Function test_pkg/packet::copy at .......
What is wrong with the copy class.
Thanks a lot!