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

Subversion Repositories pcie_sg_dma

[/] [pcie_sg_dma/] [branches/] [Virtex6/] [ML605_ISE12.3/] [MyUserLogic/] [top_level_0_PCIe_UserLogic_00_INOUT_LOGIC/] [SgIseProject.tcl] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 barabba
namespace eval ::xilinx::dsptool::iseproject {
2
 
3
    namespace eval ise {}
4
    namespace export \
5
        VERBOSITY_QUIET VERBOSITY_ERROR VERBOSITY_WARNING \
6
        VERBOSITY_INFORMATION VERBOSITY_DEBUG
7
 
8
    set VERBOSITY_QUIET       0
9
    set VERBOSITY_ERROR       1
10
    set VERBOSITY_WARNING     2
11
    set VERBOSITY_INFORMATION 3
12
    set VERBOSITY_DEBUG       4
13
 
14
    #-------------------------------------------------------------------------
15
    # Checks for a required parameter.
16
    #
17
    # @param  param          Parameter name.
18
    # @param  postproc       Post processor.
19
    # @return the parameter value.
20
    #-------------------------------------------------------------------------
21
    proc required_parameter {param {postproc ""}} {
22
        upvar $param p
23
        if {![info exists p]} {
24
            error "Required parameter \"[namespace tail $param]\" is not specified."
25
        }
26
        if {$postproc != ""} {
27
            eval $postproc p
28
        }
29
        return $p
30
    }
31
 
32
    #-------------------------------------------------------------------------
33
    # Checks for an optional parameter.
34
    #
35
    # @param  param          Parameter name.
36
    # @param  defval         Default value of the parameter if unspecified.
37
    # @param  postproc       Post processor.
38
    # @return the parameter value.
39
    #-------------------------------------------------------------------------
40
    proc optional_parameter {param {defval ""} {postproc ""}} {
41
        upvar $param p
42
        if {![info exists p]} {
43
            set p $defval
44
        }
45
        if {$postproc != ""} {
46
            eval $postproc p
47
        }
48
        return $p
49
    }
50
 
51
    #-------------------------------------------------------------------------
52
    # Deletes an existing empty parameter.
53
    #
54
    # @param  param          Parameter name.
55
    #-------------------------------------------------------------------------
56
    proc clear_empty_parameter {param} {
57
        upvar $param p
58
        if {[info exists p] && [expr { [string length $p] == 0 }]} {
59
            unset p
60
        }
61
    }
62
 
63
    #-------------------------------------------------------------------------
64
    # Checks a Boolean flag.
65
    #
66
    # @param  param          Parameter name.
67
    # @param  defval         Default value of the parameter if unspecified.
68
    # @return 1 if the flag is specified and is true, or 0 othewise.
69
    #-------------------------------------------------------------------------
70
    proc check_flag {param {defval ""}} {
71
        upvar $param p
72
        return [expr { [info exists p] && $p }]
73
    }
74
 
75
    #-------------------------------------------------------------------------
76
    # Tests if the current verbosity level is equal to or
77
    # greater than the target verbosity level.
78
    #
79
    # @param  level          Target verbosity level.
80
    # @return True if the current verbosity level is equal to or
81
    #         greater than the target verbosity level.
82
    #-------------------------------------------------------------------------
83
    proc meet_verbosity {level} {
84
        set curr_level [subst $[namespace current]::$level]
85
        return [expr { $param::_VERBOSITY >= $curr_level }]
86
    }
87
 
88
    #-------------------------------------------------------------------------
89
    # Post processor to turn the given parameter to lower case.
90
    #
91
    # @param  param          Parameter name.
92
    # @return the processed parameter value.
93
    #-------------------------------------------------------------------------
94
    proc lowercase_pp {param} {
95
        upvar $param p
96
        set p [string tolower $p]
97
        return $p
98
    }
99
 
100
    #-------------------------------------------------------------------------
101
    # Post processor for the SynthesisTool parameter.
102
    #
103
    # @param  param          Parameter name.
104
    # @return the processed parameter value.
105
    #-------------------------------------------------------------------------
106
    proc synthesis_tool_pp {param} {
107
        upvar $param p
108
        switch [string tolower $p] {
109
            "xst" {
110
                set p "XST"
111
            }
112
            "synplify" {
113
                set p "Synplify"
114
            }
115
            "synplify pro" {
116
                set p "Synplify Pro"
117
            }
118
            default {
119
                error "Invalid value for parameter \"SynthesisTool\": $p"
120
            }
121
        }
122
    }
123
 
124
    #-------------------------------------------------------------------------
125
    # Post processor for the HDLLanguage parameter.
126
    #
127
    # @param  param          Parameter name.
128
    # @return the processed parameter value.
129
    #-------------------------------------------------------------------------
130
    proc hdl_language_pp {param} {
131
        upvar $param p
132
        switch [string tolower $p] {
133
            "vhdl" {
134
                set p "VHDL"
135
            }
136
            "verilog" {
137
                set p "Verilog"
138
            }
139
            default {
140
                error "Invalid value for parameter \"HDLLanguage\": $p"
141
            }
142
        }
143
    }
144
 
145
    #-------------------------------------------------------------------------
146
    # Dumps all variables of a given namespace. The current namespace is used
147
    # if no namespace is specified.
148
    #
149
    # @param  ns             Target namespace.
150
    #-------------------------------------------------------------------------
151
    proc dump_variables {{ns ""}} {
152
        if {$ns eq ""} {
153
            set ns [namespace current]
154
        }
155
        foreach param [lsort [info vars $ns\::*]] {
156
            upvar $param p
157
            # TODO : print array, remove upvar
158
            puts [namespace tail $param]\ =\ $p
159
        }
160
    }
161
 
162
    #-------------------------------------------------------------------------
163
    # Obtains a new unique command name for the given command.
164
    #
165
    # @param  cmd            Fully qualified command name.
166
    # @return fully qualified name of the new command.
167
    #-------------------------------------------------------------------------
168
    proc unique_command_name {cmd} {
169
        upvar _unique_command_id_ id
170
        if {![info exists id]} {
171
            set id 0
172
        }
173
 
174
        set ns [namespace qualifiers $cmd]
175
        set old_name [namespace tail $cmd]
176
        set new_name "$old_name\_$id\_"
177
        set eval_ns [expr { $ns eq "" ? "::" : $ns }]
178
        while { [lsearch [namespace eval $eval_ns {info proc}] $new_name] >= 0 } {
179
            incr id
180
            set new_name "$old_name\_$id\_"
181
        }
182
 
183
        return "$ns\::$new_name"
184
    }
185
 
186
    #-------------------------------------------------------------------------
187
    # Decorates a command with the given decorator. Unless a new command name
188
    # is specified, the original command is renamed and then replaced by
189
    # the decorated command.
190
    #
191
    # @param  decorator      Fully qualified name of the decorator command.
192
    # @param  cmd            Fully qualified name of the command to be
193
    #                        decorated.
194
    # @param  new_cmd        Fully qualified name of the new command.
195
    #-------------------------------------------------------------------------
196
    proc decorate_command {decorator cmd {new_cmd ""}} {
197
        if {[expr {$new_cmd eq ""}] || [expr {$new_cmd eq $cmd}]} {
198
            set new_cmd [unique_command_name $cmd]
199
            set s "rename $cmd $new_cmd; \
200
                   proc $cmd {args} { \
201
                       return \[uplevel {$decorator} \[linsert \$args 0 {$cmd} {$new_cmd}\] \] \
202
                   };"
203
        } else {
204
            set s "proc $new_cmd {args} { \
205
                       return \[uplevel {$decorator} \[linsert \$args 0 {$new_cmd} {$cmd}\] \] \
206
                   };"
207
        }
208
        eval $s
209
    }
