OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /qaz_libs/trunk/BFM/src
    from Rev 49 to Rev 50
    Reverse comparison

Rev 49 → Rev 50

/SPI/spi_agent.svh
25,32 → 25,24
//// ////
//////////////////////////////////////////////////////////////////////
 
class spi_agent
class spi_agent #(N=1)
extends uvm_agent;
`uvm_component_utils(spi_agent)
`uvm_component_param_utils(spi_agent #(N))
 
// --------------------------------------------------------------------
virtual spi_if vif;
spi_driver driver_h;
virtual spi_if #(N) vif;
spi_driver #(N) driver_h;
spi_sequencer sequencer_h;
// spi_monitor monitor_h;
 
// --------------------------------------------------------------------
virtual function void build_phase(uvm_phase phase);
// super.build_phase(phase);
driver_h = spi_driver::type_id::create("driver_h", this);
// monitor_h = spi_monitor ::type_id::create("monitor_h", this);
driver_h = spi_driver #(N)::type_id::create("driver_h", this);
sequencer_h = spi_sequencer::type_id::create("sequencer_h", this);
 
endfunction
 
// --------------------------------------------------------------------
virtual function void connect_phase(uvm_phase phase);
// super.connect_phase(phase);
 
driver_h.vif = vif;
// monitor_h.vif = vif;
 
driver_h.seq_item_port.connect(sequencer_h.seq_item_export);
endfunction
 
60,4 → 52,4
endfunction
 
// --------------------------------------------------------------------
endclass : spi_agent
endclass
/SPI/spi_driver.svh
25,17 → 25,17
//// ////
//////////////////////////////////////////////////////////////////////
 
class spi_driver
class spi_driver #(N)
extends uvm_driver #(spi_sequence_item);
`uvm_component_utils(spi_driver)
`uvm_component_param_utils(spi_driver #(N))
 
// --------------------------------------------------------------------
virtual spi_if vif;
virtual spi_if #(N) vif;
 
//--------------------------------------------------------------------
function void set_default;
vif.sclk <= 0;
vif.ss_n <= 1;
vif.ss_n <= '1;
vif.mosi <= 'x;
endfunction: set_default
 
51,7 → 51,8
index = 0;
seq_item_port.get_next_item(item);
 
vif.ss_n <= 0;
vif.ss_n <= ~(1 << item.ss_index);
 
vif.mosi <= item.mosi_data[index];
#(vif.period / 2);
 
75,7 → 76,7
end
 
#(vif.period / 2);
vif.ss_n <= 1;
vif.ss_n <= '1;
 
set_default();
seq_item_port.item_done();
89,4 → 90,4
endfunction
 
// --------------------------------------------------------------------
endclass : spi_driver
endclass
/SPI/spi_if.sv
25,8 → 25,7
//// ////
//////////////////////////////////////////////////////////////////////
 
interface
spi_if();
interface spi_if #(N=1);
import uvm_pkg::*;
`include "uvm_macros.svh"
import tb_spi_pkg::*;
33,7 → 32,7
 
// --------------------------------------------------------------------
logic sclk;
logic ss_n;
logic [N-1:0] ss_n;
logic mosi;
logic miso;
 
/SPI/spi_sequence_item.svh
35,6 → 35,7
// --------------------------------------------------------------------
logic miso_data[]; // data from slave to master
logic mosi_data[]; // data from master to slave
int ss_index = 0;
bit read;
bit write;
 
56,38 → 57,34
mosi_data[i] = 0;
endfunction : init
 
// // --------------------------------------------------------------------
// function bit do_compare(uvm_object rhs, uvm_comparer comparer);
// spi_sequence_item tested;
// bit same;
// --------------------------------------------------------------------
function void load_mosi_from_file(string file_name);
byte buffer;
integer fd;
integer code;
integer size;
 
// if (rhs==null)
// `uvm_fatal(get_type_name(), "| %m | comparison to a null pointer");
fd = $fopen(file_name, "rb");
code = $fseek(fd, 0, 2); // SEEK_END
size = $ftell(fd);
code = $rewind(fd);
data_width = size*8;
mosi_data = new[data_width];
write = 1;
 
// if (!$cast(tested,rhs))
// same = 0;
// else
// same = super.do_compare(rhs, comparer);
for(int i = 0; i < size; i++) begin
code = $fread(buffer, fd);
mosi_data[i*8 +: 8] = {>>{buffer}};
end
 
// return same;
// endfunction : do_compare
$fclose(fd);
endfunction
 
// // --------------------------------------------------------------------
// function void do_copy(uvm_object rhs);
// spi_sequence_item item;
// assert(rhs != null) else
// `uvm_fatal(get_type_name(), "| %m | copy null transaction");
// super.do_copy(rhs);
// assert($cast(item,rhs)) else
// `uvm_fatal(get_type_name(), "| %m | failed cast");
// delay = item.delay;
// command = item.command;
// wr_full = item.wr_full;
// rd_empty = item.rd_empty;
// wr_data = item.wr_data;
// rd_data = item.rd_data;
// count = item.count;
// endfunction : do_copy
// --------------------------------------------------------------------
function void load_mosi_from_byte_array(byte byte_array[]);
foreach(byte_array[i])
mosi_data[i*8 +: 8] = {>>{byte_array[i]}};
endfunction
 
// --------------------------------------------------------------------
function string convert2string();
102,8 → 99,7
);
s0 = {s0, s1};
 
if(read)
begin
if(read) begin
data = {>>{miso_data}};
 
foreach(data[i])
113,8 → 109,7
s0 = {s0, s2};
end
 
if(write)
begin
if(write) begin
data = {>>{mosi_data}};
 
foreach(data[i])
128,4 → 123,4
endfunction : convert2string
 
// --------------------------------------------------------------------
endclass : spi_sequence_item
endclass
/SPI/tb_spi_pkg.sv
28,28 → 28,12
package tb_spi_pkg;
import uvm_pkg::*;
`include "uvm_macros.svh"
import bfm_pkg::*;
 
// // --------------------------------------------------------------------
// localparam W = 16;
// localparam D = 8;
// localparam UB = $clog2(D);
 
// --------------------------------------------------------------------
// typedef enum {FIFO_RD, FIFO_WR, FIFO_BOTH, FIFO_NULL} fifo_command_t;
 
// --------------------------------------------------------------------
`include "spi_sequence_item.svh"
typedef uvm_sequencer #(spi_sequence_item) spi_sequencer;
`include "spi_driver.svh"
// `include "spi_monitor.svh"
// `include "spi_scoreboard.svh"
`include "spi_agent.svh"
// `include "tb_env.svh"
// `include "s_debug.svh"
// `include "t_top_base.svh"
// `include "t_debug.svh"
 
// --------------------------------------------------------------------
endpackage : tb_spi_pkg
endpackage
/tb/tb_bfm_pkg.sv File deleted
/tb/bfm_pkg.sv File deleted
/tb/tb_clk_pkg.sv File deleted
/tb/q_pkg.sv File deleted
/tb/tb_clk_class.sv File deleted
/tb/logger_pkg.sv File deleted
/tb/tb_clk.sv File deleted
/tb/legacy/bfm_pkg.sv
0,0 → 1,106
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 bfm_pkg;
 
// --------------------------------------------------------------------
//
typedef enum
{
NONE,
REGULAR
// BURSTY
} traffic_type_e;
 
// --------------------------------------------------------------------
//
class delay_class;
 
rand int unsigned delay = 0;
 
// --------------------------------------------------------------------
//
virtual function void set_delay(traffic_type_e kind = REGULAR);
case(kind)
NONE: delay = 0;
REGULAR: assert(this.randomize() with{delay dist {0 := 60, [1:3] := 30, [4:7] := 10};});
default: delay = 0;
endcase
endfunction: set_delay
 
// --------------------------------------------------------------------
//
virtual function int next(traffic_type_e kind = REGULAR);
set_delay(kind);
return(delay);
endfunction: next
 
// --------------------------------------------------------------------
//
endclass: delay_class
 
// --------------------------------------------------------------------
//
virtual class transaction_class #(parameter type TR_T);
 
delay_class delay_h;
 
// --------------------------------------------------------------------
//
function void random;
assert(this.randomize());
endfunction: random
 
//--------------------------------------------------------------------
//
function new;
delay_h = new();
endfunction: new
 
// --------------------------------------------------------------------
//
pure virtual function void copy(TR_T from);
 
// --------------------------------------------------------------------
//
function automatic TR_T clone;
TR_T child;
clone = new();
$cast(child, this);
clone.copy(child);
return(clone);
endfunction: clone
 
// --------------------------------------------------------------------
//
endclass: transaction_class
 
//--------------------------------------------------------------------
//
endpackage: bfm_pkg
 
/tb/legacy/logger_pkg.sv
0,0 → 1,136
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 logger_pkg;
 
// --------------------------------------------------------------------
//
typedef enum
{
FATAL,
ERROR,
WARNING,
INFO
} logger_severity_t;
 
 
// --------------------------------------------------------------------
//
class logger_class;
 
logger_severity_t verbosity = WARNING;
bit log_debug = 0;
string time_string;
int error_count = 0;
int max_error_display = 8;
bit stop_at_max_error = 1;
 
// --------------------------------------------------------------------
//
function void
set_verbosity(logger_severity_t level);
verbosity = level;
endfunction: set_verbosity
 
 
// --------------------------------------------------------------------
//
function void
debug_enable;
log_debug = 1;
endfunction: debug_enable
 
 
// --------------------------------------------------------------------
//
function void debug(string message);
time_string = $sformatf("??? %16.t | ", $time);
if(log_debug == 1)
$display({time_string, message});
endfunction: debug
 
 
// --------------------------------------------------------------------
//
function void display(string message);
time_string = $sformatf("--- %16.t | ", $time);
$display({time_string, message});
endfunction: display
 
 
// --------------------------------------------------------------------
//
function void info(string message);
time_string = $sformatf("^^^ %16.t | ", $time);
if(verbosity >= INFO)
$display({time_string, message});
endfunction: info
 
 
// --------------------------------------------------------------------
//
function void warning(string message);
time_string = $sformatf("*** %16.t | ", $time);
if(verbosity >= WARNING)
$display({time_string, message});
endfunction: warning
 
 
// --------------------------------------------------------------------
//
function void error(string message);
time_string = $sformatf("!!! %16.t | ", $time);
error_count++;
if(error_count > max_error_display)
if(stop_at_max_error)
$stop;
else
return;
if(verbosity >= ERROR)
$display({time_string, message});
endfunction: error
 
 
// --------------------------------------------------------------------
//
function void fatal(string message);
if(verbosity >= FATAL)
$fatal(1, message);
endfunction: fatal
 
 
//--------------------------------------------------------------------
//
endclass: logger_class
 
 
//--------------------------------------------------------------------
//
endpackage: logger_pkg
 
/tb/legacy/q_pkg.sv
0,0 → 1,147
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 q_pkg;
 
// --------------------------------------------------------------------
//
virtual class q_base_class #(parameter type Q_T = logic);
 
Q_T tr_h;
mailbox #(Q_T) q;
 
// --------------------------------------------------------------------
//
pure virtual task run_q;
 
 
// --------------------------------------------------------------------
//
task put(ref Q_T tr_h);
q.put(tr_h);
endtask: put
 
 
// --------------------------------------------------------------------
//
task get(ref Q_T tr_h);
q.get(tr_h);
endtask: get
 
 
//--------------------------------------------------------------------
function new;
this.q = new();
fork
forever
run_q();
join_none
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: q_base_class
 
 
// --------------------------------------------------------------------
//
virtual class nonblocking_transmission_q_class #(parameter type Q_T = logic)
extends q_base_class #(Q_T);
 
// --------------------------------------------------------------------
//
pure virtual task transmit(ref Q_T tr_h);
pure virtual task idle();
 
 
// --------------------------------------------------------------------
//
task automatic run_q;
if(q.try_get(tr_h) != 0)
transmit(tr_h);
else
idle();
endtask: run_q
 
 
// --------------------------------------------------------------------
//
endclass: nonblocking_transmission_q_class
 
 
// --------------------------------------------------------------------
//
virtual class blocking_transmission_q_class #(parameter type Q_T = logic)
extends q_base_class #(Q_T);
 
// --------------------------------------------------------------------
//
pure virtual task transmit(ref Q_T tr_h);
 
 
// --------------------------------------------------------------------
//
task run_q;
q.get(tr_h);
transmit(tr_h);
endtask: run_q
 
 
// --------------------------------------------------------------------
//
endclass: blocking_transmission_q_class
 
 
// --------------------------------------------------------------------
//
virtual class blocking_receiver_q_class #(parameter type Q_T = logic)
extends q_base_class #(Q_T);
 
// --------------------------------------------------------------------
//
pure virtual task receive(ref Q_T tr_h);
 
 
// --------------------------------------------------------------------
//
task run_q;
receive(tr_h);
q.put(tr_h);
endtask: run_q
 
 
//--------------------------------------------------------------------
//
endclass: blocking_receiver_q_class
 
 
//--------------------------------------------------------------------
//
endpackage: q_pkg
 
/tb/legacy/tb_base.sv
0,0 → 1,106
//////////////////////////////////////////////////////////////////////
//// ////
//// 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
 
import tb_clk_pkg::*;
 
 
module
tb_base
#(
parameter PERIOD = 0,
parameter ASSERT_TIME = 0
)
(
output clock,
output reg reset
);
 
