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

Subversion Repositories yac

[/] [yac/] [trunk/] [sw/] [src/] [yac.c] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 feddischso
/* -------------------------------------------------------------------
2
 *
3
 *
4
 *
5
 *   File           : yac.c
6
 *   Project        : YAC (Yet Another CORDIC Core)
7
 *   Creation       : Jun. 2015
8
 *   Limitations    :
9
 *   Synthesizer    :
10
 *   Target         :
11
 *
12
 *   Author(s):     : Christian Haettich
13
 *   Email          : feddischson@opencores.org
14
 *
15
 *
16
 *
17
 *
18
 *   Description
19
 *        Implementation of functions to access the yac.
20
 *
21
 *
22
 *
23
 *
24
 *
25
 *
26
 *
27
 *  -------------------------------------------------------------------
28
 *
29
 *                   Copyright Notice
30
 *
31
 *  This file is part of YAC - Yet Another CORDIC Core
32
 *  Copyright (c) 2015, Author(s), All rights reserved.
33
 *
34
 *  YAC is free software; you can redistribute it and/or
35
 *  modify it under the terms of the GNU Lesser General Public
36
 *  License as published by the Free Software Foundation; either
37
 *  version 3.0 of the License, or (at your option) any later version.
38
 *
39
 *  YAC is distributed in the hope that it will be useful,
40
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
41
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
42
 *  Lesser General Public License for more details.
43
 *
44
 *  You should have received a copy of the GNU Lesser General Public
45
 *  License along with this library. If not, download it from
46
 *  http://www.gnu.org/licenses/lgpl
47
 *
48
 *  -------------------------------------------------------------------
49
 */
50
#include "yac.h"
51
 
52
 
53
#define REG32(adr) *((volatile unsigned long *)(adr))
54
 
55
 
56
void yac_init( YAC * yac,
57
               uint32_t   base,
58
               uint32_t   xy_width,
59
               uint32_t   a_width,
60
               uint8_t    rm_gain,
61
               uint16_t   entries )
62
{
63
  yac->base         = base;
64
  yac->xy_width     = xy_width;
65
  yac->a_width      = a_width;
66
  yac->rm_gain      = rm_gain;
67
  yac->entries      = entries;
68
  yac->status_reg   = base + ( entries<<4);
69
}
70
 
71
 
72
 
73
void yac_single( YAC * yac,
74
                 int32_t * x_i,
75
                 int32_t * y_i,
76
                 int32_t * z_i,
77
                 int32_t * x_o,
78
                 int32_t * y_o,
79
                 int32_t * z_o,
80
                 uint8_t * mode )
81
{
82
    REG32( yac->base + 0   ) =  *x_i;
83
    REG32( yac->base + 4   ) =  *y_i;
84
    REG32( yac->base + 8   ) =  *z_i;
85
    REG32( yac->base + 12  ) = *mode;
86
    REG32( yac->status_reg ) = (1<<YAC_ENTRIES_SHIFT) | 1;
87
 
88
    /* busy wait loop until the yac is done */
89
    while( REG32( yac->status_reg ) & 1 );
90
 
91
    *x_o = REG32( yac->base + 0 );
92
    *y_o = REG32( yac->base + 4 );
93
    *z_o = REG32( yac->base + 8 );
94
}

powered by: WebSVN 2.1.0

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