Merge branch 'feature/real_signal_support' into develop

This commit is contained in:
Eyck Jentzsch 2018-10-11 14:53:07 +02:00
commit c4b16338a8
16 changed files with 351 additions and 129 deletions

View File

@ -45,6 +45,7 @@ $var wire 1 aaabd s_gpio_29 $end
$var wire 1 aaabe s_gpio_30 $end
$var wire 1 aaabf s_gpio_31 $end
$var wire 1 aaabg s_rst_n $end
$var real 1 bbbbb a_real $end
$scope module i_platform $end
$var wire 1 aaabh erst_n $end
$var wire 64 aabdc s_tlclk [63:0] $end
@ -1621,6 +1622,7 @@ b1110100011010100101001010 aabdd
0aabdv
0aabdw
0aabdx
r0.0 bbbbb
$end
#10000
@ -1641,6 +1643,7 @@ $end
#1287121272
b1000000000100000000000000000100 aabcr
r1.0 bbbbb
#1288121272
b111111110100111110 aaabi
@ -1656,33 +1659,43 @@ b11000000000100000000000000000100 aabcr
b111111110100111110 aabcw
b101010 aabdb
b111111110100111110 aabdc
r2.0 bbbbb
#1303801016
b1000 aaacx
r3.0 bbbbb
#1311382718
b100000000 aabcu
r2.0 bbbbb
#1312689908
b1000000010111110001 aabct
r1.0 bbbbb
#1315304288
b10000000000000000000010111110001 aabct
r0.0 bbbbb
#1317395792
b101011 aabdb
r-1.0 bbbbb
#1345892534
b101100 aabdb
r-2.0 bbbbb
#1375173590
b101101 aabdb
r-3.0 bbbbb
#1404454646
b101110 aabdb
r-2.0 bbbbb
#1437918710
b101111 aabdb
r-1.0 bbbbb
#1443670346
b11111111010100 aaabi
@ -1697,6 +1710,7 @@ b11111111010100 aabac
b10000000000000010000010111110001 aabct
b11111111010100 aabcw
b11111111010100 aabdc
r0.0 bbbbb
#1444438324
1aaaar

View File

@ -92,7 +92,7 @@ public class DatabaseServicesTest {
assertTrue(f.exists());
waveformDb.load(f);
assertNotNull(waveformDb);
assertEquals(778, waveformDb.getAllWaves().size());
assertEquals(779, waveformDb.getAllWaves().size());
assertEquals(1, waveformDb.getChildNodes().size());
}

View File