// --------------------------------------------------------------------
//
task assert_reset
(
input time reset_assert
);
 
reset = 1;
$display( "-#- %16.t | %m | reset asserted!", $time );
 
#reset_assert;
 
reset = 0;
$display( "-#- %16.t | %m | reset deasserted!", $time );
 
endtask
 
 
// --------------------------------------------------------------------
//
task timeout_stop
(
input time timeout
);
 
$display("-#- %16.t | %m | timeout_stop at %t", $time, timeout);
 
fork
#(timeout) $stop;
join_none
 
endtask
 
 
// --------------------------------------------------------------------
//
tb_clk_class tb_clk_c;
tb_clk_if tb_clk_driver();
assign clock = tb_clk_driver.clk;
time reset_assert = (PERIOD * 5) + (PERIOD / 3);
logic init_done = 0;
 
initial
begin
 
reset = 1;
 
tb_clk_c = new( tb_clk_driver );
 
if( PERIOD != 0 )
tb_clk_c.init_basic_clock( PERIOD );
 
if( ASSERT_TIME != 0 )
assert_reset( ASSERT_TIME );
else if( reset_assert != 0 )
assert_reset( reset_assert );
 
init_done = 1;
 
end
endmodule
 
 
/tb/legacy/tb_bfm_pkg.sv
0,0 → 1,230
//////////////////////////////////////////////////////////////////////
//// ////
//// 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
 
