Clocks

Most projects are simulations of sychronous systems in which the entities are clocked. HASE has a number of built-in clock mechanisms which can be invoked by (a) declaring the appropriate clock entity in the project definition file (b) using the EXTENDS option in the definition of an entity to link the entity to the clock.

A clock in HASE serve two purposes:

  1. to simulate the clock in the real-life version of the system being simulated
  2. to sychronise the simulation code of the entities against ticks of the clock, in order to ensure an orderly transfer of data between entities.

The entities required to support these mechanisms:
Clock Clocked Biclocked Pll
are contained in the sync library.


Clock

The Clock entity operates in two phases:
  1. Send a tick signal to any registered entity. The tick signal contains an integer value which represents the tick number.
  2. Wait for completion signals from any of the registered entities. If the period time is reached and some entities have not sent their completion signals, then an error message is printed to inform the user that the Clock is too fast (Clock.period is too small).
    An integer value should be attached to the completion signal. If this value is negative, then the clock stops its behaviour assuming an error has occurred. Otherwise, the cycle starts again at phase1.
Declaration: ENTITY Clock sync ()

Parameters:


Clocked

Declaration:
ENTITYLIB (
ABSTRACT Clocked sync ( )
ENTITY Clock sync ( )
ENTITY cpu (
EXTENDS (Clocked)
etc.
);
Clocked defines the basic behaviour of a 1-phase synchronous entity which:

DebugMode:

The Clocked entity has a debug mode in which a statement is printed at the begin and the end of the tick service. Use the bool debug; attribute to set and reset the debug mode.

Parameters

AENTITY cpu CPU(
DESCRIPTION("CPU")
ATTRIB(RPARAM(clockName,CPU_CLOCK))
)

Biclocked

Declaration:

ENTITYLIB (
ABSTRACT Biclocked sync ( )
ENTITY Clock sync ( )
ENTITY Clockphase sync ( )
ENTITY cpu (
EXTENDS (Biclocked)
etc.
);
Biclocked defines the basic behaviour of a 2-phase synchronous entity:

Debug mode:

The Biclocked entity has also a debug mode in which a statement is printed at the begin and the end of each phase0/phase1 service. Use the bool debug; attribute to set and reset the debug mode.

NB: Only one service (either phase0 or phase1) is executed for each signal coming from the Clock entity. This means that the overall period of a Biclocked entity is twice the period of the Clock.

Parameters


Pll

The Pll entity acts in a similar manner to a phase lock loop, in that it is synchronised to a clock but runs at a different frequency. As a HASE entity it has the same behaviour as a Clock entity but is only activated when a tick signal is received from the entity with which it has registered (a Clock or another Pll).

Syntax

ENTITY Pll sync ()
AENTITY Pll CPU_CLOCK(
DESCRIPTION("CPU fast clock")
ATTRIB(RPARAM(ratio,4))
AENTITY cpu CPU(
DESCRIPTION("CPU")
ATTRIB(RPARAM(clockName,CPU_CLOCK))
)

Parameters: