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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
# usage: cat pseudocode | sed -f act2num | awk -f compile.awk
2
#
3
#
4
BEGIN { "date" | getline
5
        today = $0
6
        printf("\n/* this file generated on %s  */\n", today )
7
        printf("\nstatic char pseudo_code [ ] = { \n" )
8
        opl = 0                 # op codes on the current line
9
 
10
        opc = 0                 # opcode counter
11
        fpi = 0                 # fill pointer for idx array
12
}
13
 
14
/^;/ { }                        # line starting with semicolon is comment
15
 
16
/^[A-Z]/ {                      # start of a new action
17
        emit( 0 )
18
        idx[ ++fpi ] = opc
19
        name[ fpi ] = $1
20
        emit( $2 )
21
}
22
 
23
/^[\t ]/ {
24
        emit( $1 )
25
}
26
 
27
END {
28
        if ( opl > 8 ) {
29
            printf("\n")
30
        }
31
        printf("\t  0\n};\n\n")
32
        printf("static short int pseudo_code_idx [ ] ={\n")
33
        opl = 0
34
        emit( 0 )
35
        for( ii = 1; ii <= fpi; ii++ )
36
           emit( idx[ ii ] )
37
        if ( opl > 8 ) {
38
            printf("\n")
39
        }
40
        printf("\t  0\n};\n\n")
41
 
42
        printf("#define %-10s \t %3d \n", "NOP", 0 )
43
        for( ii = 1; ii <= fpi; ii++ )
44
            printf("#define %-10s \t %3d \n", name[ ii ], ii )
45
        printf("\n")
46
}
47
 
48
function emit( opcode ){        # Niclaus Wirth
49
        if ( opl > 8 ) {
50
            printf("\n")
51
            opl = 0
52
        }
53
        opl = opl +1
54
        printf("\t%4d,", opcode )
55
        opc++
56
}
57
 

powered by: WebSVN 2.1.0

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