Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
dsd1-10 / dsd-07=Verilog / esug.pdf
Скачиваний:
94
Добавлен:
05.06.2015
Размер:
1.38 Mб
Скачать

Ambit BuildGates Synthesis User Guide

Using Tcl within ac_shell and pks_shell

Tcl also supports a convenient demand-load mechanism for personal procedures to avoid the

first source command above. See autoload in a standard Tcl reference book for more details.

Tcl procedures support arguments, such as:

proc my_set_constraints {clock_name period} { puts “Creating $clock_name with period $period”

# …commands…

}

and arguments with defaults, such as:

proc my_set_constraints {clock_name {period 10}} { puts “Creating $clock_name with period $period”

# …commands…

}

This applet approach is recommended and should be extended to the entire synthesis flow. The top-level script should look similar to the code in the following example. Use of a unique prefix is recommended to avoid Tcl command name collisions.

Example: Top-Level Script Using the Applet Approach

#Synthesis for block ‘alu’ set design alu

set clock clk2 set period 8

my_set_project_globals my_read_library my_read_design_files $alu

my_set_default_time_budget $clock $period

#…commands…

Tcl Variables and Control Structures

Variables

Like most shells, Tcl allows for defining, modifying, and referencing variables, and using these variables in control structures.

September 2000

213

Product Version 4.0

Ambit BuildGates Synthesis User Guide

Using Tcl within ac_shell and pks_shell

There are no reserved shell variables in ac_shell. Tcl variables have no restrictions. The set_global and get_global commands in ac_shell handle all of the global settings that affect synthesis operations. These commands are described in the Envisia and Ambit

Synthesis Command Reference.

Character Strings

A variable has no type (everything is a character string), and does not need to be declared.

The first occurrence is equivalent to the declaration.

ac_shell> set myvar 100 ac_shell> puts $myvar

100

ac_shell>

A variable has a global scope if the first occurrence of the variable is in the global context (not inside a procedure). If the first occurrence of a variable is inside a procedure then it has scope of that procedure and will not conflict with another variable having the same name in a different scope. The commands global, upvar, and uplevel allow the use of variables across scopes.

Using the $ Prefix

Use the $ prefix to get the value of a variable. In Tcl, placing the $ in front of a variable causes the value of a variable to be substituted for that variable. This is shown in the following example:

set x 1

if { $x == 1 } {

#

}else {

#

}

Some commands use the variable value, as in the If statement above. Other commands require the name of a variable as an argument (usually so they can modify it) as follows:

ac_shell> puts $x

1

ac_shell> incr x

2

September 2000

214

Product Version 4.0

Ambit BuildGates Synthesis User Guide

Using Tcl within ac_shell and pks_shell

Syntax

Tcl terminates all commands (built-in or user-defined) when it reaches a newline character or a semicolon in a line. The trailing left-brace in the if-else statement above is a mandated Tcl style. Using the open brace before the new line character indicates that the text should be read as one argument to the if command.

Variables may also be used to hold lists of items, which can be defined recursively

ac_shell> set y {a b {c d}} a b {c d}

ac_shell> foreach val $y {puts “$val”} a

b

c d

Use double quotes to group items together with (one pass of) substitution, and curly braces group items together without any substitution.

ac_shell> set val 4 ac_shell> puts “$val”

4

ac_shell> puts $val

4

ac_shell> puts {$val}

$val

Note: In Tcl, the square brackets ([ ]) contain commands which are evaluated and return values. In ac_shell, square brackets indicate bus indices.

Tcl supports the standard C language arithmetic operators, and also performs comparisons on numbers and strings, according to the C language definition. For example, use == to perform a string comparison and use expr (Tcl command) to evaluate an expression:

ac_shell> set_port_capacitance [expr {1 + 0.4}] {out[2]}

Note: Because Tcl treats square brackets ([ ]) differently, using square brackets when referring to a single bit of a bussed net requires enclosing the expression in braces ({ }). If braces are not used, the literal value of the calculated expression is given. This is similar to the backquote in C-shell (see examples below).

The following results in an error:

ac_shell> set_port_capacitance [expr {1 + 0.4}] out[2]

September 2000

215

Product Version 4.0

Соседние файлы в папке dsd-07=Verilog