Added handler and configurability of wavefrom view

This commit is contained in:
2018-10-14 08:59:17 +02:00
parent 694423be3b
commit 6cc5597c25
12 changed files with 469 additions and 175 deletions

View File

@ -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;
}
}