Skip to content
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

Bluesim's symbol-probing interface has wrong values for FIFO #677

Open
quark17 opened this issue Feb 27, 2024 · 0 comments
Open

Bluesim's symbol-probing interface has wrong values for FIFO #677

quark17 opened this issue Feb 27, 2024 · 0 comments
Labels
bluesim Relates to Bluesim bug Something isn't working good first issue Good for newcomers

Comments

@quark17
Copy link
Collaborator

quark17 commented Feb 27, 2024

This issue was uncovered on the b-lang-discuss mailing list ("How to get fifo's runtime status in bluetcl?"). Bluesim has a "symbols" interface which allows probing values in the modules of a design.

For the FIFO primitives, they appear to provide access to three things: the array of values in the FIFO, a "depth", and a "level":

% sim ls f.*
{f. {signal range(0:1)}} {f.depth signal} {f.level signal}

However, I think there's a bug in the implementation. I believe that depth is attempting to provide the configured depth of the FIFO (a constant value) and that level is the current number of elements (a dynamic value). What I observe is that depth returns the value of an invalid memory location! And level returns the static size. (The depth is defined as a pointer to a constructor argument, which is no longer a valid location after the constructor finishes.)

We can probably fix this by changing these two definitions in bsc/src/bluesim/bs_prim_mod_fifo.h (around line 73):

symbols[1].value = (void*)(&depth);
symbols[2].value = (void*)(&size);

to instead be:

symbols[1].value = (void*)(&size);
symbols[2].value = (void*)(&elems);

That is, depth should point to size (a local variable with constant value) and level should point to elems (a local variable that indicates the current number of elements).

Interactive mode is tested in bsc/testsuite/bsc.bluesim/interactive/ and there is a script prims.cmd for testing primitives, but it only tests that signals can be probed and not that they have the right dynamic values, so that would need to be added.

@quark17 quark17 added bug Something isn't working good first issue Good for newcomers bluesim Relates to Bluesim labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bluesim Relates to Bluesim bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant