fix: Failed to store the data collected on loop mode

This commit is contained in:
dreamsourcelabTAI
2023-06-17 10:48:01 +08:00
parent d37ece76de
commit b03a52e65a
3 changed files with 13 additions and 26 deletions
+10 -21
View File
@@ -1333,23 +1333,15 @@ bool LogicSnapshot::has_data(int sig_index)
int LogicSnapshot::get_block_num()
{
// return (_ring_sample_count >> LeafBlockPower) +
// ((_ring_sample_count & LeafMask) != 0);
int block = _ring_sample_count / LeafBlockSamples;
if (_ring_sample_count % LeafBlockSamples != 0){
block++;
}
if (_loop_offset % LeafBlockSamples != 0){
block++;
}
return block;
int block = ceil((_ring_sample_count+_loop_offset) * 1.0 / LeafBlockSamples)
- floor(_loop_offset * 1.0 / LeafBlockSamples);
return block;
}
uint64_t LogicSnapshot::get_block_size(int block_index)
{
int block_num = get_block_num();
uint64_t samples = 0;
assert(block_index < block_num);
@@ -1359,17 +1351,14 @@ uint64_t LogicSnapshot::get_block_size(int block_index)
return LeafBlockSamples / 8;
}
else if (block_index == 0){
if (_loop_offset % LeafBlockSamples == 0)
return LeafBlockSamples / 8;
else
return (LeafBlockSamples - _loop_offset % LeafBlockSamples) / 8;
samples = min(_ring_sample_count+_loop_offset,
(uint64_t)LeafBlockSamples) - (_loop_offset % (uint64_t)LeafBlockSamples);
return samples/8;
}
else{
uint64_t ring_sample_count = _ring_sample_count + _loop_offset;
if (ring_sample_count % LeafBlockSamples == 0)
return LeafBlockSamples / 8;
else
return (ring_sample_count % LeafBlockSamples) / 8;
samples = (_ring_sample_count + _loop_offset) - (_ring_sample_count + _loop_offset - 1)
/ LeafBlockSamples * LeafBlockSamples;
return samples/8;
}
}
else{
+1 -1
View File
@@ -144,7 +144,7 @@ public:
inline bool is_able_free(){
return _able_free;
}
}
private:
bool get_sample_unlock(uint64_t index, int sig_index);
+2 -4
View File
@@ -223,9 +223,8 @@ void StoreSession::save_logic(pv::data::LogicSnapshot *logic_snapshot)
to_save_probes++;
}
_unit_count = logic_snapshot->get_sample_count() / 8 * to_save_probes;
_unit_count = logic_snapshot->get_ring_sample_count() / 8 * to_save_probes;
num = logic_snapshot->get_block_num();
dsv_info("total bytes:%llu", _unit_count);
for(auto s : _session->get_signals())
{
@@ -265,8 +264,7 @@ void StoreSession::save_logic(pv::data::LogicSnapshot *logic_snapshot)
QFile::remove(_file_name);
return;
}
_units_stored += size;
dsv_info("read bytes:%llu, size:%llu,block:%d", _units_stored, size, i);
_units_stored += size;
if (need_malloc)
free(buf);