Fixed inconsitencies

This commit is contained in:
Eyck Jentzsch 2015-01-09 09:16:40 +01:00
parent 4062d24897
commit cb77a5da33
26 changed files with 174 additions and 73 deletions

View File

@ -24,6 +24,9 @@ The plugins are structured as follows:
outline of the DB and the properties of the transaction
- com.minres.scviewer.feature
the feature combining the plugins above into a somhow usable form
- scv_tr_sqlite
a C++ project containing the SQLite based SCV database implementation. A simple
example (scv_tr_recording_example.cpp) for testig purposes is provided.
To build the plugins the Eclipse SDK or PDE can be used. In both cases the Groovy
eclipse plugin (http://groovy.codehaus.org/Eclipse+Plugin or Market) has to be

View File

@ -96,7 +96,7 @@ public class SQLiteDb extends HierNode implements IWaveformDb {
@Override
public IWaveform getStreamByName(String name) {
for (IWaveform n : getAllWaves())
if (n.getName().equals(name))
if (n.getFullName().equals(name))
return n;
return null;
}
@ -110,7 +110,7 @@ public class SQLiteDb extends HierNode implements IWaveformDb {
private void buildHierarchyNodes() throws InputFormatException{
for(IWaveform stream:getAllWaves()){
String[] hier = stream.getFullName().split("\\./");
String[] hier = stream.getFullName().split("\\.");
IHierNode node = this;
for(String name:hier){
IHierNode n1 = null;

View File

@ -151,4 +151,9 @@ public class Tx implements ITx {
return null;
}
@Override
public int compareTo(ITx o) {
return this.getBeginTime().compareTo(o.getBeginTime());
}
}

View File

@ -6,6 +6,8 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.NavigableSet;
import java.util.TreeSet;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ITxGenerator;
@ -26,7 +28,7 @@ public class TxStream extends HierNode implements ITxStream {
private HashMap<Integer, TxGenerator> generators;
private List<ITx> transactions;
private NavigableSet<ITx> transactions;
public TxStream(SQLiteDb trSQLiteDb, ScvStream scvStream) {
super(scvStream.getName());
@ -74,7 +76,7 @@ public class TxStream extends HierNode implements ITxStream {
}
@Override
public List<ITx> getTransactions() {
public NavigableSet<ITx> getTransactions() {
checkTransactions();
return transactions;
}
@ -94,7 +96,7 @@ public class TxStream extends HierNode implements ITxStream {
if(generators==null) getGenerators();
SQLiteDatabaseSelectHandler<ScvTx> handler = new SQLiteDatabaseSelectHandler<ScvTx>(ScvTx.class, db.getDb(),
"stream="+scvStream.getId());
transactions=new ArrayList<ITx>();
transactions=new TreeSet<ITx>();
try {
for(ScvTx scvTx:handler.selectObjects()){
transactions.add(new Tx(this, generators.get(scvTx.getGenerator()), scvTx));

View File

@ -1,6 +1,6 @@
scv_tr_stream (ID 1, name "pipelined_stream", kind "transactor")
scv_tr_stream (ID 2, name "addr_stream", kind "transactor")
scv_tr_stream (ID 3, name "data_stream", kind "transactor")
scv_tr_stream (ID 1, name "tr.pipelined_stream", kind "transactor")
scv_tr_stream (ID 2, name "tr.addr_stream", kind "transactor")
scv_tr_stream (ID 3, name "tr.data_stream", kind "transactor")
scv_tr_generator (ID 4, name "read", scv_tr_stream 1,
begin_attribute (ID 0, name "addr", type "UNSIGNED")
end_attribute (ID 1, name "data", type "UNSIGNED")

View File

@ -1,5 +1,5 @@
$date
Jan 03, 2015 20:58:29
Jan 07, 2015 08:03:07
$end
$version

View File

@ -35,6 +35,7 @@ class Tx implements ITx {
Tx(int id, TxStream stream, TxGenerator generator, EventTime begin){
this.id=id
this.stream=stream
this.generator=generator
this.beginTime=begin
}
@ -49,4 +50,9 @@ class Tx implements ITx {
return outgoingRelations;
}
@Override
public int compareTo(ITx o) {
return beginTime.compareTo(o.beginTime)
}
}

View File

@ -33,7 +33,7 @@ class TxStream extends HierNode implements ITxStream {
def generators = [];
private allTransactions;
private TreeSet<Tx> allTransactions;
TxStream(int id, TextDb db, String name, String kind){
super(name)
@ -68,9 +68,11 @@ class TxStream extends HierNode implements ITxStream {
}
@Override
public List<ITx> getTransactions() {
if(!allTransactions)
allTransactions=generators.transactions.flatten().sort{it.beginTime.value}
public NavigableSet<ITx> getTransactions() {
if(!allTransactions){
allTransactions=new TreeSet<Tx>()
allTransactions.addAll(generators.transactions.flatten())
}
return allTransactions
}

View File

@ -0,0 +1,56 @@
package com.minres.scviewer.database;
public class BitVector {
public static final char VALUE_X = 'X';
public static final char VALUE_Z = 'Z';
public static final char VALUE_1 = '1';
public static final char VALUE_0 = '0';
private final int width;
private char[] value;
public BitVector(int netWidth) {
this.width=netWidth;
value = new char[netWidth];
for(int i=0; i<netWidth; i++) value[i]='0';
}
public void setValue(int i, char value) {
this.value[i]=value;
}
public char[] getValue() {
return value;
}
public void setValue(char[] value) {
this.value = value;
}
public int getWidth() {
return width;
}
public String toString(){
return new String(value);
}
public String toHexString(){
int resWidth=(width-1)/4+1;
char[] res = new char[resWidth];
for(int i=resWidth-1; i>=0; i--){
int digit=0;
for(int j=3; j>=0; j--){
if(value[4*i+j]==VALUE_X ||value[4*i+j]==VALUE_Z ){
res[i]=VALUE_X;
}
if(value[4*i+j]==VALUE_1)
digit+=1<<(3-j);
res[i]=Character.forDigit(digit, 16); //((digit < 10) ? '0' + digit : 'a' + digit -10)
}
}
return new String(res);
}
}

View File

@ -1,7 +1,8 @@
package com.minres.scviewer.database;
public interface ISignalChangeMulti extends ISignalChange {
public String getValue();
public BitVector getValue();
}

View File

@ -13,7 +13,7 @@ package com.minres.scviewer.database;
import java.util.Collection;
import java.util.List;
public interface ITx {
public interface ITx extends Comparable<ITx>{
public Long getId();

View File

@ -11,12 +11,13 @@
package com.minres.scviewer.database;
import java.util.List;
import java.util.NavigableSet;
public interface ITxStream extends IWaveform {
public List<ITxGenerator> getGenerators();
public List<ITx> getTransactions();
public NavigableSet<ITx> getTransactions();
public ITx getTransactionById(long id);

View File

@ -1,5 +1,7 @@
package com.minres.scviewer.database.vcd;
import com.minres.scviewer.database.BitVector;
// TODO: Auto-generated Javadoc
/**
* The Interface ITraceBuilder.

View File

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Stack;
import java.util.Vector;
import com.minres.scviewer.database.BitVector;
import com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.HierNode;
import com.minres.scviewer.database.ISignal;
@ -54,8 +55,8 @@ public class VCDDb extends HierNode implements IWaveformDb, IVCDDatabaseBuilder
* @see com.minres.scviewer.database.ITrDb#getStreamByName(java.lang.String)
*/
@Override
public ITxStream getStreamByName(String name) {
return null;
public IWaveform getStreamByName(String name) {
return waveformLookup.get(name);
}
/* (non-Javadoc)
@ -163,7 +164,7 @@ public class VCDDb extends HierNode implements IWaveformDb, IVCDDatabaseBuilder
VCDSignalChangeSingle change = new VCDSignalChangeSingle(time, decodedValues.getValue()[0]);
((VCDSignal<ISignalChangeSingle>)signal).addSignalChange(change);
} else {
VCDSignalChangeMulti change = new VCDSignalChangeMulti(time, new String(decodedValues.getValue()));
VCDSignalChangeMulti change = new VCDSignalChangeMulti(time, decodedValues);
((VCDSignal<VCDSignalChangeMulti>)signal).addSignalChange(change);
}
maxTime= Math.max(maxTime, fCurrentTime);

View File

@ -3,6 +3,8 @@ package com.minres.scviewer.database.vcd;
import java.io.*;
import java.util.*;
import com.minres.scviewer.database.BitVector;
class VCDFileParser {
private StreamTokenizer tokenizer;
private IVCDDatabaseBuilder traceBuilder;

View File

@ -1,27 +1,28 @@
package com.minres.scviewer.database.vcd;
import com.minres.scviewer.database.BitVector;
import com.minres.scviewer.database.EventTime;
import com.minres.scviewer.database.ISignalChangeMulti;
import com.minres.scviewer.database.SignalChange;
public class VCDSignalChangeMulti extends SignalChange implements ISignalChangeMulti, Cloneable {
private String value;
private BitVector value;
public VCDSignalChangeMulti(EventTime time) {
super(time);
}
public VCDSignalChangeMulti(EventTime time, String value) {
public VCDSignalChangeMulti(EventTime time, BitVector decodedValues) {
super(time);
this.value=value;
this.value=decodedValues;
}
public String getValue() {
public BitVector getValue() {
return value;
}
public void setValue(String value) {
public void setValue(BitVector value) {
this.value = value;
}

View File

@ -67,7 +67,7 @@
id="com.minres.scviewer.ui.propertySectionAll"
tab="com.minres.scviewer.ui.propertyTabTransaction">
<input
type="com.minres.scviewer.database.ITransaction">
type="com.minres.scviewer.database.ITx">
</input>
</propertySection>
<propertySection
@ -76,7 +76,7 @@
id="com.minres.scviewer.ui.propertySectionAttributes"
tab="com.minres.scviewer.ui.propertyTabAttributes">
<input
type="com.minres.scviewer.database.ITransaction">
type="com.minres.scviewer.database.ITx">
</input>
</propertySection>
<propertySection
@ -85,7 +85,7 @@
id="com.minres.scviewer.ui.propertySectionRelated"
tab="com.minres.scviewer.ui.propertyTabRelated">
<input
type="com.minres.scviewer.database.ITransaction">
type="com.minres.scviewer.database.ITx">
</input>
</propertySection>
</propertySections>
@ -93,8 +93,8 @@
<extension
point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="com.minres.scviewer.database.ITransaction"
class="com.minres.scviewer.ui.adapter.AdapterFactory">
adaptableType="com.minres.scviewer.database.ITx"
class="com.minres.scviewer.ui.adapter.TxAdapterFactory">
<adapter
type="org.eclipse.ui.views.properties.IPropertySource">
</adapter>

View File

@ -118,7 +118,8 @@ public class TxEditorPlugin extends AbstractUIPlugin {
case trackBgLightColor:
return SWTResourceManager.getColor(220, 220, 220);
case trackBgDarkColor:
return SWTResourceManager.getColor(200, 200, 200);
// return SWTResourceManager.getColor(200, 200, 200);
return SWTResourceManager.getColor(SWT.COLOR_BLACK);
case headerBgColor:
return SWTResourceManager.getColor(255, 255, 255);
case headerFgColor:

View File

@ -0,0 +1,24 @@
package com.minres.scviewer.ui.adapter;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.views.properties.IPropertySource;
import com.minres.scviewer.database.ITx;
public class TxAdapterFactory implements IAdapterFactory {
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adapterType == IPropertySource.class)
return new ITransactionPropertySource((ITx) adaptableObject);
return null;
}
@SuppressWarnings("rawtypes")
@Override
public Class[] getAdapterList() {
return new Class[]{IPropertySource.class};
}
}

View File

@ -23,7 +23,7 @@ import com.minres.scviewer.ui.TxEditorPlugin;
public class SignalWidget extends Canvas implements IWaveformWidget{
static final int trackHeight = 50;
static final int trackInset = 2;
static final int trackInset = 1;
static final int txHeight = trackHeight - 2 * trackInset;
static double zoomFactor = EventTime.NS;
@ -32,10 +32,8 @@ public class SignalWidget extends Canvas implements IWaveformWidget{
private Color color0;
private Color color1;
private Color colorZ;
private Color colorZdark;
private Color colorX;
private Color colorXdark;
private Color colorC;
private Color colorText;
private long length;
ISignal<ISignalChange> signal;
@ -50,12 +48,10 @@ public class SignalWidget extends Canvas implements IWaveformWidget{
lineColor=plugin.getColor(TxEditorPlugin.lineColor);
trackBgColor=plugin.getColor(TxEditorPlugin.trackBgDarkColor);
color0=SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
color1=SWTResourceManager.getColor(SWT.COLOR_GREEN);
color1=SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
colorZ=SWTResourceManager.getColor(SWT.COLOR_GRAY);
colorX=SWTResourceManager.getColor(SWT.COLOR_RED);
colorZdark=SWTResourceManager.getColor(SWT.COLOR_DARK_GRAY);
colorXdark=SWTResourceManager.getColor(SWT.COLOR_DARK_RED);
colorC=SWTResourceManager.getColor(SWT.COLOR_BLUE);
colorText=SWTResourceManager.getColor(SWT.COLOR_WHITE);
}
public void setTransactions(ISignal<ISignalChange> signal) {
@ -97,11 +93,11 @@ public class SignalWidget extends Canvas implements IWaveformWidget{
switch(((ISignalChangeSingle) lastChange).getValue()){
case '1':
color=color1;
yOffset = trackHeight/3;
yOffset = trackHeight/5;
break;
case '0':
color=color0;
yOffset = 2*trackHeight/3;
yOffset = 4*trackHeight/5;
break;
case 'Z':
color=colorZ;
@ -110,37 +106,33 @@ public class SignalWidget extends Canvas implements IWaveformWidget{
}
gc.setForeground(color);
int endTime= (int)(actChange.getTime().getValue()/zoomFactor);
gc.drawLine((int)(lastChange.getTime().getValue()/zoomFactor), yOffset,
endTime, yOffset);
gc.drawLine((int)(lastChange.getTime().getValue()/zoomFactor), yOffset, endTime, yOffset);
int yNext = trackHeight/2;
switch(((ISignalChangeSingle) actChange).getValue()){
case '1':
yNext = trackHeight/3;
yNext = trackHeight/5;
break;
case '0':
yNext = 2*trackHeight/3;
yNext = 4*trackHeight/5;
break;
default:
}
gc.setForeground(colorC);
// gc.setForeground(colorC);
if(yOffset<yNext)
gc.drawLine(endTime, yOffset, endTime, yNext);
else
gc.drawLine(endTime, yNext, endTime, yOffset);
} else if(lastChange instanceof ISignalChangeMulti){
int yOffsetT = trackHeight/3;
int yOffsetT = trackHeight/5;
int yOffsetM = trackHeight/2;
int yOffsetB = 2*trackHeight/3;
Color color = color1;
int yOffsetB = 4*trackHeight/5;
Color colorBorder = color0;
ISignalChangeMulti last = (ISignalChangeMulti) lastChange;
if(last.getValue().contains("X")){
color=colorX;
colorBorder=colorXdark;
}else if(last.getValue().contains("Z")){
color=colorZ;
colorBorder=colorZdark;
if(last.getValue().toString().contains("X")){
colorBorder=colorX;
}else if(last.getValue().toString().contains("Z")){
colorBorder=colorZ;
}
int beginTime= (int)(lastChange.getTime().getValue()/zoomFactor);
int endTime= (int)(actChange.getTime().getValue()/zoomFactor);
@ -152,11 +144,12 @@ public class SignalWidget extends Canvas implements IWaveformWidget{
endTime-1,yOffsetB,
beginTime+1,yOffsetB
};
gc.setBackground(color);
gc.fillPolygon(points);
gc.setForeground(colorBorder);
gc.drawPolygon(points);
gc.drawText(last.getValue(), beginTime+1, yOffsetT+1);
gc.setForeground(colorText);
int size = gc.getDevice().getDPI().y * gc.getFont().getFontData()[0].getHeight()/72;
// gc.setClipping(beginTime+3,yOffsetM-size/2-1,endTime-beginTime-4, yOffsetM+size/2+1);
gc.drawText("h'"+last.getValue().toHexString(), beginTime+3, yOffsetM-size/2-1);
}
}

View File

@ -2,6 +2,7 @@ package com.minres.scviewer.ui.swt;
import java.util.HashMap;
import java.util.List;
import java.util.NavigableSet;
import java.util.Vector;
import org.eclipse.swt.SWT;
@ -27,7 +28,7 @@ import com.minres.scviewer.ui.TxEditorPlugin;
public class Track extends Composite implements IWaveformWidget, MouseListener {
static final int trackHeight = 50;
static final int trackInset = 2;
static final int trackInset = 1;
static final int txHeight = trackHeight - 2 * trackInset;
static double zoomFactor = EventTime.NS;
@ -101,7 +102,7 @@ public class Track extends Composite implements IWaveformWidget, MouseListener {
});
TxEditorPlugin plugin=TxEditorPlugin.getDefault();
lineColor=plugin.getColor(TxEditorPlugin.lineColor);
trackBgColor=plugin.getColor(TxEditorPlugin.trackBgLightColor);
trackBgColor=plugin.getColor(TxEditorPlugin.trackBgDarkColor);
}
@ -121,7 +122,7 @@ public class Track extends Composite implements IWaveformWidget, MouseListener {
}
public void setTransactions(List<ITx> transactions) {
public void setTransactions(NavigableSet<ITx> transactions) {
Vector<ITx> rowendtime = new Vector<ITx>();
for (ITx tx : transactions) {
int rowIdx = 0;
@ -188,7 +189,7 @@ public class Track extends Composite implements IWaveformWidget, MouseListener {
}
public Transaction highlight(Object obj){
if(obj instanceof ITx){
if(obj==null || obj instanceof ITx){
ITx tx = (ITx) obj;
if(highlightedTx!=null){
transactionMap.get(highlightedTx).highlight(false);

View File

@ -24,7 +24,7 @@ public class Transaction extends Composite {
private boolean highlighted=false;
Transaction(Composite parent, int style, int lenght) {
super(parent, style);
super(parent, style|SWT.NO_BACKGROUND);
this.length=lenght;
addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
@ -53,7 +53,7 @@ public class Transaction extends Composite {
gc.setBackground(highlighted?txHighliteBgColor:txBgColor);
gc.setLineWidth(1);
gc.setLineStyle(SWT.LINE_SOLID);
Rectangle bb = new Rectangle(0, 0, length-1, height-1);
Rectangle bb = new Rectangle(0, height/5, length-1, 3*height/5);
if(bb.width<8){
gc.fillRectangle(bb);
gc.drawRectangle(bb);

View File

@ -174,7 +174,7 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
protected RowLayout createScrolledLayoutData(boolean center) {
RowLayout nameListLayout = new RowLayout(SWT.VERTICAL);
nameListLayout.spacing = 4;
nameListLayout.spacing = 2;
nameListLayout.marginTop = 0;
nameListLayout.marginRight = 0;
nameListLayout.marginLeft = 0;
@ -337,11 +337,11 @@ public class TxDisplay implements PropertyChangeListener, ISelectionProvider, Mo
Object sel =((IStructuredSelection)selection).getFirstElement();
if(sel instanceof ITx && currentSelection!=sel){
if(currentSelection!=null){
ITxStream stream = currentSelection.getGenerator().getStream();
ITxStream stream = currentSelection.getStream();
if(trackMap.containsKey(stream)) trackMap.get(stream).highlight(null);
}
currentSelection=(ITx) sel;
ITxStream stream = currentSelection.getGenerator().getStream();
ITxStream stream = currentSelection.getStream();
if(trackMap.containsKey(stream)){
Transaction trans = trackMap.get(stream).highlight(sel);
trackListScrolled.showControl(trans);

View File

@ -221,7 +221,7 @@ public class AttributeProperty extends AbstractPropertySection implements ISelec
public void menuAboutToShow(IMenuManager mgr) {
ISelection selection = treeViewer.getSelection();
if (selection instanceof IStructuredSelection) {
System.out.println(((IStructuredSelection)selection).getFirstElement().toString());
// System.out.println(((IStructuredSelection)selection).getFirstElement().toString());
}
}
});

View File

@ -90,9 +90,9 @@ public:
: pipelined_bus_ports(nm)
, addr_phase("addr_phase")
, data_phase("data_phase")
, pipelined_stream("pipelined_stream", "transactor")
, addr_stream( "addr_stream", "transactor")
, data_stream("data_stream", "transactor")
, pipelined_stream((std::string(name()) +".pipelined_stream").c_str(), "transactor")
, addr_stream( (std::string(name()) +".addr_stream").c_str(), "transactor")
, data_stream((std::string(name()) +".data_stream").c_str(), "transactor")
, read_gen("read", pipelined_stream, "addr", "data")
, write_gen("write", pipelined_stream, "addr", "data")
, addr_gen("addr", addr_stream, "addr")
@ -327,9 +327,9 @@ extern void scv_tr_sqlite_init();
int sc_main(int argc, char *argv[]) {
scv_startup();
#if 0
#if 1
scv_tr_text_init();
const char* fileName = "my_db.log";
const char* fileName = "my_db.txlog";
#else
scv_tr_sqlite_init();
const char* fileName = "my_db";