Sign in to follow this  
Followers 0
zdprikryl

Clock to Q Propagation Delay

2 posts in this topic

Hi,

Recently I used the following Verilog code in my project:

module dff8(
    input  wire CLK,
    input  wire RST,
    input  wire [7:0] D0,
    output reg [7:0] Q0
);
    always @( posedge CLK or negedge RST ) begin
        if ( RST == 1'b0 ) begin
            Q0 <= 8'b0;
        end else begin
            Q0 <= #10 D0;
        end
    end
endmodule

Is there any way how to model #<DELAY> in SystemC. The example of systemc register that I use is below.

SC_MODULE(dff8)
{
    // port declarations
    sc_in<bool> CLK;
    sc_in<bool> RST;
    sc_in<sc_uint<8> > D0;
    sc_out<sc_uint<8> > Q0;

    // process declaration
    void do_dff8()
    {
        if (RST.read() == 0)
        {
            Q0.write(0);
        }
        else
        {
            // HOW TO ADD DELAY HERE?
            Q0.write(D0.read());
        }
    }

    SC_HAS_PROCESS(dff8);
    dff8(sc_module_name inst)
      : sc_module(inst)
    {
        SC_METHOD(do_dff8);
        sensitive << CLK.pos();
        sensitive << RST.neg();
    }
};

Thanks for any help.

 

Share this post


Link to post
Share on other sites

Hello,

In SystemC you can use SC_THREAD's to model delays by using wait statements but you will incur performance penalty.

Instead you can use event's and event queues to model delays using in SystemC as mentioned here:

http://workspace.accellera.org/Discussion_Forums/helpforum/archive/msg/msg?list_name=help_forum&monthdir=200803&msg=msg00061.html

You can replace the SC_THREAD example given in the above mentioned link with SC_METHOD removing the infinite while loop.

Here's the modified example listed from the above mentioned link:

template<typename T>
class delay_transport : public sc_module {
public:
  sc_in<T> in;
  sc_out<T> out;
  SC_HAS_PROCESS(delay_transport);
  delay_transport(sc_module_name name_, sc_time tdelay_) :
    sc_module(name_),
    tdelay(tdelay_),
    in("in"), out("out")
  {
    SC_METHOD(mi);
    sensitive << in.default_event();
    SC_METHOD(mo);
    sensitive << eq;
  }
  sc_time tdelay;
  void mi() {
    val = in.read();
    vq.push(val);
    eq.notify(tdelay);
  }
  void mo() {
    val = vq.front();
    out.write(val);
    vq.pop();
  }
  sc_event_queue eq;
  std::queue<T> vq;
  T val;
};

Regards,

Ameya Vikram Singh

 

maehne likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0