210
 
211
    #-------------------------------------------------------------------------
212
    # Decorator that logs a given command without execution.
213
    #
214
    # @param  invoked_cmd    Invoked command.
215
    # @param  actual_cmd     Actual command.
216
    # @param  args           Additional argument list.
217
    #-------------------------------------------------------------------------
218
    proc log_command {invoked_cmd actual_cmd args} {
219
        if [meet_verbosity VERBOSITY_INFORMATION] {
220
            set cmd "[namespace qualifiers $actual_cmd][namespace tail $actual_cmd]"
221
            puts "$cmd $args"
222
        }
223
    }
224
 
225
    #-------------------------------------------------------------------------
226
    # Decorator that executes a given command.
227
    #
228
    # @param  invoked_cmd    Invoked command.
229
    # @param  actual_cmd     Actual command.
230
    # @param  args           Additional argument list.
231
    # @return the command result.
232
    #-------------------------------------------------------------------------
233
    proc run_command {invoked_cmd actual_cmd args} {
234
        set cmd "[namespace qualifiers $actual_cmd][namespace tail $actual_cmd]"
235
        if [meet_verbosity VERBOSITY_INFORMATION] {
236
            puts "$cmd $args"
237
        }
238
        if [catch { uplevel $actual_cmd $args } result] {
239
            error "Failed to execute command \"$cmd $args\".\n$result"
240
        }
241
        return $result
242
    }
