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

Subversion Repositories radiohdl

[/] [radiohdl/] [trunk/] [quartus/] [run_reg] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 danv
#!/bin/bash -eu
2
# -------------------------------------------------------------------------- #
3
#
4
# Copyright (C) 2012
5
# ASTRON (Netherlands Institute for Radio Astronomy) 
6
# JIVE (Joint Institute for VLBI in Europe) 
7
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
8
#
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 3 of the License, or
12
# (at your option) any later version.
13
#
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with this program.  If not, see .
21
#
22
# -------------------------------------------------------------------------- #
23
 
24
# Run this tool with at least the commandline arguments:
25
#   run_reg buildset design_name
26
# example:
27
#   run_reg unb2 unb2_minimal
28
 
29
# read generic functions/definitions
30
. ${RADIOHDL_GEAR}/generic.sh
31
 
32
# helper function for command parsing
33
exit_with_error() {
34
    hdl_error_noexit $0 "$@"
35
    cat <<@EndOfHelp@
36
Usage: $(basename $0) buildset project [options]
37
Arguments: buildset     Name of the buildset to create the registermap for.
38
           project      Project file to use.
39
 
40
Options: --rev=*        which revision to use.
41
--> Note: It does not matter where the options are placed: before, in between or after the arguments.
42
@EndOfHelp@
43
    exit 1
44
}
45
 
46
# parse cmdline
47
POSITIONAL=()
48
rev=
49
while [[ $# -gt 0 ]]
50
do
51
    case $1 in
52
        --rev=*)
53
            rev=${1#*=}
54
            ;;
55
        -*|--*)
56
            exit_with_error "Unknown option: "$1
57
            ;;
58
        *)  POSITIONAL+=("$1")
59
            ;;
60
    esac
61
    shift
62
done
63
if [ ${#POSITIONAL[@]} -gt 0 ]; then
64
    set -- "${POSITIONAL[@]}"
65
fi
66
 
67
# check the positional parameters
68
if [ $# -ne 2 ]; then
69
    exit_with_error "Wrong number of arguments specified."
70
fi
71
buildset=$1
72
project=$2
73
# read in the configuration based on the user arguments
74
. ${RADIOHDL_GEAR}/quartus/set_quartus ${buildset}
75
 
76
# check projectfile
77
PRJS="${RADIOHDL_BUILD_DIR}"
78
PRJ=
79
for prj in ${PRJS}
80
    do
81
        if [ -d "${prj}/${buildset}/quartus/${project}" ]; then
82
            PRJ=${prj}
83
        fi
84
    done
85
if [ -z "${project}" -o -z "${PRJ}" ]; then
86
    hdl_error $0 "Please enter a valid project name"
87
fi
88
 
89
quartusdir="${PRJ}/${buildset}/quartus/${project}"
90
builddir="${quartusdir}/software"
91
bspdstdir="${builddir}/bsp"
92
 
93
if [ -z "${rev}" ]; then
94
    project_rev="${project}"
95
    hdl_info $0 "No project revision passed, defaulting to ${project_rev}"
96
else
97
    if [ -f "${quartusdir}/${rev}.qsf" ]; then
98
        project_rev="${rev}"
99
        hdl_info $0 "Selecting project revision ${project_rev}"
100
    else
101
      hdl_error $0 "Invalid project revision"
102
    fi
103
fi
104
 
105
system_h=${bspdstdir}/system.h
106
if [ ! -f "${system_h}" ]; then
107
    hdl_error $0 "system.h file not found in [${bspdstdir}]"
108
fi
109
 
110
hdl_info $0 "Extracting peripherals from ${bspdstdir}/system.h:"
111
 
112
# Extract lines with 'BASE' or 'SPAN', remove ALT* stuff etc., remove '0x' prefix, remove '#define' and peripheral name preceding '_SPAN', remove '_BASE', finally replace newlines with spaces.
113
egrep "BASE|SPAN" ${system_h} | egrep -v 'ALT|TIMER|SYSTEM_INFO|ONCHIP_MEMORY2_0|JTAG_UART' | sed -e "s/\0x//g" | sed 's/^#define //' | sed 's/^.*_SPAN //' | sed -e "s/\_BASE//g" | sed ':a;N;$!ba;s/\n/ /g' > ${quartusdir}/${project_rev}.reg
114
 
115
cat ${quartusdir}/${project_rev}.reg
116
 
117
# Add a null character to the end of the file.
118
printf '\0' >> ${quartusdir}/${project_rev}.reg
119
 
120
# sed: extract first number on the line (returned by wc) = size
121
size=`wc -c ${quartusdir}/${project_rev}.reg | sed 's/\([0-9]*\).*/\1/'`
122
 
123
# See if byte size happens to be on word boundary, if not pad with more null characters
124
while [ $(( $size % 4 )) -ne 0 ]
125
do
126
  printf '\0' >> ${quartusdir}/${project_rev}.reg
127
  size=`wc -c ${quartusdir}/${project_rev}.reg | sed 's/\([0-9]*\).*/\1/'`
128
done
129
 
130
hdl_info $0 "Created ${quartusdir}/${project_rev}.reg"
131
hdl_info $0 "Size of ${project_rev}.reg: ${size} bytes"
132
 
133
hdl_exec $0 msg="Calling run_mif to convert ${project_rev}.reg to ${project_rev}.mif" run_mif ${buildset} ${project} ${rev}
134
 
135
hdl_info $0 "Done"
136
 

powered by: WebSVN 2.1.0

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