In Verilog Procedural Interface, is it possible to scan through iteration loop several times?












0














We can use vpi_scan in the following way:



vpiHandle iter = vpi_iterate(property, handle);
if (iter)
while ( entry = vpi_scan(iter) )
/*code*/;


iter will be freed when vpi_scan() returns NULL.
But what if I need to scan through the loop several times? Is there a way to tell vpi_scan not to free the iterator, so that I could vpi_free_object when I'm done?
I think I can solve the problem using an additional container (to collect and keep all entries), but is it really needed?



EDIT:
1. I would not like to call vpi_iterate more than once, since it can be expensive.
2. Suppose I go with an additional container solution. Is there a way to find out the number of entries in the vpi_scan loop without actual scanning through the loop? This could make implementation simpler.










share|improve this question
























  • Can you not call vpi_iterate again?
    – immibis
    Nov 19 at 23:22










  • @immibis Not sure about performance. The property can be "expensive" to recognize.
    – TT_
    Nov 19 at 23:26








  • 1




    1) to re-run your loop again, call vpi_iterate again, it will return a new handle.; 2) there is no way to tell iterator to not free the objects. 3) keeping entries in a separate container might be a good solution performance-wise.4) there is no way to know the number of elements in the iteration before scanning. Use lists.
    – Serge
    Nov 20 at 2:29












  • @Serge If you want to post as an answer, I'll accept it. Just in case - any references for #2,4?
    – TT_
    Nov 20 at 14:05
















0














We can use vpi_scan in the following way:



vpiHandle iter = vpi_iterate(property, handle);
if (iter)
while ( entry = vpi_scan(iter) )
/*code*/;


iter will be freed when vpi_scan() returns NULL.
But what if I need to scan through the loop several times? Is there a way to tell vpi_scan not to free the iterator, so that I could vpi_free_object when I'm done?
I think I can solve the problem using an additional container (to collect and keep all entries), but is it really needed?



EDIT:
1. I would not like to call vpi_iterate more than once, since it can be expensive.
2. Suppose I go with an additional container solution. Is there a way to find out the number of entries in the vpi_scan loop without actual scanning through the loop? This could make implementation simpler.










share|improve this question
























  • Can you not call vpi_iterate again?
    – immibis
    Nov 19 at 23:22










  • @immibis Not sure about performance. The property can be "expensive" to recognize.
    – TT_
    Nov 19 at 23:26








  • 1




    1) to re-run your loop again, call vpi_iterate again, it will return a new handle.; 2) there is no way to tell iterator to not free the objects. 3) keeping entries in a separate container might be a good solution performance-wise.4) there is no way to know the number of elements in the iteration before scanning. Use lists.
    – Serge
    Nov 20 at 2:29












  • @Serge If you want to post as an answer, I'll accept it. Just in case - any references for #2,4?
    – TT_
    Nov 20 at 14:05














0












0








0


1





We can use vpi_scan in the following way:



vpiHandle iter = vpi_iterate(property, handle);
if (iter)
while ( entry = vpi_scan(iter) )
/*code*/;


iter will be freed when vpi_scan() returns NULL.
But what if I need to scan through the loop several times? Is there a way to tell vpi_scan not to free the iterator, so that I could vpi_free_object when I'm done?
I think I can solve the problem using an additional container (to collect and keep all entries), but is it really needed?



EDIT:
1. I would not like to call vpi_iterate more than once, since it can be expensive.
2. Suppose I go with an additional container solution. Is there a way to find out the number of entries in the vpi_scan loop without actual scanning through the loop? This could make implementation simpler.










share|improve this question















We can use vpi_scan in the following way:



vpiHandle iter = vpi_iterate(property, handle);
if (iter)
while ( entry = vpi_scan(iter) )
/*code*/;


iter will be freed when vpi_scan() returns NULL.
But what if I need to scan through the loop several times? Is there a way to tell vpi_scan not to free the iterator, so that I could vpi_free_object when I'm done?
I think I can solve the problem using an additional container (to collect and keep all entries), but is it really needed?



EDIT:
1. I would not like to call vpi_iterate more than once, since it can be expensive.
2. Suppose I go with an additional container solution. Is there a way to find out the number of entries in the vpi_scan loop without actual scanning through the loop? This could make implementation simpler.







c verilog vpi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 1:00

























asked Nov 19 at 22:34









TT_

89321424




89321424












  • Can you not call vpi_iterate again?
    – immibis
    Nov 19 at 23:22










  • @immibis Not sure about performance. The property can be "expensive" to recognize.
    – TT_
    Nov 19 at 23:26








  • 1




    1) to re-run your loop again, call vpi_iterate again, it will return a new handle.; 2) there is no way to tell iterator to not free the objects. 3) keeping entries in a separate container might be a good solution performance-wise.4) there is no way to know the number of elements in the iteration before scanning. Use lists.
    – Serge
    Nov 20 at 2:29












  • @Serge If you want to post as an answer, I'll accept it. Just in case - any references for #2,4?
    – TT_
    Nov 20 at 14:05


















  • Can you not call vpi_iterate again?
    – immibis
    Nov 19 at 23:22










  • @immibis Not sure about performance. The property can be "expensive" to recognize.
    – TT_
    Nov 19 at 23:26








  • 1




    1) to re-run your loop again, call vpi_iterate again, it will return a new handle.; 2) there is no way to tell iterator to not free the objects. 3) keeping entries in a separate container might be a good solution performance-wise.4) there is no way to know the number of elements in the iteration before scanning. Use lists.
    – Serge
    Nov 20 at 2:29












  • @Serge If you want to post as an answer, I'll accept it. Just in case - any references for #2,4?
    – TT_
    Nov 20 at 14:05
