243
 
244
    #-------------------------------------------------------------------------
245
    # Decorates ISE commands with appropriate decorators.
246
    #-------------------------------------------------------------------------
247
    proc decorate_ise_commands {} {
248
        upvar _ise_commands_already_decorated_ decorated
249
        if [check_flag decorated] {
250
            return
251
        } else {
252
            set decorated True
253
        }
254
 
255
        set ise_cmd_list {
256
            ::collection
257
            ::lib_vhdl
258
            ::object
259
            ::partition
260
            ::process
261
            ::project
262
            ::xfile
263
        }
264
        if [check_flag param::_DRY_RUN] {
265
            set decorator [namespace current]::log_command
266
        } else {
267
            set decorator [namespace current]::run_command
268
        }
269
        foreach cmd $ise_cmd_list {
270
            set new_cmd "[namespace current]::ise::[namespace tail $cmd]"
271
            decorate_command $decorator $cmd $new_cmd
272
        }
273
    }
274
 
275
    #-------------------------------------------------------------------------
276
    # Handles an exception when evaluating the given script and displays an
277
    # appropriate error message.
278
    #
279
    # @param  script         Script to evaluate.
280
    # @param  msg            Message to display upon an exception.
281
    # @param  append_msg     Specifies whether any returned error message is
282
    #                        also displayed.
283
    # @return 1 if the script is evaluated successfully, or 0 othewise.
284
    #-------------------------------------------------------------------------
285
    proc handle_exception {script {msg ""} {append_msg True}} {
286
        if [catch { uplevel $script } result] {
287
            if {$msg eq ""} {
288
                set msg "An internal error occurred."
289
            }
290
            puts stderr "$msg"
291
            if {$append_msg} {
292
                puts stderr "\n$result"
293
            }
294
            return 0
295
        }
296
        return 1
297
    }
298
 
299
    #-------------------------------------------------------------------------
300
    # Processes all project parameters.
301
    #
302
    # REQUIRED PARAMETERS
303
    # ======================================================================
304
    #   Project
305
    #     ISE project name.
306
    #
307
    #   Family
308
    #     Device family into which the design is implemented.
309
    #
310
    #   Device
311
    #     Device into which the design is implemented.
312
    #
313
    #   Package
314
    #     Package for the device being targeted.
315
    #
316
    #   Speed
317
    #     Speed grade of the device being targeted.
318
    #
319
    #   ProjectFiles
320
    #     Source files to be added in the project.
321
    #
322
    #
323
    # OPTIONAL PARAMETERS
324
    # ======================================================================
325
    # (*) Notes:
326
    #     "::=" denotes the list of supported values for each parameter.
327
    #
328
    # ----------------------------------------------------------------------
329
    #
330
    #   CompilationFlow
331
    #     Compilation flow.
332
    #
333
    #   TopLevelModule
334
    #     Top-level module of the design.
335
    #
336
    #   HDLLanguage
337
    #     Preferred language property controls the default setting for
338
    #     process properties that generate HDL output.
339
    #       ::= "VHDL" | "Verilog"
340
    #
341
    #   SynthesisTool
342
    #     Synthesis tool used for the design.
343
    #       ::= "XST" | "Synplify" | "Synplify Pro"
344
    #
345
    #   SynthesisConstraintsFile
346
    #     Synthesis constraints file. XCF for XST,
347
    #     SDC for Synplify/Synplify Pro.
348
    #
349
    #   SynthesisRegisterBalancing
350
    #     Register balancing option of the Synthesis process.
351
    #
352
    #   SynthesisRegisterDuplication
353
    #     Register duplication option of the Synthesis process.
354
    #
355
    #   SynthesisRetiming
356
    #     Retiming option of the Synthesis process. Synplify Pro Only.
357
    #       ::= True | False
