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

Debug features for Rust + verilator #86

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Verilator simulations can be invoked from the repository root with
make verilate simv TEST=<name of test, e.g. 'uart_sanity'>
# Rust
make verilate simv RUST=1 TEST_DIR=examples/hello_rt TEST=<name of test, e.g. 'uart'>
# Rust (debug mode with software assertions)
make verilate simv RUST=1 DEBUG=1 TEST_DIR=examples/hello_rt TEST=<name of test, e.g. 'uart'>
```

This will clean and compile the design and the software test, then invoke the simulation.
Expand Down
6 changes: 6 additions & 0 deletions examples/atalanta_bsp/src/timer_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ impl Timer {
/// Set current timer counter value
#[inline]
pub fn set_counter(&mut self, cnt: u32) {
#[cfg(debug_assertions)]
{
// Counter must not be set to a value higher than compare
let cmp = read_u32p(unsafe { &mut (*self.0).cmp as *mut u32 });
debug_assert!(cnt <= cmp);
}
write_u32p(unsafe { &mut (*self.0).cnt as *mut u32 }, cnt)
}

Expand Down
6 changes: 5 additions & 1 deletion examples/hello_rt/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
ifndef DEBUG
MAYBE_RELEASE = --release
endif

# Build the entire program
.PHONY: $(TEST)
$(TEST):
cargo build --release -Frtl-tb --example $(TEST) $(CARGO_FLAGS)
cargo build $(MAYBE_RELEASE) -Frtl-tb --example $(TEST) $(CARGO_FLAGS)
6 changes: 5 additions & 1 deletion examples/periodic_tasks/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
ifndef DEBUG
MAYBE_RELEASE = --release
endif

# Build the entire program
.PHONY: $(TEST)
$(TEST):
cargo build --release -Frtl-tb --bin $(TEST) $(CARGO_FLAGS)
cargo build $(MAYBE_RELEASE) -Frtl-tb --bin $(TEST) $(CARGO_FLAGS)