/tb/legacy/tb_clk.sv
0,0 → 1,55
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
import tb_clk_pkg::*;
 
module
tb_clk
#(
parameter PERIOD = 0
)
(
output clock
);
 
tb_clk_class tb_clk_c;
tb_clk_if tb_clk_driver();
assign clock = tb_clk_driver.clk;
 
initial
begin
 
tb_clk_c = new( tb_clk_driver );
 
if( PERIOD != 0 )
tb_clk_c.init_basic_clock( PERIOD );
 
end
 
endmodule
 
 
/tb/legacy/tb_clk_class.sv
0,0 → 1,110
//////////////////////////////////////////////////////////////////////
//// ////
//// 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
 
 
// --------------------------------------------------------------------
//
class
tb_clk_class;
virtual tb_clk_if tb;
 
// --------------------------------------------------------------------
//
function
new
(
virtual tb_clk_if tb
);
this.tb = tb;
endfunction: new
 
// --------------------------------------------------------------------
//
task
init_basic_clock
(
time period
);
tb.period = period;
tb.enable = 1;
$display( "^^^ %16.t | %m | Starting clock with period %t.", $time, period );
fork
forever
if( tb.enable )
begin
#(period/2) tb.clk = 1;
-> tb.clk_rise;
#(period/2) tb.clk = 0;
-> tb.clk_fall;
end
join_none
endtask: init_basic_clock
// --------------------------------------------------------------------
//
task
enable_clock
(
logic enable
);
tb.enable = enable;
$display( "^^^ %16.t | %m | Clock Enable = %h.", $time, enable );
endtask: enable_clock
endclass: tb_clk_class
 
 
/tb/legacy/tb_clk_pkg.sv
0,0 → 1,118
//////////////////////////////////////////////////////////////////////
//// ////
//// 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;
 