358
    #
359
    #   WriteTimingConstraints
360
    #     Specifies whether or not to place timing constraints in the NGC
361
    #     file.
362
    #       ::= True | False
363
    #
364
    #   WriteVendorConstraints
365
    #     Specifies whether or not to generate vendor constraints file.
366
    #       ::= True | False
367
    #
368
    #   ReadCores
369
    #     Specifies whether or not black box cores are read for timing
370
    #     and area estimation in order to get better optimization of
371
    #     the rest of the design.
372
    #       ::= True | False
373
    #
374
    #   InsertIOBuffers
375
    #     Specifies whether or not to infer input/output buffers on all
376
    #     top-level I/O ports of the design.
377
    #       ::= True | False
378
    #
379
    #   BusDelimiter
380
    #     Specifies the delimiter type used to define the signal vectors in
381
    #     the resulting netlist.
382
    #       ::= "<>" | "[]" | "{}" | "()"
383
    #
384
    #   HierarchySeparator
385
    #     Hierarchy separator character which will be used in name
386
    #     generation when the design hierarchy is flattened.
387
    #       ::= "/" | "_"
388
    #
389
    #   KeepHierarchy
390
    #     Specifies whether or not the corresponding design unit should be
391
    #     preserved and not merged with the rest of the design.
392
    #       ::= "Yes" | "No" | "Soft"
393
    #
394
    #   Frequency
395
    #     Global clock frequency for timing-driven synthesis.
396
    #
397
    #   FanoutLimit
398
    #     Maximum limit of the fanout of nets.
399
    #
400
    #   MapRegisterDuplication
401
    #     Register duplication option of the Map process.
402
    #
403
    #   MapEffortLevel
404
    #     Effort level of the Map process.
405
    #
406
    #   PAREffortLevel
407
    #     Effort level of the Place & Route process.
408
    #
409
    #   BlockMemoryMapFile
410
    #     Block memory map (.bmm) file for the Data2MEM process.
411
    #
412
    #   BlockMemoryContentFile
413
    #     Block memory content file for the Data2MEM process.
414
    #
415
    #   Simulator
416
    #     Tool used for simulation.
417
    #
418
    #   DesignInstance
419
    #     Design instance name.
420
    #
421
    #   TestBenchModule
422
    #     Test-bench module.
423
    #
424
    #   SimulationTime
425
    #     Simulation time.
426
    #
427
    #   BehavioralSimulationCustomDoFile
428
    #     Custom Do file for the Behavioral Simulation process.
429
    #
430
    #   PostTranslateSimulationCustomDoFile
431
    #     Custom Do file for the Post-Translate Simulation process.
432
    #
433
    #   PostMapSimulationCustomDoFile
434
    #     Custom Do file for the Post-Map Simulation process.
435
    #
436
    #   PostPARSimulationCustomDoFile
437
    #     Custom Do file for the Post-Place & Route Simulation process.
438
    #
439
    #   ISimCustomProjectFile
440
    #     Custom project file for ISE Simulator.
441
    #
442
    #   HasVerilogSource
443
    #     Indicate the project contains a Verilog source file.
444
    #
445
    #   ImplementationStopView
446
    #
447
    #   ProjectGenerator
448
    #
449
    #-------------------------------------------------------------------------
