Added handler and configurability of wavefrom view

This commit is contained in:
eyck committed 2018-10-14 08:59:17 +02:00
1 parent 694423be3b
commit 6cc5597c25
12 files changed
+469 -175

No files matched your search

@@ -63,4 +63,49 @@ public class BitVector {
}
return new String(res);
}
public long toUnsignedValue() {
long res = 0;
for(char c:value) {
res<<=1;
switch (c) {
case VALUE_1:
res++;
break;
case VALUE_X:
case VALUE_Z:
return 0;
default:
break;
}
}
return res;
}
public long toSignedValue() {
Boolean negative=null;
long res = 0;
for(char c:value) {
if(negative == null) {
switch (c) {
case VALUE_1: negative=true; break;
case VALUE_0: negative=false; break;
case VALUE_X:
case VALUE_Z: return 0;
default:
}
} else {
res<<=1;
switch (c) {
case VALUE_1: if(!negative) res++; break;
case VALUE_0: if(negative) res++; break;
case VALUE_X:
case VALUE_Z: return 0;
default:
}
}
}
return negative?-1*(res+1):res;
}
}