URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [BFM/] [src/] [tb/] [legacy/] [tb_bfm_pkg.sv] - Rev 51
Go to most recent revision | Compare with Previous | Blame | View Log
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer. ////
//// ////
//// This source file is free software; you can redistribute it ////
//// and/or modify it under the terms of the GNU Lesser General ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any ////
//// later version. ////
//// ////
//// This source is distributed in the hope that it will be ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
//// PURPOSE. See the GNU Lesser General Public License for more ////
//// details. ////
//// ////
//// You should have received a copy of the GNU Lesser General ////
//// Public License along with this source; if not, download it ////
//// from http://www.opencores.org/lgpl.shtml ////
//// ////
//////////////////////////////////////////////////////////////////////
package tb_bfm_pkg;
// --------------------------------------------------------------------
//
class tb_nonblocking_transaction_q_class #(parameter type T = logic);
T tr_h;
mailbox #(T) q;
semaphore q_semaphore;
//--------------------------------------------------------------------
function new;
this.q = new();
this.q_semaphore = new(1);
endfunction: new
// --------------------------------------------------------------------
//
event start;
event done;
virtual task automatic
transaction
(
ref T tr_h
);
->start;
$display("^^^ %16.t | %m | ERROR! Task not defined |", $time);
->done;
endtask: transaction
// --------------------------------------------------------------------
//
virtual task automatic
idle;
$display("^^^ %16.t | %m | ERROR! Task not defined |", $time);
endtask: idle
// --------------------------------------------------------------------
//
task
put
(
ref T tr_h
);
$display("^^^ %16.t | %m | ", $time);
q.put(tr_h);
endtask: put
// --------------------------------------------------------------------
//
task automatic
run_q;
if(q_semaphore.try_get() == 0)
begin
$display("^^^ %16.t | %m | ERROR! Aready active |", $time);
return;
end
$display("^^^ %16.t | %m is active |", $time);
run_q_fork : fork
forever
if(q.try_get(tr_h) != 0)
transaction(tr_h);
else
idle();
join_none
#0;
endtask: run_q
// --------------------------------------------------------------------
//
function void
init;
fork
run_q();
join_none
$display("^^^ %16.t | %m | initialization", $time);
endfunction: init
endclass: tb_nonblocking_transaction_q_class
// --------------------------------------------------------------------
//
class tb_blocking_transaction_q_class #(parameter type T = logic);
T tr_h;
mailbox #(T) q;
semaphore q_semaphore;
//--------------------------------------------------------------------
function new;
this.q = new();
this.q_semaphore = new(1);
endfunction: new
// --------------------------------------------------------------------
//
event start;
event done;
virtual task automatic
transaction
(
ref T tr_h
);
->start;
$display("^^^ %16.t | %m | ERROR! Task not defined |", $time);
->done;
endtask: transaction
// --------------------------------------------------------------------
//
task
put
(
ref T tr_h
);
q.put(tr_h);
endtask: put
// --------------------------------------------------------------------
//
task automatic
run_q;
if(q_semaphore.try_get() == 0)
begin
$display("^^^ %16.t | %m | ERROR! Aready active |", $time);
return;
end
$display("^^^ %16.t | %m is active |", $time);
this.q = new();
run_q_fork : fork
forever
begin
q.get(tr_h);
transaction(tr_h);
end
join_none
#0;
endtask: run_q
// --------------------------------------------------------------------
//
function void
init;
fork
run_q();
join_none
$display("^^^ %16.t | %m | initialization", $time);
endfunction: init
endclass: tb_blocking_transaction_q_class
endpackage: tb_bfm_pkg
Go to most recent revision | Compare with Previous | Blame | View Log