#pragma once

#include <cstdint>
#include <string>
#include <vector>

struct tb_cli_args {
	bool load_bin;
	std::string bin_path;
	bool dump_waves;
	std::string waves_path;
	std::vector<std::pair<uint32_t, uint32_t>> dump_ranges;
	int64_t max_cycles;
	bool propagate_return_code;
	uint16_t port;
	uint16_t vpi_port;
	uint16_t gdb_port;
	uint16_t uart0_port;
	uint16_t uart1_port;
	// JTAG_VPI socket polling backoff in core cycles (0 = poll every cycle).
	// When idle, the testbench ramps up to this maximum backoff to reduce
	// syscall overhead without adding huge latency between back-to-back packets.
	uint32_t vpi_poll_cycles;
	// When using --vpi-port, run N core clock cycles per JTAG TCK cycle during
	// OpenOCD TMS sequences (helps DMI/APB CDC make progress and avoids BUSY).
	// 0 disables this coupling (legacy behaviour).
	uint32_t vpi_clk_per_tck;
	bool dump_jtag;
	std::string jtag_dump_path;
	bool replay_jtag;
	std::string jtag_replay_path;
	std::string log_path;
	std::string sig_path;
#ifdef CXXRTL_DEBUG_AGENT
	bool run_agent;
#endif
	tb_cli_args() {
		load_bin = false;
		dump_waves = false;
		max_cycles = 0;
		propagate_return_code = false;
		port = 0;
		vpi_port = 0;
		gdb_port = 0;
		uart0_port = 0;
		uart1_port = 0;
		vpi_poll_cycles = 256;
		vpi_clk_per_tck = 2;
		dump_jtag = false;
		replay_jtag = false;
#ifdef CXXRTL_DEBUG_AGENT
		run_agent = false;
#endif
	}
};

void tb_parse_args(int argc, char **argv, tb_cli_args &args);
