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

Rev 42 → Rev 43

/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/dpi_video_array.py
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 ////
# ////////////////////////////////////////////////////////////////////
import numpy as np
import py_to_video_frame as vf
 
# -----------------------------------------------------
class dpi_video_array:
 
def __init__(self, width, height):
self.width = width
self.height = height
print('~~~ | dpi_video_array __init__ | ' + str(width) + 'x' + str(height))
 
def py_get_array(self):
print('~~~ | dpi_video_array | py_get_array() | ')
size = self.width * self.height
x = np.arange(0, size, dtype=np.uint32)
vf.np_to_frame(x)
 
def make_counting_raw_video_file(self):
print('~~~ | dpi_video_array | make_counting_raw_video_file() | ')
 
def do_it(self):
print('~~~ | dpi_video_array | do_it() | ')
 
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/init_test.do
0,0 → 1,28
# ------------------------------------
#
# ------------------------------------
 
global env
 
# setup environment
do ../../../../scripts/sim_env.do
set env(SIM_TARGET) fpga
 
radix -hexadecimal
quietly set env(PATH) "D:/Anaconda2;$::env(PATH)"
 
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) axi4_lib
# 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
 
# run the sim
sim_run_test
 
 
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/py_dpi.c
0,0 → 1,142
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <conio.h>
#include <Python.h>
#include "vpi_user.h"
#include "py_dpi.h"
 
// --------------------------------------------------------------------
PyObject *g_dva_i;
 
// --------------------------------------------------------------------
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);
// 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);
}
 
// --------------------------------------------------------------------
unsigned int *g_va = NULL;
 
void c_get_array(const svOpenArrayHandle va)
{
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);
}
 
// --------------------------------------------------------------------
int py_run_file
( const char *filename
, int argc
, const svOpenArrayHandle args
)
{
printf("^^^ | py_run_file | %s |\n", filename);
 
char *argv[4]; // limit of 4 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]
);
}
 
PySys_SetArgv(argc, argv);
PyObject *PyFileObject = PyFile_FromString((char *)filename, "r");
return PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject), filename, 1);
}
 
// --------------------------------------------------------------------
void init_py_dpi(int width, int height)
{
printf("^^^ | init_py_dpi() | %dx%d\n", width, height);
Py_Initialize();
init_py_to_video_frame();
PyObject *dva_m = PyImport_ImportModule("dpi_video_array");
if(!dva_m)
{
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)
{
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);
Py_DECREF(dva_c);
if(!g_dva_i)
{
PyErr_Print();
printf("^^^ | init_py_dpi() | g_dva_i Error\n");
Py_DECREF(g_dva_i);
g_dva_i = NULL;
}
}
 
// --------------------------------------------------------------------
void exit_py_dpi()
{
printf("^^^ | exit_py_dpi()\n");
if(g_dva_i)
Py_DECREF(g_dva_i);
Py_Finalize();
}
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/py_dpi.h
0,0 → 1,71
/* MTI_DPI */
 
/*
* Copyright 2002-2018 Mentor Graphics Corporation.
*
* Note:
* This file is automatically generated.
* Please do not edit this file - you will lose your edits.
*
* Settings when this file was generated:
* PLATFORM = 'win64'
*/
#ifndef INCLUDED_PY_DPI
#define INCLUDED_PY_DPI
 
#ifdef __cplusplus
#define DPI_LINK_DECL extern "C"
#else
#define DPI_LINK_DECL
#endif
 
#include "svdpi.h"
 
 
#ifndef MTI_INCLUDED_TYPEDEF_frame_coordinate_t
#define MTI_INCLUDED_TYPEDEF_frame_coordinate_t
 
typedef struct {
int x;
int y;
} frame_coordinate_t;
 
#endif
 
 
DPI_LINK_DECL DPI_DLLESPEC
void
c_do_it();
 
DPI_LINK_DECL DPI_DLLESPEC
void
c_get_array(
const svOpenArrayHandle va);
 
DPI_LINK_DECL DPI_DLLESPEC
void
exit_py_dpi();
 
DPI_LINK_DECL DPI_DLLESPEC
void
init_py_dpi(
int width,
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,
int argc,
const svOpenArrayHandle args);
 
DPI_LINK_DECL int
sv_write(
int data,
int address);
 
