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

Subversion Repositories ha1588

[/] [ha1588/] [trunk/] [sim/] [top/] [ptp_drv_bfm/] [ptp_drv_bfm.v] - Blame information for rev 37

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

Line No. Rev Author Line
1 34 edn_walter
/*
2
 * $ptp_drv_bfm.v
3
 *
4 37 edn_walter
 * Copyright (c) 2012, BABY&HW. All rights reserved.
5 34 edn_walter
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA 02110-1301  USA
20
 */
21
 
22 21 edn_walter
`timescale 1ns/1ns
23
 
24
module ptp_drv_bfm_sv
25
(
26
        input         up_clk,
27
        output        up_wr,
28
        output        up_rd,
29
        output [ 7:0] up_addr,
30
        output [31:0] up_data_wr,
31
        input  [31:0] up_data_rd
32
);
33
 
34
import "DPI-C" context task ptp_drv_bfm_c
35
(
36
        input real fw_delay
37
);
38
 
39
reg  [ 7:0] up_addr_o;
40
reg  [31:0] up_data_o;
41
wire [31:0] up_data_i;
42
reg         up_wr_o;
43
reg         up_rd_o;
44
 
45
export "DPI-C" task cpu_wr;
46
task cpu_wr(input int addr, input int data);
47
        integer i;
48
        //$display("wr %08x %08x", addr, data);
49
        for (i=0; i<1; i=i+1) @(posedge up_clk);
50
        up_addr_o = addr;
51
        up_data_o = data;
52
        up_wr_o   = 1'b1;
53
        for (i=0; i<1; i=i+1) @(posedge up_clk);
54
        up_addr_o = addr;
55
        up_data_o = data;
56
        up_wr_o   = 1'b0;
57
        for (i=0; i<1; i=i+1) @(posedge up_clk);
58
endtask
59
 
60
export "DPI-C" task cpu_rd;
61
task cpu_rd(input int addr, output int data);
62
        integer i;
63
        for (i=0; i<2; i=i+1) @(posedge up_clk);
64
        up_addr_o = addr;
65
        up_rd_o   = 1'b1;
66
        for (i=0; i<1; i=i+1) @(posedge up_clk);
67
        up_addr_o = addr;
68
        up_rd_o   = 1'b0;
69
        for (i=0; i<2; i=i+1) @(posedge up_clk);
70 24 edn_walter
        data      = up_data_rd;
71 21 edn_walter
        //$display("rd %08x %08x", addr, data);
72
endtask
73
 
74
export "DPI-C" task cpu_hd;
75
task cpu_hd(input int t);
76
        integer i;
77
        //$display("#%d",t);
78
        for (i=0; i<=t; i=i+1) @(posedge up_clk);
79
endtask
80
 
81
assign up_wr      = up_wr_o;
82
assign up_rd      = up_rd_o;
83
assign up_addr    = up_addr_o;
84
assign up_data_wr = up_data_o;
85
assign up_data_i  = up_data_rd;
86
 
87
 
88
 
89
// start cpu bfm C model
90
reg up_start;
91
initial begin
92
        up_wr_o   = 1'b0;
93
        up_rd_o   = 1'b0;
94
        up_addr_o = 'd0;
95
        up_data_o = 'd0;
96
 
97
        @(posedge up_start);
98
        #100 ptp_drv_bfm_c(5);
99
end
100
 
101
endmodule

powered by: WebSVN 2.1.0

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