SV-CC DirectC Issues
| Issue # | 1.1 |
| Issue Summary | DirectC i/f should support mechanism for calling Verilog task/function from a DirectC application |
| Opening Date | Oct 19 2002 |
| Opened By | Swapnajit Mittra |
| Current Owner | None |
| Current Status | Accepted. |
| Added Comment | I believe this has been discussed many times over email
and in the meetings. I am formally filing this as an ISSUE to keep a record
of this. (The other emails related to this proposal are attached below).
As many of you had pointed out earlier, the idea of calling a Verilog task or function from a C function is not new, and has been there in CBlend/Superlog for some time. I am proposing the following at the risk of being redundant if a CBlend donation takes place in the future. In any case, here are my proposals. o A DirectC application shall be allowed to call a Verilog task or function from a C function similar to a call to another C function. o If an external C function calls a Verilog task, no simulation time must elapse during the execution of that task. (This is, because a C function in DirectC is a zero-time event). However, no such restriction shall be in place when a Verilog task is called from a cmodule. o The type of the arguments and the return type (for a Verilog function) shall be one of the types allowed by DirectC for a Verilog task or function calling a C function. o The called Verilog task or function can be specified from the DirectC domain by Verilog full pathname. (This will allow us to call a specific Verilog task or function in the design hierarchy. We need to think about the actual syntax of this). ================================================================== Previous emails on this subject: On Sep 24 2002, Swapnajit Mittra wrote:
On Sep 26 2002, Stuart Sutherland wrote:
On Sep 26 2002, Alain Raynaud wrote:
On Sep 24 2002, Joao Geada wrote:
On Oct 07 2002, Doug Warmke wrote:
|
| Resolution | Joao and John's proposal is here. |
| Issue # | 1.2 |
| Issue Summary | A DirectC external C function should override a built-in C function by the same name. |
| Opening Date | Oct 19 2002 |
| Opened By | Swapnajit Mittra |
| Current Owner | None |
| Current Status | Rejected. |
| Added Comment | DirectC should have an explicit provision that allows user
to write an external C function that overrides a system provided function
of the same name.
This will give a user complete independence to re-write, for example, cm_*(). This will be similar to the way a user-defined function $random overrides the system function by the same name in PLI. Probably this is already true, but I could not find it mentioned in the VCS 6.2 DirectC User Guide. - Swapnajit. |
| Resolution | None. |
| Issue # | 1.3 |
| Issue Summary | Name resolution between a Verilog task and a DirectC external C function. |
| Opening Date | Oct 19 2002 |
| Opened By | Swapnajit Mittra |
| Current Owner | None |
| Current Status | Duplicate (of 1.6). |
| Added Comment | I propose: A Verilog task or function shall override an
external C function by the same name within the scope of the module where
this task or function is located.
I believe this is already the case in VCS. I propose SV-CC makes this part of the requirement for DirectC i/f as this provides control to each Verilog module to re-define a task within its boundary. - Swapnajit.
|
| Resolution | This issue is addressed and resolved by the rules 6a and 6c of issue 1.6 [according to Andrzej]. |
| Issue # | 1.4 |
| Issue Summary | No clear relationship to other APIs |
| Opening Date | Oct 29 2002 |
| Opened By | Michael Rohleder |
| Current Owner | None |
| Current Status | Accepted. |
| Added Comment | There is no clear relationship between DirectC and other
API's (PLI,VPI).
Do we want to permit calling PLI functions from a DirectC call or prohibit it? The first might be a nice feature, but result in less opportunities for code optimizations (as a result you'll never know what a function really can do). My proposal is either to prohibit this or to define some definition that clearly identifies whether a DirectC function calls other API's functions or not ... - Michael.
|
| Resolution | Covered by Andrzej's proposal for issues 1.7, 1.11. |
| Issue # | 1.5 |
| Issue Summary | Should use a common and unique prefix for all functions |
| Opening Date | Oct 29 2002 |
| Opened By | Michael Rohleder |
| Current Owner | None |
| Current Status | Accepted |
| Added Comment | The subject says everything ...
-Michael. |
| Resolution |
All agread on sv_ |
| Issue # | 1.6 |
| Issue Summary | Proposals for HDL-to-C and C-to-HDL functions. |
| Opening Date | Oct 29 2002 |
| Opened By | Andrzej Litwiniuk |
| Current Owner | None |
| Current Status | Accepted |
| Added Comment | Fellow SV-CC'ers,
I've been reading the recent discussions about HDL-to-C and C-to-HDL funcion
DirectC SV-nonSV interface may be roughly divided into the four functionality
Apart from this classification there is the separate issue of what data types
The "kernel" functionality for sure includes (1).
That will leave the other three classes of functionality still open,
but at least
Observation:
Proposition:
The specifics of the argument
passing may be eventually reflected in tiny
(1) DirectC interface includes as a minimum the capability to call non-SV
functions
Note:
(2) xf executes in 0 time. In other words, no simulation time passes
during
Note:
(3) The usage and syntax for calling xf is identical as for native SV
functions
(a) any xf can be called as a void function, i.e. its call may
occur as a statement,
(b) xf may have zero or more formal arguments. (c) xf may have input, output and inout formal arguments.
(d) The evaluation order of formal args follows general SV rules (is unspecified). (4) xf may access only SV data objects explictly passed as actual arguments
to
(5) Each xf must be declared. Such declaration will be further refered
to as
(a) An external declaration specifies function name, optional
function result
(b) Escaped names are not allowed for xf. (6) A scope of an external declaration is the whole design.
A name of xf should not classh with any name declared in $root scope. An external declaration of xf need not to precede an invocation of that xf. Regular name resolving rules apply to xf. Therefore local names declared
Note:
(7) xf may have multiple declarations as long as they are all equivalent.
Note:
(8) Syntax of an external declaration
external_declaration:
optional_function_type: 'void' | func_result_type function_name: identifier optional_arg_list: optional_direction group_of_args optional_groups_of_args optional_direction: /*empty*/ | direction direction: 'input' | 'output' | 'inout' group_of_args: formal_arg | formal_arg ',' group_of_args formal_arg: formal_arg_type optional_name optional_name: /*empty*/ | identifier optional_groups_of_args: /*empty*/
func_result_type and formal_arg_type will be discussed later. (9) Arguments passing for xf is ruled by WYSIWYG principle:
(The possible exceptions for packed and unpacked
ranges will be discussed
If the actual arg does not match exactly the formal one, a temporary
variable
(10) For the SV side of the interface, the semantics of arguments passing
is as
(a) xf must not modify the values of its input args (b) The initial values of formal output args are unspecified and
may be
(c) For output and inout args the value propagation (i.e. value
change events)
Types of formal arguments and function result
Note: Ideally, any SV data type would be allowed.
(11) As the minimum the following basic types are allowed for function
result type
These are the minimal requirements; other types will be discussed later. (12) New primitive types: pointer, string. These types are meant solely for DirectC interface and are intended
for passing
The proposition to introduce these new types does not preclude full-fledged
pointers,
Type 'pointer' represents a generic pointer, 'string' represent a pointer
to
Note that typedef allows to define different pointer types, e.g.:
The use of the types pointer and string is restricted as follows: - pointer/string may be used as types of function result and formal
arguments
- may not be used as types of module or interface ports - may not occur in packed structs or unions - may be used in assignments (if both sides are of the same type)
- 0 (unsized constant zero) may be used as a value compatible with any
pointer or
- the only applicable operations for the values of these types are comparisons
- may not be used in explicit or implicit sensitivity lists or posedge/negedge
- the initial value of a variable of type pointer/string is 0 (unsized constant). - a string literal, i.e. characters in quotes, e.g. "a text" occuring
as an actual
More on types of result and formal args of xf
Ideally, any SV and C/C++ data type would be allowed.
Contrary to popular belief (?), there are no common types between SV
and C
[VCS DirectC avoids the problem by generating headers that map V types
onto
Of course, it's possible to define inductively the set of data types
that
SV parser might support full C or C++ syntax, but this will only add the burden. A type of a formal arg or func result of xf usually will not be be useful,
if user
(13) DirectC interface should not impose any constraints on how SV data
types
We may specify that the layout of SV structs should be the same as the
layout
We shouldn't specify the layout of 2- or 4-state vectors, as this may
be
(14) I propose to restrict the types allowed for formal args and func
result
(15) All vectors/arrays will be normalized to [n:0] regardless of the
original range and increasing or decreasing order of indexing.
(16) For the convenience, the size of the packed dimension or the unpacked
This will allow to write a generic code good for different sizes. If a formal argument is specified as an open vector or an open array,
then the
Here are the examples of types of formal args:
Comment: empty [] denotes open vector or open array. Keyword 'array' separates packed and unpacked dimension (refered here
as a
(17) I propose to further restrict the types of function result to "small"
Andrzej . |
| Resolution | Andrzej's updated proposal (SV side) is here |
| Issue # | 1.7 |
| Issue Summary | Abstract Access Method requires rewrite of code |
| Opening Date | Nov 5 2002 |
| Opened By | Michael Rohleder |
| Current Owner | None |
| Current Status | Accepted. |
| Added Comment | From a user perspective it is _not_ acceptable that I have
to rewrite a DirectC function after I have debugged it. This is a
manual, error prone process I will want to avoid under any circumstance. It is also a problem, since after changing the already debugged version, I might just introduce some more problems. There must be some way to automate this work, something I would regard as a critical and important feature. On the other side it is my experience that having a more secure version
for debugging or providing additional checks is very useful.
A poor man's solution we have implemented some years ago in one of our
internal simulator is as follows [I do not propose this
Simple hypothetical example how the method we have used would look like on SystemVerilog: A) Assume the Direct C function definition extern "C" void my_function( input bit [31:0] r1, output bit [32:0] r2 ); ... module dev1;
B) When using the argument type mappings in table 1-4 of the DirectC
document, we might want to define some access functions of
C) The real mapping of one of this functions is dependent on the mode
choosen ...
In all cases the function code of my_function looks the same. It always
uses sv_get_bit() to get the first parameter; I choose by
Just loud thinking, but this is some problem we clearly need to attack.
Regards,
|
| Resolution | Andrzej's updated proposal (C-layer) is here |
| Issue # | 1.8 |
| Issue Summary | Distinguish C and C++ code |
| Opening Date | Nov 5 2002 |
| Opened By | Michael Rohleder |
| Current Owner | None |
| Current Status | Accepted. |
| Added Comment | This is actually not an issue, more a brainstorming proposal:
It would be nice to be able to distinguish C and C++ functions when defining DirectC functions. Of course this is dependent on Kevin's proposal to support C++. But when I just have some simple C function, I am not sure whether I would like to think about all the additional C++ stuff. Probably it would already help to extend the directC definition to permit access_mode ::= ( "A" | "C" | "C++" ) Just loud thinking -Michael |
| Resolution |
From the
meeting minutes of 12/03/02,
extern [ "linkname" ] svname ( ansi-args ); where linkname is the link name to be put into the object file |
| Issue # | 1.9 |
| Issue Summary | How to find C/C++ code ??? |
| Opening Date | Nov 5 2002 |
| Opened By | Michael Rohleder |
| Current Owner | None |
| Current Status | Part 1 has been accepted. Part 2 has been rejected and Part 3 has been deferred to SV 3.2. |
| Added Comment | This is actually more a question than an issue. Do we need
to define how C/C++ code is being found/linked?
-Michael |
| Resolution | Michael's proposals had three parts. Part 1 of the proposals has been accepted. Part 2 has been rejected. Part 3 has been deferred to SV 3.2. |
| Issue # | 1.10 |
| Issue Summary | cmodules vs. external "C" tasks |
| Opening Date | Nov 06 2002 |
| Opened By | Doug Warmke |
| Current Owner | Doug Warmke |
| Current Status | Cmodule proposal has been rejected. Proposal for external module has been deferred to SV 3.2. |
| Added Comment | Team,
I would like to formally create an issue surrounding
This issue was originally brought up on October 7th
I will copy a few excerpts from these mails as the
*** From Doug's posting October 7th ***
*** From Stuart's posting on 10/24/02 ***
*** Andrej's posting on 11/06/02 *** > There have been strong demands to add the capability to
*** Kevin Cameron wrote on 11/06/02 ***
*** John Stickley wrote on 11/06/02 ***
*** Andrzej wrote on 11/06/02 ***
More to follow on this ISSUE, I hope! Regards,
|
| Resolution | Cmodule proposal has been rejected. Proposal for External module has been deferred to SV 3.2. |
| Issue # | 1.11 |
| Issue Summary | Direct vs. Abstract function parameter interfaces |
| Opening Date | Nov 06 2002 |
| Opened By | Doug Warmke |
| Current Owner | None |
| Current Status | Accepted. |
| Added Comment | Team,
I'd like to formalize the issue of direct vs. abstract parameters. Several people have expressed that they don't like having an either/or approach to parameters. My feeling is that we can have direct access for simple types that are easy to understand and document. Best performance will result, and usability will be fine. For complex types, we need an abstract interface. Also, if extern "C" tasks are supposed to drive signals in the HDL design, an API call (probably one already in PLI) will be needed anyways. Let's get some discussion going on this issue. Regards, Doug |
| Resolution | Andrej's proposal (for C layer) is here. |
| Issue # | 1.12 |
| Issue Summary | ISSUE:DirectC:Proposal: "queueable" attribute for functions |
| Opening Date | Nov 26 2002 |
| Opened By | John Stickley |
| Current Owner | None |
| Current Status | Rejected (actually, withdrawn by John S.) |
| Added Comment | Team,
I just wanted to squeeze in one last requirement issue before today's deadline for issues. I would like to request a simple attribute that we can add to extern/export declarations called queueable. What this does is to gives the compiler a hint that a function call can be queued rather than having to wait for a full round trip confirmation that the callee has been called and has returned. It turns out that this simple extension to our function call interface elegantly opens up a whole facility to implement the equivalent of SystemC channels, Berkeley sockets, message queues, Unix named pipes, etc. Ironically, the OpenVera LRM has a similar facility called the VSV interface. So they apparently recognized the need to have something above and beyond DirectC for this type of capability. But what this proposal does is it gives you the entire capability without adding a whole new API to support it. With an ultra simple modification of DirectC, you can cleanly support a socket type of channel like VSV did. This is extremely useful for creating efficient 1-way blocking and non blocking channels between SV processes and C threads. Queueable functions are ideal for implementing efficient, optmized streaming channels between models. And, in an implementation, if you've paid the price to imiplement DirectC function calls, with slightly more work you can get this feature almost for free. The only requirement of queueable functions they can only have input arguments, no outputs. Think of these as one way transaction channels that the infrastructure can queue to arbitrary depth before blocking the caller. Here's an enhanced syntax that shows the queueable attribute: extern_decl ::= extern [attribute {, attribute}] return_type fname ( [arg {,arg} ); attribute ::= pure | queueable export_decl ::= export [attribute {, attribute}] [scopename{::scopename}::]fname ["cname"]; scopename ::= modulename|interfacename attribute ::= pure | queueable By placing the queueable attribute on the function declarations the user is hinting to the compiler that it can do this one-way optimization. In many cases that will save having to send extra messages in the opposite direction when the function call returns. Remember, even if the function has a void return argument, a return confirmation message is still required on a non-queueable function call. I've attached a revision of my PowerPoint proposal that adds this. -- johnS
|
| Resolution | None. |
| Issue # | 1.13 |
| Issue Summary | ISSUE: DirectC:Proposal: const attribute for input params |
| Opening Date | Nov 26 2002 |
| Opened By | Michael Rohleder |
| Current Owner | None |
| Current Status | Accepted. |
| Added Comment | Team,
Hi all, Since today is the deadline [ and we Germans always need to have the last word ;-) ] I would like to enter another proposal I already said once, but forgot to include in the ISSUE list: Provide all parameters declared as INPUT (and only them) with the const keyword on the C side of the API. By doing so the compiler on the C side can validate that the corresponding C value is not being overwritten. IMHO it makes sense to use such built-in functionality whenever it is possible -- especially at no cost. -Michael
|
| Resolution | Accepted unanimously during 01/14/03 meeting. |