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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [software/] [greth/] [greth.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
/*****************************************************************************/
2
/*   This file is a part of the GRLIB VHDL IP LIBRARY                        */
3
/*   Copyright (C) 2007 GAISLER RESEARCH                                     */
4
/*                                                                           */
5
/*   This program is free software; you can redistribute it and/or modify    */
6
/*   it under the terms of the GNU General Public License as published by    */
7
/*   the Free Software Foundation; either version 2 of the License, or       */
8
/*   (at your option) any later version.                                     */
9
/*                                                                           */
10
/*   See the file COPYING for the full details of the license.               */
11
/*****************************************************************************/
12
 
13
/* Changelog */
14
/* 2007-11-13: Simple Ethernet speed test added - Kristoffer Glembo */
15
/* 2007-11-13: GRETH BareC API added            - Kristoffer Glembo */
16
 
17
#include <stdlib.h>
18
#include <time.h>
19
#include "greth_api.h"
20
 
21
/* Set to 1 if using GRETH_GBIT, otherwise 0 */
22
#define GRETH_GBIT 1
23
 
24
/* Set to 10,100, or 1000 */
25
#define GRETH_SPEED 100
26
 
27
/* Set to 1 to run full duplex, 0 to run half duplex */
28
#define GRETH_FULLDUPLEX 1
29
 
30
#define GRETH_ADDR 0x80000b00
31
 
32
/* Destination MAC address */
33
#define DEST_MAC0  0x00
34
#define DEST_MAC1  0x13
35
#define DEST_MAC2  0x72
36
#define DEST_MAC3  0xAE
37
#define DEST_MAC4  0x72
38
#define DEST_MAC5  0x21
39
 
40
/* Source MAC address */
41
#define SRC_MAC0  0xDE
42
#define SRC_MAC1  0xAD
43
#define SRC_MAC2  0xBE
44
#define SRC_MAC3  0xEF
45
#define SRC_MAC4  0x00
46
#define SRC_MAC5  0x20 
47
 
48
struct greth_info greth;
49
 
50
int main(void) {
51
 
52
    unsigned long long i;
53
    unsigned char buf[1514];
54
    clock_t t1, t2;
55
    unsigned long long datasize;
56
    double time, bitrate;
57
 
58
    greth.regs = (greth_regs *) GRETH_ADDR;
59
 
60
    /* Dest. addr */
61
    buf[0] = DEST_MAC0;
62
    buf[1] = DEST_MAC1;
63
    buf[2] = DEST_MAC2;
64
    buf[3] = DEST_MAC3;
65
    buf[4] = DEST_MAC4;
66
    buf[5] = DEST_MAC5;
67
 
68
    /* Source addr */
69
    buf[6]  = SRC_MAC0;
70
    buf[7]  = SRC_MAC1;
71
    buf[8]  = SRC_MAC2;
72
    buf[9]  = SRC_MAC3;
73
    buf[10] = SRC_MAC4;
74
    buf[11] = SRC_MAC5;
75
 
76
    /* Length 1500 */
77
    buf[12] = 0x05;
78
    buf[13] = 0xDC;
79
 
80
    memcpy(greth.esa, &buf[6], 6);
81
 
82
    for (i = 14; i < 1514; i++) {
83
        buf[i] = i;
84
    }
85
 
86
    greth_init(&greth);
87
 
88
    printf("\nSending 1500 Mbyte of data to %.02x:%.02x:%.02x:%.02x:%.02x:%.02x\n", buf[0], buf[1], \
89
                                                                                    buf[2], buf[3], \
90
                                                                                    buf[4], buf[5]);
91
    t1 = clock();
92
    i = 0;
93
    while(i < (unsigned long long) 1024*1024) {
94
 
95
        /* greth_tx() returns 1 if a free descriptor is found, otherwise 0 */
96
        i += greth_tx(1514, buf, &greth);
97
 
98
    }
99
    t2 = clock();
100
 
101
    time = (double)(t2 - t1)/CLOCKS_PER_SEC;
102
    printf("\nTime: %f\n", time);
103
 
104
    datasize = (unsigned long long)1024*1024*1500*8; /* In bits */
105
    bitrate = (double) datasize/time;
106
    printf("Bitrate: %f Mbps\n", bitrate/(1024*1024));
107
 
108
    return 0;
109
}

powered by: WebSVN 2.1.0

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