450
    proc process_parameters {} {
451
        optional_parameter param::_DRY_RUN False
452
        optional_parameter param::_VERBOSITY $[namespace current]::VERBOSITY_ERROR
453
 
454
        required_parameter param::Project
455
        required_parameter param::Family lowercase_pp
456
        required_parameter param::Device lowercase_pp
457
        required_parameter param::Package lowercase_pp
458
        required_parameter param::Speed
459
        required_parameter param::ProjectFiles
460
 
461
        optional_parameter param::CompilationFlow {general}
462
        optional_parameter param::HDLLanguage {VHDL} hdl_language_pp
463
        optional_parameter param::SynthesisTool {XST} synthesis_tool_pp
464
        optional_parameter param::SynthesisRegisterBalancing {No}
465
        optional_parameter param::SynthesisRegisterDuplication True
466
        optional_parameter param::SynthesisRetiming True
467
        optional_parameter param::WriteTimingConstraints False
468
        optional_parameter param::WriteVendorConstraints False
469
        optional_parameter param::ReadCores True
470
        optional_parameter param::InsertIOBuffers True
471
        set is_vhdl [expr { $param::HDLLanguage eq "VHDL" }]
472
        optional_parameter param::BusDelimiter [expr { $is_vhdl ? {()} : {[]} }]
473
        optional_parameter param::HierarchySeparator {/}
474
        optional_parameter param::KeepHierarchy {No}
475
        optional_parameter param::HasVerilogSource False
476
        optional_parameter param::MapRegisterDuplication True
477
        optional_parameter param::MapEffortLevel {High}
478
        optional_parameter param::PAREffortLevel {High}
479
        optional_parameter param::DesignInstance {sysgen_dut}
480
 
481
        clear_empty_parameter param::TopLevelModule
482
        clear_empty_parameter param::SynthesisConstraintsFile
483
        clear_empty_parameter param::Frequency
484
        clear_empty_parameter param::FanoutLimit
485
        clear_empty_parameter param::BlockMemoryMapFile
486
        clear_empty_parameter param::BlockMemoryContentFile
487
        clear_empty_parameter param::Simulator
488
        clear_empty_parameter param::TestBenchModule
489
        clear_empty_parameter param::BehavioralSimulationCustomDoFile
490
        clear_empty_parameter param::PostTranslateSimulationCustomDoFile
491
        clear_empty_parameter param::PostMapSimulationCustomDoFile
492
        clear_empty_parameter param::PostPARSimulationCustomDoFile
493
        clear_empty_parameter param::ISimCustomProjectFile
494
        clear_empty_parameter param::ProjectGenerator
495
        clear_empty_parameter param::ImplementationStopView
496
    }
497
 
498
    #-------------------------------------------------------------------------
499
    # Dumps all parameters.
500
    #-------------------------------------------------------------------------
501
    proc dump_parameters {} {
502
        if [meet_verbosity VERBOSITY_DEBUG] {
503
            dump_variables param
504
        }
505
    }
506
 
507
    #-------------------------------------------------------------------------
508
    # Adds source files to the project.
509
    #-------------------------------------------------------------------------
510
    proc add_project_files {} {
511
        foreach p $param::ProjectFiles {
512
            set filename [file normalize [lindex $p 0]]
513
            set opts [lrange $p 1 end]
514
            set nopts [llength $opts]
515
            if {$nopts % 2 != 0} {
516
                error "Parameter \"ProjectFiles\" contains an invalid value \"$p\"."
517
            }
518
            # Remember it if the project contains a Verilog source file.
519
            if [string match -nocase "*.v" $filename] {
520
                set param::HasVerilogSource True
521
            }
522
            set args [list ise::xfile add $filename]
523
            for {set i 0} {$i < $nopts} {set i [expr {$i + 2}]} {
524
                set key [lindex $opts $i]
525
                set val [lindex $opts [expr {$i + 1}]]
526
                switch -- $key {
527
                    "-lib" {
528
                        if {![info exists lib_list($val)]} {
529
                            set lib_list($val) True
530
                            ise::lib_vhdl new $val
531
                        }
532
                        lappend args "-lib_vhdl" $val
533
                    }
534
                    "-view" {
535
                        lappend args "-view" $val
536
                    }
537
                    default {
538
                        error "Parameter \"ProjectFiles\" contains an invalid value \"$p\". Unknown option \"$key\"."
539
                    }
540
                }
541
            }
542
            eval $args
543
        }
544
        if [info exists param::TopLevelModule] {
545
            ise::project set top "/$param::TopLevelModule"
546
        }
547
    }
548
 
549
    #-------------------------------------------------------------------------
550
    # Sets the general project settings.
551
    #-------------------------------------------------------------------------
552
    proc set_project_settings {} {
553
        ise::project set family $param::Family
554
        ise::project set device $param::Device
555
        ise::project set package $param::Package
556
        ise::project set speed $param::Speed
557
    }
558
 
559
    #-------------------------------------------------------------------------
560
    # Sets the synthesis settings for XST.
561
    #-------------------------------------------------------------------------
