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

Subversion Repositories pc_fpga_com

[/] [pc_fpga_com/] [trunk/] [PC_FPGA_PLATFPORM/] [SOFTWARE/] [testcase1.cpp] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 NikosAl
/*
2
 * Copyright (C) 2011 Simon A. Berger
3
 *
4
 *  This program is free software; you may redistribute it and/or modify its
5
 *  under the terms of the GNU Lesser General Public License as published by the Free
6
 *  Software Foundation; either version 2 of the License, or (at your option)
7
 *  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 more details.
13
 */
14
 
15
#include <stdio.h>
16
 
17
#include <unistd.h>
18
#include <stdlib.h>
19
#include <string.h>
20
#include <cmath>
21
#include <iostream>
22
#include "fpga_com.h"
23
#include "background_reader.h"
24
 
25
int main() {
26
 
27
    fpga_con_t fc;
28
 
29
    fpga_con_init( &fc, "192.168.1.1", 21844, 21845 );
30
 
31
    fpga_bgr_t bgr;
32
 
33
    fpga_bgr_init( &bgr, fc.s, 1024 * 1024 * 10 );
34
 
35
    fpga_bgr_start( &bgr );
36
 
37
 
38
    fpga_con_send_init_packet( &fc );
39
 
40
    bool do_char = !false;
41
    bool do_short = !false;
42
    bool do_int = true;
43
    bool do_long = true;
44
    bool do_float = true;
45
    bool do_double = true;
46
    const int N = 127;
47
    if(do_char)
48
    {
49
        char test[N];
50
        for( int i = 0; i < N; i++ ) {
51
 
52
            test[i] = i;// + 'a';
53
 
54
        }
55
 
56
        fpga_con_send_charv( &fc, test, N);
57
 
58
 
59
        char rec[N];
60
        fpga_con_rpack_char(&fc,N);
61
        fpga_bgr_recv_charv(&bgr, rec, N );
62
 
63
 
64
        printf( "recv char: \n" );
65
        for( int i = 0; i < N; i++ ) {
66
            printf( " recv: %d %d\n", test[i], rec[i] );
67
        }
68
 
69
    }
70
    if(do_short)
71
    {
72
 
73
        short test[N];
74
        for( int i = 0; i < N; i++ ) {
75
 
76
            test[i] = i;
77
 
78
        }
79
 
80
        fpga_con_send_shortv( &fc, test, N);
81
 
82
 
83
        short rec[N];
84
        fpga_con_rpack_short(&fc,N);
85
        fpga_bgr_recv_shortv(&bgr, rec, N );
86
 
87
 
88
        printf( "recv short: \n" );
89
        for( int i = 0; i < N; i++ ) {
90
            printf( " recv: %d %d\n", test[i], rec[i] );
91
 
92
 
93
        }
94
 
95
 
96
 
97
    }
98
    if( do_int )
99
    {
100
        int test[N];
101
        for( int i = 0; i < N; i++ ) {
102
 
103
            test[i] = i;
104
 
105
        }
106
 
107
        fpga_con_send_intv( &fc, test, N);
108
 
109
 
110
 
111
 
112
        int rec[N];
113
        fpga_con_rpack_int(&fc,N);
114
        fpga_bgr_recv_intv(&bgr, rec, N );
115
 
116
 
117
        printf( "recv int: \n" );
118
        for( int i = 0; i < N; i++ ) {
119
            printf( " recv: %d %d\n", test[i], rec[i] );
120
        }
121
 
122
    }
123
    if( do_long )
124
    {
125
        int64_t test[N];
126
        for( int i = 0; i < N; i++ ) {
127
 
128
            test[i] = i * int64_t(1024) * 1024 * 1024;
129
 
130
        }
131
 
132
        fpga_con_send_longv( &fc, test, N);
133
 
134
 
135
        int64_t rec[N];
136
        fpga_con_rpack_long(&fc,N);
137
        fpga_bgr_recv_longv(&bgr, rec, N );
138
 
139
 
140
        printf( "recv long: \n" );
141
        for( int i = 0; i < N; i++ ) {
142
            std::cout << " recv " << test[i] << " " << rec[i] << std::endl;
143
        }
144
    }
145
 
146
    if( do_float )
147
    {
148
        float test[N];
149
        for( int i = 0; i < N; i++ ) {
150
 
151
            test[i] = i * 100000;
152
 
153
        }
154
 
155
        fpga_con_send_floatv( &fc, test, N);
156
 
157
 
158
        float rec[N];
159
        fpga_con_rpack_float(&fc,N);
160
        fpga_bgr_recv_floatv(&bgr, rec, N );
161
 
162
 
163
        printf( "recv float: \n" );
164
        for( int i = 0; i < N; i++ ) {
165
            printf( " recv: %f %f\n", test[i], rec[i] );
166
        }
167
    }
168
 
169
    if(do_double)
170
    {
171
        double test[N];
172
        for( int i = 0; i < N; i++ ) {
173
 
174
            test[i] = i * 1000000;
175
 
176
        }
177
 
178
        fpga_con_send_doublev( &fc, test, N);
179
 
180
        double rec[N];
181
        fpga_con_rpack_double(&fc,N);
182
        fpga_bgr_recv_doublev(&bgr, rec, N );
183
 
184
 
185
        printf( "recv double: \n" );
186
        for( int i = 0; i < N; i++ ) {
187
            printf( " recv: %f %f\n", test[i], rec[i] );
188
        }
189
    }
190
 
191
    fpga_bgr_stop_interrupt_join(&bgr);
192
    fpga_bgr_delete(&bgr);
193
 
194
 
195
}

powered by: WebSVN 2.1.0

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