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
    from Rev 43 to Rev 44
    Reverse comparison

Rev 43 → Rev 44

/trunk/BFM/sim/tests/tb_video_frame_dpi/count.raw Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
trunk/BFM/sim/tests/tb_video_frame_dpi/count.raw Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: trunk/BFM/sim/tests/tb_video_frame_dpi/init_test.do =================================================================== --- trunk/BFM/sim/tests/tb_video_frame_dpi/init_test.do (revision 43) +++ trunk/BFM/sim/tests/tb_video_frame_dpi/init_test.do (revision 44) @@ -9,7 +9,8 @@ set env(SIM_TARGET) fpga radix -hexadecimal -quietly set env(PATH) "D:/Anaconda2;$::env(PATH)" +# quietly set env(PATH) "D:/Anaconda2;$::env(PATH)" +quietly set env(PATH) "D:/anaconda3;$::env(PATH)" make_lib work 1
/trunk/BFM/sim/tests/tb_video_frame_dpi/py_dpi.c
37,7 → 37,7
void c_do_it()
{
printf("^^^ | c_do_it()\n");
 
/* result = instance.method(x,y) */
PyObject *pmeth = PyObject_GetAttrString(g_dva_i, "do_it");
// Py_DECREF(pinst);
56,15 → 56,15
{
int va_y = svSize(va, 1);
int va_x = svSize(va, 2);
 
printf("^^^ | c_get_array() | %dx%d\n", va_x, va_y);
g_va = (unsigned int *)svGetArrElemPtr2(va, 0, 0);
 
PyObject *pmeth = PyObject_GetAttrString(g_dva_i, "py_get_array");
// pargs = Py_BuildValue("(ss)", arg1, arg2); /* convert to Python */
// PyObject *pres = PyEval_CallObject(pmeth, pargs); /* call method(x,y) */
PyObject *pres = PyEval_CallObject(pmeth, NULL);
 
Py_DECREF(pmeth);
// Py_DECREF(pargs);
Py_DECREF(pres);
71,6 → 71,8
}
 
// --------------------------------------------------------------------
#define MAX_ARGV 4
 
int py_run_file
( const char *filename
, int argc
79,29 → 81,40
{
printf("^^^ | py_run_file | %s |\n", filename);
 
char *argv[4]; // limit of 4 args
wchar_t *w_argv[MAX_ARGV]; // limit of MAX_ARGV args
int i;
for(i = 0; i < argc && i < 4; i++)
{
argv[i] = *(char **)svGetArrElemPtr1(args, i);
printf( "^^^ | py_run_file | args[%d] = %s\n"
, i
, argv[i]
);
}
for(i = 0; i < argc && i < MAX_ARGV; i++)
w_argv[i] = Py_DecodeLocale(*((char **)svGetArrElemPtr1(args, i)), NULL);
 
PySys_SetArgv(argc, argv);
PyObject *PyFileObject = PyFile_FromString((char *)filename, "r");
return PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject), filename, 1);
PySys_SetArgv(argc, w_argv);
 
char pre_string[] = "exec(open('./";
char post_string[] = "').read())";
char v_filename[] = "try_it.py";
unsigned int size = (sizeof(pre_string) + sizeof(post_string)) * sizeof(char);
size += strlen(filename);
char *run_string = (char *)malloc(size);
sprintf(run_string, "%s%s%s", pre_string, filename, post_string);
 
PyRun_SimpleString(run_string);
free(run_string);
return 0;
}
 
// --------------------------------------------------------------------
extern PyMODINIT_FUNC PyInit_py_to_video_frame(void);
 
void init_py_dpi(int width, int height)
{
printf("^^^ | init_py_dpi() | %dx%d\n", width, height);
 
PyImport_AppendInittab("py_to_video_frame", PyInit_py_to_video_frame);
Py_Initialize();
init_py_to_video_frame();
 
PyObject *sys = PyImport_ImportModule("sys");
PyObject *path = PyObject_GetAttrString(sys, "path");
PyList_Append(path, PyUnicode_FromString("."));
 
PyObject *dva_m = PyImport_ImportModule("dpi_video_array");
if(!dva_m)
{
108,7 → 121,7
PyErr_Print();
printf("^^^ | init_py_dpi() | dva_m Error\n");
}
 
PyObject *dva_c = PyObject_GetAttrString(dva_m, "dpi_video_array");
Py_DECREF(dva_m);
if(!dva_c)
116,7 → 129,7
PyErr_Print();
printf("^^^ | init_py_dpi() | dva_c Error\n");
}
 
