H2 Simple Use of the Connect Primitive

This example shows the use of the connect primitive to join a pair of interfaces. In this simple example, the interfaces are compatible, since they are both built from the same source code and one is the backwards version of the other. No glue logic is required to be synthesised.

Source Code

The vanilla channel source code is given on the previous page. The rest is below.


//------------------------------------------------------------------
// Centronix components, in this version they are defined using imperative code:


// Physical level pin definitions
interface CENTRONIX_KERNEL()
{
   protocol centronix;

     forward:
        node out [7:0] : d8;
        node out : n_strobe;
        node in  : n_ack;
        node in  : busy;

  idle K.n_strobe ==0, K.n_ack == 0, K.busy == 0;
  initial K.n_strobe == 0;  
  initial K.busy == 0, K.n_ack == 0;
}


// Sending side
interface centronix_host(datasrc)
{
  node [7:0]: din;
  node forward CENTRONIX_KERNEL : K;

  {
    din =  ?datasrc;
    printf("Centronix host received %i\n", din);
    wait (!K.busy);
    play Sendop(din): 
    {
       K.d8 = din;
       pause();
       K.n_strobe = 1;
    } 
    wait (K.n_ack);
    K.n_strobe = 0;
    wait (!K.n_ack);
  }
}

interface centronix_slave(datasink)
{
  node [7:0]: rxd;
  node reverse CENTRONIX_KERNEL : IF;

  {
    IF.busy = 0;
    play Receiveop(rxd):
    {
        wait (IF.n_strobe);
	rxd = IF.d8;
    }
    printf("Centronix sink received %i\n", rxd);
    datasink ! rxd;
    IF.n_ack = 1;
    wait (!IF.n_strobe);
    IF.n_ack = 0;
  }
}
//---------------------------------------------------------------
// Test wrapper components now follow


// No mitre is needed in this example since it is a 'simple join'

section SIMSYS()
{
  channel [7:0]: inputstream, outputstream;
  protocol vanilla_source : Source (inputstream);
  protocol centronix_host : Centronix_host (inputstream);

  protocol centronix_slave : Centronix_slave (outputstream);

  connect sink_to_src: Centronix_host.K, Centronix_slave.IF;


  protocol vanilla_sink : Sink (outputstream);
}
//
// eof

Simulation using builtin H2 simulator

The H2 tool has a builtin simulator which is run using the 'sim' command line flag, with events plotted to a plot file if requested.

./h2comp /home/djg11/d310/hprls/h2tool/gpibcent/gpibcent.h2 -root SIMSYS -sim 80 -plot a.plt -titl\
e "Simple_demonstration_of_connect_primitive"
Sending data 111
Centronix host received 111
Sending data 122
Centronix sink received 111
Received 111
Centronix host received 122
Sending data 133
Centronix sink received 122
Received 122
Centronix host received 133
Sending data 144
Simulation cycle limit reached at 80
h2comp done
diogif -o a.gif -x a.plt

Plot Output File

The plot file can be rendered under X windows or converted to a gif using the diogif program.


UP.