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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [synthesis/] [xilinx/] [run_analysis.tcl] - Blame information for rev 222

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

Line No. Rev Author Line
1 62 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 {{spartan3     xc3s400pq208    {4 5}      {30.0 34.0}}
47
                 {spartan3e    xc3s500epq208   {4 5}      {32.0 38.0}}
48
                 {spartan3a    xc3s700aft256   {4 5}      {31.0 36.0}}
49
                 {spartan3adsp xc3sd1800acs484 {4 5}      {31.0 39.0}}
50
                 {spartan6     xc6slx45tfgg484 {2 3 4}    {41.0 58.0 68.0}}
51
                 {virtex4      xc4vlx25sf363   {10 11 12} {51.0 57.0 69.0}}
52
                 {virtex5      xc5vlx30ff324   {1 2 3}    {75.0 82.0 97.0}}
53
                 {virtex6      xc6vlx75tff484  {1 2 3}    {92.0 102.0 115.0}}}
54
 
55
 
56
# Set the different RTL configurations to be analysed
57 68 olivier.gi
set rtlDefines  {PMEM_AWIDTH DMEM_AWIDTH  DBG_EN  DBG_HWBRK_0 DBG_HWBRK_1 DBG_HWBRK_2 DBG_HWBRK_3 MULTIPLIER}
58
set rtlConfigs {{    12          10          0         0            0          0            0         0}
59
                {    12          10          1         0            0          0            0         0}
60
                {    12          10          1         1            0          0            0         0}
61
                {    12          10          1         1            1          0            0         0}
62
                {    12          10          1         1            1          1            0         0}
63
                {    12          10          1         1            1          1            1         0}}
64 62 olivier.gi
set clkRatios  {1.00 0.95 0.85 0.85 0.85 0.85}
65 68 olivier.gi
set rtlConfigs {{    12          10          0         0            0          0            0         1}}
66 62 olivier.gi
set clkRatios  {1.00}
67
 
68
 
69
# RTL configuration files
70
set omspConfigFile "../../rtl/verilog/openMSP430_defines.v"
71
set rtlConfigFile  "./src/arch.v"
72
 
73
 
74
###############################################################################
75
#                              PERFORM ANALYSIS                               #
76
###############################################################################
77
 
78
 
