NAME

SystemPerl - SystemPerl Language Extension to SystemC

DESCRIPTION

SystemPerl is a version of the SystemC language. It is designed to expand text so that needless repitition in the language is minimized. By using sp_preproc, SystemPerl files can be expanded into C++ files at compile time, or expanded in place to make them valid stand-alone SystemC files.

The concept of SystemPerl is based upon the AUTOS in the verilog-mode package for Emacs, by the same author.

LANGUAGE

#sp

#sp directives are recognized by SystemPerl to split up files and control preprocessing. Use of any #sp's forces use of SystemPerl preprocessing, and removes full SystemC compatibility.

/*AUTOS*/

AUTOmatics provide a way of expanding interconnections, while potentially retaining fully compatible SystemC code. The preprocessor can edit the source code file directly, resulting in the source code having the expanded automatics.

Code with expanded AUTOs are fully valid SystemC code, and can be sent to anyone who does not even have system perl. Anyone with SystemPerl has the benefit of being able to automatically regenerate them, and saves coding time.

LANGUAGE REQUIREMENTS

SystemPerl requires the following coding conventions. These tokens are not changed in any way, but are simply required for SystemPerl to be able to derrive required information from the source code.

SP_CELL_DECL (refname, instname[s])

SP_CELL_DECL declares the cell structures. It is only needed to declare those cells that AUTOCELLS will not create itself; currently this is any cells which are arrayed.

SP_CELL (instname, refname)

SP_CELL instantiates the given module named refname as a instantiation called instname. The instname is also passed as a parameter to refname as a string. Note if you are doing an array, you probably want SP_CELL_FORM.

SP_CELL_FORM (instname, refname, form, ...)

SP_CELL_FORM instantiates the given module named refname as a instantiation. The instantiation is named by using a sprintf of the given format and arguments. Generally this is used for arrays: i.e.:

SC_MODULE (modulename)

Though a standard optional SystemC construct, SystemC requires use of the SC_MODULE macro when defining a module class. For example "struct mod1 : public sc_module" must instead be coded as "SC_MODULE(mod1)".

SP_CELL_FORM(slice[i], smm_pi_slice, "slice[%d]", i);
SP_PIN (instname, portname, netname)

SP_PIN declares a connection of a instantation's port to the specified net.

EXPANSIONS

SystemPerl expands the following special tokens.

__MODULE__

__MODULE__ is predefined to the name of the module, from the basename of the filename. This allows files to be more easily replicated, and to avoid obscure errors when the filename does not match the module name.

For example:

SC_MODULE (__MODULE__) { ...

/*AUTOENUM_CLASS|GLOBAL(enum)*/

AUTOENUM is used to take an existing enumeration and make it into a class with functions to return the ASCII name of the enumeration. This makes it easy to print the value of the enumeration in text form.

For example:

class MyENumClass { public: enum en { IDLE = 0, ONE, TWO, THREE, FOUR, FIVE }; /*AUTOENUM_CLASS(MyENumClass.en)*/ }; /*AUTOENUM_GLOBAL(MyENumClass.en)*/

Becomes:

class MyENumClass { public: enum en { IDLE = 0, ONE, TWO }; /*AUTOENUM_CLASS(MyENumClass.en)*/ // Beginning of SystemPerl automatic enumeration enum en e_en; inline MyENumClass () {}; inline MyENumClass (en _e) : e_en(_e) {}; explicit inline MyENumClass (int _e) : e_en(static_cast<en>(_e)) {}; operator const char * (void) const { return ascii(); }; operator en (void) const { return e_en; }; const char *ascii (void) const { switch (e_en) { case IDLE: return "IDLE"; case ONE: return "ONE"; case TWO: return "TWO"; default: return "%E:BadVal:MyENumClass"; }; }; // End of SystemPerl automatic enumeration }; /*AUTOENUM_GLOBAL(MyENumClass.en)*/ // Beginning of SystemPerl automatic enumeration inline bool operator== (MyENumClass lhs, MyENumClass rhs) { return (lhs.e_en == rhs.e_en); } //... other accessors // End of SystemPerl automatic enumeration

/*AUTOINST*/

AUTOINST connects any unreferenced ports for the current SP_CELL to signals named the same as the port name.

For example:

SC_MODULE(submod) { sc_in_clk clk; ...

SC_MODULE(mod) { SC_CTOR(mod) { SP_CELL (sub, submod); /*AUTOINST*/

Becomes:

SC_MODULE(mod) { SC_CTOR(mod) { SP_CELL (sub, submod); // Beginning of SystemPerl automatic instantiation pins SP_PIN (sub, clk, clk); // End of SystemPerl automatic instantiation pins

/*AUTOSUBCELLS*/

AUTOSUBCELLS declares the submodules instantiated in SP_CELL declarations.

For example:

SC_MODULE(mod) { /*AUTOSUBCELLS*/ SC_CTOR(mod) { SP_CELL (sub, submod); SP_PIN (sub, a, a);

Becomes:

SC_MODULE(mod) { /*AUTOSUBCELLS*/ // Beginning of SystemPerl automatic subcells submod *sub; // End of SystemPerl automatic subcells

    SC_CTOR(mod) {
	SP_CELL (sub, submod);
	  SP_PIN (sub, a,	a);
/*AUTOSIGNAL*/

AUTOSIGNAL declares any signals used in SP_PIN connections that are not declared elsewhere.

For example:

SC_MODULE(mod) { /*AUTOSIGNAL*/ SC_CTOR(mod) { SP_CELL (sub, submod); SP_PIN (sub, a, a);

Becomes:

SC_MODULE(mod) { /*AUTOSUBCELLS*/ // Beginning of SystemPerl automatic signals sc_signal<bool> a; // For submod // End of SystemPerl automatic signals

    SC_CTOR(mod) {
	SP_CELL (sub, submod);
	  SP_PIN (sub, a,	a);
#sp interface

Interface specifies the following code should be moved into a the header file. This allows a common .sp file to contain both .h and .cpp information. SystemPerl automatically adds include guards in the header, to protect against multiple inclusion.

#sp implementation

The Interface specifies the following code should be part of the cpp file. This allows a common .sp file to contain both .h and .cpp information.

SEE ALSO

sp_preproc SystemC::Netlist SystemC::Parser

DISTRIBUTION

The latest version is available from CPAN and from http://veripool.com/.

AUTHORS

Wilson Snyder <wsnyder@wsnyder.org>