562
    proc set_xst_synthesis_settings {} {
563
        # XST specific properties
564
        ise::project set {Synthesis Tool} {XST (VHDL/Verilog)}
565
        ise::project set {Optimization Goal} {Speed}
566
        ise::project set {Optimization Effort} {Normal}
567
        ise::project set {Keep Hierarchy} $param::KeepHierarchy
568
        ise::project set {Bus Delimiter} $param::BusDelimiter
569
        ise::project set {Hierarchy Separator} $param::HierarchySeparator
570
        set read_cores [project get {Read Cores}]
571
        # TODO: Remove this check when ISE settles with the read core property value
572
        if {[string equal -nocase $read_cores "true"] || [string equal -nocase $read_cores "false"]} {
573
            ise::project set {Read Cores} $param::ReadCores
574
        } else {
575
            ise::project set {Read Cores} [ expr { $param::ReadCores ? "Yes" : "No" } ]
576
        }
577
        ise::project set {Add I/O Buffers} $param::InsertIOBuffers
578
        # ise::project set {Optimize Instantiated Primitives} True
579
        ise::project set {Register Balancing} $param::SynthesisRegisterBalancing
580
        ise::project set {Register Duplication} $param::SynthesisRegisterDuplication -process {Synthesize - XST}
581
        ise::project set {Write Timing Constraints} $param::WriteTimingConstraints
582
        if [info exists param::SynthesisConstraintsFile] {
583
            ise::project set {Use Synthesis Constraints File} True
584
            ise::project set {Synthesis Constraints File} $param::SynthesisConstraintsFile
585
        } else {
586
            ise::project set {Use Synthesis Constraints File} False
587
        }
588
        if [info exists param::FanoutLimit] {
589
            ise::project set {Max Fanout} $param::FanoutLimit
590
        }
591
    }
592
 
593
    #-------------------------------------------------------------------------
594
    # Sets the synthesis settings for Synplify/Synplify Pro.
595
    #-------------------------------------------------------------------------
596
    proc set_synplify_synthesis_settings {} {
597
        set is_vhdl [expr { $param::HDLLanguage eq "VHDL" }]
598
 
599
        switch $param::SynthesisTool {
600
            "Synplify" {
601
                if {$is_vhdl} {
602
                    ise::project set {Synthesis Tool} {Synplify (VHDL)}
603
                } else {
604
                    ise::project set {Synthesis Tool} {Synplify (Verilog)}
605
                }
606
            }
607
            "Synplify Pro" {
608
                ise::project set {Synthesis Tool} {Synplify Pro (VHDL/Verilog)}
609
                ise::project set {Retiming} $param::SynthesisRetiming -process {Synthesize - Synplify Pro}
610
            }
611
        }
612
 
613
        # Synplify/Synplify Pro specific properties
614
        ise::project set {Symbolic FSM Compiler} False
615
        ise::project set {Pipelining} False
616
        ise::project set {Resource Sharing} False
617
        ise::project set {Disable I/O insertion} [ expr { $param::InsertIOBuffers ? False : True } ]
618
        ise::project set {Auto Constrain} False
619
        if [info exists param::SynthesisConstraintsFile] {
620
            ise::project set {Constraint File Name} $param::SynthesisConstraintsFile
621
        }
622
        ise::project set {Write Vendor Constraint File} $param::WriteVendorConstraints
623
        if [info exists param::Frequency] {
624
            ise::project set {Frequency} $param::Frequency
625
        }
626
        if [info exists param::FanoutLimit] {
627
            ise::project set {Fanout Guide} $param::FanoutLimit
628
        }
629
    }
630
 
631
    #-------------------------------------------------------------------------
632
    # Sets the synthesis settings.
633
    #-------------------------------------------------------------------------
634
    proc set_synthesis_settings {} {
635
        ise::project set {Preferred Language} $param::HDLLanguage
636
 
637
        switch -- $param::SynthesisTool {
638
            "XST" {
639
                set_xst_synthesis_settings
640
            }
641
            "Synplify" - "Synplify Pro" {
642
                set_synplify_synthesis_settings
643
            }
644
        }
645
    }
646
 
647
    #-------------------------------------------------------------------------
648
    # Sets the implementation settings.
649
    #-------------------------------------------------------------------------