// --------------------------------------------------------------------
//
class
tb_clk_class;
virtual tb_clk_if tb;
 
// --------------------------------------------------------------------
//
function
new
(
virtual tb_clk_if tb
);
this.tb = tb;
endfunction: new
 
// --------------------------------------------------------------------
//
task
init_basic_clock
(
time period
);
tb.period = period;
tb.enable = 1;
$display( "^^^ %16.t | %m | Starting clock with period %t.", $time, period );
fork
forever
if( tb.enable )
begin
#(period/2) tb.clk = 1;
-> tb.clk_rise;
#(period/2) tb.clk = 0;
-> tb.clk_fall;
end
join_none
endtask: init_basic_clock
// --------------------------------------------------------------------
//
task
enable_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
 
/tb/tb_base.sv
1,6 → 1,6
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG ////
//// Copyright (C) 2019 Authors and OPENCORES.ORG ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
25,82 → 25,62
//// ////
//////////////////////////////////////////////////////////////////////
 
`timescale 1ps/1ps
 
import tb_clk_pkg::*;
 
 
module
tb_base
#(
parameter PERIOD = 0,
parameter ASSERT_TIME = 0
N = 1,
realtime PERIODS[N],
realtime ASSERT_TIME = (PERIODS[0] * 5) + (PERIODS[0] / 3)
)
(
output clock,
output reg reset
output bit tb_clk[N],
output bit tb_aresetn,
output bit tb_reset[N]
);
timeunit 1ns;
timeprecision 100ps;
 
// --------------------------------------------------------------------
//
task assert_reset
(
input time reset_assert
);
function void assert_reset(realtime reset_assert=ASSERT_TIME);
fork
begin
tb_aresetn = 0;
#reset_assert;
tb_aresetn = 1;
end
join_none
endfunction
 
reset = 1;
$display( "-#- %16.t | %m | reset asserted!", $time );
// --------------------------------------------------------------------
bit disable_clks[N];
 
#reset_assert;
generate
for(genvar j = 0; j < N; j++) begin
always
if(disable_clks[j])
tb_clk[j] = 0;
else
#(PERIODS[j]/2) tb_clk[j] = ~tb_clk[j];
end
endgenerate
 
reset = 0;
$display( "-#- %16.t | %m | reset deasserted!", $time );
 
endtask
 
 
// --------------------------------------------------------------------
//
task timeout_stop
(
input time timeout
);
generate
for(genvar j = 0; j < N; j++) begin
bit reset = 1;
assign tb_reset[j] = reset;
 
$display("-#- %16.t | %m | timeout_stop at %t", $time, timeout);
always @(posedge tb_clk[j] or negedge tb_aresetn)
if(~tb_aresetn)
reset = 1;
else
reset = 0;
end
endgenerate
 
fork
#(timeout) $stop;
join_none
 
endtask
 
 
// --------------------------------------------------------------------
//
tb_clk_class tb_clk_c;
tb_clk_if tb_clk_driver();
assign clock = tb_clk_driver.clk;
time reset_assert = (PERIOD * 5) + (PERIOD / 3);
logic init_done = 0;
 
initial
begin
assert_reset();
 
reset = 1;
 
tb_clk_c = new( tb_clk_driver );
 
if( PERIOD != 0 )
tb_clk_c.init_basic_clock( PERIOD );
 
if( ASSERT_TIME != 0 )
assert_reset( ASSERT_TIME );
else if( reset_assert != 0 )
assert_reset( reset_assert );
 
init_done = 1;
 
end
// --------------------------------------------------------------------
endmodule
 
 
/tb/tb_pkg.sv
31,4 → 31,4
`include "random_delay.svh"
 
