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 50
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 automatictransaction(ref T tr_h);->start;$display("^^^ %16.t | %m | ERROR! Task not defined |", $time);->done;endtask: transaction// --------------------------------------------------------------------//virtual task automaticidle;$display("^^^ %16.t | %m | ERROR! Task not defined |", $time);endtask: idle// --------------------------------------------------------------------//taskput(ref T tr_h);$display("^^^ %16.t | %m | ", $time);q.put(tr_h);endtask: put// --------------------------------------------------------------------//task automaticrun_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 : forkforeverif(q.try_get(tr_h) != 0)transaction(tr_h);elseidle();join_none#0;endtask: run_q// --------------------------------------------------------------------//function voidinit;forkrun_q();join_none$display("^^^ %16.t | %m | initialization", $time);endfunction: initendclass: 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 automatictransaction(ref T tr_h);->start;$display("^^^ %16.t | %m | ERROR! Task not defined |", $time);->done;endtask: transaction// --------------------------------------------------------------------//taskput(ref T tr_h);q.put(tr_h);endtask: put// --------------------------------------------------------------------//task automaticrun_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 : forkforeverbeginq.get(tr_h);transaction(tr_h);endjoin_none#0;endtask: run_q// --------------------------------------------------------------------//function voidinit;forkrun_q();join_none$display("^^^ %16.t | %m | initialization", $time);endfunction: initendclass: tb_blocking_transaction_q_classendpackage: tb_bfm_pkg
