ABSTRACT - Abstract Entity Definition.

Syntax

ABSTRACT name library_name (
DESCRIPTION ( "description" )
INTERFACE ( SERVICE ( service_name1 , param1, ...) , ... )
PARAMS ( reference_parameters, ...)
)

Synopsis

A new entity type called ABSTRACT has been introduced in JavaHase. This creates an abstract entity with an interface described as a set of services (all methods which must be defined by the inheriting entity). The basic behaviour of such an entity is still described under the $body label in the corresponding .hase file.

Example

As an example, the abstract entity clocked has been declared in the tomasulo project.

ENTITYLIB (
ABSTRACT clocked (
DESCRIPTION ("two phases clock entities")
INTERFACE(
SERVICE (pre)
SERVICE (phase0)
SERVICE (phase1)
)
)

This means that the abstract clocked entity declares the pre, phase0 and phase1 services. Those services have to be defined in the concrete entities which will inherit from clocked

Then, one can define concrete entities which claims they define that interface and they want to inherit the body behaviour.
This can be done in an entity declaration by adding the field EXTENDS (clocked). All entities which inherits from an abstract class must define a label for each service declared by the abstract class. This label marks the beginning of the code corresponding to this service. However, these entities must not define a body label as it will be inherited from the abstract class.

With the previous example, the rsc entity declaration of the tomasulo project may be declared as following :

ENTITY rsc (
EXTENDS (clocked)
DESCRIPTION ("Reservation Station Control Register")
PARAMS (
RENUM(rsc_state, cur_state, 0)
RSTRING (FUNC, "FREE")
)
PORTS (
PORT (input, l_con, DESTINATION)
PORT (output, l_con, SOURCE)
)
)

Actually, all the following entities may inherits from clocked : source, flb_reg, flos, decoder, cdb, sdb_reg, fp_reg, rs_opr, rsc, add_res, mul_res, add, mul.

Now let us have a look at an example of .hase code for an abstract entity (here clocked.hase). Note that the pre, phase0 and phase1 code is not defined here, it will be asbtract and will be defined by the concrete classes :
$class_decls
int ClockPhase;
int DONE;
//clock reference
sim_entity_id clk;

$startup
clk = sim.get_entity_id("CLOCK");
((clock *)sim.get_entity(clk))->registering(get_id());

$body
pre();
DONE = 1;

// predicate
sim_from_p start(clk);

while (1) {
sim_wait_for(start, ev);

SIM_CAST(int, ClockPhase, ev); //to avoid memory leakage

if (ClockPhase == 0) // First phase of clock
phase0();
else // Second phase of clock
phase1();

sim_schedule( clk, 0.0, CLOCK, SIM_PUT(int, DONE));
}
clocked.hase

As an example of concrete class, let us have a look at the rsc.hase code:
$class_decls

//entity references
sim_entity_id bus;
sim_entity_id add_res;
sim_entity_id mul_res;

//structures and variables
t_rs_control Instruction, Register;
int RS_no;
int output_to_au;

//methods
void Output_to_au();

$class_defs

void rsc::Output_to_au()
{
// Invoked by a Reservation Station: set output_to_au = 1
output_to_au = 1;
}

$pre

bus = sim.get_entity_id("CDB");
add_res = sim.get_entity_id("ADD_RES");
output_to_au = 0;

cur_state = RSC;
strcpy(FUNC, "FREE");
dump_state();

$phase0
// predicate
sim_from_port receive(input);

sim_hold(5);
// If there is an event from the CDB, copy function and tag number
// into Register.

if (sim_waiting(ev, receive) > 0)
{
SIM_CAST(t_rs_control, Instruction, ev);
Register.instrn = Instruction.instrn;
Register.tag_no = Instruction.tag_no;
if (Register.instrn.function == VOID)
strcpy(FUNC, "FREE");
else if (Register.instrn.function == ADD)
strcpy(FUNC, "ADD");
else if (Register.instrn.function == SUB)
strcpy(FUNC, "SUB");
else if (Register.instrn.function == MUL)
strcpy(FUNC, "MUL");
else if (Register.instrn.function == DIV)
strcpy(FUNC, "DIV");
dump_state();
}

$phase1

// if output_to_au is set, send content of register to arithmetic unit
if (output_to_au == 1)
{
send_CONTROL(output, Register);
output_to_au = 0;
}
rsc.hase


Frederic Mallet
Last modified: Wed Jul 3 11:47:06 BST 2002