// --------------------------------------------------------------------
endpackage : tb_pkg
endpackage
/video_frame/video_frame_class.svh
27,7 → 27,6
 
// --------------------------------------------------------------------
class video_frame_class;
logger_class log;
rand int frame_id;
rand int pixels_per_line;
rand int lines_per_frame;
59,7 → 58,6
 
//--------------------------------------------------------------------
function new;
this.log = new;
this.frame_id = 0;
endfunction: new
 
72,7 → 70,6
int pixels_per_clk = 1,
string name = ""
);
log.info($sformatf("%m"));
this.pixels_per_line = pixels_per_line;
this.lines_per_frame = lines_per_frame;
this.bits_per_pixel = bits_per_pixel;
113,7 → 110,6
 
// --------------------------------------------------------------------
function void make_constant(int pixel);
log.info($sformatf("%m"));
this.lines = new[lines_per_frame];
 
foreach(this.lines[l])
129,7 → 125,6
 
// --------------------------------------------------------------------
function void make_counting(int offset = 0);
log.info($sformatf("%m"));
this.lines = new[lines_per_frame];
 
foreach(this.lines[l])
145,7 → 140,6
 
// --------------------------------------------------------------------
function void make_horizontal();
log.info($sformatf("%m"));
this.lines = new[lines_per_frame];
 
