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

Subversion Repositories openmsp430

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

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

powered by: WebSVN 2.1.0

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