650
    proc set_implementation_settings {} {
651
        # Translate properties
652
        ise::project set {Netlist Translation Type} {Timestamp}
653
        ise::project set {Use LOC Constraints} True
654
        if [info exists param::BlockMemoryMapFile] {
655
            ise::project set {Other Ngdbuild Command Line Options} "-bm $param::BlockMemoryMapFile"
656
        }
657
 
658
        # Determine the type of value the "Map Register Duplication" property accepts
659
        switch -- $param::Family {
660
            "virtex" - "virtexe" - "spartan2" - "spartan2e" {
661
            }
662
            default {
663
                set map_reg_dup [project get {Register Duplication} -process {Map}]
664
                if {[string equal -nocase $map_reg_dup "true"] || [string equal -nocase $map_reg_dup "false"]} {
665
                    set map_reg_dup $param::MapRegisterDuplication
666
                } elseif {[string equal -nocase $map_reg_dup "on"] || [string equal -nocase $map_reg_dup "off"]} {
667
                    set map_reg_dup [ expr { $param::MapRegisterDuplication ? "On" : "Off" } ]
668
                } else {
669
                    set map_reg_dup [ expr { $param::MapRegisterDuplication ? "Yes" : "No" } ]
670
                }
671
            }
672
        }
673
 
674
        # Map properties
675
        switch -- $param::Family {
676
            "virtex5" - "virtex6" - "spartan6" {
677
                ise::project set {Placer Effort Level} $param::MapEffortLevel
678
                ise::project set {Register Duplication} $map_reg_dup -process {Map}
679
            }
680
            "virtex" - "virtexe" - "spartan2" - "spartan2e" {
681
                ise::project set {Perform Timing-Driven Packing} True
682
            }
683
            default {
684
                ise::project set {Map Effort Level} $param::MapEffortLevel
685
                ise::project set {Perform Timing-Driven Packing and Placement} True
686
                ise::project set {Register Duplication} $map_reg_dup -process {Map}
687
            }
688
        }
689
 
690
        # Place & Route properties
691
        ise::project set {Place & Route Effort Level (Overall)} $param::PAREffortLevel
692
    }
693
 
694
    #-------------------------------------------------------------------------
695
    # Sets the configuration settings
696
    #-------------------------------------------------------------------------
697
    proc set_configuration_settings {} {
698
        switch -- $param::CompilationFlow {
699
            "hwcosim" {
700
                ise::project set {FPGA Start-Up Clock} {JTAG Clock}
701
                ise::project set {Drive Done Pin High} True
702
                switch -- $param::Family {
703
                    "virtex2" - "virtex2p" - "virtex4" - "virtex5" {
704
                        ise::project set {Configuration Pin M0} {Pull Up}
705
                        ise::project set {Configuration Pin M1} {Pull Down}
706
                        ise::project set {Configuration Pin M2} {Pull Up}
707
                    }
708
                }
709
            }
710
        }
711
        if [info exists param::BlockMemoryContentFile] {
712
            ise::project set {Other Bitgen Command Line Options} "-bd $param::BlockMemoryContentFile"
713
        }
714
    }
715
 
716
    #-------------------------------------------------------------------------
717
    # Sets the simulation settings
718
    #-------------------------------------------------------------------------
719
    proc set_simulation_settings {} {
720
        set has_testbench [info exists param::TestBenchModule]
721
        if {!$has_testbench} { return }
722
 
723
        set has_simtime [info exists param::SimulationTime]
724
 
725
        # ISE Simulator settings
726
        ise::project set {Simulator} "ISim (VHDL/Verilog)"
727
 
728
        set sim_proc_list {
729
            {Simulate Behavioral Model}
730
            {Simulate Post-Place & Route Model}
731
        }
732
 
733
        set top_level_modules [expr { $param::HasVerilogSource ? "$param::TestBenchModule glbl": $param::TestBenchModule }]
734
        set has_isim_custom_prj_file [info exists param::ISimCustomProjectFile]
735
        foreach {process} $sim_proc_list {
736
            ise::project set {Specify Top Level Instance Names} $top_level_modules -process $process
737
            if {$has_isim_custom_prj_file} {
738
                ise::project set {Use Custom Project File} True -process $process
739
                ise::project set {Custom Project Filename} $param::ISimCustomProjectFile -process $process
740
            } else {
741
                ise::project set {Use Custom Project File} False -process $process
742
            }
743
            ise::project set {Run for Specified Time} $has_simtime -process $process
744
            if {$has_simtime} {
745
                ise::project set {Simulation Run Time} $param::SimulationTime -process $process
746
            }
747
            if {$param::HasVerilogSource} {
748
                ise::project set {Other Compiler Options} {-L unisims_ver -L simprims_ver -L xilinxcorelib_ver -L secureip} -process $process
749
            }
750
        }
751
 
752
        ise::project set {ISim UUT Instance Name} $param::DesignInstance
753
 
754
        if [info exists param::Simulator] {
755
            switch [string tolower $param::Simulator] {
756
                "isim" - "ise simulator" {
757
                    return
758
                }
759
                default {
760
                    ise::project set {Simulator} "$param::Simulator $param::HDLLanguage"
761
                }
762
            }
763
        }
764
 
765
        # Modelsim settings
766
        set sim_proc_param_map {
767
            {Simulate Behavioral Model} param::BehavioralSimulationCustomDoFile
768
            {Simulate Post-Translate Model} param::PostTranslateSimulationCustomDoFile
769
            {Simulate Post-Map Model} param::PostMapSimulationCustomDoFile
770
            {Simulate Post-Place & Route Model} param::PostPARSimulationCustomDoFile
771
        }
772
 
773
        foreach {process param} $sim_proc_param_map {
774
                if [info exists $param] {
775
                    ise::project set {Use Custom Do File} True -process $process
776
                    ise::project set {Custom Do File} [subst $$param] -process $process
777
                    ise::project set {Use Automatic Do File} False -process $process
778
                }
779
        }
780
 
781
        if {$has_simtime} {
782
            foreach {process param} $sim_proc_param_map {
783
                ise::project set {Simulation Run Time} $param::SimulationTime -process $process
784
            }
785
        }
786
    }
