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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [synthesis/] [altera/] [run_analysis.tcl] - Blame information for rev 63

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

Line No. Rev Author Line
1 63 olivier.gi
#!/usr/bin/tclsh
2
#------------------------------------------------------------------------------
3
# Copyright (C) 2001 Authors
4
#
5
# This source file may be used and distributed without restriction provided
6
# that this copyright statement is not removed from the file and that any
7
# derivative work contains the original copyright notice and the associated
8
# disclaimer.
9
#
10
# This source file is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU Lesser General Public License as published
12
# by the Free Software Foundation; either version 2.1 of the License, or
13
# (at your option) any later version.
14
#
15
# This source is distributed in the hope that it will be useful, but WITHOUT
16
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18
# License for more details.
19
#
20
# You should have received a copy of the GNU Lesser General Public License
21
# along with this source; if not, write to the Free Software Foundation,
22
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
#
24
#------------------------------------------------------------------------------
25
# 
26
# File Name: run_analysis.tcl
27
# 
28
# Author(s):
29
#             - Olivier Girard,    olgirard@gmail.com
30
#
31
#------------------------------------------------------------------------------
32
# $Rev: 17 $
33
# $LastChangedBy: olivier.girard $
34
# $LastChangedDate: 2009-08-04 23:15:39 +0200 (Tue, 04 Aug 2009) $
35
#------------------------------------------------------------------------------
36
 
37
###############################################################################
38
#                         SET SOME GLOBAL VARIABLES                           #
39
###############################################################################
40
 
41
# Analysis type
42
set analysisType SPEED
43
#set analysisType AREA
44
 
45
# Set the different FPGA architectures & models to be checked
46
set fpgaConfigs {{"Cyclone II"     EP2C20F484C    {6 7 8}}
47
                 {"Cyclone III"    EP3C55F484C    {6 7 8}}
48
                 {"Cyclone IV GX"  EP4CGX22CF19C  {6 7 8}}
49
                 {"Arria GX"       EP1AGX50CF484C {6}}
50
                 {"Arria II GX"    EP2AGX45DF29C  {4 5 6}}
51
                 {"Stratix"        EP1S10F484C    {5 6 7}}
52
                 {"Stratix II"     EP2S15F484C    {3 4 5}}
53
                 {"Stratix III"    EP3SE50F484C   {2 3 4}}}
54
set fpgaConfigs {{"Cyclone II"     EP2C20F484C    {7}}}
55
 
56
 
57
# Set the different RTL configurations to be analysed
58
set rtlDefines  {PMEM_AWIDTH DMEM_AWIDTH  DBG_EN  DBG_HWBRK_0 DBG_HWBRK_1 DBG_HWBRK_2 DBG_HWBRK_3}
59
set rtlConfigs {{    12          10          0         0            0          0            0    }
60
                {    12          10          1         0            0          0            0    }
61
                {    12          10          1         1            0          0            0    }
62
                {    12          10          1         1            1          0            0    }
63
                {    12          10          1         1            1          1            0    }
64
                {    12          10          1         1            1          1            1    }}
65
set rtlConfigs {{    12          10          0         0            0          0            0    }}
66
 
67
 
68
# RTL configuration files
69
set omspConfigFile "../../rtl/verilog/openMSP430_defines.v"
70
set rtlConfigFile  "./src/arch.v"
71
 
72
 
73
###############################################################################
74
#                              PERFORM ANALYSIS                               #
75
###############################################################################
76
 
77
 
