Skip to content

Commit

Permalink
adds documentation of cbor format and extends recorded relation info
Browse files Browse the repository at this point in the history
  • Loading branch information
eyck committed Mar 18, 2023
1 parent 4eb589b commit e510457
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
33 changes: 22 additions & 11 deletions src/sysc/scc/scv/cbor.h
Expand Up @@ -287,12 +287,14 @@ struct relations {
dictionary& dict;
relations(dictionary& dict):dict(dict){}

inline void add_relation(std::string const& name, uint64_t from, uint64_t to) {
inline void add_relation(std::string const& name, unsigned from_stream, uint64_t from, unsigned to_stream, uint64_t to) {
if(enc.is_empty()) enc.start_array();
enc.start_array(3);
enc.start_array(5);
enc.write(dict.get_key(name));
enc.write(from);
enc.write(to);
enc.write(from_stream);
enc.write(to_stream);
}

template<bool COMPRESSED>
Expand Down Expand Up @@ -425,17 +427,17 @@ struct tx_block {
* array(*) of either
* cbor tag(16)
* array(3)
* unsinged - id
* unsinged - name (id of string)
* unsinged - kind (id of string)
* unsigned - id
* unsigned - name (id of string)
* unsigned - kind (id of string)
* cbor tag(17)
* array(3)
* unsinged - id
* unsinged - name (id of string)
* unsinged - kind (id of string)
* unsigned - id
* unsigned - name (id of string)
* unsigned - kind (id of string)
* - chunk of type 3
* array(*) - list of transactions
* array() - transaction with pro12perties:
* array() - transaction with properties:
* cbor tag(6) - time stamps
* array(4)
* unsigned - id
Expand All @@ -457,6 +459,15 @@ struct tx_block {
* unsigned - name (id of string)
* unsigned - data_type
* [signed, unsigned, double] - value (depending of type)
* - chunk of type 4
* array(*) - list of relations
* array(5) - relation:
* unsigned - name (id of string)
* uint64_t - source tx id
* uint64_t - sink tx id
* unsigned - source stream id
* unsigned - sink stream id
*
*/
enum class event_type { BEGIN, RECORD, END };
enum class data_type {
Expand Down Expand Up @@ -563,8 +574,8 @@ struct chunked_writer {
txs[id]->add_attribute(static_cast<uint64_t>(event), dict.get_key(name), static_cast<uint64_t>(type), value);
}

inline void writeRelation(const std::string& name, uint64_t sink_id, uint64_t src_id) {
rel.add_relation(name, src_id, sink_id);
inline void writeRelation(const std::string& name, uint64_t sink_stream_id, uint64_t sink_tx_id, uint64_t src_stream_id, uint64_t src_tx_id) {
rel.add_relation(name, src_stream_id, src_tx_id, sink_stream_id, sink_tx_id);
if(rel.size()>MAX_REL_SIZE){
rel.flush(cw);
}
Expand Down
10 changes: 5 additions & 5 deletions src/sysc/scc/scv/scv_tr_ftr.cpp
Expand Up @@ -241,13 +241,13 @@ struct tx_db {
// ----------------------------------------------------------------------------
static void relationCb(const scv_tr_handle& tr_1, const scv_tr_handle& tr_2, void* data,
scv_tr_relation_handle_t relation_handle) {
if(!db ||
!tr_1.get_scv_tr_stream().get_scv_tr_db() ||
!tr_1.get_scv_tr_stream().get_scv_tr_db()->get_recording())
auto& stream1 = tr_1.get_scv_tr_stream();
auto txdb = stream1.get_scv_tr_db();
if(!db || !txdb || !txdb->get_recording())
return;
try {
db->writeRelation(tr_1.get_scv_tr_stream().get_scv_tr_db()->get_relation_name(relation_handle), tr_1.get_id(),
tr_2.get_id());
auto& stream2 = tr_2.get_scv_tr_stream();
db->writeRelation(txdb->get_relation_name(relation_handle), stream1.get_id(), tr_1.get_id(), stream2.get_id(), tr_2.get_id());
} catch(std::runtime_error& e) {
_scv_message::message(_scv_message::TRANSACTION_RECORDING_INTERNAL, "Can't create transaction relation");
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/lwtr4sc

0 comments on commit e510457

Please sign in to comment.