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

Rev 44 → Rev 43

/sim/tests/tb_video_frame_dpi/count.raw Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
sim/tests/tb_video_frame_dpi/count.raw Property changes : Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: sim/tests/tb_video_frame_dpi/py_raw_to_frame.py =================================================================== --- sim/tests/tb_video_frame_dpi/py_raw_to_frame.py (revision 44) +++ sim/tests/tb_video_frame_dpi/py_raw_to_frame.py (nonexistent) @@ -1,92 +0,0 @@ -# -# //////////////////////////////////////////////////////////////////// -# // //// -# // 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 - - \ No newline at end of file Index: sim/tests/tb_video_frame_dpi/init_test.do =================================================================== --- sim/tests/tb_video_frame_dpi/init_test.do (revision 44) +++ sim/tests/tb_video_frame_dpi/init_test.do (revision 43) @@ -9,8 +9,7 @@ set env(SIM_TARGET) fpga radix -hexadecimal -# quietly set env(PATH) "D:/Anaconda2;$::env(PATH)" -quietly set env(PATH) "D:/anaconda3;$::env(PATH)" +quietly set env(PATH) "D:/Anaconda2;$::env(PATH)" make_lib work 1
/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,8 → 71,6
}
 
// --------------------------------------------------------------------
#define MAX_ARGV 4
 
int py_run_file
( const char *filename
, int argc
81,40 → 79,29
{
printf("^^^ | py_run_file | %s |\n", filename);
 
wchar_t *w_argv[MAX_ARGV]; // limit of MAX_ARGV args
char *argv[4]; // limit of 4 args
int i;
for(i = 0; i < argc && i < MAX_ARGV; i++)
w_argv[i] = Py_DecodeLocale(*((char **)svGetArrElemPtr1(args, i)), NULL);
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, 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;
PySys_SetArgv(argc, argv);
PyObject *PyFileObject = PyFile_FromString((char *)filename, "r");
return PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject), filename, 1);
}
 
// --------------------------------------------------------------------
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();
 
PyObject *sys = PyImport_ImportModule("sys");
PyObject *path = PyObject_GetAttrString(sys, "path");
PyList_Append(path, PyUnicode_FromString("."));
 
init_py_to_video_frame();
PyObject *dva_m = PyImport_ImportModule("dpi_video_array");
if(!dva_m)
{
121,7 → 108,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)
129,7 → 116,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);
147,9 → 134,9
void exit_py_dpi()
{
printf("^^^ | exit_py_dpi()\n");
 
if(g_dva_i)
Py_DECREF(g_dva_i);
 
Py_Finalize();
}
/sim/tests/tb_video_frame_dpi/py_dpi.h
53,6 → 53,10
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,
/sim/tests/tb_video_frame_dpi/py_video.py
1,30 → 1,5
#
# ////////////////////////////////////////////////////////////////////
# // ////
# // 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
 
/sim/tests/tb_video_frame_dpi/sim.f
1,5 → 1,11
#
#
 
# -ldflags "D:/Anaconda2/python27.dll"
-ldflags "D:/anaconda3/python36.dll"
# -voptargs="-f ./acc_file.f"
 
# -suppress 12110
# -novopt
 
-ldflags "D:/Anaconda2/python27.dll"
# -ldflags "D:/Anaconda2/Lib/site-packages/numpy/core/lib/npymath.lib"
 
/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,6 → 51,11
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");
57,14 → 62,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!");
71,7 → 76,7
$stop;
end
end
 
init_py_dpi(width, height);
endfunction
 
81,11 → 86,6
exit_py_dpi();
endfunction
 
// --------------------------------------------------------------------
function new;
$display("^^^ | video_frame_dpi | new");
endfunction
 
// --------------------------------------------------------------------
endclass : video_frame_dpi
 
/sim/tests/tb_video_frame_dpi/tb_files.f
1,10 → 1,10
#
 
# -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"
# ${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
 
/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))
 
/sim/tests/tb_video_frame_dpi/video_frame_dpi.sv
40,6 → 40,7
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;
 
// --------------------------------------------------------------------
61,8 → 62,7
vf_h.init(WIDTH, HEIGHT);
 
vf_h.get_frame(va);
vf_h.do_it();
vf_h.py_file("try_it.py", '{"Larry", "Curly", "Moe"});
// vf_h.do_it();
 
vf_h.exit();
 

powered by: WebSVN 2.1.0

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