78
foreach rtlConfig $rtlConfigs {
79
 
80
    #-------------------------------------------------------------------------#
81
    #                        Generate RTL configuration                       #
82
    #-------------------------------------------------------------------------#
83
 
84
    # Read original define file
85
    if [catch {open $omspConfigFile r} f_omspConfigFile] {
86
        puts "ERROR: Cannot open file $omspConfigFile"
87
        exit 1
88
    }
89
    set configFile [read $f_omspConfigFile]
90
    close $f_omspConfigFile
91
 
92
 
93
    # Update defines
94
    set idx 0
95
    foreach rtlDefine $rtlDefines {
96
 
97
        if {[regsub "`define\\s+$rtlDefine\\s+\\d+" $configFile "`define $rtlDefine [lindex $rtlConfig $idx]" configFile]} {
98
        } else {
99
            if {[lindex $rtlConfig $idx]==0} {
100
                regsub "\\n`define\\s+$rtlDefine" $configFile "\n//`define $rtlDefine" configFile
101
            }
102
        }
103
        set idx [expr $idx+1]
104
    }
105
 
106
 
107
    # Write the new file
108
    set f_configFile [open "./src/[file tail $omspConfigFile]" w]
109
    puts $f_configFile $configFile
110
    close $f_configFile
111
 
112
 
113
    #-------------------------------------------------------------------------#
114
    #                      Perform analysis for each FPGA                     #
115
    #-------------------------------------------------------------------------#
116
    foreach fpgaConfig $fpgaConfigs {
117
        foreach speedGrade [lindex $fpgaConfig 2] {
118
 
119
            # Create verilog arch define
120
            set f_configFile [open $rtlConfigFile w]
121
            regsub -all {\s} [lindex $fpgaConfig 0] {_} defineName
122
            set defineName [string toupper $defineName]
123
            puts $f_configFile "\n`define $defineName\n"
124
            close $f_configFile
125
 
126
            # Cleanup
127
            file delete -force ./WORK
128
            file mkdir ./WORK
129
            cd ./WORK
130
 
131
            # Copy Quartus tcl command file
132
            if [catch {open "../openMSP430_fpga.tcl" r} f_quartus_tcl] {
133
                puts "ERROR: Cannot open Quartus command file file ../openMSP430_fpga.tcl"
134
                exit 1
135
            }
136
            set quartus_tcl [read $f_quartus_tcl]
137
            close $f_quartus_tcl
138
 
139
            set fpgaName "[lindex $fpgaConfig 1]$speedGrade"
140
 
141
            regsub -all {<DEVICE_NAME>}   $quartus_tcl "$fpgaName"              quartus_tcl
142
            regsub -all {<DEVICE_FAMILY>} $quartus_tcl "[lindex $fpgaConfig 0]" quartus_tcl
143
            regsub -all {<SPEED_AREA>}    $quartus_tcl "$analysisType"          quartus_tcl
144
 
145
            set f_quartus_tcl [open "openMSP430_fpga.tcl" w]
146
            puts $f_quartus_tcl $quartus_tcl
147
            close $f_quartus_tcl
148
 
149
            # Run synthesis
150
            puts "#####################################################################################"
151
            puts "#                            START SYNTHESIS ($analysisType optimized)"
152
            puts "#===================================================================================="
153
            puts "# [lindex $fpgaConfig 0] ([lindex $fpgaConfig 1]), speedgrade: -$speedGrade"
154
            puts "#===================================================================================="
155
            puts "# $rtlDefines"
156
            puts "# $rtlConfig"
157
            puts "#===================================================================================="
158
            if {[catch "exec quartus_sh -t openMSP430_fpga.tcl | tee quartus_sh.log"]} {
159
                puts "ERROR: Synthesis error !!!!!!"
160
                exit 1
161
            }
162
 
163
            # Extract timing information
164
            if [catch {open "openMSP430_fpga.tan.summary" r} f_timing] {
165
                if [catch {open "openMSP430_fpga.sta.rpt" r} f_timing] {
166
                    puts "ERROR: Cannot open timing file"
167
                    exit 1
168
                }
169
            }
170
            set timingFile [read $f_timing]
171
            close $f_timing
172
            if {![regexp {(Type\s+?: Clock Setup: 'dco_clk'.*?)From} $timingFile whole_match timing]} {
173
                regexp {([^\n]+?\n;\s+Slow .*?Model Fmax Summary[^\n]+?\n[^\n]+?\n[^\n]+?\n[^\n]+?\n[^\n]+?\n[^\n]+?\n)} $timingFile whole_match timing
174
            }
175
            puts $timing
176
            puts "===================================================================================="
177
 
178
            # Extract size information
179
            if [catch {open "openMSP430_fpga.fit.summary" r} f_log] {
180
                puts "ERROR: Cannot open timing file openMSP430_fpga.fit.summary"
181
                exit 1
182
            }
183
            set logFile [read $f_log]
184
            close $f_log
185
            regexp {Timing Models[^\n]+\n(.+)} $logFile whole_match area
186
            puts $area
187
            puts "===================================================================================="
188
 
189
            puts "#                            SYNTHESIS DONE"
190
            puts "#####################################################################################"
191
            puts ""
192
            cd ../
193
        }
194
    }
195
 
196
}
197
 
198
exit 0

powered by: WebSVN 2.1.0

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