@ -11,6 +11,8 @@
package com.minres.scviewer.database.swt.internal;
import java.util.Map.Entry;
import java.util.Collection;
import java.util.Map;
import java.util.NavigableMap;
import javax.swing.JPanel;
@ -24,8 +26,9 @@ import org.eclipse.swt.graphics.Rectangle;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.ISignalChangeMulti;
import com.minres.scviewer.database.ISignalChangeSingle;
import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.ISignalChangeReal;
import com.minres.scviewer.database.ISignalChangeBit;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.database.ui.WaveformColors;
@ -107,7 +110,6 @@ public class SignalPainter extends TrackPainter {
NavigableMap<Long, ? extends ISignalChange> entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true);
SignalChange left = new SignalChange(first);
SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first);
SignalStencil stencil = left.value instanceof ISignalChangeSingle ? new SingleBitStencil() : new MultiBitStencil(gc);
maxX = area.x + area.width;
yOffsetT = this.waveCanvas.getTrackHeight() / 5 + area.y;
@ -132,6 +134,7 @@ public class SignalPainter extends TrackPainter {
xEnd = getXEnd(right.time);
}
SignalStencil stencil = getStencil(gc, left, entries);
do {
stencil.draw(gc, area, left.value, right.value, xBegin, xEnd, multiple);
if (right.time >= endTime)
@ -150,6 +153,17 @@ public class SignalPainter extends TrackPainter {
} while (left.time < endTime);
}
private SignalStencil getStencil(GC gc, SignalChange left, NavigableMap<Long, ? extends ISignalChange> entries) {
if(left.value instanceof ISignalChangeBit)
return new SingleBitStencil();
else if (left.value instanceof ISignalChangeBitVector)
return new MultiBitStencil(gc);
else if (left.value instanceof ISignalChangeReal)
return new RealStencil(entries, left.value);
else
return null;
}
private interface SignalStencil {
public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple);
@ -168,7 +182,7 @@ public class SignalPainter extends TrackPainter {
public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) {
Color colorBorder = waveCanvas.colors[WaveformColors.SIGNAL0.ordinal()];
ISignalChangeMulti last = (ISignalChangeMulti) left;
ISignalChangeBitVector last = (ISignalChangeBitVector) left;
if (last.getValue().toString().contains("X")) {
colorBorder = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()];
} else if (last.getValue().toString().contains("Z")) {
@ -216,11 +230,12 @@ public class SignalPainter extends TrackPainter {
if (multiple) {
gc.setForeground(waveCanvas.colors[WaveformColors.SIGNALU.ordinal()]);
gc.drawLine(xBegin, yOffsetT, xBegin, yOffsetB);
gc.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
if(xEnd>xBegin)
gc.drawLine(xEnd, yOffsetT, xEnd, yOffsetB);
} else {
Color color = waveCanvas.colors[WaveformColors.SIGNALX.ordinal()];
int yOffset = yOffsetM;
switch (((ISignalChangeSingle) left).getValue()) {
switch (((ISignalChangeBit) left).getValue()) {
case '1':
color = waveCanvas.colors[WaveformColors.SIGNAL1.ordinal()];
yOffset = yOffsetT;
@ -240,7 +255,7 @@ public class SignalPainter extends TrackPainter {
} else {
gc.drawLine(xBegin, yOffset, xEnd, yOffset);
int yNext = yOffsetM;
switch (((ISignalChangeSingle) right).getValue()) {
switch (((ISignalChangeBit) right).getValue()) {
case '1':
yNext = yOffsetT;
break;
@ -257,6 +272,61 @@ public class SignalPainter extends TrackPainter {
}
private class RealStencil implements SignalStencil {
double minVal, range;
final double scaleFactor = 1.05;
boolean stepWise=true;
@SuppressWarnings("unchecked")
public RealStencil(NavigableMap<Long, ? extends ISignalChange> entries, ISignalChange left) {
Collection<ISignalChangeReal> values = ((NavigableMap<Long, ISignalChangeReal>) entries).values();
minVal=((ISignalChangeReal) left).getValue();
range=2.0;
if(!values.isEmpty()) {
double maxVal=minVal;
for(ISignalChangeReal v:values) {
minVal=Math.min(minVal, v.getValue());
maxVal=Math.max(maxVal, v.getValue());
}
range = (maxVal-minVal)*scaleFactor;
double avg = (maxVal+minVal)/2.0;
minVal=avg-(avg-minVal)*scaleFactor;
}
}
public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) {
double leftVal = ((ISignalChangeReal) left).getValue();
double rightVal= ((ISignalChangeReal) right).getValue();
// if (multiple) {
// gc.setForeground(waveCanvas.colors[WaveformColors.SIGNALX.ordinal()]);
// } else {
gc.setForeground(waveCanvas.colors[WaveformColors.SIGNAL_REAL.ordinal()]);
// }
int yOffsetLeft = (int) ((leftVal-minVal) / range * (yOffsetB-yOffsetT));
int yOffsetRight = (int) ((rightVal-minVal) / range * (yOffsetB-yOffsetT));
if(stepWise) {
if (xEnd > maxX) {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxX, yOffsetB-yOffsetLeft);
} else {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetLeft);
if(yOffsetRight!=yOffsetLeft) {
gc.drawLine(xEnd, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetRight);
}
}
} else {
if (xEnd > maxX) {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxX, yOffsetB-yOffsetRight);
} else {
gc.drawLine(xBegin, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetRight);
}
}
}
}
public ISignal<? extends ISignalChange> getSignal() {
return signal;
}

View File

@ -126,6 +126,30 @@ public class WaveformCanvas extends Canvas {
painterList.add(marker);
cursorPainters.add(marker);
wave2painterMap=new HashMap<>();
// fall back initialization
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.SIGNAL_REAL.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
}
public void addCursoPainter(CursorPainter cursorPainter){
@ -137,33 +161,10 @@ public class WaveformCanvas extends Canvas {
Display d = getDisplay();
if (colourMap != null) {
for (WaveformColors c : WaveformColors.values()) {
if (colourMap.containsKey(c)) {
if (colourMap.containsKey(c))
colors[c.ordinal()] = new Color(d, colourMap.get(c));
}
}
redraw();
} else {
colors[WaveformColors.LINE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.LINE_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_CYAN);
colors[WaveformColors.TRACK_BG_EVEN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_BLACK);
colors[WaveformColors.TRACK_BG_ODD.ordinal()] = SWTResourceManager.getColor(40, 40, 40);
colors[WaveformColors.TRACK_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(40, 40, 80);
colors[WaveformColors.TX_BG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN);
colors[WaveformColors.TX_BG_HIGHLITE.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[WaveformColors.TX_BORDER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.SIGNAL0.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[WaveformColors.SIGNAL1.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51);
colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW);
colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED);
colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY);
colors[WaveformColors.CURSOR_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.MARKER.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
colors[WaveformColors.MARKER_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE);
colors[WaveformColors.REL_ARROW.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_MAGENTA);
colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255);
}
}

View File

@ -13,6 +13,7 @@ package com.minres.scviewer.database.swt.internal;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@ -71,8 +72,9 @@ import org.eclipse.wb.swt.SWTResourceManager;
import com.google.common.collect.Lists;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.ISignalChangeMulti;
import com.minres.scviewer.database.ISignalChangeSingle;
import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.ISignalChangeReal;
import com.minres.scviewer.database.ISignalChangeBit;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxRelation;
@ -102,11 +104,11 @@ public class WaveformViewer implements IWaveformViewer {
private Control namePaneHeader;
private Canvas nameList;
final private Canvas nameList;
private Canvas valueList;
final private Canvas valueList;
WaveformCanvas waveformCanvas;
final WaveformCanvas waveformCanvas;
private Composite top;
@ -125,12 +127,11 @@ public class WaveformViewer implements IWaveformViewer {
protected MouseListener nameValueMouseListener = new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
if ((e.button == 1 || e.button == 3)) {
if (e.button == 1) {
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
if (entry != null)
setSelection(new StructuredSelection(entry.getValue()));
}
if (e.button == 3) {
} else if (e.button == 3) {
Menu topMenu= top.getMenu();
if(topMenu!=null) topMenu.setVisible(true);
}
@ -171,7 +172,7 @@ public class WaveformViewer implements IWaveformViewer {
}
});
}
}else if (e.button == 2) {
}else if (e.button == 2) {
setMarkerTime(snapOffsetToEvent(e), selectedMarker);
e.widget.getDisplay().asyncExec(new Runnable() {
@Override
@ -273,9 +274,11 @@ public class WaveformViewer implements IWaveformViewer {
nameList.addListener(SWT.Paint, new Listener() {
@Override
public void handleEvent(Event event) {
GC gc = event.gc;
Rectangle rect = ((Canvas) event.widget).getClientArea();
paintNames(gc, rect);
if(!trackVerticalOffset.isEmpty()) {
GC gc = event.gc;
Rectangle rect = ((Canvas) event.widget).getClientArea();
paintNames(gc, rect);
}
}
});
nameList.addMouseListener(nameValueMouseListener);
@ -305,9 +308,11 @@ public class WaveformViewer implements IWaveformViewer {
valueList.addListener(SWT.Paint, new Listener() {
@Override
public void handleEvent(Event event) {
GC gc = event.gc;
Rectangle rect = ((Canvas) event.widget).getClientArea();
paintValues(gc, rect);
if(!trackVerticalOffset.isEmpty()) {
GC gc = event.gc;
Rectangle rect = ((Canvas) event.widget).getClientArea();
paintValues(gc, rect);
}
}
});
valueList.addMouseListener(nameValueMouseListener);
@ -454,10 +459,16 @@ public class WaveformViewer implements IWaveformViewer {
for(Entry<IWaveform<? extends IWaveformEvent>, String> entry:actualValues.entrySet()){
if(entry.getKey() instanceof ISignal){
ISignalChange event = ((ISignal<?>)entry.getKey()).getWaveformEventsBeforeTime(time);
if(event instanceof ISignalChangeSingle){
entry.setValue("b'"+((ISignalChangeSingle)event).getValue());
} else if(event instanceof ISignalChangeMulti){
entry.setValue("h'"+((ISignalChangeMulti)event).getValue().toHexString());
if(event instanceof ISignalChangeBit){
entry.setValue("b'"+((ISignalChangeBit)event).getValue());
} else if(event instanceof ISignalChangeBitVector){
entry.setValue("h'"+((ISignalChangeBitVector)event).getValue().toHexString());
} else if(event instanceof ISignalChangeReal){
double val = ((ISignalChangeReal)event).getValue();
if(val>0.001)
entry.setValue(String.format("%1$,.3f", val));
else
entry.setValue(Double.toString(val));
}
} else if(entry.getKey() instanceof ITxStream<?>){
ITxStream<?> stream = (ITxStream<?>) entry.getKey();
@ -551,9 +562,10 @@ public class WaveformViewer implements IWaveformViewer {
public ISelection getSelection() {
if (currentTxSelection != null)
return new StructuredSelection(currentTxSelection);
else if (currentWaveformSelection != null)
return new StructuredSelection(currentWaveformSelection.waveform);
else
else if (currentWaveformSelection != null) {
Object[] elem = {currentWaveformSelection.waveform, currentWaveformSelection};
return new StructuredSelection(elem);
} else
return new StructuredSelection();
}
@ -738,6 +750,7 @@ public class WaveformViewer implements IWaveformViewer {
setCursorTime(time);
waveformCanvas.reveal(time);
waveformCanvas.redraw();
updateValueList();
}
}

View File

@ -14,7 +14,7 @@ public enum WaveformColors {
LINE, LINE_HIGHLITE,
TRACK_BG_EVEN, TRACK_BG_ODD, TRACK_BG_HIGHLITE,
TX_BG, TX_BG_HIGHLITE, TX_BORDER,
SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT,
SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT, SIGNAL_REAL,
CURSOR, CURSOR_DRAG, CURSOR_TEXT,
MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE
}

View File

@ -34,26 +34,44 @@ public interface IVCDDatabaseBuilder {
*
* @param netName the net name
* @param i the index of the net, -1 if a new one, otherwise the id if the referenced
* @param width the width
* @return the integer
* @param width the width, -1 equals real, 0... is a bit vector
* @return the net id
*/
public Integer newNet(String netName, int i, int width) ;
/**
* Gets the net width.
*
* @param intValue the int value
* @return the net width
* @param intValue the net id
* @return the net width, -1 means a real-valued net
*/
public int getNetWidth(int intValue);
public int getNetWidth(int netId);
/**
* Append transition.
*
* @param signalId the int value
* @param netId the int value
* @param currentTime the current time in ps
* @param decodedValues the decoded values
*/
public void appendTransition(int signalId, long currentTime, BitVector decodedValues);
public void appendTransition(int netId, long currentTime, char decodedValue);
/**
* Append transition.
*
* @param netId the int value
* @param currentTime the current time in ps
* @param decodedValues the decoded values
*/
public void appendTransition(int netId, long currentTime, BitVector decodedValue);
/**
* Append transition.
*
* @param netId the int value
* @param currentTime the current time in ps
* @param decodedValue the decoded values
*/
public void appendTransition(int netId, long currentTime, double decodedValue);
}

View File

@ -15,6 +15,7 @@ import java.io.FileInputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.NavigableMap;
import java.util.Stack;
import java.util.TreeMap;
import java.util.Vector;
@ -22,8 +23,9 @@ import java.util.Vector;
import com.minres.scviewer.database.BitVector;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.ISignalChangeMulti;
import com.minres.scviewer.database.ISignalChangeSingle;
import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.ISignalChangeReal;
import com.minres.scviewer.database.ISignalChangeBit;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbLoader;
@ -83,20 +85,25 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
moduleStack=null;
if(!res) throw new InputFormatException();
// calculate max time of database
for(IWaveform<? extends IWaveformEvent> waveform:signals)
maxTime= Math.max(maxTime, ((ISignal<? extends ISignalChange>)waveform).getEvents().lastKey());
for(IWaveform<? extends IWaveformEvent> waveform:signals) {
NavigableMap<Long, ? extends ISignalChange> events =((ISignal<? extends ISignalChange>)waveform).getEvents();
if(events.size()>0)
maxTime= Math.max(maxTime, events.lastKey());
}
// extend signals to hav a last value set at max time
for(IWaveform<? extends IWaveformEvent> waveform:signals){
TreeMap<Long,? extends ISignalChange> events = ((VCDSignal<? extends ISignalChange>)waveform).values;
if(events.lastKey()<maxTime){
if(events.size()>0 && events.lastKey()<maxTime){
ISignalChange x = events.lastEntry().getValue();
if(x instanceof ISignalChangeSingle)
((VCDSignal<ISignalChangeSingle>)waveform).values.put(maxTime,
new VCDSignalChangeSingle(maxTime, ((ISignalChangeSingle)x).getValue()));
else
if(x instanceof ISignalChangeMulti)
((VCDSignal<ISignalChangeMulti>)waveform).values.put(maxTime,
new VCDSignalChangeMulti(maxTime, ((ISignalChangeMulti)x).getValue()));
if(x instanceof ISignalChangeBit)
((VCDSignal<ISignalChangeBit>)waveform).values.put(maxTime,
new VCDSignalChangeBit(maxTime, ((ISignalChangeBit)x).getValue()));
else if(x instanceof ISignalChangeBitVector)
((VCDSignal<ISignalChangeBitVector>)waveform).values.put(maxTime,
new VCDSignalChangeBitVector(maxTime, ((ISignalChangeBitVector)x).getValue()));
else if(x instanceof ISignalChangeReal)
((VCDSignal<ISignalChangeReal>)waveform).values.put(maxTime,
new VCDSignalChangeReal(maxTime, ((ISignalChangeReal)x).getValue()));
}
}
return true;
@ -147,12 +154,15 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
String netName = moduleStack.empty()? name: moduleStack.lastElement()+"."+name;
int id = signals.size();
VCDSignal<? extends IWaveformEvent> signal;
if(width==1){
signal = i<0 ? new VCDSignal<ISignalChangeSingle>(db, id, netName) :
new VCDSignal<ISignalChangeSingle>((VCDSignal<ISignalChangeSingle>)signals.get(i), id, netName);
if(width<0) {
signal = i<0 ? new VCDSignal<ISignalChangeReal>(db, id, netName, width) :
new VCDSignal<ISignalChangeReal>((VCDSignal<ISignalChangeReal>)signals.get(i), id, netName);
} else if(width==1){
signal = i<0 ? new VCDSignal<ISignalChangeBit>(db, id, netName) :
new VCDSignal<ISignalChangeBit>((VCDSignal<ISignalChangeBit>)signals.get(i), id, netName);
} else {
signal = i<0 ? new VCDSignal<ISignalChangeMulti>(db, id, netName, width) :
new VCDSignal<ISignalChangeMulti>((VCDSignal<VCDSignalChangeMulti>)signals.get(i), id, netName);
signal = i<0 ? new VCDSignal<ISignalChangeBitVector>(db, id, netName, width) :
new VCDSignal<ISignalChangeBitVector>((VCDSignal<VCDSignalChangeBitVector>)signals.get(i), id, netName);
};
signals.add(signal);
return id;
@ -172,13 +182,37 @@ public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
*/
@SuppressWarnings("unchecked")
@Override
public void appendTransition(int signalId, long currentTime, BitVector decodedValues) {
public void appendTransition(int signalId, long currentTime, char decodedValues) {
VCDSignal<? extends IWaveformEvent> signal = (VCDSignal<? extends IWaveformEvent>) signals.get(signalId);
Long time = currentTime* TIME_RES;
if(signal.getWidth()==1){
((VCDSignal<ISignalChangeSingle>)signal).values.put(time, new VCDSignalChangeSingle(time, decodedValues.getValue()[0]));
} else {
((VCDSignal<VCDSignalChangeMulti>)signal).values.put(time, new VCDSignalChangeMulti(time, decodedValues));
((VCDSignal<ISignalChangeBit>)signal).values.put(time, new VCDSignalChangeBit(time, decodedValues));
}
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.vcd.ITraceBuilder#appendTransition(int, long, com.minres.scviewer.database.vcd.BitVector)
*/
@SuppressWarnings("unchecked")
@Override
public void appendTransition(int signalId, long currentTime, BitVector decodedValues) {
VCDSignal<? extends IWaveformEvent> signal = (VCDSignal<? extends IWaveformEvent>) signals.get(signalId);
Long time = currentTime* TIME_RES;
if(signal.getWidth()>1){
((VCDSignal<VCDSignalChangeBitVector>)signal).values.put(time, new VCDSignalChangeBitVector(time, decodedValues));
}
}
/* (non-Javadoc)
* @see com.minres.scviewer.database.vcd.ITraceBuilder#appendTransition(int, long, com.minres.scviewer.database.vcd.BitVector)
*/
@SuppressWarnings("unchecked")
@Override
public void appendTransition(int signalId, long currentTime, double decodedValue) {
VCDSignal<? extends IWaveformEvent> signal = (VCDSignal<? extends IWaveformEvent>) signals.get(signalId);
Long time = currentTime* TIME_RES;
if(signal.getWidth()<0){
((VCDSignal<ISignalChangeReal>)signal).values.put(time, new VCDSignalChangeReal(time, decodedValue));
}
}

View File

@ -61,9 +61,11 @@ class VCDFileParser {
private void parseVar() throws Exception {
nextToken(); // type
String type = tokenizer.sval;
nextToken(); // size
int width = Integer.parseInt(tokenizer.sval);
if("real".equals(type))
width*=-1;
nextToken();
String id = tokenizer.sval;
nextToken();
@ -153,7 +155,8 @@ class VCDFileParser {
} while (!tokenizer.sval.equals("$end"));
return true;
}
if (tokenizer.sval.equals("$dumpvars") || tokenizer.sval.equals("$end")) return true;
if (tokenizer.sval.equals("$dumpvars") || tokenizer.sval.equals("$end"))
return true;
String value, id;
if (tokenizer.sval.charAt(0) == 'b') {
// Multiple value net. Value appears first, followed by space,
@ -161,6 +164,12 @@ class VCDFileParser {
value = tokenizer.sval.substring(1);
nextToken();
id = tokenizer.sval;
}else if (tokenizer.sval.charAt(0) == 'r') {
// Multiple value net. Value appears first, followed by space,
// then identifier
value = tokenizer.sval.substring(1);
nextToken();
id = tokenizer.sval;
} else {
// Single value net. identifier first, then value, no space.
value = tokenizer.sval.substring(0, 1);
@ -174,39 +183,46 @@ class VCDFileParser {
}
int netWidth = traceBuilder.getNetWidth(net);
BitVector decodedValues = new BitVector(netWidth);
if (value.equals("z") && netWidth > 1) {
for (int i = 0; i < netWidth; i++)
decodedValues.setValue(i, BitVector.VALUE_Z);
} else if (value.equals("x") && netWidth > 1) {
for (int i = 0; i < netWidth; i++)
decodedValues.setValue(i, BitVector.VALUE_X);
if(netWidth<0) {
traceBuilder.appendTransition(net, currentTime, Double.parseDouble(value));
} else {
int stringIndex = 0;
for (int convertedIndex = netWidth - value.length(); convertedIndex < netWidth; convertedIndex++) {
switch (value.charAt(stringIndex++)) {
case 'z':
decodedValues.setValue(convertedIndex, BitVector.VALUE_Z);
break;
BitVector decodedValues = new BitVector(netWidth);
if (value.equals("z") && netWidth > 1) {
for (int i = 0; i < netWidth; i++)
decodedValues.setValue(i, BitVector.VALUE_Z);
} else if (value.equals("x") && netWidth > 1) {
for (int i = 0; i < netWidth; i++)
decodedValues.setValue(i, BitVector.VALUE_X);
} else {
int stringIndex = 0;
for (int convertedIndex = netWidth - value.length(); convertedIndex < netWidth; convertedIndex++) {
switch (value.charAt(stringIndex++)) {
case 'z':
decodedValues.setValue(convertedIndex, BitVector.VALUE_Z);
break;
case '1':
decodedValues.setValue(convertedIndex, BitVector.VALUE_1);
break;
case '1':
decodedValues.setValue(convertedIndex, BitVector.VALUE_1);
break;
case '0':
decodedValues.setValue(convertedIndex, BitVector.VALUE_0);
break;
case '0':
decodedValues.setValue(convertedIndex, BitVector.VALUE_0);
break;
case 'x':
decodedValues.setValue(convertedIndex, BitVector.VALUE_X);
break;
case 'x':
decodedValues.setValue(convertedIndex, BitVector.VALUE_X);
break;
default:
decodedValues.setValue(convertedIndex, BitVector.VALUE_X);
default:
decodedValues.setValue(convertedIndex, BitVector.VALUE_X);
}
}
}
if(netWidth==1)
traceBuilder.appendTransition(net, currentTime, decodedValues.getValue()[0]);
else
traceBuilder.appendTransition(net, currentTime, decodedValues);
}
traceBuilder.appendTransition(net, currentTime, decodedValues);
}
return true;
}

View File

@ -10,14 +10,14 @@
*******************************************************************************/
package com.minres.scviewer.database.vcd;
import com.minres.scviewer.database.ISignalChangeSingle;
import com.minres.scviewer.database.ISignalChangeBit;
import com.minres.scviewer.database.SignalChange;
public class VCDSignalChangeSingle extends SignalChange implements ISignalChangeSingle, Cloneable {
public class VCDSignalChangeBit extends SignalChange implements ISignalChangeBit, Cloneable {
private char value;
public VCDSignalChangeSingle(Long time, char value) {
public VCDSignalChangeBit(Long time, char value) {
super(time);
this.value=value;
}

View File

@ -11,18 +11,18 @@
package com.minres.scviewer.database.vcd;
import com.minres.scviewer.database.BitVector;
import com.minres.scviewer.database.ISignalChangeMulti;
import com.minres.scviewer.database.ISignalChangeBitVector;
import com.minres.scviewer.database.SignalChange;
public class VCDSignalChangeMulti extends SignalChange implements ISignalChangeMulti, Cloneable {
public class VCDSignalChangeBitVector extends SignalChange implements ISignalChangeBitVector, Cloneable {
private BitVector value;
public VCDSignalChangeMulti(Long time) {
public VCDSignalChangeBitVector(Long time) {
super(time);
}
public VCDSignalChangeMulti(Long time, BitVector decodedValues) {
public VCDSignalChangeBitVector(Long time, BitVector decodedValues) {
super(time);
this.value=decodedValues;
}

View File

@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.vcd;
import com.minres.scviewer.database.ISignalChangeReal;
import com.minres.scviewer.database.SignalChange;
public class VCDSignalChangeReal extends SignalChange implements ISignalChangeReal, Cloneable {
private double value;
public VCDSignalChangeReal(Long time, double value) {
super(time);
this.value=value;
}
public double getValue() {
return value;
}
public void setValue(double value) {
this.value = value;
}
@Override
public String toString() {
return value+"@"+getTime();
}
}

View File

@ -10,7 +10,7 @@
*******************************************************************************/
package com.minres.scviewer.database;
public interface ISignalChangeSingle extends ISignalChange{
public interface ISignalChangeBit extends ISignalChange{
public char getValue();

View File

@ -10,8 +10,7 @@
*******************************************************************************/
package com.minres.scviewer.database;
public interface ISignalChangeMulti extends ISignalChange {
public interface ISignalChangeBitVector extends ISignalChange {
public BitVector getValue();

View File

@ -0,0 +1,17 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database;
public interface ISignalChangeReal extends ISignalChange{
public double getValue();
}

View File

@ -245,10 +245,12 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
if (filesToLoad.size() > 0)
loadDatabase(persistedState);
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]);
// menuService.registerContextMenu(waveformPane.getNameControl(),
// "com.minres.scviewer.e4.application.popupmenu.namecontext"); //$NON-NLS-1$
menuService.registerContextMenu(waveformPane.getNameControl(),
"com.minres.scviewer.e4.application.popupmenu.namecontext"); //$NON-NLS-1$
"com.minres.scviewer.e4.application.popupmenu.wavecontext"); //$NON-NLS-1$
menuService.registerContextMenu(waveformPane.getValueControl(),
"com.minres.scviewer.e4.application.popupmenu.namecontext"); //$NON-NLS-1$
"com.minres.scviewer.e4.application.popupmenu.wavecontext"); //$NON-NLS-1$
menuService.registerContextMenu(waveformPane.getWaveformControl(),
"com.minres.scviewer.e4.application.popupmenu.wavecontext"); //$NON-NLS-1$
ePartService.addPartListener(new PartListener() {
@ -412,7 +414,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
*/
@Focus
public void setFocus() {
myParent.setFocus();
waveformPane.getWaveformControl().setFocus();
}
/**
@ -658,6 +660,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
index++;
waveformPane.getStreamList().addAll(index, streams);
}
setFocus();
}
/**