79
foreach rtlConfig $rtlConfigs clkRatio $clkRatios {
80
 
81
    #-------------------------------------------------------------------------#
82
    #                        Generate RTL configuration                       #
83
    #-------------------------------------------------------------------------#
84
 
85
    # Read original define file
86
    if [catch {open $omspConfigFile r} f_omspConfigFile] {
87
        puts "ERROR: Cannot open file $omspConfigFile"
88
        exit 1
89
    }
90
    set configFile [read $f_omspConfigFile]
91
    close $f_omspConfigFile
92
 
93
 
94
    # Update defines
95
    set idx 0
96
    foreach rtlDefine $rtlDefines {
97
 
98
        if {[regsub "`define\\s+$rtlDefine\\s+\\d+" $configFile "`define $rtlDefine [lindex $rtlConfig $idx]" configFile]} {
99
        } else {
100
            if {[lindex $rtlConfig $idx]==0} {
101
                regsub "\\n`define\\s+$rtlDefine" $configFile "\n//`define $rtlDefine" configFile
102
            }
103
        }
104
        set idx [expr $idx+1]
105
    }
106
 
107
 
108
    # Write the new file
109
    set f_configFile [open "./src/[file tail $omspConfigFile]" w]
110
    puts $f_configFile $configFile
111
    close $f_configFile
112
 
113
 
114
    #-------------------------------------------------------------------------#
115
    #                      Perform analysis for each FPGA                     #
116
    #-------------------------------------------------------------------------#
117
    foreach fpgaConfig $fpgaConfigs {
118
        foreach speedGrade [lindex $fpgaConfig 2] clkFreq [lindex $fpgaConfig 3] {
119
 
120
            # Create verilog arch define
121
            set f_configFile [open $rtlConfigFile w]
122
            puts $f_configFile "\n`define [string toupper [lindex $fpgaConfig 0]]\n"
123
            close $f_configFile
124
 
125
            # Cleanup
126
            file delete -force ./WORK
127
            file mkdir ./WORK
128
            cd ./WORK
129
 
130
            # Create links for RAM ngc files
131
            file link "[lindex $fpgaConfig 0]_pmem.ngc" "../src/coregen/[lindex $fpgaConfig 0]_pmem.ngc"
132
            file link "[lindex $fpgaConfig 0]_dmem.ngc" "../src/coregen/[lindex $fpgaConfig 0]_dmem.ngc"
133
 
134
            # Create link to the Xilinx constraints file
135
            if [catch {open "../openMSP430_fpga.ucf" r} f_ucf] {
136
                puts "ERROR: Cannot open constrain file ../openMSP430_fpga.ucf"
137
                exit 1
138
            }
139
            set ucf [read $f_ucf]
140
            close $f_ucf
141
            if {[string eq $analysisType "AREA"] || [string eq $clkFreq "-1"]} {
142
                regsub {<COMMENT>} $ucf "\#" ucf
143
            } else {
144
                regsub {<COMMENT>} $ucf "" ucf
145
            }
146
            regsub {<PERIOD>}      $ucf "[expr 1000/($clkFreq*$clkRatio)]"     ucf
147
            regsub {<HALF_PERIOD>} $ucf "[expr (1000/($clkFreq*$clkRatio))/2]" ucf
148
            set f_ucf [open "openMSP430_fpga.ucf" w]
149
            puts $f_ucf $ucf
150
            close $f_ucf
151
 
152
 
153
            # Copy synthesis configuration script
154
            if [catch {open "../xst_verilog_[lindex $fpgaConfig 0].opt" r} f_xst_verilog] {
155
                puts "ERROR: Cannot open timing file ../xst_verilog_[lindex $fpgaConfig 0].opt"
156
                exit 1
157
            }
158
            set xst_verilog [read $f_xst_verilog]
159
            close $f_xst_verilog
160
            regsub {\"-opt_mode SPEED\";} $xst_verilog "\"-opt_mode $analysisType\";" xst_verilog
161
 
162
            set f_xst_verilog [open "xst_verilog.opt" w]
163
            puts $f_xst_verilog $xst_verilog
164
            close $f_xst_verilog
165
 
166
            # Run synthesis
167
            puts "#####################################################################################"
168
            puts "#                            START SYNTHESIS ($analysisType optimized)"
169
            puts "#===================================================================================="
170
            puts "# [lindex $fpgaConfig 0] ([lindex $fpgaConfig 1]), speedgrade: -$speedGrade"
171
            puts "#===================================================================================="
172
            puts "# $rtlDefines"
173
            puts "# $rtlConfig"
174
            puts "#===================================================================================="
175
            set fpgaName "[lindex $fpgaConfig 1]-$speedGrade"
176
            if {[catch "exec xflow -p $fpgaName -implement high_effort.opt    \
177
                                   -config    bitgen.opt         \
178
                                   -synth     ./xst_verilog.opt  \
179
                                   ../openMSP430_fpga.prj"]} {
180
 
181
                puts "ERROR: Synthesis error !!!!!!"
182
                exit 1
183
            }
184
 
185
            # Extract timing information
186
            if [catch {open "openMSP430_fpga.twr" r} f_timing] {
187
                puts "ERROR: Cannot open timing file openMSP430_fpga.twr"
188
                exit 1
189
            }
190
            set timingFile [read $f_timing]
191
            close $f_timing
192
            regexp {Clock to Setup on destination.*\+\n} $timingFile whole_match
193
            puts $whole_match
194
            puts "===================================================================================="
195
 
196
            # Extract size information
197
            if [catch {open "openMSP430_fpga_xst.log" r} f_log] {
198
                puts "ERROR: Cannot open timing file openMSP430_fpga_xst.log"
199
                exit 1
200
            }
201
            set logFile [read $f_log]
202
            close $f_log
203
            regexp {(Device utilization summary:.*\n)Partition Resource Summary:} $logFile whole_match area
204
            puts $area
205
            puts "===================================================================================="
206
 
207
            puts "#                            SYNTHESIS DONE"
208
            puts "#####################################################################################"
209
            puts ""
210
            cd ../
211
        }
212
    }
213
 
214
}
215
 
216
exit 0

powered by: WebSVN 2.1.0

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