#endif
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/py_to_video_frame_module.c
0,0 → 1,130
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
#include <Python.h>
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <numpy/arrayobject.h>
 
extern unsigned int *g_va;
 
// --------------------------------------------------------------------
static PyObject* np_to_frame(PyObject* self, PyObject* args)
{
printf("^^^ | np_to_frame()\n");
 
if(g_va == NULL)
return NULL;
 
PyArrayObject *in_array;
NpyIter *in_iter;
NpyIter_IterNextFunc *in_iternext;
 
/* parse single numpy array argument */
if(!PyArg_ParseTuple(args, "O!", &PyArray_Type, &in_array))
return NULL;
 
/* create the iterators */
in_iter = NpyIter_New
( in_array
, NPY_ITER_READONLY
, NPY_KEEPORDER
, NPY_NO_CASTING
, NULL
);
 
if(in_iter == NULL)
return NULL;
 
in_iternext = NpyIter_GetIterNext(in_iter, NULL);
 
if(in_iternext == NULL)
{
NpyIter_Deallocate(in_iter);
return NULL;
}
unsigned int **in_dataptr = (unsigned int **)NpyIter_GetDataPtrArray(in_iter);
unsigned int *p = g_va;
 
/* iterate over the arrays */
do
{
*p++ = **in_dataptr;
} while(in_iternext(in_iter));
 
/* clean up and return the result */
NpyIter_Deallocate(in_iter);
g_va = NULL;
return Py_BuildValue("");
}
 
// --------------------------------------------------------------------
/* define functions in module */
static PyMethodDef py_to_video_frame_methods[] =
{ {"np_to_frame"
, np_to_frame
, METH_VARARGS
, "numpy to video frame"
},
{NULL, NULL, 0, NULL}
};
 
// --------------------------------------------------------------------
#if PY_MAJOR_VERSION >= 3
/* module initialization */
/* Python version 3*/
static struct PyModuleDef cmod_py_to_video_frame =
{ PyModuleDef_HEAD_INIT
, "py_to_video_frame"
, "Some documentation"
, -1
, py_to_video_frame_methods
};
 
PyMODINIT_FUNC
PyInit_py_to_video_frame(void)
{
PyObject *module = PyModule_Create(&cmod_py_to_video_frame);
 
if(module != NULL)
import_array();
 
return module;
}
 
#else
 
/* module initialization */
/* Python version 2 */
PyMODINIT_FUNC
init_py_to_video_frame(void)
{
printf("^^^ | init_py_to_video_frame()\n");
(void) Py_InitModule("py_to_video_frame", py_to_video_frame_methods);
import_array();
}
 
#endif
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/py_video.py
0,0 → 1,31
#
 
import numpy as np
import matplotlib.pyplot as plt
 
fname = 'count.raw'
v_frames = 1
v_width = 8
v_height = 16
 
data = np.arange(v_frames*v_width*v_height, dtype='uint16')
 
with open(fname, 'w+') as infile:
data.tofile(infile, format='uint16')
 
infile.close()
 
# ---------------------------------------------------------
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):
fig, ax = plt.subplots()
im = ax.imshow(data[i], cmap='gray')
ax.set(xticks=[], yticks=[])
fig.colorbar(im)
plt.show()
 
print(data[0])
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/sim.do
0,0 → 1,11
#
#
 
quit -sim
 
# vsim -suppress 12110 -novopt work.tb_top
vsim -f ./sim.f work.tb_top
 
# # log all signals
# log /* -r
 
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/sim.f
0,0 → 1,11
#
#
 
# -voptargs="-f ./acc_file.f"
 
# -suppress 12110
# -novopt
 
-ldflags "D:/Anaconda2/python27.dll"
# -ldflags "D:/Anaconda2/Lib/site-packages/numpy/core/lib/npymath.lib"
 
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/sv_video_frame_dpi.svh
0,0 → 1,91
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 video_frame_dpi;
mailbox #(video_array_t) array_buffer;
mailbox #(video_frame_class) buffer_in, buffer_out;
 
// --------------------------------------------------------------------
function void py_file(string filename, string py_args[]);
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);
c_do_it();
endtask
 
