URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [BFM/] [src/] [tb/] [legacy/] [tb_clk_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 //////// //////////////////////////////////////////////////////////////////////////`timescale 1ps/1ps// --------------------------------------------------------------------//interface tb_clk_if;logic clk = 0;logic enable = 0;time period;event clk_rise;event clk_fall;modport tb_m(output clk);endinterface: tb_clk_if// --------------------------------------------------------------------//package tb_clk_pkg;// --------------------------------------------------------------------//classtb_clk_class;virtual tb_clk_if tb;// --------------------------------------------------------------------//functionnew(virtual tb_clk_if tb);this.tb = tb;endfunction: new// --------------------------------------------------------------------//taskinit_basic_clock(time period);tb.period = period;tb.enable = 1;$display( "^^^ %16.t | %m | Starting clock with period %t.", $time, period );forkforeverif( tb.enable )begin#(period/2) tb.clk = 1;-> tb.clk_rise;#(period/2) tb.clk = 0;-> tb.clk_fall;endjoin_noneendtask: init_basic_clock// --------------------------------------------------------------------//taskenable_clock(logic enable);tb.enable = enable;$display( "^^^ %16.t | %m | Clock Enable = %h.", $time, enable );endtask: enable_clock// --------------------------------------------------------------------//endclass: tb_clk_class//--------------------------------------------------------------------//endpackage: tb_clk_pkg