foreach(this.lines[l])
161,7 → 155,6
 
// --------------------------------------------------------------------
function void make_vertical();
log.info($sformatf("%m"));
this.lines = new[lines_per_frame];
 
foreach(this.lines[l])
177,7 → 170,6
 
// --------------------------------------------------------------------
function void make_random();
log.info($sformatf("%m"));
this.lines = new[lines_per_frame];
 
foreach(this.lines[l])
193,7 → 185,6
 
// --------------------------------------------------------------------
function void copy(video_frame_class from);
log.info($sformatf("%m"));
this.frame_id = from.frame_id;
this.pixels_per_line = from.pixels_per_line;
this.lines_per_frame = from.lines_per_frame;
212,7 → 203,6
 
// --------------------------------------------------------------------
virtual function video_frame_class clone;
log.info($sformatf("%m"));
clone = new();
clone.copy(this);
endfunction: clone
219,7 → 209,6
 
// --------------------------------------------------------------------
function video_frame_class catenate_horizontally(video_frame_class tail);
log.info($sformatf("%m"));
 
if(this.lines_per_frame != tail.lines_per_frame)
return(null);
248,7 → 237,6
 
// --------------------------------------------------------------------
function void shift_right(ref line_s column);
log.info($sformatf("%m"));
 
foreach(this.lines[l])
for(int p = pixels_per_line - 1; p > 0; p--)
258,114 → 246,127
this.lines[l].pixel[0] = column.pixel[l];
endfunction: shift_right
 
// --------------------------------------------------------------------
function int compare_line
( int line
, int max_mismatches
, video_frame_class to
);
int mismatch_count = 0;
// // --------------------------------------------------------------------
// function int compare_line
// ( int line
// , int max_mismatches
// , video_frame_class to
// );
// int mismatch_count = 0;
 