Can you not call vpi_iterate again?
– immibis
Nov 19 at 23:22




Can you not call vpi_iterate again?
– immibis
Nov 19 at 23:22












@immibis Not sure about performance. The property can be "expensive" to recognize.
– TT_
Nov 19 at 23:26






@immibis Not sure about performance. The property can be "expensive" to recognize.
– TT_
Nov 19 at 23:26






1




1




1) to re-run your loop again, call vpi_iterate again, it will return a new handle.; 2) there is no way to tell iterator to not free the objects. 3) keeping entries in a separate container might be a good solution performance-wise.4) there is no way to know the number of elements in the iteration before scanning. Use lists.
– Serge
Nov 20 at 2:29






1) to re-run your loop again, call vpi_iterate again, it will return a new handle.; 2) there is no way to tell iterator to not free the objects. 3) keeping entries in a separate container might be a good solution performance-wise.4) there is no way to know the number of elements in the iteration before scanning. Use lists.
– Serge
Nov 20 at 2:29














@Serge If you want to post as an answer, I'll accept it. Just in case - any references for #2,4?
– TT_
Nov 20 at 14:05




@Serge If you want to post as an answer, I'll accept it. Just in case - any references for #2,4?
– TT_
Nov 20 at 14:05












1 Answer
1






active

oldest

votes


















2















  1. ut what if I need to scan through the loop several times? vpi_iterate returns an initialized pointer to the iterator. Every vpi_scan removes an element from the list and frees it. If vpi_scan did not run till the end, you'd better use vpi_free_object to clean the rest of the iterator list. If you need to rescan the same object again, you can call vpi_iterate again and it will return a new iterator object which you can re-scan.


  2. s there a way to tell vpi_scan not to free the iterator, so that I could vpi_free_object when I'm done? No, (1) is the only mechanism which can be used to access and free iterator elements. There is no other exist in the standard.


  3. I think I can solve the problem using an additional container (to collect and keep all entries), but is it really needed? -- this is a good idea if you want to re-scan your data structs. It could be much better from the performance point of view. Verilog simulator usually has a separately generated vpi database which it needs to consult, probably multiple times to provide you with vpi access information.


  4. Is there a way to find out the number of entries in the vpi_scan loop without actual scanning through the loop? not really. there are no defined way to query this information from the iterator. There might be a work-around with using vpi_handle(vpiUse, iterator) but it depends on the underlying data and the type of iteration. It is much easier to use linked lists created by the first scanning loop.



you can get all additional information for LRM or a verilog pli handbook.






share|improve this answer





















  • Thanks! What is LRM ?
    – TT_
    Nov 20 at 18:09






  • 2




    Language Reference Manual (verilog standard), for example verilog IEEE1364-2005 or system verilog IEEE1800-2012
    – Serge
    Nov 20 at 18:54











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383628%2fin-verilog-procedural-interface-is-it-possible-to-scan-through-iteration-loop-s%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2















  1. ut what if I need to scan through the loop several times? vpi_iterate returns an initialized pointer to the iterator. Every vpi_scan removes an element from the list and frees it. If vpi_scan did not run till the end, you'd better use vpi_free_object to clean the rest of the iterator list. If you need to rescan the same object again, you can call vpi_iterate again and it will return a new iterator object which you can re-scan.


  2. s there a way to tell vpi_scan not to free the iterator, so that I could vpi_free_object when I'm done? No, (1) is the only mechanism which can be used to access and free iterator elements. There is no other exist in the standard.


  3. I think I can solve the problem using an additional container (to collect and keep all entries), but is it really needed? -- this is a good idea if you want to re-scan your data structs. It could be much better from the performance point of view. Verilog simulator usually has a separately generated vpi database which it needs to consult, probably multiple times to provide you with vpi access information.


  4. Is there a way to find out the number of entries in the vpi_scan loop without actual scanning through the loop? not really. there are no defined way to query this information from the iterator. There might be a work-around with using vpi_handle(vpiUse, iterator) but it depends on the underlying data and the type of iteration. It is much easier to use linked lists created by the first scanning loop.



you can get all additional information for LRM or a verilog pli handbook.






share|improve this answer





















  • Thanks! What is LRM ?
    – TT_
    Nov 20 at 18:09






  • 2




    Language Reference Manual (verilog standard), for example verilog IEEE1364-2005 or system verilog IEEE1800-2012
    – Serge
    Nov 20 at 18:54
















