Skip to content

Commit

Permalink
fix intel#129, waveform dump dump bug for multi-bit values
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorbel1 committed Jun 6, 2022
1 parent 67ecc38 commit 97224f5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/src/wave_dumper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ class WaveDumper {
void _writeSignalValueUpdate(Logic signal) {
var updateValue = signal.width > 1
? 'b' +
signal.value.reversed.toList().map((e) => e.toString()).join() +
signal.value.reversed
.toList()
.map((e) => e.toString(includeWidth: false))
.join() +
' '
: signal.value.toString(includeWidth: false);
var marker = _signalToMarkerMap[signal];
Expand Down
50 changes: 48 additions & 2 deletions test/wave_dumper_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import 'package:test/test.dart';

class SimpleModule extends Module {
SimpleModule(Logic a) {
a = addInput('a', a);
addOutput('b') <= ~a;
a = addInput('a', a, width: a.width);
addOutput('b', width: a.width) <= ~a;
}
}

Expand Down Expand Up @@ -194,4 +194,50 @@ void main() {

deleteTemporaryDump(dumpName);
});

test('multi-bit value', () async {
var a = Logic(name: 'a', width: 8);
var mod = SimpleModule(a);
await mod.build();

var dumpName = 'multiBit';

createTemporaryDump(mod, dumpName);
a.inject(0x5a);

Simulator.registerAction(10, () => a.put(0xa5));
await Simulator.run();

var vcdContents = File(temporaryDumpPath(dumpName)).readAsStringSync();

expect(confirmValue(vcdContents, 'a', 0, LogicValue.ofInt(0x5a, 8)),
equals(true));
expect(confirmValue(vcdContents, 'a', 10, LogicValue.ofInt(0xa5, 8)),
equals(true));

deleteTemporaryDump(dumpName);
});

test('multi-bit value mixed invalid', () async {
var a = Logic(name: 'a', width: 8);
var mod = SimpleModule(a);
await mod.build();

var dumpName = 'multiBitInvalid';

createTemporaryDump(mod, dumpName);
a.inject(LogicValue.ofString('01xzzx10'));

Simulator.registerAction(10, () => a.put(LogicValue.ofString('0x0x1z1z')));
await Simulator.run();

var vcdContents = File(temporaryDumpPath(dumpName)).readAsStringSync();

expect(confirmValue(vcdContents, 'a', 0, LogicValue.ofString('01xzzx10')),
equals(true));
expect(confirmValue(vcdContents, 'a', 10, LogicValue.ofString('0x0x1z1z')),
equals(true));

deleteTemporaryDump(dumpName);
});
}

0 comments on commit 97224f5

Please sign in to comment.