if(to.bits_per_pixel != this.bits_per_pixel)
begin
log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name));
return(-3);
end
// if(to.bits_per_pixel != this.bits_per_pixel)
// begin
// log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name));
// return(-3);
// end
 
foreach(this.lines[line].pixel[p])
if(to.lines[line].pixel[p] != this.lines[line].pixel[p])
begin
// foreach(this.lines[line].pixel[p])
// if(to.lines[line].pixel[p] != this.lines[line].pixel[p])
// begin
 
if(max_mismatches > 0)
mismatch_count++;
// if(max_mismatches > 0)
// mismatch_count++;
 
log.error($sformatf("mismatch @ frame[%4h][%4h] | to == %4h | this == %4h | %s",
line, p, to.lines[line].pixel[p], this.lines[line].pixel[p], name));
// log.error($sformatf("mismatch @ frame[%4h][%4h] | to == %4h | this == %4h | %s",
// line, p, to.lines[line].pixel[p], this.lines[line].pixel[p], name));
 
if(mismatch_count > max_mismatches)
return(mismatch_count);
end
// if(mismatch_count > max_mismatches)
// return(mismatch_count);
// end
 
return(mismatch_count);
endfunction: compare_line
// return(mismatch_count);
// endfunction: compare_line
 
// --------------------------------------------------------------------
function int compare(int max_mismatches, video_frame_class to);
int mismatch_count = 0;
log.info($sformatf("%m"));
// // --------------------------------------------------------------------
// function int compare(int max_mismatches, video_frame_class to);
// int mismatch_count = 0;
// log.info($sformatf("%m"));
 
if(to.pixels_per_line != this.pixels_per_line)
begin
log.error($sformatf("to.pixels_per_line != this.pixels_per_line | %s", name));
return(-1);
end
// if(to.pixels_per_line != this.pixels_per_line)
// begin
// log.error($sformatf("to.pixels_per_line != this.pixels_per_line | %s", name));
// return(-1);
// end
 
if(to.lines_per_frame != this.lines_per_frame)
begin
log.error($sformatf("to.lines_per_frame != this.lines_per_frame | %s", name));
return(-2);
end
// if(to.lines_per_frame != this.lines_per_frame)
// begin
// log.error($sformatf("to.lines_per_frame != this.lines_per_frame | %s", name));
// return(-2);
// end
 
if(to.bits_per_pixel != this.bits_per_pixel)
begin
log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name));
return(-3);
end
// if(to.bits_per_pixel != this.bits_per_pixel)
// begin
// log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name));
// return(-3);
// end
 
foreach(this.lines[l])
begin
foreach(this.lines[l].pixel[p])
if(to.lines[l].pixel[p] != this.lines[l].pixel[p])
begin
if(max_mismatches > 0)
mismatch_count++;
// foreach(this.lines[l])
// begin
// foreach(this.lines[l].pixel[p])
// if(to.lines[l].pixel[p] != this.lines[l].pixel[p])
// begin
// if(max_mismatches > 0)
// mismatch_count++;
 
log.error($sformatf("mismatch @ frame[%4h][%4h] | to == %4h | this == %4h | %s", l, p, to.lines[l].pixel[p], this.lines[l].pixel[p], name));
// log.error($sformatf("mismatch @ frame[%4h][%4h] | to == %4h | this == %4h | %s", l, p, to.lines[l].pixel[p], this.lines[l].pixel[p], name));
 
if(mismatch_count > max_mismatches)
return(mismatch_count);
end
end
// if(mismatch_count > max_mismatches)
// return(mismatch_count);
// end
// end
 
return(mismatch_count);
endfunction: compare
// return(mismatch_count);
// endfunction: compare
 
// --------------------------------------------------------------------
function void print_line(int line, int pixel, int count);
log.info($sformatf("%m"));
// // --------------------------------------------------------------------
// function void print_line(int line, int pixel, int count);
// log.info($sformatf("%m"));
 