// --------------------------------------------------------------------
task get_frame(ref video_array_t va);
$display("^^^ %16.t | %m |", $time);
array_buffer.get(va);
c_get_array(va);
$display("^^^ %16.t | %m | %p |", $time, va);
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");
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!");
$stop;
end
end
init_py_dpi(width, height);
endfunction
 
// --------------------------------------------------------------------
function void exit;
$display("^^^ | video_frame_dpi | exit");
exit_py_dpi();
endfunction
 
// --------------------------------------------------------------------
endclass : video_frame_dpi
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/tb_files.f
0,0 → 1,16
#
 
# ${PROJECT_DIR}/sim/src//.sv
 
-ccflags "-Bsymbolic -ID:/Anaconda2/include -D MS_WIN64"
-ccflags "-ID:/Anaconda2/Lib/site-packages/numpy/core/include"
 
-ccflags "-std=c99"
-dpiheader py_dpi.h
 
#
./video_frame_dpi.sv
./tb_video_frame_dpi.sv
./py_dpi.c
./py_to_video_frame_module.c
 
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/tb_video_frame_dpi.sv
0,0 → 1,39
//////////////////////////////////////////////////////////////////////
//// ////
//// 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;
 
// --------------------------------------------------------------------
localparam WIDTH = 8;
localparam HEIGHT = 16;
 
// --------------------------------------------------------------------
video_frame_dpi #(.WIDTH(WIDTH), .HEIGHT(HEIGHT))
dut();
 
// --------------------------------------------------------------------
endmodule
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/try_it.py
0,0 → 1,35
#
# ////////////////////////////////////////////////////////////////////
# // 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 py_to_video_frame as vf
import numpy as np
 
print("^^^ | running python!")
print('Number of arguments:', len(sys.argv), 'arguments.')
print('Argument List:', str(sys.argv))
 
 
print("~~~ | try_it | DONE!")
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/video_frame_dpi.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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
`timescale 1 ns/1 ns
module
video_frame_dpi
#( WIDTH = 8
, HEIGHT = 16
);
import bfm_pkg::*;
import video_frame_pkg::*;
 
// --------------------------------------------------------------------
import "DPI-C" context function void init_py_dpi(int width, int height);
import "DPI-C" context function void exit_py_dpi();
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;
 
// --------------------------------------------------------------------
`include "./sv_video_frame_dpi.svh"
 
// --------------------------------------------------------------------
// Exported SV task. Can be called by C, SV or Python
task sv_write(input int data, address);
$display("sv_write(data = %d, address = %d)",data,address);
endtask
 
// --------------------------------------------------------------------
video_frame_dpi vf_h;
video_array_t va;
 
initial
begin
vf_h = new();
vf_h.init(WIDTH, HEIGHT);
 
vf_h.get_frame(va);
// vf_h.do_it();
 
vf_h.exit();
 
$display("DONE!!");
end
 
// --------------------------------------------------------------------
endmodule
/qaz_libs/trunk/BFM/src/video_frame/video_frame_pkg.sv
30,16 → 30,20
import logger_pkg::*;
 
typedef struct
{
int pixel[];
} line_s;
{
int pixel[];
} line_s;
 
typedef struct
{
int x;
int y;
} frame_coordinate_t;
typedef struct
{
int x;
int y;
} frame_coordinate_t;
 
typedef int flattened_frame_t[];
typedef int unsigned video_array_t[][];
 
// --------------------------------------------------------------------
class video_frame_class;
logger_class log;
rand int frame_id;
112,6 → 116,8
input frame_coordinate_t coordinate
);
 
extern function flattened_frame_t flatten_frame();
 
