SystemC signals
Sep 15, 2008 at 3:27pm UTC
Hi, please let's look at the code below.
After that, please consider the problem of modelling the signal-level communication between master and slave:
1) How many signals are needed to implement the same semantics offered by the channel?
2) Please write the adapters' declaration between master and slave and the transmission signals, highlighting the interfaces to implement and the ports.
Thanks a lot,
Saggiatorius
__SystemC code_________________________
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
include "systemc.h"
#include <iostream>
class write_if: public sc_interface
{
public :
virtual void write(int dato)=0;
};
class canale: public sc_channel, public write_if
{
public :
sc_port<write_if> write_port;
void write(int dato)
{
write_port->write(dato);
}
SC_CTOR(canale){}
};
class slave: public sc_channel, public write_if
{
public :
void write(int dato)
{
cout << dato << endl;
}
SC_CTOR(slave){}
};
class master: public sc_module
{
public :
sc_port<write_if> write_port;
sc_in<bool > clk;
void action()
{
int a=0;
wait();
while (true )
{
write_port->write(a++);
wait();
}
}
SC_CTOR(master)
{
SC_CTHREAD(action,clk.pos());
}
};
Last edited on Sep 16, 2008 at 7:32am UTC
Sep 15, 2008 at 4:54pm UTC
Please repost the code using tags so it gets formatted. Also, please use indentation.
Sep 16, 2008 at 7:32am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
include "systemc.h"
#include <iostream>
class write_if: public sc_interface
{
public :
virtual void write(int dato)=0;
};
class canale: public sc_channel, public write_if
{
public :
sc_port<write_if> write_port;
void write(int dato)
{
write_port->write(dato);
}
SC_CTOR(canale){}
};
class slave: public sc_channel, public write_if
{
public :
void write(int dato)
{
cout << dato << endl;
}
SC_CTOR(slave){}
};
class master: public sc_module
{
public :
sc_port<write_if> write_port;
sc_in<bool > clk;
void action()
{
int a=0;
wait();
while (true )
{
write_port->write(a++);
wait();
}
}
SC_CTOR(master)
{
SC_CTHREAD(action,clk.pos());
}
};
Topic archived. No new replies allowed.