Skip to content

Commit 20089f6

Browse files
committed
feat: add event trace visualization tools and enhance simulator with trace file support
1 parent a45c9c9 commit 20089f6

File tree

13 files changed

+915
-74
lines changed

13 files changed

+915
-74
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
target/
22
Cargo.lock
33
build/
4+
5+
.json

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ cargo build --release --bin bebop
2121
```
2222

2323
3. Run the simulation
24+
4.
2425
```
2526
cd bebop
2627
./target/release/bebop
28+
29+
# run in quiet with only workload logs
30+
cargo run --release --bin bebop -- -q
2731
```

bebop/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ path = "src/bin/bebop.rs"
1111
sim = "0.13"
1212
serde = { version = "1.0", features = ["derive"] }
1313
serde_json = "1.0"
14+
rustyline = "14.0"
15+
clap = { version = "4.5", features = ["derive"] }

bebop/src/bin/bebop.rs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
11
use bebop::simulator::sim::mode::{SimConfig, StepMode};
22
use bebop::simulator::Simulator;
3+
use clap::Parser;
34

4-
use std::env;
5+
/// Bebop - A RISC-V NPU simulator
6+
#[derive(Parser, Debug)]
7+
#[command(name = "bebop")]
8+
#[command(version = "0.1.0")]
9+
#[command(about = "Bebop simulator developed by buckyball", long_about = None)]
10+
struct Args {
11+
/// Enable step mode (interactive stepping)
12+
#[arg(short, long)]
13+
step: bool,
14+
15+
/// Quiet mode (suppress log messages)
16+
#[arg(short, long)]
17+
quiet: bool,
18+
19+
/// Output trace file path
20+
#[arg(long, value_name = "FILE")]
21+
trace_file: Option<String>,
22+
}
523

624
fn main() -> std::io::Result<()> {
7-
let args: Vec<String> = env::args().collect();
25+
let args = Args::parse();
826

9-
let step_mode = if args.iter().any(|arg| arg == "--step" || arg == "-s") {
27+
let step_mode = if args.step {
1028
StepMode::Step
1129
} else {
1230
StepMode::Continuous
1331
};
1432

15-
let quiet = args.iter().any(|arg| arg == "--quiet" || arg == "-q");
16-
17-
let config = SimConfig { quiet, step_mode };
33+
let config = SimConfig {
34+
quiet: args.quiet,
35+
step_mode,
36+
trace_file: args.trace_file,
37+
};
1838

1939
let mut simulator = Simulator::new(config)?;
2040
simulator.run()

bebop/src/buckyball/inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn inject_message(
2020
content: &str,
2121
) {
2222
let msg = Message::new(
23-
source_id.unwrap_or("default").to_string(),
23+
source_id.unwrap_or("host").to_string(),
2424
source_port.unwrap_or("default").to_string(),
2525
target_model.to_string(),
2626
target_port.unwrap_or("default").to_string(),

bebop/src/buckyball/tdma.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ impl DevsModel for Tdma {
198198
port_name: self.commit_to_rob_port.clone(),
199199
});
200200
self.all_bank_read_iter = 0; // Reset to avoid re-sending
201+
self.until_next_event = 1.0;
201202
has_work = true;
202203
}
203204

@@ -211,6 +212,7 @@ impl DevsModel for Tdma {
211212
port_name: self.commit_to_rob_port.clone(),
212213
});
213214
self.all_bank_write_iter = 0; // Reset to avoid re-sending
215+
self.until_next_event = 1.0;
214216
has_work = true;
215217
}
216218

bebop/src/prof/etrace/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Event Trace Visualization
2+
3+
Event trace visualization tools for the Bebop simulator. Analyzes JSON Lines trace files and generates interactive HTML visualizations.
4+
5+
**graph.py**: Generates an interactive network graph showing module connections and event statistics.
6+
**timeline.py**: Creates a timeline visualization displaying events for each module over time.
7+
8+
## Usage
9+
10+
```bash
11+
python graph.py trace.jsonl [output.html]
12+
python timeline.py trace.jsonl [output.html]
13+
```
14+
15+
Both tools read JSON Lines format and produce standalone HTML files viewable in any browser.

0 commit comments

Comments
 (0)