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

Subversion Repositories gecko3

[/] [gecko3/] [trunk/] [GECKO3COM/] [gecko3com-fw/] [firmware/] [gpif-design/] [edit-gpif] - Blame information for rev 32

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 nussgipfel
#!/usr/bin/env python
2
# -*- Python -*-
3
#
4
# Copyright 2003 Free Software Foundation, Inc.
5
#
6
# This file is part of GNU Radio
7
#
8
# GNU Radio is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3, or (at your option)
11
# any later version.
12
#
13
# GNU Radio is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with GNU Radio; see the file COPYING.  If not, write to
20
# the Free Software Foundation, Inc., 51 Franklin Street,
21
# Boston, MA 02110-1301, USA.
22
#
23
 
24
 
25
# Edit the gpif.c file generated by the Cypress GPIF Designer Tool and
26
# produce usrp_gpif.c, and usrp_gpif_inline.h, files suitable for our
27
# uses.
28
 
29
import re
30
import string
31
import sys
32
 
33
def check_flow_state (line, flow_state_dict):
34
    mo = re.match (r'/\* Wave (\d) FlowStates \*/ (.*),', line)
35
    if mo:
36
        wave = int (mo.group (1))
37
        data = mo.group (2)
38
        split = data.split (',', 8)
39
        v = map (lambda x : int (x, 16), split)
40
        # print "%s, %s" % (wave, data)
41
        # print "split: ", split
42
        # print "v    : ", v
43
        flow_state_dict[wave] = v
44
 
45
 
46
def delta (xseq, yseq):
47
    # set subtraction
48
    z = []
49
    for x in xseq:
50
        if x not in yseq:
51
            z.append (x)
52
    return z
53
 
54
 
55
def write_define (output, name, pairs):
56
    output.write ('#define %s()\t\\\n' % name)
57
    output.write ('do {\t\t\t\t\t\\\n')
58
    for reg, val in pairs:
59
        output.write ('%14s = 0x%02x;\t\t\t\\\n' % (reg, val))
60
    output.write ('} while (0)\n\n')
61
 
62
def write_inlines (output, dict):
63
    regs = ['FLOWSTATE', 'FLOWLOGIC', 'FLOWEQ0CTL', 'FLOWEQ1CTL', 'FLOWHOLDOFF',
64
            'FLOWSTB', 'FLOWSTBEDGE', 'FLOWSTBHPERIOD', 'GPIFHOLDAMOUNT']
65
 
66
    READ_FLOW_STATE = 2
67
    WRITE_FLOW_STATE = 3
68
 
69
    read_info = zip (regs, dict[READ_FLOW_STATE])
70
    write_info = zip (regs, dict[WRITE_FLOW_STATE])
71
 
72
    output.write ('''/*
73
 * Machine generated by "edit-gpif".  Do not edit by hand.
74
 */
75
 
76
''')
77
    write_define (output, 'setup_flowstate_common', read_info)
78
    write_define (output, 'setup_flowstate_read', delta (read_info, write_info))
79
    write_define (output, 'setup_flowstate_write', delta (write_info, read_info))
80
 
81
 
82
def edit_gpif (input_name, output_name, inline_name):
83
    input = open (input_name, 'r')
84
    output = open (output_name, 'w')
85
    inline = open (inline_name, 'w')
86
    flow_state_dict = {}
87
 
88
    output.write ('''/*
89
 * Machine generated by "edit-gpif".  Do not edit by hand.
90
 */
91
 
92
''')
93
 
94
    while 1:
95
        line = input.readline ()
96
        line = string.replace (line, '\r','')
97
        line = re.sub (r' *$', r'', line)
98
 
99
        check_flow_state (line, flow_state_dict)
100
 
101
        line = re.sub (r'#include', r'// #include', line)
102
        line = re.sub (r'xdata ', r'', line)
103
        if re.search (r'GpifInit', line):
104
            break
105
 
106
        output.write (line)
107
 
108
    output.close ()
109
    write_inlines (inline, flow_state_dict)
110
    inline.close ()
111
 
112
 
113
# gpif.c usrp_gpif.c usrp_gpif_inline.h
114
edit_gpif (sys.argv[1], sys.argv[2], sys.argv[3])

powered by: WebSVN 2.1.0

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