Download Agility Compiler manual

Transcript
Celoxica SystemC synthesizable subset
Example: ag_signal_default
#include “systemc.h”
#include “agility.h”
SC_MODULE( myModule )
{
sc_in<bool> Clk;
sc_out< sc_uint<32> > Result;
/*
* Declaration of signal with default
*/
ag_signal_default< sc_uint<32> > mySig;
SC_CTOR( myModule ) :
mySig( “mySignal”, 5 ) // construct signal with default set to 5
{
/*
* Assign clock to the signal
*/
mySig.Clock(Clk);
SC_THREAD( test1 );
sensitive_pos << Clk;
SC_THREAD( test2 );
sensitive_pos << Clk;
}
void test1()
{
wait();
// mySig is not assigned to in this cycle, thus mySig = 5
wait();
mySig.write( 10 ); // mySig = 10
wait();
// mySig = 5
wait();
mySig.write( 20 ); // mySig = 20
wait();
// mySig = 5
}
void test2()
{
wait();
while(1)
{
Page 82
www.celoxica.com