Jump to content
Sign in to follow this  
Zdenek Prikryl

Clock to Q Propagation Delay

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...