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

VHDL2019 assert api - partial #748

Merged
merged 3 commits into from
Aug 4, 2023
Merged

Conversation

Blebowski
Copy link
Contributor

Add partial implementation of: LCS2016-050

Still need to look at tests, some are failing.

Escaped identifiers with leading underscores are used in std.env to minimize "exposure" of the
implementation specific function and shared variable (instead of e.g. assert_cnt).

@Blebowski Blebowski changed the title WIP: Vhdl assert api WIP: VHDL2019 assert api Jul 31, 2023
@nickg
Copy link
Owner

nickg commented Jul 31, 2023

This isn't the right way to implement it: the counters should be in C (e.g. in src/rt/stdenv.c) and incremented when x_assert_fail is called. The VHDL functions can then call into native code to read/clear the counters. Similar to how the directory and time functions in that file work.

@Blebowski
Copy link
Contributor Author

OK, I will give it some more work. So the counters will be incremented by x_assert_fail. To access the counters from std.env.body, I should then use the foreign function that then links agains the C implementation (similarly as in e.g. file_line)?

@Blebowski
Copy link
Contributor Author

OK, I see, similar to: ea457d5

@Blebowski Blebowski force-pushed the vhdl-assert-api branch 2 times, most recently from 180c20c to 9133c66 Compare August 2, 2023 17:12
@Blebowski
Copy link
Contributor Author

Now ready for review

lib/std.19/env-body.vhd Outdated Show resolved Hide resolved
begin
report "not implemented" severity failure;
return impl(warning) + impl(error) + impl(failure);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return impl(warning) + impl(error) + impl(failure);
return GetVhdlAssertCount(warning) + GetVhdlAssertCount(error) + GetVhdlAssertCount(failure);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit of these two changes besides reducing number of places in the code where
the run-time is called? Isn't it going to be slower (altough negligibly, but still) to execute when
the "wrapping" function is called first instead of directly the function that returns the counter?
Or will the optimizations take care of that?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overhead of the extra call is minimal and should be inlined anyway. This way avoid duplicating the symbol name / interface of the foreign function.

src/rt/structs.h Outdated Show resolved Hide resolved
src/rt/model.c Outdated Show resolved Hide resolved

assert (False) report "First warning" severity warning;

print_asrt_state;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to make the test self-checking and assert on the result of GetVhdlAssertCount, IsVhdlAssertFailed, etc. E.g.

assert GetVhdlAssertCount(warning) = 1;
assert IsVhdlAssertFailed;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true, but still the test needs to have "gold" report since the asserts are expected to fail. Return
code will not distinguish correct/incorrect

@Blebowski Blebowski changed the title WIP: VHDL2019 assert api VHDL2019 assert api - partial Aug 3, 2023
@nickg nickg merged commit d00d562 into nickg:master Aug 4, 2023
7 checks passed
@nickg
Copy link
Owner

nickg commented Aug 4, 2023

I added the format string part.

@Blebowski Blebowski deleted the vhdl-assert-api branch October 5, 2024 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants