What's the meaning of repeat with relational operators

I know what is the meaning of repeat (number), but what is the meanning in the following case:

repeat(m_wr_queue.size()==0) @(posedge m_vif.AXI_ACLK);?

3 Answers

This is really bad code. The result of a relational operator is either 1'b0 or 1'b1, so the resulting effect is the same as

if (m_wr_queue.size()==0) @(posedge m_vif.AXI_ACLK);

which is even fewer characters than the original and more readable.

However, there is a possibility they wrote something that was not their intent. Usually you want to keep waiting until there is something in the queue. Then what they should have wrote is

while(m_wr_queue.size()==0) @(posedge m_vif.AXI_ACLK);

The code will wait for a positive edge on the AXI_ACLK line if the m_wr_queue is empty. Basically it's a hard to read way to write an if-clause.

Here's the two possibilities:

  • Queue empty (i.e. size() == 0)

    repeat (1) @(posedge m_vif.AXI_ACLK);

  • Queue size > 0:

    repeat (0) @(posedge m_vif.AXI_ACLK);

I would recommend replacing it with something more readable (i.e. a simple if-clause). Concise code is of no use if you have to stare at it twice as long to understand it. Storage (a couple extra lines of code) is practically infinite nowadays, your time isn't.

I agree with dave_59. I believe the author is reading the AXI slave driver implementation in, .

These are what I have understood so far,

axi_slave_monitor observed that the write transaction has completed. It means that write address and data are driven by the axi_master_driver and axi_slave_monitor detected that master/slave handshaking was done for both address and data (AWREADY == AWVALID==1 and WREADY==WVALID==1).

Then monitor calls a function (TLM exports called 'write') implemented in the axi_slave_driver, which fills in a queue.

axi_slave_driver monitors if this queue is empty or not; if not empty it means the driver should drive axi write response signals.

The one line code should do this 'waiting' for the queue to be filled.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like