787
 
788
    #-------------------------------------------------------------------------
789
    # Sets the specific settings related to DSP Tools
790
    #-------------------------------------------------------------------------
791
    proc set_dsptools_specific_settings {} {
792
        if [info exists param::ImplementationStopView] {
793
            ise::project set {Implementation Stop View} $param::ImplementationStopView
794
        }
795
        if [info exists param::ProjectGenerator] {
796
            ise::project set {Project Generator} $param::ProjectGenerator
797
        }
798
    }
799
 
800
    #-------------------------------------------------------------------------
801
    # Starts the project creation.
802
    #-------------------------------------------------------------------------
803
    proc start_project_creation {} {
804
        file delete "$param::Project\.ise"
805
        file delete "$param::Project\.xise"
806
        file delete "$param::Project\.gise"
807
        file delete "$param::Project\.sgp"
808
        ise::project new $param::Project
809
    }
810
 
811
    #-------------------------------------------------------------------------
812
    # Finishes the project creation.
813
    #-------------------------------------------------------------------------
814
    proc finish_project_creation {} {
815
        ise::project close
816
    }
817
 
818
    #-------------------------------------------------------------------------
819
    # Creates a new ISE project.
820
    #-------------------------------------------------------------------------
821
    proc create_ise_project {} {
822
        start_project_creation
823
        set_project_settings
824
        add_project_files
825
        set_dsptools_specific_settings
826
        set_synthesis_settings
827
        set_implementation_settings
828
        set_configuration_settings
829
        set_simulation_settings
830
        finish_project_creation
831
    }
832
 
833
    #-------------------------------------------------------------------------
834
    # Compiles an ISE project into a bitstream.
835
    #-------------------------------------------------------------------------
836
    proc compile_ise_project {} {
837
        ise::project open $param::Project
838
        ise::process run {Synthesize}
839
        ise::process run {Translate}
840
        ise::process run {Map}
841
        ise::process run {Place & Route}
842
        ise::process run {Generate Post-Place & Route Static Timing}
843
        ise::process run {Generate Programming File}
844
        ise::project close
845
    }
846
 
847
    #-------------------------------------------------------------------------
848
    # Entry point for creating a new ISE project.
849
    #-------------------------------------------------------------------------
850
    proc create {} {
851
        set status [handle_exception {
852
            decorate_ise_commands
853
        } "ERROR: An error occurred when loading ISE Tcl commands." False]
854
        if {!$status} { return }
855
 
856
        set status [handle_exception {
857
            process_parameters
858
            dump_parameters
859
        } "ERROR: An error occurred when processing project parameters."]
860
        if {!$status} { return }
861
 
862
        set status [handle_exception {
863
            create_ise_project
864
        } "ERROR: An error occurred when creating the ISE project."]
865
        if {!$status} { return }
866
    }
867
 
868
}
869
# END namespace ::xilinx::dsptool::iseproject

powered by: WebSVN 2.1.0

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