-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Peek functionality #814
base: master
Are you sure you want to change the base?
Peek functionality #814
Conversation
Corresponding issue: #812 |
I took a first quick look at the user interfaces for |
It is the same idea than the |
@LarsAsplund, I am currently working on #818. If the issue is accepted, I plan to do the same thing with the |
I don't think you need the high-level peek procedures with offset/index since the user will never peek a number of bytes into the queue. A high-level peek function needs lower-level peek functions for a fix or a variable length string starting at the head of the queue. These low-level functions need to peek characters with offset/index but only at this level there is a need to handle offset/index. Once you have peeked the string of correct length the value can be calculated using the decode function. However, we can extend the scope and provide peek functions that allow you to peek the n:th element in the queue. I think this is a feature that can be done in a second iteration I also see a use case where you don't know the type at the head of the queue so you start peeking the type and then based on the response you pop or peek an element of that type. |
I agree that the user will never use the offset/index functionality provided by the procedure. It's not intended for them but for other VUnit developer (or advanced users). Each predefined type has a function and a procedure to peek. For example, an integer can be peek using:
The procedure is needed to build procedure peek(
queue : queue_t;
variable ret_val : out msg_t;
variable offset : inout natural
) is
variable value : integer;
begin
peek(queue, ret_val.id, offset);
peek(queue, value, offset);
ret_val.msg_type := (p_code => value);
peek(queue, value, offset);
ret_val.status := com_status_t'val(value);
peek(queue, ret_val.sender.id, offset);
peek(queue, ret_val.receiver.id, offset);
peek(queue, ret_val.request_id, offset);
peek_queue_ref(queue, ret_val.data, offset);
end procedure; As you can see, the
A user can peek several element (not byte) as shown in the procedure above. But, I think that this is a feature more likely to be used by VUnit developers.
I can work on that. (Note that there is a function |
If you find that my message did not answer your questions or remarks, then I probably did not understood your point. Do you find the changes I did are too important and/or too complex for the functionality it provides ? |
That's a valid use case. The only thing I would ask for is to move these to a separate package. I think the same distinction is done for codecs where the codec package is separate from the codec builder package.
I was thinking a peek that allow the user to specify what element index to peek. However, leave that for now to avoid making huge commits/PRs. I think such a feature may drive the need for another internal representation of queues so that's why I think we better release the other stuff first.
That is what I was looking for. I missed it. Just make it public. Now it is an unused function in the package body. In general I think it would also be good if we can break up this PR in smaller pieces. The normal user queue features feels complete and could be released first. I need to look further into the codec updates. |
Indeed, it is done this way in the codec package. However, (I intend to raise an issue about that), I do not think it is a good thing to do. From the user point of view, when looking for information directly into the code, he has to understand why the From the VUnit developer (or advanced user) point of view, it is not desirable either because the implementation of the When I personally wanted to understand how the What do you think ? (for the
Sure, no problem, when we are done discussing, I'll cancel this PR and do that. So, do you want a PR by package ?
Or something even smaller ? |
Hum, after sometime, I think you are right. I will move the |
Yes, documentation is lacking here and it would be great if you could improve. However, if the documentation of a subprogram just restates the obvious I rather don't have it at all. I think standard pop, push, and peek fall into that category but the peek procedure does not. I'm thinking a first separate PR for the queue package is a good start. That is the most obvious extension and a good first iteration to get released. Try to redefine this PR or reference it from the new PR such that the discussion history isn't lost. |
I agree. Thank you for the various feedback. Here is what I will do:
|
Add a peek functionality to the queue_pkg: returns the element at the front the queue. It does not delete the element in the queue (contrary to the already existing pop command).
The peek functionality has alos been added to the com package and some of the verification components.
Added a small description of the peek functionality in the documentation of the com library when using messages.
My first Pull Request (ever), don't hesitate to give feedback.