Skip to content

Commit

Permalink
[xsi] util functions to read signals in C++ template
Browse files Browse the repository at this point in the history
  • Loading branch information
maltanar authored and auphelia committed Oct 29, 2024
1 parent 02f9c4b commit 2ae55c1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/finn/qnn-data/cpp/xsi_simdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ void populate_port_map() {
}
}

string read_signal_binstr(string name) {
int port_id = port_map[name];
int n_bits = top->get_int_property_port(port_id, xsiHDLValueSize);
size_t n_logicvals = roundup_int_div(n_bits, 32);
s_xsi_vlog_logicval *buf = new s_xsi_vlog_logicval[n_logicvals];
top->get_value(port_id, buf);
string ret = logic_val_to_string(buf, n_bits);
delete [] buf;
return ret;
}

unsigned int read_signal_uint(string name) {
return stoi(read_signal_binstr(name), 0, 2);
}

// set the 1-bit signal with given name to 1
void set_bool(string name) {
top->put_value(port_map[name], &one_val);
Expand Down

0 comments on commit 2ae55c1

Please sign in to comment.