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

Subversion Repositories openmsp430

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

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 68 olivier.gi
 
55 63 olivier.gi
# Set the different RTL configurations to be analysed
56 68 olivier.gi
set rtlDefines  {PMEM_AWIDTH DMEM_AWIDTH  DBG_EN  DBG_HWBRK_0 DBG_HWBRK_1 DBG_HWBRK_2 DBG_HWBRK_3 MULTIPLIER}
57
set rtlConfigs {{    12          10          0         0            0          0            0         0}
58
                {    12          10          1         0            0          0            0         0}
59
                {    12          10          1         1            0          0            0         0}
60
                {    12          10          1         1            1          0            0         0}
61
                {    12          10          1         1            1          1            0         0}
62
                {    12          10          1         1            1          1            1         0}}
63
set rtlConfigs {{    12          10          0         0            0          0            0         1}}
64 63 olivier.gi
 
65
 
66
# RTL configuration files
67
set omspConfigFile "../../rtl/verilog/openMSP430_defines.v"
68
set rtlConfigFile  "./src/arch.v"
69
 
70
 
71
###############################################################################
72
#                              PERFORM ANALYSIS                               #
73
###############################################################################
74
 
75
 
76
foreach rtlConfig $rtlConfigs {
77
 
78
    #-------------------------------------------------------------------------#
79
    #                        Generate RTL configuration                       #
80
    #-------------------------------------------------------------------------#
81
 
82
    # Read original define file
83
    if [catch {open $omspConfigFile r} f_omspConfigFile] {
84
        puts "ERROR: Cannot open file $omspConfigFile"
85
        exit 1
86
    }
87
    set configFile [read $f_omspConfigFile]
88
    close $f_omspConfigFile
89
 
90
 
91
    # Update defines
92
    set idx 0
93
    foreach rtlDefine $rtlDefines {
94
 
95
        if {[regsub "`define\\s+$rtlDefine\\s+\\d+" $configFile "`define $rtlDefine [lindex $rtlConfig $idx]" configFile]} {
96
        } else {
97
            if {[lindex $rtlConfig $idx]==0} {
98
                regsub "\\n`define\\s+$rtlDefine" $configFile "\n//`define $rtlDefine" configFile
99
            }
100
        }
101
        set idx [expr $idx+1]
102
    }
103
 
104
 
105
    # Write the new file
106
    set f_configFile [open "./src/[file tail $omspConfigFile]" w]
107
    puts $f_configFile $configFile
108
    close $f_configFile
109
 
110
 
111
    #-------------------------------------------------------------------------#
112
    #                      Perform analysis for each FPGA                     #
113
    #-------------------------------------------------------------------------#
114
    foreach fpgaConfig $fpgaConfigs {
115
        foreach speedGrade [lindex $fpgaConfig 2] {
116
 
117
            # Create verilog arch define
118
            set f_configFile [open $rtlConfigFile w]
119
            regsub -all {\s} [lindex $fpgaConfig 0] {_} defineName
120
            set defineName [string toupper $defineName]
121
            puts $f_configFile "\n`define $defineName\n"
122
            close $f_configFile
123
 
124
            # Cleanup
125
            file delete -force ./WORK
126
            file mkdir ./WORK
127
            cd ./WORK
128
 
129
            # Copy Quartus tcl command file
130
            if [catch {open "../openMSP430_fpga.tcl" r} f_quartus_tcl] {
131
                puts "ERROR: Cannot open Quartus command file file ../openMSP430_fpga.tcl"
132
                exit 1
133
            }
134
            set quartus_tcl [read $f_quartus_tcl]
135
            close $f_quartus_tcl
136
 
137
            set fpgaName "[lindex $fpgaConfig 1]$speedGrade"
138
 
139
            regsub -all {<DEVICE_NAME>}   $quartus_tcl "$fpgaName"              quartus_tcl
140
            regsub -all {<DEVICE_FAMILY>} $quartus_tcl "[lindex $fpgaConfig 0]" quartus_tcl
141
            regsub -all {<SPEED_AREA>}    $quartus_tcl "$analysisType"          quartus_tcl
142
 
143
            set f_quartus_tcl [open "openMSP430_fpga.tcl" w]
144
            puts $f_quartus_tcl $quartus_tcl
145
            close $f_quartus_tcl
146
 
147
            # Run synthesis
148
            puts "#####################################################################################"
149
            puts "#                            START SYNTHESIS ($analysisType optimized)"
150
            puts "#===================================================================================="
151
            puts "# [lindex $fpgaConfig 0] ([lindex $fpgaConfig 1]), speedgrade: -$speedGrade"
152
            puts "#===================================================================================="
153
            puts "# $rtlDefines"
154
            puts "# $rtlConfig"
155
            puts "#===================================================================================="
156
            if {[catch "exec quartus_sh -t openMSP430_fpga.tcl | tee quartus_sh.log"]} {
157
                puts "ERROR: Synthesis error !!!!!!"
158
                exit 1
159
            }
160
 
161
            # Extract timing information
162
            if [catch {open "openMSP430_fpga.tan.summary" r} f_timing] {
163
                if [catch {open "openMSP430_fpga.sta.rpt" r} f_timing] {
164
                    puts "ERROR: Cannot open timing file"
165
                    exit 1
166
                }
167
            }
168
            set timingFile [read $f_timing]
169
            close $f_timing
170
            if {![regexp {(Type\s+?: Clock Setup: 'dco_clk'.*?)From} $timingFile whole_match timing]} {
171
                regexp {([^\n]+?\n;\s+Slow .*?Model Fmax Summary[^\n]+?\n[^\n]+?\n[^\n]+?\n[^\n]+?\n[^\n]+?\n[^\n]+?\n)} $timingFile whole_match timing
172
            }
173
            puts $timing
174
            puts "===================================================================================="
175
 
176
            # Extract size information
177
            if [catch {open "openMSP430_fpga.fit.summary" r} f_log] {
178
                puts "ERROR: Cannot open timing file openMSP430_fpga.fit.summary"
179
                exit 1
180
            }
181
            set logFile [read $f_log]
182
            close $f_log
183
            regexp {Timing Models[^\n]+\n(.+)} $logFile whole_match area
184
            puts $area
185
            puts "===================================================================================="
186
 
187
            puts "#                            SYNTHESIS DONE"
188
            puts "#####################################################################################"
189
            puts ""
190
            cd ../
191
        }
192
    }
193
 
194
}
195
 
196
exit 0

powered by: WebSVN 2.1.0

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