2















  1. ut what if I need to scan through the loop several times? vpi_iterate returns an initialized pointer to the iterator. Every vpi_scan removes an element from the list and frees it. If vpi_scan did not run till the end, you'd better use vpi_free_object to clean the rest of the iterator list. If you need to rescan the same object again, you can call vpi_iterate again and it will return a new iterator object which you can re-scan.


  2. s there a way to tell vpi_scan not to free the iterator, so that I could vpi_free_object when I'm done? No, (1) is the only mechanism which can be used to access and free iterator elements. There is no other exist in the standard.


  3. I think I can solve the problem using an additional container (to collect and keep all entries), but is it really needed? -- this is a good idea if you want to re-scan your data structs. It could be much better from the performance point of view. Verilog simulator usually has a separately generated vpi database which it needs to consult, probably multiple times to provide you with vpi access information.


  4. Is there a way to find out the number of entries in the vpi_scan loop without actual scanning through the loop? not really. there are no defined way to query this information from the iterator. There might be a work-around with using vpi_handle(vpiUse, iterator) but it depends on the underlying data and the type of iteration. It is much easier to use linked lists created by the first scanning loop.



you can get all additional information for LRM or a verilog pli handbook.






share|improve this answer





















  • Thanks! What is LRM ?
    – TT_
    Nov 20 at 18:09






  • 2




    Language Reference Manual (verilog standard), for example verilog IEEE1364-2005 or system verilog IEEE1800-2012
    – Serge
    Nov 20 at 18:54














2












2








2







  1. ut what if I need to scan through the loop several times? vpi_iterate returns an initialized pointer to the iterator. Every vpi_scan removes an element from the list and frees it. If vpi_scan did not run till the end, you'd better use vpi_free_object to clean the rest of the iterator list. If you need to rescan the same object again, you can call vpi_iterate again and it will return a new iterator object which you can re-scan.


  2. s there a way to tell vpi_scan not to free the iterator, so that I could vpi_free_object when I'm done? No, (1) is the only mechanism which can be used to access and free iterator elements. There is no other exist in the standard.


  3. I think I can solve the problem using an additional container (to collect and keep all entries), but is it really needed? -- this is a good idea if you want to re-scan your data structs. It could be much better from the performance point of view. Verilog simulator usually has a separately generated vpi database which it needs to consult, probably multiple times to provide you with vpi access information.


  4. Is there a way to find out the number of entries in the vpi_scan loop without actual scanning through the loop? not really. there are no defined way to query this information from the iterator. There might be a work-around with using vpi_handle(vpiUse, iterator) but it depends on the underlying data and the type of iteration. It is much easier to use linked lists created by the first scanning loop.



you can get all additional information for LRM or a verilog pli handbook.






share|improve this answer













  1. ut what if I need to scan through the loop several times? vpi_iterate returns an initialized pointer to the iterator. Every vpi_scan removes an element from the list and frees it. If vpi_scan did not run till the end, you'd better use vpi_free_object to clean the rest of the iterator list. If you need to rescan the same object again, you can call vpi_iterate again and it will return a new iterator object which you can re-scan.


  2. s there a way to tell vpi_scan not to free the iterator, so that I could vpi_free_object when I'm done? No, (1) is the only mechanism which can be used to access and free iterator elements. There is no other exist in the standard.


  3. I think I can solve the problem using an additional container (to collect and keep all entries), but is it really needed? -- this is a good idea if you want to re-scan your data structs. It could be much better from the performance point of view. Verilog simulator usually has a separately generated vpi database which it needs to consult, probably multiple times to provide you with vpi access information.


  4. Is there a way to find out the number of entries in the vpi_scan loop without actual scanning through the loop? not really. there are no defined way to query this information from the iterator. There might be a work-around with using vpi_handle(vpiUse, iterator) but it depends on the underlying data and the type of iteration. It is much easier to use linked lists created by the first scanning loop.



you can get all additional information for LRM or a verilog pli handbook.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 at 17:56









Serge

3,4402914




3,4402914












  • Thanks! What is LRM ?
    – TT_
    Nov 20 at 18:09






  • 2




    Language Reference Manual (verilog standard), for example verilog IEEE1364-2005 or system verilog IEEE1800-2012
    – Serge
    Nov 20 at 18:54


















  • Thanks! What is LRM ?
    – TT_
    Nov 20 at 18:09






  • 2




    Language Reference Manual (verilog standard), for example verilog IEEE1364-2005 or system verilog IEEE1800-2012
    – Serge
    Nov 20 at 18:54
















Thanks! What is LRM ?
– TT_
Nov 20 at 18:09




Thanks! What is LRM ?
– TT_
Nov 20 at 18:09




2




2




Language Reference Manual (verilog standard), for example verilog IEEE1364-2005 or system verilog IEEE1800-2012
– Serge
Nov 20 at 18:54




Language Reference Manual (verilog standard), for example verilog IEEE1364-2005 or system verilog IEEE1800-2012
– Serge
Nov 20 at 18:54


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383628%2fin-verilog-procedural-interface-is-it-possible-to-scan-through-iteration-loop-s%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]