PyObject *args = Py_BuildValue("(ii)", width, height);
g_dva_i = PyObject_CallObject(dva_c, args);
Py_DECREF(args);
134,9 → 147,9
void exit_py_dpi()
{
printf("^^^ | exit_py_dpi()\n");
 
if(g_dva_i)
Py_DECREF(g_dva_i);
 
Py_Finalize();
}
/trunk/BFM/sim/tests/tb_video_frame_dpi/py_dpi.h
53,10 → 53,6
int height);
 
DPI_LINK_DECL DPI_DLLESPEC
void
init_py_to_video_frame();
 
DPI_LINK_DECL DPI_DLLESPEC
int
py_run_file(
const char* filename,
/trunk/BFM/sim/tests/tb_video_frame_dpi/py_raw_to_frame.py
0,0 → 1,92
#
# ////////////////////////////////////////////////////////////////////
# // ////
# // Copyright (C) 2018 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 sys
# import sv_video
import numpy as np
# import matplotlib.pyplot as plt
 
print("^^^ | py_raw_to_frame |")
print('Number of arguments:', len(sys.argv), 'arguments.')
print('Argument List:', str(sys.argv))
 
# dataSend = np.arange(1, 9 + 1, dtype=np.uint32)
 
# tiny_frame = np.arange(32, 32 + 32, dtype=np.uint32)
# data_list = tiny_frame.flatten()
# data_list = tiny_frame.tolist()
 
# sv_video.py_list_to_c_array(data_list)
 
# ---------------------------------------------------------
v_frames = 1
v_width = 8
v_height = 16
 
# # fname = sys.argv[0]
# fname = 'count.raw'
# print("file name: ", fname)
 
# with open(fname, 'r') as infile:
# data = np.fromfile(infile, dtype='uint16').reshape(v_frames, v_height, v_width)
 
# np.set_printoptions(formatter={'int':hex})
 
# for i in range(v_frames):
# print(data[i])
# fig, ax = plt.subplots()
# im = ax.imshow(data[i], cmap='gray')
# ax.set(xticks=[], yticks=[])
# fig.colorbar(im)
# plt.show()
 
# from __future__ import print_function
# with open('out.txt', 'w') as f:
# print('qqq\n', file=f)
# print(data[0], file=f)
# f = open('out.txt','w')
# print >>f,'some Text'
# print >>f, data[0].flatten()
# for i in range(v_frames*v_height*v_width):
# print >>f, data[0].flatten()[i]
 
# data = np.arange(v_frames*v_width*v_height, dtype='uint16')
# data = data.reshape(v_frames, v_height, v_width)
 
# f = open('count.raw','r')
data = np.fromfile('count.raw', dtype='uint16')
 
print(data)
print(data.shape)
# with open('init_test.do') as fp:
# for line in fp:
# print line
/trunk/BFM/sim/tests/tb_video_frame_dpi/py_video.py
1,5 → 1,30
#
 
# ////////////////////////////////////////////////////////////////////
# // ////
# // Copyright (C) 2018 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 numpy as np
import matplotlib.pyplot as plt
 
/trunk/BFM/sim/tests/tb_video_frame_dpi/sim.f
1,11 → 1,5
#
#
 
# -voptargs="-f ./acc_file.f"
 
# -suppress 12110
# -novopt
 
-ldflags "D:/Anaconda2/python27.dll"
# -ldflags "D:/Anaconda2/Lib/site-packages/numpy/core/lib/npymath.lib"
 
# -ldflags "D:/Anaconda2/python27.dll"
-ldflags "D:/anaconda3/python36.dll"
/trunk/BFM/sim/tests/tb_video_frame_dpi/sv_video_frame_dpi.svh
35,7 → 35,7
int return_status;
return_status = py_run_file(filename, py_args.size(), py_args);
endfunction : py_file
 
// --------------------------------------------------------------------
task do_it();
$display("^^^ %16.t | %m |", $time);
51,11 → 51,6
endtask
 
// --------------------------------------------------------------------
function new;
$display("^^^ | video_frame_dpi | new");
endfunction
 
// --------------------------------------------------------------------
function void init(int width, int height, buffer_in_size=2, buffer_out_size=2);
video_array_t a_h;
$display("^^^ | video_frame_dpi | init");
62,14 → 57,14
this.array_buffer = new(buffer_in_size);
this.buffer_in = new(buffer_in_size);
this.buffer_out = new(buffer_out_size);
 
for(int i = 0; i < buffer_in_size; i++)
begin
a_h = new[height];
 
foreach(a_h[y])
a_h[y] = new[width];
 
if(array_buffer.try_put(a_h) == 0)
begin
$display("^^^ | video_frame_dpi | init ERROR!");
76,7 → 71,7
$stop;
end
end
 
init_py_dpi(width, height);
endfunction
 
86,6 → 81,11
exit_py_dpi();
endfunction
 
// --------------------------------------------------------------------
function new;
$display("^^^ | video_frame_dpi | new");
endfunction
 
// --------------------------------------------------------------------
endclass : video_frame_dpi
 
/trunk/BFM/sim/tests/tb_video_frame_dpi/tb_files.f
1,10 → 1,10
#
 
# ${PROJECT_DIR}/sim/src//.sv
# -ccflags "-Bsymbolic -ID:/Anaconda2/include -D MS_WIN64"
# -ccflags "-ID:/Anaconda2/Lib/site-packages/numpy/core/include"
-ccflags "-Bsymbolic -ID:/anaconda3/include -D MS_WIN64"
-ccflags "-ID:/anaconda3/Lib/site-packages/numpy/core/include"
 
-ccflags "-Bsymbolic -ID:/Anaconda2/include -D MS_WIN64"
-ccflags "-ID:/Anaconda2/Lib/site-packages/numpy/core/include"
 
-ccflags "-std=c99"
-dpiheader py_dpi.h
 
/trunk/BFM/sim/tests/tb_video_frame_dpi/try_it.py
24,10 → 24,10
# // from http://www.opencores.org/lgpl.shtml ////
# ////////////////////////////////////////////////////////////////////
import sys
# import py_to_video_frame as vf
import py_to_video_frame as vf
import numpy as np
 
print("^^^ | running python!")
print("~~~ | running python!")
print('Number of arguments:', len(sys.argv), 'arguments.')
print('Argument List:', str(sys.argv))
 
/trunk/BFM/sim/tests/tb_video_frame_dpi/video_frame_dpi.sv
40,7 → 40,6
import "DPI-C" context function void c_do_it();
import "DPI-C" context function void c_get_array(inout video_array_t va);
import "DPI-C" context function int py_run_file(string filename, int argc, string args[]);
import "DPI-C" context function void init_py_to_video_frame();
export "DPI-C" task sv_write;
 
// --------------------------------------------------------------------
62,7 → 61,8
vf_h.init(WIDTH, HEIGHT);
 
vf_h.get_frame(va);
// vf_h.do_it();
vf_h.do_it();
vf_h.py_file("try_it.py", '{"Larry", "Curly", "Moe"});
 
vf_h.exit();
 
/trunk/basal/sim/tests/tb_fifo/fifo_agent.svh
0,0 → 1,63
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class fifo_agent
extends uvm_agent;
`uvm_component_utils(fifo_agent)
 
// --------------------------------------------------------------------
virtual fifo_if #(.W(W), .D(D)) vif;
fifo_driver driver_h;
fifo_sequencer sequencer_h;
fifo_monitor monitor_h;
 
// --------------------------------------------------------------------
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
driver_h = fifo_driver::type_id::create("driver_h", this);
monitor_h = fifo_monitor ::type_id::create("monitor_h", this);
sequencer_h = fifo_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
 
// --------------------------------------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
 
// --------------------------------------------------------------------
endclass : fifo_agent
/trunk/basal/sim/tests/tb_fifo/fifo_driver.svh
0,0 → 1,88
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class fifo_driver
extends uvm_driver #(fifo_sequence_item);
`uvm_component_utils(fifo_driver)
 
// --------------------------------------------------------------------
virtual fifo_if #(.W(W), .D(D)) vif;
 
//--------------------------------------------------------------------
function void set_default;
vif.cb.wr_en <= 0;
vif.cb.rd_en <= 0;
vif.cb.wr_data <= 'x;
endfunction: set_default
 
//--------------------------------------------------------------------
virtual task run_phase(uvm_phase phase);
fifo_sequence_item item;
super.run_phase(phase);
 
set_default();
 
forever
begin
wait(~vif.cb.reset);
vif.zero_cycle_delay();
seq_item_port.get_next_item(item);
 
repeat(item.delay) @(vif.cb);
 
if((item.command == FIFO_WR) || (item.command == FIFO_BOTH))
begin
if(vif.wr_full)
`uvm_error(get_name(), "writing to full FIFO!")
vif.cb.wr_data <= item.wr_data;
vif.cb.wr_en <= 1;
end
 
if((item.command == FIFO_RD) || (item.command == FIFO_BOTH))
begin
if(vif.rd_empty)
`uvm_error(get_name(), "reading empty FIFO!")
item.rd_data = vif.cb.rd_data;
vif.cb.rd_en <= 1;
end
 
@(vif.cb);
item.wr_full = vif.wr_full;
item.rd_empty = vif.rd_empty;
item.count = vif.count;
set_default();
seq_item_port.item_done();
end
endtask : run_phase
 
//--------------------------------------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
 
// --------------------------------------------------------------------
endclass : fifo_driver
/trunk/basal/sim/tests/tb_fifo/fifo_if.sv
0,0 → 1,70
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
interface
fifo_if
#(
W,
D,
UB = $clog2(D)
)
(
input reset,
input clk
);
import uvm_pkg::*;
`include "uvm_macros.svh"
import tb_fifo_pkg::*;
 
// --------------------------------------------------------------------
wire wr_full;
wire [W-1:0] wr_data;
wire wr_en;
wire rd_empty;
wire [W-1:0] rd_data;
wire rd_en;
wire [UB:0] count;
 
// --------------------------------------------------------------------
default clocking cb @(posedge clk);
input reset;
input wr_full;
input rd_empty;
input rd_data;
input count;
inout rd_en;
inout wr_en;
inout wr_data;
endclocking
 
// --------------------------------------------------------------------
task zero_cycle_delay;
##0;
endtask: zero_cycle_delay
 
// --------------------------------------------------------------------
endinterface
/trunk/basal/sim/tests/tb_fifo/fifo_monitor.svh
0,0 → 1,72
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class fifo_monitor extends uvm_component;
`uvm_component_utils(fifo_monitor);
 
virtual fifo_if #(.W(W), .D(D)) vif;
uvm_analysis_port #(fifo_sequence_item) ap;
 
// --------------------------------------------------------------------
function new (string name, uvm_component parent);
super.new(name,parent);
endfunction
 
// --------------------------------------------------------------------
function void build_phase(uvm_phase phase);
ap = new("ap", this);
endfunction : build_phase
 
// --------------------------------------------------------------------
task run_phase(uvm_phase phase);
fifo_sequence_item item;
fifo_sequence_item c_item;
item = fifo_sequence_item::type_id::create("item");
 
forever @(vif.cb iff vif.cb.reset === 0)
if(vif.cb.wr_en || vif.cb.rd_en)
begin
$cast(c_item, item.clone);
c_item.wr_full = vif.cb.wr_full;
c_item.wr_data = vif.cb.wr_data;
c_item.rd_empty = vif.cb.rd_empty;
c_item.rd_data = vif.cb.rd_data;
c_item.count = vif.cb.count;
 
if(vif.cb.wr_en && vif.cb.rd_en)
c_item.command = FIFO_BOTH;
else if(vif.cb.wr_en)
c_item.command = FIFO_WR;
else if(vif.cb.rd_en)
c_item.command = FIFO_RD;
 
ap.write(c_item);
end
endtask : run_phase
 
// --------------------------------------------------------------------
endclass : fifo_monitor
/trunk/basal/sim/tests/tb_fifo/fifo_scoreboard.svh
0,0 → 1,75
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class fifo_scoreboard extends uvm_subscriber #(fifo_sequence_item);
`uvm_component_utils(fifo_scoreboard);
 
// --------------------------------------------------------------------
function new (string name, uvm_component parent);
super.new(name, parent);
endfunction : new
 
// --------------------------------------------------------------------
function void build_phase(uvm_phase phase);
endfunction : build_phase
 
// --------------------------------------------------------------------
mailbox #(fifo_sequence_item) mb = new();
fifo_sequence_item c_t;
fifo_sequence_item item;
int m_matches = 0;
int m_mismatches = 0;
 
function void write(fifo_sequence_item t);
 
$cast(c_t, t.clone);
 
if((c_t.command = FIFO_WR) || (c_t.command = FIFO_BOTH))
mb.try_put(c_t);
 
if((c_t.command = FIFO_RD) || (c_t.command = FIFO_BOTH))
mb.try_get(item);
 
if(~c_t.compare(item))
begin
uvm_report_info(get_name(), $sformatf("^^^ %16.t | %m | MISMATCH!!! | %s", $time, {20{"-"}}));
uvm_report_info(get_name(), c_t.convert2string);
uvm_report_info(get_name(), item.convert2string);
m_mismatches++;
end
else
m_matches++;
endfunction : write
 
// --------------------------------------------------------------------
function void report_phase(uvm_phase phase);
uvm_report_info(get_name(), $sformatf("Matches : %0d", m_matches));
uvm_report_info(get_name(), $sformatf("Mismatches: %0d", m_mismatches));
endfunction
 
// --------------------------------------------------------------------
endclass : fifo_scoreboard
/trunk/basal/sim/tests/tb_fifo/fifo_sequence_item.svh
0,0 → 1,111
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class fifo_sequence_item
extends uvm_sequence_item;
`uvm_object_utils(fifo_sequence_item)
 
// --------------------------------------------------------------------
rand int delay;
rand fifo_command_t command;
rand logic [W-1:0] wr_data;
 
// --------------------------------------------------------------------
logic wr_full;
logic rd_empty;
logic [W-1:0] rd_data;
logic [UB:0] count;
 
// --------------------------------------------------------------------
constraint delay_c
{
delay dist {0 := 90, [1:2] := 7, [3:7] := 3};
}
 
// --------------------------------------------------------------------
function new(string name = "");
super.new(name);
endfunction : new
 
// --------------------------------------------------------------------
function bit do_compare(uvm_object rhs, uvm_comparer comparer);
fifo_sequence_item tested;
bit same;
 
if (rhs==null)
`uvm_fatal(get_type_name(), "| %m | comparison to a null pointer");
 
if (!$cast(tested,rhs))
same = 0;
else
same = super.do_compare(rhs, comparer);
 
return same;
endfunction : do_compare
 
// --------------------------------------------------------------------
function void do_copy(uvm_object rhs);
fifo_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 string convert2string();
string s0, s1, s2, s3;
s0 = $sformatf( "| %m | wr | rd | full | empty |\n");
s1 = $sformatf( "| %m | %1h | %1h | %1h | %1h |\n"
, (command == FIFO_WR) || (command == FIFO_BOTH)
, (command == FIFO_RD) || (command == FIFO_BOTH)
, wr_full
, rd_empty
);
s2 = $sformatf("| %m | wr_data: %h\n" , wr_data);
s3 = $sformatf("| %m | rd_data: %h\n" , rd_data);
 
if(command == FIFO_NULL)
return {s1, s0};
else if(command == FIFO_BOTH)
return {s3, s2, s1, s0};
else if(command == FIFO_WR)
return {s2, s1, s0};
else if(command == FIFO_RD)
return {s3, s1, s0};
endfunction : convert2string
 
// --------------------------------------------------------------------
endclass : fifo_sequence_item
/trunk/basal/sim/tests/tb_fifo/files.f
0,0 → 1,3
#
 
${PROJECT_DIR}/src/FIFOs/sync_fifo.sv
/trunk/basal/sim/tests/tb_fifo/init_test.do
0,0 → 1,29
# ------------------------------------
#
# ------------------------------------
 
global env
 
# setup environment
do ../../../../scripts/sim_env.do
set env(SIM_TARGET) fpga
 
radix -hexadecimal
 
make_lib work 1
 
sim_compile_lib $env(LIB_BASE_DIR) tb_packages
sim_compile_lib $env(LIB_BASE_DIR) bfm_packages
sim_compile_lib $env(LIB_BASE_DIR) qaz_lib
sim_compile_lib $env(LIB_BASE_DIR) sim
 
# compile simulation files
vlog -f ./tb_files.f
 
#
vlog -f ./files.f
 
# run the sim
sim_run_test
 
 
/trunk/basal/sim/tests/tb_fifo/s_debug.svh
0,0 → 1,72
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class s_debug
extends uvm_sequence #(fifo_sequence_item);
`uvm_object_utils(s_debug)
 
// --------------------------------------------------------------------
function new(string name = "s_debug");
super.new(name);
endfunction
 
// --------------------------------------------------------------------
task body();
logic wr_full = 0;
logic rd_empty = 1;
int count;
fifo_sequence_item item;
fifo_sequence_item c_item;
item = fifo_sequence_item::type_id::create("item");
 
repeat(64)
begin
$cast(c_item, item.clone);
start_item(c_item);
assert(c_item.randomize());
if(wr_full)
c_item.command = FIFO_RD;
else if(rd_empty)
c_item.command = FIFO_WR;
finish_item(c_item);
wr_full = c_item.wr_full;
rd_empty = c_item.rd_empty;
end
 
count = c_item.count;
repeat(count)
begin
$cast(c_item, item.clone);
start_item(c_item);
assert(c_item.randomize());
c_item.command = FIFO_RD;
finish_item(c_item);
end
endtask: body
 
// --------------------------------------------------------------------
endclass : s_debug
/trunk/basal/sim/tests/tb_fifo/sim.do
0,0 → 1,10
#
#
 
quit -sim
 
vsim -suppress 12110 -novopt work.tb_top
# vsim -f ./sim.f work.tb_top
 
# log all signals
log /* -r
/trunk/basal/sim/tests/tb_fifo/t_debug.svh
0,0 → 1,63
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class t_debug extends t_top_base;
`uvm_component_utils(t_debug)
 
// --------------------------------------------------------------------
tb_dut_config #(.W(W), .D(D)) cfg_h;
 
// --------------------------------------------------------------------
function new(string name = "t_debug", uvm_component parent);
super.new(name, parent);
if (!uvm_config_db#(tb_dut_config #(.W(W), .D(D)))::get(this, "", "tb_dut_config", cfg_h))
`uvm_fatal(get_name(), "Couldn't get config object!")
endfunction
 
// --------------------------------------------------------------------
function void end_of_elaboration_phase(uvm_phase phase);
uvm_phase run_phase = uvm_run_phase::get();
run_phase.phase_done.set_drain_time(this, 100ns);
endfunction
 
// --------------------------------------------------------------------
function void final_phase(uvm_phase phase);
super.final_phase(phase);
$display("^^^ %16.t | %m | Test Done!!!", $time);
$stop;
endfunction : final_phase
 
// --------------------------------------------------------------------
virtual task run_phase(uvm_phase phase);
s_debug seq = s_debug::type_id::create("seq");
phase.raise_objection(this);
seq.start(env_h.agent_h.sequencer_h);
phase.drop_objection(this);
endtask : run_phase
 
// --------------------------------------------------------------------
endclass : t_debug
/trunk/basal/sim/tests/tb_fifo/t_top_base.svh
0,0 → 1,43
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
virtual class t_top_base extends uvm_test;
`uvm_component_utils(t_top_base);
tb_env env_h;
 
// --------------------------------------------------------------------
function new (string name, uvm_component parent);
super.new(name,parent);
endfunction : new
 
// --------------------------------------------------------------------
function void build_phase(uvm_phase phase);
env_h = tb_env::type_id::create("env_h",this);
endfunction : build_phase
 
// --------------------------------------------------------------------
endclass : t_top_base
/trunk/basal/sim/tests/tb_fifo/tb_dut_config.svh
0,0 → 1,48
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class tb_dut_config #(W, D);
 
virtual fifo_if #(.W(W), .D(D)) vif;
protected uvm_active_passive_enum is_active; // UVM_ACTIVE or UVM_PASSIVE
 
// --------------------------------------------------------------------
function new
( virtual fifo_if #(.W(W), .D(D)) vif
, uvm_active_passive_enum is_active = UVM_ACTIVE
);
this.vif = vif;
this.is_active = is_active;
endfunction : new
 
// --------------------------------------------------------------------
function uvm_active_passive_enum get_is_active();
return is_active;
endfunction : get_is_active
 
// --------------------------------------------------------------------
endclass : tb_dut_config
/trunk/basal/sim/tests/tb_fifo/tb_env.svh
0,0 → 1,58
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class tb_env extends uvm_env;
`uvm_component_utils(tb_env);
 
// --------------------------------------------------------------------
tb_dut_config #(.W(W), .D(D)) cfg_h;
// coverage coverage_h;
fifo_scoreboard scoreboard_h;
fifo_agent agent_h;
 
// --------------------------------------------------------------------
function new (string name, uvm_component parent);
super.new(name,parent);
endfunction : new
 
// --------------------------------------------------------------------
function void build_phase(uvm_phase phase);
if (!uvm_config_db#(tb_dut_config #(.W(W), .D(D)))::get(this, "", "tb_dut_config", cfg_h))
`uvm_fatal(get_name(), "Couldn't get config object!")
 
agent_h = fifo_agent::type_id::create("agent_h", this);
agent_h.vif = cfg_h.vif;
scoreboard_h = fifo_scoreboard::type_id::create("scoreboard_h", this);
endfunction : build_phase
 
// --------------------------------------------------------------------
function void connect_phase(uvm_phase phase);
agent_h.monitor_h.ap.connect(scoreboard_h.analysis_export);
endfunction : connect_phase
 
// --------------------------------------------------------------------
endclass : tb_env
/trunk/basal/sim/tests/tb_fifo/tb_fifo_pkg.sv
0,0 → 1,55
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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_fifo_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 "tb_dut_config.svh"
`include "fifo_sequence_item.svh"
typedef uvm_sequencer #(fifo_sequence_item) fifo_sequencer;
`include "fifo_driver.svh"
`include "fifo_monitor.svh"
`include "fifo_scoreboard.svh"
`include "fifo_agent.svh"
`include "tb_env.svh"
`include "s_debug.svh"
`include "t_top_base.svh"
`include "t_debug.svh"
 
// --------------------------------------------------------------------
endpackage : tb_fifo_pkg
/trunk/basal/sim/tests/tb_fifo/tb_files.f
0,0 → 1,6
#
 
./tb_fifo_pkg.sv
 
./fifo_if.sv
./tb_top.sv
/trunk/basal/sim/tests/tb_fifo/tb_top.sv
0,0 → 1,73
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
module tb_top;
import uvm_pkg::*;
import tb_fifo_pkg::*;
`include "uvm_macros.svh"
 
// --------------------------------------------------------------------
wire clk_100mhz;
wire tb_clk = clk_100mhz;
wire tb_rst;
wire clk_1000mhz;
 
tb_base #(.PERIOD(10_000)) tb(clk_100mhz, tb_rst);
 
// --------------------------------------------------------------------
wire clk = clk_100mhz;
wire reset = tb_rst;
 
// --------------------------------------------------------------------
fifo_if #(.W(W), .D(D)) dut_if(.*);
 
sync_fifo #(.W(W), .D(D))
dut
(
.wr_full(dut_if.wr_full),
.wr_data(dut_if.wr_data),
.wr_en(dut_if.wr_en),
.rd_empty(dut_if.rd_empty),
.rd_data(dut_if.rd_data),
.rd_en(dut_if.rd_en),
.count(dut_if.count),
.clk(dut_if.clk),
.reset(dut_if.reset)
);
 
 
// --------------------------------------------------------------------
tb_dut_config #(.W(W), .D(D)) cfg_h = new(dut_if);
 
initial
begin
uvm_config_db #(tb_dut_config #(.W(W), .D(D)))::set(null, "*", "tb_dut_config", cfg_h);
run_test("t_debug");
end
 
// --------------------------------------------------------------------
endmodule
/trunk/basal/sim/tests/tb_fifo/wip.do
0,0 → 1,6
#
 
# compile test bench files
vlog -f ./tb_files.f
vlog -f ./files.f
 

powered by: WebSVN 2.1.0

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