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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [net/] [802/] [transit/] [compile.awk] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
# to run: awk -f transit.awk transit.p0
2
#
3
BEGIN { "date" | getline
4
        enable_index = 1
5
        today = $0
6
        printf("\n/* this file was generated on %s  */\n", today )
7
        not_firstone = 0        # flag to avoid empty entry in 1st table
8
        fpe = 0                 # entry tbl array fill pointer
9
        fpeo = 0                # entry tbl offset list fill pointer
10
        fpdef = 0               # define list fill pointer
11
}
12
 
13
### /^;/ { }                    # line starting with a semicolon is comment
14
 
15
/^[A-Z]/ {                      # table name
16
        if ( $1 == "TABLE" ) {
17
           tbl = $2             # get table name
18
           newtbl( tbl )
19
        }
20
        else if ( $1 == "COMPILE" ) {
21
           array_name = $2
22
           if ( $3 == "NOINDEX" ) { enable_index = 0 }
23
        }
24
        else {                  # table entry
25
           ec = ec +1
26
           n = split( $0, fld, " " )
27
           action = fld[ n-1 ]
28
           newstate = fld[ n ]
29
           store( action, newstate )
30
           ecct = ecct +1
31
        }
32
}
33
 
34
END {   store( action, newstate )
35
 
36
        if ( enable_index ) {
37
            printf( "\n/* index name #defines: */\n\n",
38
                 ec, ecct )
39
 
40
            for( ii = 1; ii <= fpeo; ii++ ){
41
               printf( "#define %-12s %3d\n", define[ ii ], ii -1 )
42
            }
43
        }
44
 
45
        printf( "\n\n/* size of transition table is %d bytes */\n",
46
                 fpe )
47
 
48
        if ( enable_index ) {
49
            printf( "\nstatic short int %s_offset [ ] ={", array_name )
50
            for( ii = 1; ii <= fpeo; ii++ ){
51
                if ( (ii % 10) == 1 ) printf("\n  ")
52
                printf( " %4d", entry_offset[ ii ] )
53
                if ( ii < fpeo ) printf( "," )
54
            }
55
            printf(" };\n")
56
        }
57
 
58
        printf( "\nstatic char %s_entry [ ] = {", array_name )
59
        for( ii = 1; ii <= fpe; ii++ ){
60
            if ( (ii % 6) == 1 ) printf("\n  ")
61
            printf( " %-14s", entry[ ii ] )
62
            if ( ii < fpe ) printf( "," )
63
        }
64
        printf(" };\n")
65
 
66
}
67
 
68
function store(  act, ns ){
69
#       printf( "%s %s\n",  act, ns )
70
        entry[ ++fpe ] = act
71
        entry[ ++fpe ] = ns
72
}
73
 
74
function newtbl( tbl ){
75
           if ( not_firstone ) {
76
                store( action, newstate )
77
           }
78
           not_firstone = 1
79
           entry_offset[ ++fpeo ] = fpe         # entry tbl offset list
80
           define[ ++fpdef ] = tbl      # state name to define
81
}

powered by: WebSVN 2.1.0

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