extern virtual function void make_constant
(
input int pixel
128,6 → 134,8
 
extern virtual function void make_random();
 
extern virtual function void shift_right(ref line_s column);
 
extern virtual function void copy
(
ref video_frame_class from
190,7 → 198,21
 
endfunction: read_pixel
 
// --------------------------------------------------------------------
//
function flattened_frame_t video_frame_class::flatten_frame();
int i = 0;
log.info($sformatf("%m"));
flatten_frame = new[lines_per_frame*pixels_per_line];
 
foreach(this.lines[l])
foreach(this.lines[l].pixel[p])
begin
flatten_frame[i] = this.lines[l].pixel[p];
i++;
end
endfunction: flatten_frame
 
// --------------------------------------------------------------------
//
function void video_frame_class::make_constant
383,12 → 405,22
 
foreach(tail.lines[l].pixel[p])
catenate_horizontally.lines[l].pixel[p + this.pixels_per_line] = tail.lines[l].pixel[p];
 
end
 
endfunction: catenate_horizontally
 
// --------------------------------------------------------------------
//
function void video_frame_class::shift_right(ref line_s column);
log.info($sformatf("%m"));
 
foreach(this.lines[l])
for(int p = pixels_per_line - 1; p > 0; p--)
this.lines[l].pixel[p] = this.lines[l].pixel[p - 1];
 
foreach(this.lines[l])
this.lines[l].pixel[0] = column.pixel[l];
endfunction: shift_right
 
// --------------------------------------------------------------------
//
function int video_frame_class::compare_line
/qaz_libs/trunk/PCIe/src/RIFFA/riffa_chnl_rx.sv
84,7 → 84,7
//
always_ff @(posedge clk)
if(reset | rx_done)
rx_index = 0;
rx_index <= 0;
else if(rd_en)
rx_index <= rx_index + (N/4); // increment by 32 bit words
 
/qaz_libs/trunk/PCIe/src/RIFFA/riffa_chnl_tx.sv
59,7 → 59,7
//
always_ff @(posedge clk)
if(reset | ~chnl_bus.tx | tx_done)
tx_index = 0;
tx_index <= 0;
else if(chnl_bus.tx_data_valid & chnl_bus.tx_data_ren)
tx_index <= tx_index + (N/4); // increment by 32 bit words
 
/qaz_libs/trunk/axi4_lib/src/axi4_m_to_read_fifos.sv
28,11 → 28,11
module
axi4_m_to_read_fifos
#(
A = 32, // address bus width
N = 8, // data bus width in bytes
I = 1, // ID width
R_D = 32,
AR_D = 2,
A, // address bus width
N, // data bus width in bytes
I, // ID width
R_D,
AR_D,
WATERMARK = 0,
USE_ADVANCED_PROTOCOL = 0
)
183,18 → 183,18
 
assign r_wr_data =
{
axi4_m.rdata,
axi4_m.rid,
axi4_m.rresp,
axi4_m.rlast,
axi4_m.rresp
axi4_m.rdata
};
 
assign
{
axi4_read_fifo.rdata,
axi4_read_fifo.rid,
axi4_read_fifo.rresp,
axi4_read_fifo.rlast,
axi4_read_fifo.rresp
axi4_read_fifo.rdata
} = r_rd_data;
 
 
/qaz_libs/trunk/axi4_lite_lib/sim/src/tb_axi4_lite_register_file.sv
74,7 → 74,8
 
// --------------------------------------------------------------------
//
axi4_checker #(.A(A), .N(N), .PROTOCOL(2'b10))
// axi4_checker #(.A(A), .N(N), .PROTOCOL(2'b10))
axi4_checker #(.A(A), .N(N))
axi4_s_check(.axi4_in(axi4_s));
 
 
/qaz_libs/trunk/axi4_lite_lib/sim/tests/debug_axi4_lite_register_file/init_test.do
4,30 → 4,30
 
global env
 
set env(ROOT_DIR) ../../../../..
set env(PROJECT_DIR) ../../..
# setup environment
do ../../../../scripts/sim_env.do
set env(SIM_TARGET) fpga
set env(SIM_TB) tb_recursive_axis_mux
 
# load sim procedures
do $env(ROOT_DIR)/qaz_libs/scripts/sim_procs.do
 
radix -hexadecimal
 
make_lib work 1
 
sim_compile_all packages
sim_compile_all sim
sim_compile_all axi4_lib
sim_compile_all axi4_lite_lib
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) axi4_lib
sim_compile_lib $env(LIB_BASE_DIR) qaz_lib
sim_compile_lib $env(LIB_BASE_DIR) sim
 
# simulation $root
vlog $env(LIB_BASE_DIR)/axi4_lib/sim/src/axi4_bfm/axi4_transaction_pkg.sv
vlog $env(LIB_BASE_DIR)/axi4_lib/sim/src/axi4_bfm/axi4_master_bfm_if.sv
vlog $env(PROJECT_DIR)/sim/src/axi4_lite_agent_pkg.sv
vlog $env(PROJECT_DIR)/sim/src/tb_axi4_lite_register_file.sv
 
