diff --git a/DSView/pv/data/logicsnapshot.cpp b/DSView/pv/data/logicsnapshot.cpp index 123a3841..35025d39 100644 --- a/DSView/pv/data/logicsnapshot.cpp +++ b/DSView/pv/data/logicsnapshot.cpp @@ -54,7 +54,6 @@ LogicSnapshot::LogicSnapshot() : _channel_num = 0; _block_num = 0; _total_sample_count = 0; - _rootnode_size = 0; } LogicSnapshot::~LogicSnapshot() @@ -66,14 +65,13 @@ void LogicSnapshot::free_data() Snapshot::free_data(); for(auto& iter : _ch_data) { - for(RootNode *r : iter) { + for(auto& iter_rn : iter) { for (unsigned int k = 0; k < Scale; k++){ - if (r->lbp[k] != NULL) - free(r->lbp[k]); + if (iter_rn.lbp[k] != NULL) + free(iter_rn.lbp[k]); } - delete r; } - std::vector void_vector; + std::vector void_vector; iter.swap(void_vector); } _ch_data.clear(); @@ -88,13 +86,13 @@ void LogicSnapshot::init() void LogicSnapshot::init_all() { - _sample_count = 0; - _real_sample_count = 0; + _sample_count = 0; _ring_sample_count = 0; _block_num = 0; _byte_fraction = 0; _ch_fraction = 0; - _dest_wrt_ptr = NULL; + _src_ptr = NULL; + _dest_ptr = NULL; _data = NULL; _memory_failed = false; _last_ended = true; @@ -114,27 +112,24 @@ void LogicSnapshot::capture_ended() uint64_t block_index = _ring_sample_count / LeafBlockSamples; uint64_t block_offset = (_ring_sample_count % LeafBlockSamples) / Scale; - if (block_offset != 0) { uint64_t index0 = block_index / RootScale; uint64_t index1 = block_index % RootScale; int order = 0; - for(auto& iter : _ch_data) - { - RootNode *r = iter[index0]; - - if (r->lbp[index1] == NULL){ - r->lbp[index1] = malloc(LeafBlockSpace); - if (r->lbp[index1] == NULL){ + for(auto& iter : _ch_data) { + if (iter[index0].lbp[index1] == NULL){ + iter[index0].lbp[index1] = malloc(LeafBlockSpace); + if (iter[index0].lbp[index1] == NULL) + { _memory_failed = true; return; } - memset(r->lbp[index1], 0, LeafBlockSpace); + memset(iter[index0].lbp[index1], 0, LeafBlockSpace); } - const uint64_t *end_ptr = (uint64_t *)r->lbp[index1] + (LeafBlockSamples / Scale); - uint64_t *ptr = (uint64_t *)r->lbp[index1] + block_offset; + const uint64_t *end_ptr = (uint64_t *)iter[index0].lbp[index1] + (LeafBlockSamples / Scale); + uint64_t *ptr = (uint64_t *)iter[index0].lbp[index1] + block_offset; while (ptr < end_ptr) *ptr++ = 0; @@ -143,16 +138,14 @@ void LogicSnapshot::capture_ended() calc_mipmap(order, index0, index1, block_offset * Scale); // calc root of current block - if (*((uint64_t *)r->lbp[index1]) != 0) - r->value += 1ULL << index1; - - if (*((uint64_t *)r->lbp[index1] + LeafBlockSpace / sizeof(uint64_t) - 1) != 0) { - r->tog += 1ULL << index1; - } - else { + if (*((uint64_t *)iter[index0].lbp[index1]) != 0) + iter[index0].value += 1ULL << index1; + if (*((uint64_t *)iter[index0].lbp[index1] + LeafBlockSpace / sizeof(uint64_t) - 1) != 0) { + iter[index0].tog += 1ULL << index1; + } else { // trim leaf to free space - free(r->lbp[index1]); - r->lbp[index1] = NULL; + free(iter[index0].lbp[index1]); + iter[index0].lbp[index1] = NULL; } order++; @@ -186,31 +179,29 @@ void LogicSnapshot::first_payload(const sr_datafeed_logic &logic, uint64_t total _total_sample_count = total_sample_count; _channel_num = channel_num; - _rootnode_size = (_total_sample_count + RootNodeSamples - 1) / RootNodeSamples; + uint64_t rootnode_size = (_total_sample_count + RootNodeSamples - 1) / RootNodeSamples; for (const GSList *l = channels; l; l = l->next) { sr_channel *const probe = (sr_channel*)l->data; - if (probe->type == SR_CHANNEL_LOGIC && probe->enabled) { - std::vector root_vector; - - for (uint64_t j = 0; j < _rootnode_size; j++) { - class RootNode *r = new RootNode(); - r->tog = 0; - r->value = 0; - memset(r->lbp, 0, sizeof(r->lbp)); - root_vector.push_back(r); + std::vector root_vector; + for (uint64_t j = 0; j < rootnode_size; j++) { + struct RootNode rn; + rn.tog = 0; + rn.value = 0; + memset(rn.lbp, 0, sizeof(rn.lbp)); + root_vector.push_back(rn); } _ch_data.push_back(root_vector); - _ch_index.push_back(probe->index); //The channel data root node index. + _ch_index.push_back(probe->index); } } } else { for(auto& iter : _ch_data) { - for(RootNode *r : iter) { - r->tog = 0; - r->value = 0; + for(auto& iter_rn : iter) { + iter_rn.tog = 0; + iter_rn.value = 0; } } } @@ -250,61 +241,54 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic) if (_sample_count >= _total_sample_count) return; - void *src_data_ptr = logic.data; - uint64_t data_len = logic.length; - + _src_ptr = logic.data; + uint64_t len = logic.length; // samples not accurate, lead to a larger _sampole_count // _sample_count should be fixed in the last packet // so _total_sample_count must be align to LeafBlock - uint64_t sample_num = ceil(data_len * 8.0 / _channel_num); - - if (_sample_count + sample_num < _total_sample_count) - _sample_count += sample_num; - else + uint64_t samples = ceil(logic.length * 8.0 / _channel_num); + if (_sample_count + samples < _total_sample_count) { + _sample_count += samples; + } else { + //len = ceil((_total_sample_count - _sample_count) * _channel_num / 8.0); _sample_count = _total_sample_count; - - // malloc memory buffer. + } + while (_sample_count > _block_num * LeafBlockSamples) { uint8_t index0 = _block_num / RootScale; uint8_t index1 = _block_num % RootScale; - for(auto& iter : _ch_data) { - RootNode *r = iter[index0]; - if (r->lbp[index1] == NULL){ - r->lbp[index1] = malloc(LeafBlockSpace); + if (iter[index0].lbp[index1] == NULL){ + iter[index0].lbp[index1] = malloc(LeafBlockSpace); - if (r->lbp[index1] == NULL) { + if (iter[index0].lbp[index1] == NULL) { _memory_failed = true; - dsv_err("%s", "LogicSnapshot::append_cross_payload(), malloc failed."); return; } } - uint64_t *mipmap_ptr = (uint64_t *)r->lbp[index1] + (LeafBlockSamples / Scale); + uint64_t *mipmap_ptr = (uint64_t *)iter[index0].lbp[index1] + + (LeafBlockSamples / Scale); memset(mipmap_ptr, 0, LeafBlockSpace - (LeafBlockSamples / 8)); } _block_num++; } // bit align - while (((_ch_fraction != 0) || (_byte_fraction != 0)) && (data_len != 0)) { - uint8_t *dp_tmp = (uint8_t *)_dest_wrt_ptr; - uint8_t *sp_tmp = (uint8_t *)src_data_ptr; - - if (_dest_wrt_ptr == NULL){ - assert(false); - } + while (((_ch_fraction != 0) || (_byte_fraction != 0)) && (len != 0)) { + uint8_t *dp_tmp = (uint8_t *)_dest_ptr; + uint8_t *sp_tmp = (uint8_t *)_src_ptr; do { + //*(uint8_t *)_dest_ptr++ = *(uint8_t *)_src_ptr++; *dp_tmp++ = *sp_tmp++; _byte_fraction = (_byte_fraction + 1) % ScaleSize; - data_len--; - } - while ((_byte_fraction != 0) && (data_len != 0)); + len--; + } while ((_byte_fraction != 0) && (len != 0)); - _dest_wrt_ptr = dp_tmp; - src_data_ptr = sp_tmp; + _dest_ptr = dp_tmp; + _src_ptr = sp_tmp; if (_byte_fraction == 0) { const uint64_t index0 = _ring_sample_count / RootNodeSamples; @@ -312,12 +296,9 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic) const uint64_t offset = (_ring_sample_count % LeafBlockSamples) / Scale; _ch_fraction = (_ch_fraction + 1) % _channel_num; - if (_ch_fraction == 0) _ring_sample_count += Scale; - - RootNode *r = _ch_data[_ch_fraction][index0]; - _dest_wrt_ptr = (uint8_t *)r->lbp[index1] + (offset * ScaleSize); + _dest_ptr = (uint8_t *)_ch_data[_ch_fraction][index0].lbp[index1] + (offset * ScaleSize); } } @@ -326,46 +307,41 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic) assert(_ch_fraction == 0); assert(_byte_fraction == 0); assert(_ring_sample_count % Scale == 0); - uint64_t pre_index0 = _ring_sample_count / RootNodeSamples; uint64_t pre_index1 = (_ring_sample_count >> LeafBlockPower) % RootScale; uint64_t pre_offset = (_ring_sample_count % LeafBlockSamples) / Scale; uint64_t *src_ptr = NULL; uint64_t *dest_ptr; int order = 0; - const uint64_t align_size = data_len / _channel_num / ScaleSize; + const uint64_t align_size = len / ScaleSize / _channel_num; _ring_sample_count += align_size * Scale; + - for(auto& iter : _ch_data) - { + for(auto& iter : _ch_data) { uint64_t index0 = pre_index0; uint64_t index1 = pre_index1; - RootNode *r = iter[index0]; + src_ptr = (uint64_t *)_src_ptr + order; + _dest_ptr = iter[index0].lbp[index1]; + dest_ptr = (uint64_t *)_dest_ptr + pre_offset; - src_ptr = (uint64_t *)src_data_ptr + order; - _dest_wrt_ptr = r->lbp[index1]; - dest_ptr = (uint64_t *)_dest_wrt_ptr + pre_offset; - - while (src_ptr < (uint64_t *)src_data_ptr + (align_size * _channel_num)) { - *dest_ptr++ = *src_ptr; + while (src_ptr < (uint64_t *)_src_ptr + (align_size * _channel_num)) { + const uint64_t tmp_u64 = *src_ptr; + *dest_ptr++ = tmp_u64; src_ptr += _channel_num; - //mipmap - if (dest_ptr == (uint64_t *)_dest_wrt_ptr + (LeafBlockSamples / Scale)) { + if (dest_ptr == (uint64_t *)_dest_ptr + (LeafBlockSamples / Scale)) { // calc mipmap of current block calc_mipmap(order, index0, index1, LeafBlockSamples); // calc root of current block - if (*((uint64_t *)r->lbp[index1]) != 0) - r->value += 1ULL<< index1; - - if (*((uint64_t *)r->lbp[index1] + LeafBlockSpace / sizeof(uint64_t) - 1) != 0) { - r->tog += 1ULL << index1; - } - else { + if (*((uint64_t *)iter[index0].lbp[index1]) != 0) + iter[index0].value += 1ULL<< index1; + if (*((uint64_t *)iter[index0].lbp[index1] + LeafBlockSpace / sizeof(uint64_t) - 1) != 0) { + iter[index0].tog += 1ULL << index1; + } else { // trim leaf to free space - free(r->lbp[index1]); - r->lbp[index1] = NULL; + free(iter[index0].lbp[index1]); + iter[index0].lbp[index1] = NULL; } index1++; @@ -373,14 +349,14 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic) index0++; index1 = 0; } - _dest_wrt_ptr = r->lbp[index1]; - dest_ptr = (uint64_t *)_dest_wrt_ptr; + _dest_ptr = iter[index0].lbp[index1]; + dest_ptr = (uint64_t *)_dest_ptr; } } order++; } - data_len -= align_size * _channel_num * ScaleSize; - src_data_ptr = src_ptr - _channel_num + 1; + len -= align_size * _channel_num * ScaleSize; + _src_ptr = src_ptr - _channel_num + 1; } // fraction data append @@ -388,42 +364,36 @@ void LogicSnapshot::append_cross_payload(const sr_datafeed_logic &logic) uint64_t index0 = _ring_sample_count / RootNodeSamples; uint64_t index1 = (_ring_sample_count >> LeafBlockPower) % RootScale; uint64_t offset = (_ring_sample_count % LeafBlockSamples) / 8; - RootNode *r = _ch_data[_ch_fraction][index0]; - _dest_wrt_ptr = (uint8_t *)r->lbp[index1] + offset; + _dest_ptr = (uint8_t *)_ch_data[_ch_fraction][index0].lbp[index1] + offset; - uint8_t *dp_tmp = (uint8_t *)_dest_wrt_ptr; - uint8_t *sp_tmp = (uint8_t *)src_data_ptr; - - while(data_len-- != 0) { + uint8_t *dp_tmp = (uint8_t *)_dest_ptr; + uint8_t *sp_tmp = (uint8_t *)_src_ptr; + while(len-- != 0) { *dp_tmp++ = *sp_tmp++; - if (++_byte_fraction == ScaleSize) { _ch_fraction = (_ch_fraction + 1) % _channel_num; _byte_fraction = 0; - dp_tmp = (uint8_t *)r->lbp[index1] + offset; + dp_tmp = (uint8_t *)_ch_data[_ch_fraction][index0].lbp[index1] + offset; } } - _dest_wrt_ptr = dp_tmp + _byte_fraction; + _dest_ptr = dp_tmp + _byte_fraction; } - - _real_sample_count = _sample_count / RootNodeSamples * RootNodeSamples; } void LogicSnapshot::append_split_payload(const sr_datafeed_logic &logic) -{ +{ + assert(logic.format == LA_SPLIT_DATA); + uint64_t samples = logic.length * 8; uint16_t order = logic.order; - - assert(logic.format == LA_SPLIT_DATA); - assert(order < _ch_data.size()); + assert(order < _ch_data.size()); if (_sample_cnt[order] >= _total_sample_count) return; if (_sample_cnt[order] + samples < _total_sample_count) { _sample_cnt[order] += samples; - } - else { + } else { samples = _total_sample_count - _sample_cnt[order]; _sample_cnt[order] = _total_sample_count; } @@ -431,18 +401,18 @@ void LogicSnapshot::append_split_payload(const sr_datafeed_logic &logic) while (_sample_cnt[order] > _block_cnt[order] * LeafBlockSamples) { uint8_t index0 = _block_cnt[order] / RootScale; uint8_t index1 = _block_cnt[order] % RootScale; - RootNode *r = _ch_data[order][index0]; - if (r->lbp[index1] == NULL){ - r->lbp[index1] = malloc(LeafBlockSpace); - - if (r->lbp[index1] == NULL){ + if (_ch_data[order][index0].lbp[index1] == NULL) + { + _ch_data[order][index0].lbp[index1] = malloc(LeafBlockSpace); + if (_ch_data[order][index0].lbp[index1] == NULL) + { _memory_failed = true; return; } } - memset(r->lbp[index1], 0, LeafBlockSpace); + memset(_ch_data[order][index0].lbp[index1], 0, LeafBlockSpace); _block_cnt[order]++; } @@ -450,13 +420,11 @@ void LogicSnapshot::append_split_payload(const sr_datafeed_logic &logic) const uint64_t index0 = _ring_sample_cnt[order] / RootNodeSamples; const uint64_t index1 = (_ring_sample_cnt[order] >> LeafBlockPower) % RootScale; const uint64_t offset = (_ring_sample_cnt[order] % LeafBlockSamples) / 8; - RootNode *r = _ch_data[order][index0]; - - _dest_wrt_ptr = (uint8_t *)r->lbp[index1] + offset; + _dest_ptr = (uint8_t *)_ch_data[order][index0].lbp[index1] + offset; uint64_t bblank = (LeafBlockSamples - (_ring_sample_cnt[order] & LeafMask)); if (samples >= bblank) { - memcpy((uint8_t*)_dest_wrt_ptr, (uint8_t *)logic.data, bblank/8); + memcpy((uint8_t*)_dest_ptr, (uint8_t *)logic.data, bblank/8); _ring_sample_cnt[order] += bblank; samples -= bblank; @@ -464,20 +432,18 @@ void LogicSnapshot::append_split_payload(const sr_datafeed_logic &logic) calc_mipmap(order, index0, index1, LeafBlockSamples); // calc root of current block - if (*((uint64_t *)r->lbp[index1]) != 0) - r->value += 1ULL<< index1; - - if (*((uint64_t *)r->lbp[index1] + LeafBlockSpace / sizeof(uint64_t) - 1) != 0) { - r->tog += 1ULL << index1; - } - else { + if (*((uint64_t *)_ch_data[order][index0].lbp[index1]) != 0) + _ch_data[order][index0].value += 1ULL<< index1; + if (*((uint64_t *)_ch_data[order][index0].lbp[index1] + LeafBlockSpace / sizeof(uint64_t) - 1) != 0) { + _ch_data[order][index0].tog += 1ULL << index1; + + } else { // trim leaf to free space - free(r->lbp[index1]); - r->lbp[index1] = NULL; + free(_ch_data[order][index0].lbp[index1]); + _ch_data[order][index0].lbp[index1] = NULL; } - } - else { - memcpy((uint8_t*)_dest_wrt_ptr, (uint8_t *)logic.data, samples/8); + } else { + memcpy((uint8_t*)_dest_ptr, (uint8_t *)logic.data, samples/8); _ring_sample_cnt[order] += samples; samples = 0; } @@ -488,18 +454,16 @@ void LogicSnapshot::append_split_payload(const sr_datafeed_logic &logic) } void LogicSnapshot::calc_mipmap(unsigned int order, uint8_t index0, uint8_t index1, uint64_t samples) -{ +{ uint8_t offset; uint64_t *src_ptr; uint64_t *dest_ptr; unsigned int i; - RootNode *r = _ch_data[order][index0]; // level 1 - src_ptr = (uint64_t *)r->lbp[index1]; + src_ptr = (uint64_t *)_ch_data[order][index0].lbp[index1]; dest_ptr = src_ptr + (LeafBlockSamples / Scale) - 1; const uint64_t mask = 1ULL << (Scale - 1); - for(i = 0; i < samples / Scale; i++) { offset = i % Scale; if (offset == 0) @@ -510,9 +474,8 @@ void LogicSnapshot::calc_mipmap(unsigned int order, uint8_t index0, uint8_t inde } // level 2/3 - src_ptr = (uint64_t *)r->lbp[index1] + (LeafBlockSamples / Scale); + src_ptr = (uint64_t *)_ch_data[order][index0].lbp[index1] + (LeafBlockSamples / Scale); dest_ptr = src_ptr + (LeafBlockSamples / Scale / Scale) - 1; - for(i = LeafBlockSamples / Scale; i < LeafBlockSpace / sizeof(uint64_t) - 1; i++) { offset = i % Scale; if (offset == 0) @@ -534,24 +497,16 @@ const uint8_t *LogicSnapshot::get_samples(uint64_t start_sample, uint64_t &end_s uint64_t root_index = start_sample >> (LeafBlockPower + RootScalePower); uint8_t root_pos = (start_sample & RootMask) >> LeafBlockPower; uint64_t block_offset = (start_sample & LeafMask) / 8; - end_sample = (root_index << (LeafBlockPower + RootScalePower)) + (root_pos << LeafBlockPower) + ~(~0ULL << LeafBlockPower); - end_sample = min(end_sample + 1, get_sample_count()); - RootNode *r = NULL; - if (order >= 0){ - r = _ch_data[order][root_index]; - } - - if (r == NULL || r->lbp[root_pos] == NULL){ + if (order == -1 || + _ch_data[order][root_index].lbp[root_pos] == NULL) return NULL; - } - else{ - return (uint8_t *)r->lbp[root_pos] + block_offset; - } + else + return (uint8_t *)_ch_data[order][root_index].lbp[root_pos] + block_offset; } bool LogicSnapshot::get_sample(uint64_t index, int sig_index) @@ -565,17 +520,14 @@ bool LogicSnapshot::get_sample(uint64_t index, int sig_index) uint64_t root_index = index >> (LeafBlockPower + RootScalePower); uint8_t root_pos = (index & RootMask) >> LeafBlockPower; uint64_t root_pos_mask = 1ULL << root_pos; - RootNode *r = _ch_data[order][root_index]; - if ((r->tog & root_pos_mask) == 0) { - return (r->value & root_pos_mask) != 0; - } - else { - uint64_t *lbp = (uint64_t *)r->lbp[root_pos]; + if ((_ch_data[order][root_index].tog & root_pos_mask) == 0) { + return (_ch_data[order][root_index].value & root_pos_mask) != 0; + } else { + uint64_t *lbp = (uint64_t *)_ch_data[order][root_index].lbp[root_pos]; return *(lbp + ((index & LeafMask) >> ScalePower)) & index_mask; } - } - else { + } else { return false; } } @@ -604,7 +556,6 @@ bool LogicSnapshot::get_display_edges(std::vector > &edges // Get the initial state start_sample = last_sample = get_sample(index++, sig_index); togs.push_back(pair(0, last_sample)); - while(edges.size() < width) { // search next edge bool has_edge = get_nxt_edge(index, last_sample, end, 0, sig_index); @@ -612,10 +563,8 @@ bool LogicSnapshot::get_display_edges(std::vector > &edges // calc the edge position int64_t gap = (index / min_length) - pixels_offset; index = max((uint64_t)ceil((floor(index/min_length) + 1) * min_length), index + 1); - - while(gap > (int64_t)edges.size() && edges.size() < width){ + while(gap > (int64_t)edges.size() && edges.size() < width) edges.push_back(pair(false, last_sample)); - } if (index > end) last_sample = get_sample(end, sig_index); @@ -660,37 +609,28 @@ bool LogicSnapshot::get_nxt_edge( // linear search for the next transition on the root level for (int64_t i = root_index; !edge_hit && (index <= end) && i < (int64_t)_ch_data[order].size(); i++) { uint64_t cur_mask = (~0ULL << root_pos); - RootNode *r = _ch_data[order][i]; - do { - uint64_t cur_tog = r->tog & cur_mask; - + uint64_t cur_tog = _ch_data[order][i].tog & cur_mask; if (cur_tog != 0) { uint64_t first_edge_pos = bsf_folded(cur_tog); - uint64_t *lbp = (uint64_t *)r->lbp[first_edge_pos]; + uint64_t *lbp = (uint64_t *)_ch_data[order][i].lbp[first_edge_pos]; uint64_t blk_start = (i << (LeafBlockPower + RootScalePower)) + (first_edge_pos << LeafBlockPower); index = max(blk_start, index); - if (min_level < ScaleLevel) { uint64_t block_end = min(index | LeafMask, end); edge_hit = block_nxt_edge(lbp, index, block_end, last_sample, min_level); - } - else { + } else { edge_hit = true; } - if (first_edge_pos == RootScale - 1) break; cur_mask = (~0ULL << (first_edge_pos + 1)); - } - else { + } else { index = (index + (1 << (LeafBlockPower + RootScalePower))) & (~0ULL << (LeafBlockPower + RootScalePower)); break; } - } - while (!edge_hit && index < end); - + } while (!edge_hit && index < end); root_pos = 0; } return edge_hit; @@ -714,34 +654,26 @@ bool LogicSnapshot::get_pre_edge(uint64_t &index, bool last_sample, // linear search for the previous transition on the root level for (int64_t i = root_index; !edge_hit && i >= 0; i--) { uint64_t cur_mask = (~0ULL >> (RootScale - root_pos - 1)); - RootNode *r = _ch_data[order][i]; - do { - uint64_t cur_tog = r->tog & cur_mask; - + uint64_t cur_tog = _ch_data[order][i].tog & cur_mask; if (cur_tog != 0) { uint64_t first_edge_pos = bsr64(cur_tog); - uint64_t *lbp = (uint64_t *)r->lbp[first_edge_pos]; + uint64_t *lbp = (uint64_t *)_ch_data[order][i].lbp[first_edge_pos]; uint64_t blk_end = ((i << (LeafBlockPower + RootScalePower)) + (first_edge_pos << LeafBlockPower)) | LeafMask; index = min(blk_end, index); - if (min_level < ScaleLevel) { edge_hit = block_pre_edge(lbp, index, last_sample, min_level, sig_index); - } - else { + } else { edge_hit = true; } if (first_edge_pos == 0) break; cur_mask = (~0ULL >> (RootScale - first_edge_pos)); - } - else { + } else { break; } - } - while (!edge_hit); - + } while (!edge_hit); root_pos = RootScale - 1; } @@ -766,12 +698,10 @@ bool LogicSnapshot::block_nxt_edge(uint64_t *lbp, uint64_t &index, uint64_t bloc if (sample ^ last) { index = (index & ~LevelMask[0]) + bsf_folded(last_sample ? ~sample : sample); fast_forward = false; - } - else { + } else { index = ((index >> ScalePower) + 1) << ScalePower; } - } - else { + } else { index = ((index >> level*ScalePower) + 1) << level*ScalePower; } @@ -1079,12 +1009,11 @@ uint8_t *LogicSnapshot::get_block_buf(int block_index, int sig_index, bool &samp return NULL; } uint64_t index = block_index / RootScale; - RootNode *r = _ch_data[order][index]; uint8_t pos = block_index % RootScale; - uint8_t *lbp = (uint8_t *)r->lbp[pos]; + uint8_t *lbp = (uint8_t *)_ch_data[order][index].lbp[pos]; if (lbp == NULL) - sample = (r->value & 1ULL << pos) != 0; + sample = (_ch_data[order][index].value & 1ULL << pos) != 0; return lbp; } diff --git a/DSView/pv/data/logicsnapshot.h b/DSView/pv/data/logicsnapshot.h index 7a637348..1e1abdca 100644 --- a/DSView/pv/data/logicsnapshot.h +++ b/DSView/pv/data/logicsnapshot.h @@ -66,9 +66,9 @@ private: static const uint64_t LevelMask[ScaleLevel]; static const uint64_t LevelOffset[ScaleLevel]; - class RootNode +private: + struct RootNode { -public: uint64_t tog; uint64_t value; void *lbp[Scale]; @@ -186,17 +186,17 @@ private: } private: - std::vector> _ch_data; + std::vector> _ch_data; uint64_t _block_num; uint8_t _byte_fraction; uint16_t _ch_fraction; - void *_dest_wrt_ptr; + void *_src_ptr; + void *_dest_ptr; uint64_t _sample_cnt[LOGIC_TMP_BUF_MAX_SIZE]; uint64_t _block_cnt[LOGIC_TMP_BUF_MAX_SIZE]; uint64_t _ring_sample_cnt[LOGIC_TMP_BUF_MAX_SIZE]; uint64_t _last_sample[LOGIC_TMP_BUF_MAX_SIZE]; - uint64_t _rootnode_size; friend class LogicSnapshotTest::Pow2; friend class LogicSnapshotTest::Basic;