for(int i = 0; i < count; i++)
log.display($sformatf("%4h @ frame[%4h][%4h] | %s", this.lines[line].pixel[(pixel + i)], line, (pixel + i), name));
endfunction: print_line
// for(int i = 0; i < count; i++)
// log.display($sformatf("%4h @ frame[%4h][%4h] | %s", this.lines[line].pixel[(pixel + i)], line, (pixel + i), name));
// endfunction: print_line
 
// // --------------------------------------------------------------------
// function void print_config();
// log.display($sformatf("%m | frame_id = %06d | %s", frame_id, name));
// log.display($sformatf("%m | pixels_per_line = %06d | %s", pixels_per_line, name));
// log.display($sformatf("%m | lines_per_frame = %06d | %s", lines_per_frame, name));
// log.display($sformatf("%m | bits_per_pixel = %06d | %s", bits_per_pixel, name));
// log.display($sformatf("%m | pixels_per_clk = %06d | %s", pixels_per_clk, name));
// log.display($sformatf("%m | pattern = %s | %s", pattern, name));
// endfunction: print_config
 
// --------------------------------------------------------------------
function void print_config();
log.display($sformatf("%m | frame_id = %06d | %s", frame_id, name));
log.display($sformatf("%m | pixels_per_line = %06d | %s", pixels_per_line, name));
log.display($sformatf("%m | lines_per_frame = %06d | %s", lines_per_frame, name));
log.display($sformatf("%m | bits_per_pixel = %06d | %s", bits_per_pixel, name));
log.display($sformatf("%m | pixels_per_clk = %06d | %s", pixels_per_clk, name));
log.display($sformatf("%m | pattern = %s | %s", pattern, name));
$display($sformatf("%m | frame_id = %06d | %s", frame_id, name));
$display($sformatf("%m | pixels_per_line = %06d | %s", pixels_per_line, name));
$display($sformatf("%m | lines_per_frame = %06d | %s", lines_per_frame, name));
$display($sformatf("%m | bits_per_pixel = %06d | %s", bits_per_pixel, name));
$display($sformatf("%m | pixels_per_clk = %06d | %s", pixels_per_clk, name));
$display($sformatf("%m | pattern = %s | %s", pattern, name));
endfunction: print_config
 
// --------------------------------------------------------------------
function string convert2string(int grid=8);
string s;
string s0, s1;
string f ="";
string fs = $sformatf("%%s%%%0d.h" , (bits_per_pixel % 4 == 0)
? bits_per_pixel / 4
: (bits_per_pixel / 4) + 1
);
foreach(this.lines[l])
begin
s = $sformatf("[%4.d]", l);
foreach(this.lines[l].pixel[p])
s = {s, $sformatf(fs, (p % grid == 0) ? "!" : "|", this.lines[l].pixel[p])};
int nibbles = ( bits_per_pixel % 4 == 0)
? bits_per_pixel / 4
: (bits_per_pixel / 4) + 1;
 
f = {f, s, "|\n"};
foreach(this.lines[l]) begin
s0 = $sformatf("[%4.d]", l);
foreach(this.lines[l].pixel[p]) begin
s1 = $sformatf("%.h", this.lines[l].pixel[p]);
s1 = s1.substr(nibbles, s1.len()-1);
s0 = {s0, (p % grid == 0) ? "!" : "|", s1};
end
 
f = {f, s0, "|\n"};
end
 
return f;
endfunction: convert2string
 
// --------------------------------------------------------------------
endclass: video_frame_class
endclass
/video_frame/video_frame_config.svh
57,4 → 57,4
endfunction : init
 
// --------------------------------------------------------------------
endclass: video_frame_config
endclass
/video_frame/video_frame_pkg.sv
26,7 → 26,6
//////////////////////////////////////////////////////////////////////
 
package video_frame_pkg;
import logger_pkg::*;
 
// --------------------------------------------------------------------
typedef struct
50,4 → 49,4
`include "video_frame_class.svh"
 
// --------------------------------------------------------------------
endpackage: video_frame_pkg
endpackage

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.