• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. Can queues be used to drive RTL?

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 65
  • Views 7684
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can queues be used to drive RTL?

shareefj
shareefj over 2 years ago

This may well be a case of my not being able to see the wood for the trees or generally doing something stupid, but I thought I'd ask anyway.

I'm trying to interface a bus driver with some DPI code and thought that using a queue would be the best way.  What I have on the DPI side is a function that is called when new data is available to be pushed onto the queue.  On the RTL side, I've got a module with a FIFO interface and data is popped off the queue as it is loaded into the receiving downstream flop.  So something like the following:

bit [31:0] queue[$];

function push_back;
  input bit [31:0] value;
  queue.push_back(value);
endfunction

always_ff@(posedge clk) begin
  if(fifo_pop)
    queue.pop_front();
end

assign din = queue[0];

always_ff@(posedge clk) begin
  if (fifo_pop)
    capture_r <= din;
end

What I'm seeing is that the queue is updated before din has been captured in the receiving flop.  Is that expected and if so, what should I be doing here?  I've not done a load of DPI work before and haven't seen too many examples of how to cleanly drive an interface like this.

Thanks.

  • Cancel
Parents
  • shareefj
    shareefj over 2 years ago

    Just as a side note, modifying the above example such that the pop and assignment happen on the same line in the same always block works.  I just can't do that in my real code due to hierarchy.  Putting in a simple one entry FIFO that bridges between DPI and RTL seems to work though.

    always_ff @(posedge clk) begin
      if (fifo_pop)
        capture_r <= queue.pop_front();
    end
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • shareefj
    shareefj over 2 years ago

    Just as a side note, modifying the above example such that the pop and assignment happen on the same line in the same always block works.  I just can't do that in my real code due to hierarchy.  Putting in a simple one entry FIFO that bridges between DPI and RTL seems to work though.

    always_ff @(posedge clk) begin
      if (fifo_pop)
        capture_r <= queue.pop_front();
    end
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information