BTF - BE45 - Behavioral function definition

From: Adam Krolnik (adamk@cyrix.com)
Date: Mon Apr 06 1998 - 20:47:36 PDT


Behavioral Task Force - Errata Submission

Assigned Enhancement Request Number: BE45
Errata Name (Description): Behavioral function definition
Section: 11
Date Submitted: 961217
Requestor: Steve Meyer

Status: Submitted (priority not yet assigned)

Errors found in the Verilog LRM (IEEE 1364-1995).

Details:

I just ran into the following function that I think may be illegal
according to the IEEE P1364 standard but probably needs to be explicitly
allowed because break and continue require named blocks. The function below
does not work in Cver because it treats named blocks as task enables
since they can be disabled, and for nested named blocks the downward
chain disabling rule (section 11-1 Oct. 1995 draft) must be applied.

The problem is probably one of documentation clarity. I read section
11 page 1 (but not the remaining examples) as allowing disable of any
named block, therefore named blocks are illegal inside function definitions,
but my interpretation must be wrong since the function is part of the DA
solutions benchmarks and works on other simulators.

Also, I am not sure what the meaning of parallel blocks (fork-join)
is inside functions.

The LRM grammar, in my view correctly, does not define timing behavior
semantics inside functions (see A.2 and A.6). It allows any statement.

I assume it is illegal from outside a function to disable a named block
inside a function because that implies timing control that is explicitly
dis-allowed inside functions. Such disable is, I think, unlikely except for
debuggers that allow statement by statement tracing inside functions.
However, I read section 5.4.2 sentence 2 as allowing functions to be
interrupted in the middle (say) to execute other events because there is
no non timing control statement group atomicity condition.

I hope behavior within functions and for named blocks will be defined more
exactly in the new version of the LRM.

/Steve

---

// function from DA Solutions public domain bench marks das_cpu example function [0:31] sign_extend;

input [0:15] D2; reg [0:31] result;

begin begin begin : sextend integer i; begin for (i = 0; i < 16; i = i+1) begin result[i] = D2[0]; result[i+16] = D2[i]; end end end sign_extend = result; end endfunction endmodule

// here is a test top level module module top; reg [0:15] D, X; initial begin D = 6; X = sign_extend(D); $display("sign extend of %b is %b", D, X); end -- Steve Meyer Phone: (415) 296-7017 Pragmatic C Software Corp. Fax: (415) 781-1116 220 Montgomery St., Suite 925 email: sjmeyer@crl.com San Francisco, CA 94104

<p>Hi, Steve.

I'll add my two cents worth.

Let me preface my remarks by saying that I have only the April 1995 draft since I apparently have not been judged eligible to get 1364 mailings on a regular basis.

I don't agree with your interpretations.

I don't think that named blocks should be considered task enables. My P1364 draft seems to distinguish between named blocks and tasks. 1364 does not imply, in my opinion, that because named blocks can be disabled, then they are like task enables. You don't explain why you think that one necessarily follows from the other.

In certain respects, they are similar, but different in others.

I don't see a reason that named blocks should be illegal in functions.

I have in the past argued that functions MUST be executed atomically in order to guarantee coherent execution.

Regards, ****************************************************************************** Shalom Bresticker email: shalom@msil.sps.mot.com Motorola Semiconductor Israel, Ltd. Tel #: +972 9 9522268 P.O.B. 2208, Herzlia 46120, ISRAEL Fax #: +972 9 9522444 ******************************************************************************

---------------------------------------------------------------------------

The following code is acceptable by both XL and VCS; the disable statement terminates execution of the block and the function returns the current value assigned to it.

module test;

function f; input a,b,c; begin :block f = a|b & c; disable block; f = 'b0; end endfunction

initial begin $display("Result is %0b.", f('b1, 'b0, 'b1)); end endmodule

<p>Proposal: Change the last paragraph of section 11 "Disabling of named blocks and tasks" from

"The disable statement can be used within blocks and tasks to disable the particluar block or task containing the disable statement. The disable statement cannot be used to disable functions."

to:

"The disable statement can be used within blocks and tasks to disable the particluar block or task containing the disable statement. The disable statement can be used to disable named blocks within function, but cannot be used to disable functions."

<p> Adam Krolnik Verification Engineer Cyrix - NSM. Richardson TX. 75085



This archive was generated by hypermail 2.1.4 : Mon Jul 08 2002 - 12:52:47 PDT and
sponsored by Boyd Technology, Inc.