Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Cadence / DSD 4 / ver_l3.doc
Скачиваний:
23
Добавлен:
16.04.2013
Размер:
89.6 Кб
Скачать

Writing Commands

$fdisplay will write formatted text to a specified file. Specific text, system functions/tasks and signal values can be output using this function.

$fdisplay(<file_desc>, "<string>", variables);

$fwrite acts very similar to $fdisplay in that it can write a specified string to a file however it does not specify a carriage return after performing this operation.

$fwrite(<file_desc>, "<string>", variables);

$fstrobe is also similar to $fdisplay only waits for all simulation events in the queue to be executed before writing the message.

$fstrobe(<file_desc>, "<string>", variables);

$fmonitor will write a string to the specified file whenever a change in value is detected for one of ths variables being written. After the string is written, a carriage return is issued.

$fmonitor(<file_desc>, "<string>", variables);

When using these write commands ($fdisplay, $fwrite, $fstrobe, $fmonitor), variables can be specifed to the output in a variety of formats. Also, special escape characters can be used to specify special characters or formatting. These formats are listed below.

Variables

%b .... Binary Value

%h .... Hexadecimal Value

%d .... Decimal Value

%t .... Time

%s .... String

%c .... ASCII

%f .... Real Value

%e .... Exponential Value

%o .... Octal Value

%m .... Module Hierchical Name

%v .... Strength

Escape Characters

\t ........ Tab

\n ........ Newline

\\ ........ Backslash

%% ........ Percent

\" ........ Quote

\<octal> .. ASCII representation

Reading Commands

$fgets will read an entire line of text from a file and store it as a string.

$fgets(<string_reg>, <file_desc>);

$fgets returns an integer value either indicating the number of characters read or a zero indication an error during the read attempt. The <string_reg> should be defined a width equal to the number of characters on the longest line multiplied by 8.

integer <integer>;

reg [8*<#_of_chars>:0] <string_reg>;

<integer> = $fgets(<string_reg>, <file_desc>);

$fgetc will read a character from a file and return it as an 8-bit string. If EOF is encountered, a value of -1 is written.

reg [7:0] <8-bit_reg>;

<8-bit_reg> = $fgetc(<file_desc>);

$fscanf will read a line from a file and store it in a specified form.

integer <integer>;

<integer> = $fscanf(<file_desc>, <format>, <destination_regs>);

where the format is specified similar to how it is specified in the read command above and the <destination_regs> is where the read data is stored. $fscanf will return an integer value indicating the number of matched formatted data read. If an error occurs during the read, this number will be zero.

Special Functions

$ferror tests and reports last error encountered during a file open, read or write. The written string can be up to 80 characters (640 bits) wide.

<640-bit_reg> = $ferror(<file_desc>);

$fseek will reposition the pointer within the file to the specified position.

<integer> = $fseek(<file_desc>, <offset_value>, <operation_number>);

where the operation number is one of three values:

0 - set position using the beginning of file as the refernce point

1 - set position using the current location of the pointer as refernce

2 - set position using the EOF as refernce

$fseek will return a zero if the command was successful and a -1 if not.

$ftell specifies the position of the pointer within the file by outputing an interger value indicating the number of offset bytes from the beginning of the file.

<reg> = $ftell(<file_desc>);

$fflush writes any buffered output to the specified file.

$fflush(<file_desc>);

Соседние файлы в папке DSD 4