# compile test last
vlog ./the_test.sv
 
# vopt work.glbl tb_top -L secureip -L simprims_ver -L unisims_ver -f opt_tb_top.f -o opt_tb_top
 
# run the sim
sim_run_test
 
/qaz_libs/trunk/axi4_lite_lib/src/axi4_lite_register_file.sv
28,10 → 28,10
module
axi4_lite_register_file
#(
A = 32, // address bus width, must be 32 or greater for axi lite
N = 8, // data bus width in bytes, must be 4 or 8 for axi lite
I = 1, // ID width
MW = 3 // mux select width
A, // address bus width, must be 32 or greater for axi lite
N, // data bus width in bytes, must be 4 or 8 for axi lite
I = 1, // ID width
MW // mux select width
)
(
axi4_if axi4_s,
/qaz_libs/trunk/axi4_lite_lib/src/axi4_lite_register_if.sv
32,10 → 32,6
N = 8, // data bus width in bytes, must be 4 or 8 for axi lite
MW = 3, // mux select width
MI = 2 ** MW // mux inputs
)
(
input aclk,
input aresetn
);
 
wire [(N*8)-1:0] register_in [MI-1:0];
42,13 → 38,10
reg [(N*8)-1:0] register_out [MI-1:0];
wire wr_en [MI-1:0];
 
 
// --------------------------------------------------------------------
// synthesis translate_off
initial
a_data_bus_width: assert((N == 8) | (N == 4)) else $fatal;
 
 
// synthesis translate_on
// --------------------------------------------------------------------
 
/qaz_libs/trunk/basal/src/FIFOs/tiny_sync_fifo.v
0,0 → 1,138
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
 
module
tiny_sync_fifo
#(
parameter W
)
(
output reg wr_full,
input [W-1:0] wr_data,
input wr_en,
 
output reg rd_empty,
output [W-1:0] rd_data,
input rd_en,
 
input clk,
input reset
);
 
// --------------------------------------------------------------------
//
wire writing = wr_en & ~wr_full;
wire reading = rd_en & ~rd_empty;
 
 
// --------------------------------------------------------------------
//
reg [1:0] rd_ptr_r;
reg [1:0] next_rd_ptr_r;
 
always @(*)
if(reset)
next_rd_ptr_r = 0;
else if(reading)
next_rd_ptr_r = rd_ptr_r + 1;
else
next_rd_ptr_r = rd_ptr_r;
 
always @(posedge clk)
rd_ptr_r <= next_rd_ptr_r;
 
 
// --------------------------------------------------------------------
//
reg [1:0] wr_ptr_r;
reg [1:0] next_wr_ptr_r;
 
always @(*)
if(reset)
next_wr_ptr_r = 0;
else if(writing)
next_wr_ptr_r = wr_ptr_r + 1;
else
next_wr_ptr_r = wr_ptr_r;
 
always @(posedge clk)
wr_ptr_r <= next_wr_ptr_r;
 
 
// --------------------------------------------------------------------
//
wire empty_w = (next_wr_ptr_r == next_rd_ptr_r);
 
always @(posedge clk)
if(reset)
rd_empty <= 1;
else
rd_empty <= empty_w;
 
 
// --------------------------------------------------------------------
//
wire full_w = ({~next_wr_ptr_r[1],next_wr_ptr_r[0]} == next_rd_ptr_r);
 
always @(posedge clk)
if(reset)
wr_full <= 0;
else
wr_full <= full_w;
 
 
// --------------------------------------------------------------------
//
reg [W-1:0] data_0_r;
reg [W-1:0] data_1_r;
wire [W-1:0] wr_data_mux = rd_ptr_r[0] ? data_1_r : data_0_r;
assign rd_data = wr_data_mux;
 
always @(posedge clk)
if(writing)
if(wr_ptr_r[0])
data_1_r <= wr_data;
else
data_0_r <= wr_data;
 
 
// --------------------------------------------------------------------
// synthesis translate_off
always @(posedge clk)
if(wr_en & wr_full)
$stop;
always @(posedge clk)
if(rd_en & rd_empty)
$stop;
// synthesis translate_on
// --------------------------------------------------------------------
 
 
// --------------------------------------------------------------------
//
endmodule

powered by: WebSVN 2.1.0

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