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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [altera_de0_nano_soc/] [doc/] [Terasic/] [DE0_NANO_SOC/] [Demonstrations/] [FPGA/] [DE0_NANO_SOC_ADC/] [software/] [DE0_NANO_SOC_ADC_bsp/] [drivers/] [src/] [altera_avalon_sysid_qsys.c] - Blame information for rev 221

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 221 olivier.gi
/******************************************************************************
2
*                                                                             *
3
* License Agreement                                                           *
4
*                                                                             *
5
* Copyright (c) 2003 Altera Corporation, San Jose, California, USA.           *
6
* All rights reserved.                                                        *
7
*                                                                             *
8
* Permission is hereby granted, free of charge, to any person obtaining a     *
9
* copy of this software and associated documentation files (the "Software"),  *
10
* to deal in the Software without restriction, including without limitation   *
11
* the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
12
* and/or sell copies of the Software, and to permit persons to whom the       *
13
* Software is furnished to do so, subject to the following conditions:        *
14
*                                                                             *
15
* The above copyright notice and this permission notice shall be included in  *
16
* all copies or substantial portions of the Software.                         *
17
*                                                                             *
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
19
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
20
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
22
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
23
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
24
* DEALINGS IN THE SOFTWARE.                                                   *
25
*                                                                             *
26
* This agreement shall be governed in all respects by the laws of the State   *
27
* of California and by the laws of the United States of America.              *
28
*                                                                             *
29
* Altera does not recommend, suggest or require that this reference design    *
30
* file be used in conjunction or combination with any other product.          *
31
******************************************************************************/
32
 
33
#include "altera_avalon_sysid_qsys.h"
34
#include "altera_avalon_sysid_qsys_regs.h"
35
#include "alt_types.h"
36
#include <io.h>
37
 
38
/*
39
*  This component is special: there's only one of it.
40
*  Therefore we can dispense with a bunch of complexity
41
*  normally associated with components, such as specialized
42
*  structs containing parameter info, and instead use that
43
*  info by name directly out of system.h.  A downside of this
44
*  approach is that each time the system is regenerated, and
45
*  system.h changes, this file must be recompiled.  Fortunately
46
*  this file is, and is likely to remain, quite small.
47
*/
48
#include "system.h"
49
 
50
#ifdef SYSID_BASE
51
/*
52
*  return values:
53
*    0 if the hardware and software appear to be in sync
54
*    1 if software appears to be older than hardware
55
*   -1 if hardware appears to be older than software
56
*/
57
 
58
alt_32 alt_avalon_sysid_qsys_test(void)
59
{
60
  /* Read the hardware-tag, aka value0, from the hardware. */
61
  alt_u32 hardware_id = IORD_ALTERA_AVALON_SYSID_QSYS_ID(SYSID_BASE);
62
 
63
  /* Read the time-of-generation, aka value1, from the hardware register. */
64
  alt_u32 hardware_timestamp = IORD_ALTERA_AVALON_SYSID_QSYS_TIMESTAMP(SYSID_BASE);
65
 
66
  /* Return 0 if the hardware and software appear to be in sync. */
67
  if ((SYSID_TIMESTAMP == hardware_timestamp) && (SYSID_ID == hardware_id))
68
  {
69
    return 0;
70
  }
71
 
72
  /*
73
  *  Return 1 if software appears to be older than hardware (that is,
74
  *  the value returned by the hardware is larger than that recorded by
75
  *  the generator function).
76
  *  If the hardware time happens to match the generator program's value
77
  *  (but the hardware tag, value0, doesn't match or 0 would have been
78
  *  returned above), return an arbitrary value, let's say -1.
79
  */
80
  return ((alt_32)(hardware_timestamp - SYSID_TIMESTAMP)) > 0 ? 1 : -1;
81
}
82
#endif

powered by: WebSVN 2.1.0

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