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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [rtl/] [vlib/] [rlink/] [tbcore/] [rlink_cext_iface_dpi.sv] - Blame information for rev 35

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 wfjm
// $Id: rlink_cext_iface_dpi.sv 731 2016-02-14 21:07:14Z mueller $
2
//
3
// Copyright 2016- by Walter F.J. Mueller 
4
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
//
14
//----------------------------------------------------------------------------
15
// Module Name:    rlink_cext_iface - sim
16
// Description:    Interface to external C code for tbcore_rlink - DPI version
17
//
18
// Dependencies:   -
19
//
20
// To test:        -
21
//
22
// Target Devices: generic
23
// Tool versions:  viv 2015.4
24
// Revision History:
25
// Date         Rev Version  Comment
26
// 2016-02-07   729   0.1    First draft
27
//----------------------------------------------------------------------------
28
 
29
`default_nettype none
30
 
31
package rlink_cext_dpi;
32
   import "DPI-C" function int rlink_cext_getbyte_dpi(input int clk);
33
   import "DPI-C" function int rlink_cext_putbyte_dpi(input int dat);
34
endpackage   // rlink_cext_dpi
35
 
36
module rlink_cext_iface(input  wire        clk,
37
                        input  wire [31:0] clk_cycle,
38
                        output reg  [31:0] rx_data,
39
                        output reg         rx_val,
40
                        input  wire        rx_hold,
41
                        input  wire [7:0]  tx_data,
42
                        input  wire        tx_ena
43
                        );
44
 
45
   int itxdata  = 0;
46
   int itxrc    = 0;
47
   int icycle   = 0;
48
   int irxdata  = 0;
49
   reg r_rxval  = 1'b0;
50
   int r_rxdata = 0;
51
 
52
   initial rx_data = 8'b00000000;
53
   initial rx_val  = 1'b0;
54
 
55
   always @ (posedge clk) begin
56
      if (tx_ena) begin
57
         itxdata = tx_data;
58
         itxrc   = rlink_cext_dpi::rlink_cext_putbyte_dpi(itxdata);
59
         if (itxrc != 0) begin
60
            $display("rlink_cext_putbyte error: ", itxrc);
61
            $finish;
62
         end
63
      end
64
   end
65
 
66
   always @ (posedge clk) begin
67
      if (~rx_hold | ~r_rxval ) begin
68
         icycle   = clk_cycle;
69
         irxdata  = rlink_cext_dpi::rlink_cext_getbyte_dpi(icycle);
70
         rx_data <= irxdata;
71
         rx_val  <= irxdata >= 0;
72
      end
73
   end
74
 
75
 
76
endmodule    // rlink_cext_iface
77
 
78
`default_nettype wire

powered by: WebSVN 2.1.0

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