1 |
43 |
qaztronic |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// Copyright (C) 2018 Authors and OPENCORES.ORG ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This source file may be used and distributed without ////
|
6 |
|
|
//// restriction provided that this copyright statement is not ////
|
7 |
|
|
//// removed from the file and that any derivative work contains ////
|
8 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// This source file is free software; you can redistribute it ////
|
11 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
12 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
13 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
14 |
|
|
//// later version. ////
|
15 |
|
|
//// ////
|
16 |
|
|
//// This source is distributed in the hope that it will be ////
|
17 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
18 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
19 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
20 |
|
|
//// details. ////
|
21 |
|
|
//// ////
|
22 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
23 |
|
|
//// Public License along with this source; if not, download it ////
|
24 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
25 |
|
|
//// ////
|
26 |
|
|
//////////////////////////////////////////////////////////////////////
|
27 |
|
|
|
28 |
|
|
`timescale 1 ns/1 ns
|
29 |
|
|
module
|
30 |
|
|
video_frame_dpi
|
31 |
|
|
#( WIDTH = 8
|
32 |
|
|
, HEIGHT = 16
|
33 |
|
|
);
|
34 |
|
|
import bfm_pkg::*;
|
35 |
|
|
import video_frame_pkg::*;
|
36 |
|
|
|
37 |
|
|
// --------------------------------------------------------------------
|
38 |
|
|
import "DPI-C" context function void init_py_dpi(int width, int height);
|
39 |
|
|
import "DPI-C" context function void exit_py_dpi();
|
40 |
|
|
import "DPI-C" context function void c_do_it();
|
41 |
|
|
import "DPI-C" context function void c_get_array(inout video_array_t va);
|
42 |
|
|
import "DPI-C" context function int py_run_file(string filename, int argc, string args[]);
|
43 |
|
|
export "DPI-C" task sv_write;
|
44 |
|
|
|
45 |
|
|
// --------------------------------------------------------------------
|
46 |
|
|
`include "./sv_video_frame_dpi.svh"
|
47 |
|
|
|
48 |
|
|
// --------------------------------------------------------------------
|
49 |
|
|
// Exported SV task. Can be called by C, SV or Python
|
50 |
|
|
task sv_write(input int data, address);
|
51 |
|
|
$display("sv_write(data = %d, address = %d)",data,address);
|
52 |
|
|
endtask
|
53 |
|
|
|
54 |
|
|
// --------------------------------------------------------------------
|
55 |
|
|
video_frame_dpi vf_h;
|
56 |
|
|
video_array_t va;
|
57 |
|
|
|
58 |
|
|
initial
|
59 |
|
|
begin
|
60 |
|
|
vf_h = new();
|
61 |
|
|
vf_h.init(WIDTH, HEIGHT);
|
62 |
|
|
|
63 |
|
|
vf_h.get_frame(va);
|
64 |
44 |
qaztronic |
vf_h.do_it();
|
65 |
|
|
vf_h.py_file("try_it.py", '{"Larry", "Curly", "Moe"});
|
66 |
43 |
qaztronic |
|
67 |
|
|
vf_h.exit();
|
68 |
|
|
|
69 |
|
|
$display("DONE!!");
|
70 |
|
|
end
|
71 |
|
|
|
72 |
|
|
// --------------------------------------------------------------------
|
73 |
|
|
endmodule
|