[WIP ]reorganized dir structure
This commit is contained in:
@ -0,0 +1,68 @@
|
||||
/*******************************************************************************
|
||||
* 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.BitVector;
|
||||
|
||||
/**
|
||||
* The Interface IVCDDatabaseBuilder. It allows to add VCD events into the database
|
||||
*/
|
||||
public interface IVCDDatabaseBuilder {
|
||||
|
||||
/**
|
||||
* Enter module.
|
||||
*
|
||||
* @param tokenString the token string
|
||||
*/
|
||||
public void enterModule(String tokenString);
|
||||
|
||||
/**
|
||||
* Exit module.
|
||||
*/
|
||||
public void exitModule();
|
||||
|
||||
/**
|
||||
* New net.
|
||||
*
|
||||
* @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, -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 net id
|
||||
* @return the net width, -1 means a real-valued net
|
||||
*/
|
||||
public int getNetWidth(int netId);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
@ -0,0 +1,215 @@
|
||||
/*******************************************************************************
|
||||
* 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 java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
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;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformDbLoader;
|
||||
import com.minres.scviewer.database.InputFormatException;
|
||||
import com.minres.scviewer.database.RelationType;
|
||||
|
||||
/**
|
||||
* The Class VCDDb.
|
||||
*/
|
||||
public class VCDDbLoader implements IWaveformDbLoader, IVCDDatabaseBuilder {
|
||||
|
||||
|
||||
/** The Constant TIME_RES. */
|
||||
private static final Long TIME_RES = 1000L; // ps;
|
||||
|
||||
/** The db. */
|
||||
private IWaveformDb db;
|
||||
|
||||
/** The module stack. */
|
||||
private Stack<String> moduleStack;
|
||||
|
||||
/** The signals. */
|
||||
private List<IWaveform> signals;
|
||||
|
||||
/** The max time. */
|
||||
private long maxTime;
|
||||
|
||||
/**
|
||||
* Instantiates a new VCD db.
|
||||
*/
|
||||
public VCDDbLoader() {
|
||||
}
|
||||
|
||||
private static boolean isGzipped(File f) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = new FileInputStream(f);
|
||||
byte [] signature = new byte[2];
|
||||
int nread = is.read( signature ); //read the gzip signature
|
||||
return nread == 2 && signature[ 0 ] == (byte) 0x1f && signature[ 1 ] == (byte) 0x8b;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
} finally {
|
||||
try { is.close();} catch (IOException e) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.ITrDb#load(java.io.File)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean load(IWaveformDb db, File file) throws Exception {
|
||||
if(file.isDirectory() || !file.exists()) return false;
|
||||
this.db=db;
|
||||
this.maxTime=0;
|
||||
String name = file.getCanonicalFile().getName();
|
||||
if(!(name.endsWith(".vcd") ||
|
||||
name.endsWith(".vcdz") ||
|
||||
name.endsWith(".vcdgz") ||
|
||||
name.endsWith(".vcd.gz")) )
|
||||
return false;
|
||||
signals = new Vector<IWaveform>();
|
||||
moduleStack= new Stack<String>();
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
boolean res = new VCDFileParser(false).load(isGzipped(file)?new GZIPInputStream(fis):fis, this);
|
||||
moduleStack=null;
|
||||
if(!res) throw new InputFormatException();
|
||||
// calculate max time of database
|
||||
for(IWaveform waveform:signals) {
|
||||
NavigableMap<Long, ?> events =((ISignal<?>)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 s:signals){
|
||||
if(s instanceof VCDSignal<?>) {
|
||||
TreeMap<Long,?> events = (TreeMap<Long, ?>) ((VCDSignal<?>)s).getEvents();
|
||||
if(events.size()>0 && events.lastKey()<maxTime){
|
||||
Object val = events.lastEntry().getValue();
|
||||
if(val instanceof BitVector) {
|
||||
((VCDSignal<BitVector>)s).addSignalChange(maxTime, (BitVector) val);
|
||||
} else if(val instanceof Double)
|
||||
((VCDSignal<Double>)s).addSignalChange(maxTime, (Double) val);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.ITrDb#getMaxTime()
|
||||
*/
|
||||
@Override
|
||||
public Long getMaxTime() {
|
||||
return maxTime;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.ITrDb#getAllWaves()
|
||||
*/
|
||||
@Override
|
||||
public Collection<IWaveform> getAllWaves() {
|
||||
return signals;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.vcd.ITraceBuilder#enterModule(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void enterModule(String tokenString) {
|
||||
if(moduleStack.isEmpty()) {
|
||||
if("SystemC".compareTo(tokenString)!=0) moduleStack.push(tokenString);
|
||||
} else
|
||||
moduleStack.push(moduleStack.peek()+"."+tokenString);
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.vcd.ITraceBuilder#exitModule()
|
||||
*/
|
||||
@Override
|
||||
public void exitModule() {
|
||||
if(!moduleStack.isEmpty()) moduleStack.pop();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.vcd.ITraceBuilder#newNet(java.lang.String, int, int)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Integer newNet(String name, int i, int width) {
|
||||
String netName = moduleStack.empty()? name: moduleStack.lastElement()+"."+name;
|
||||
int id = signals.size();
|
||||
assert(width>=0);
|
||||
if(width==0) {
|
||||
signals.add( i<0 ? new VCDSignal<Double>(db, id, netName, width) :
|
||||
new VCDSignal<Double>((VCDSignal<Double>)signals.get(i), id, netName));
|
||||
} else if(width>0){
|
||||
signals.add( i<0 ? new VCDSignal<BitVector>(db, id, netName, width) :
|
||||
new VCDSignal<BitVector>((VCDSignal<BitVector>)signals.get(i), id, netName));
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.vcd.ITraceBuilder#getNetWidth(int)
|
||||
*/
|
||||
@Override
|
||||
public int getNetWidth(int intValue) {
|
||||
VCDSignal<?> signal = (VCDSignal<?>) signals.get(intValue);
|
||||
return signal.getWidth();
|
||||
}
|
||||
|
||||
/* (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 value) {
|
||||
VCDSignal<BitVector> signal = (VCDSignal<BitVector>) signals.get(signalId);
|
||||
Long time = currentTime* TIME_RES;
|
||||
signal.getEvents().put(time, value);
|
||||
}
|
||||
|
||||
/* (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 value) {
|
||||
VCDSignal<?> signal = (VCDSignal<?>) signals.get(signalId);
|
||||
Long time = currentTime* TIME_RES;
|
||||
if(signal.getWidth()==0){
|
||||
((VCDSignal<Double>)signal).getEvents().put(time, value);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.minres.scviewer.database.IWaveformDbLoader#getAllRelationTypes()
|
||||
*/
|
||||
@Override
|
||||
public Collection<RelationType> getAllRelationTypes(){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,266 @@
|
||||
/*******************************************************************************
|
||||
* 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 java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.minres.scviewer.database.BitValue;
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
|
||||
class VCDFileParser {
|
||||
private StreamTokenizer tokenizer;
|
||||
private IVCDDatabaseBuilder traceBuilder;
|
||||
private HashMap<String, Integer> nameToNetMap = new HashMap<String, Integer>();
|
||||
private long picoSecondsPerIncrement;
|
||||
private boolean stripNetWidth;
|
||||
private boolean replaceColon;
|
||||
long currentTime;
|
||||
|
||||
public VCDFileParser(boolean stripNetWidth) {
|
||||
this.stripNetWidth=stripNetWidth;
|
||||
this.replaceColon=false;
|
||||
}
|
||||
|
||||
public boolean load(InputStream is, IVCDDatabaseBuilder builder) {
|
||||
tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(is)));
|
||||
tokenizer.resetSyntax();
|
||||
tokenizer.wordChars(33, 126);
|
||||
tokenizer.whitespaceChars('\r', '\r');
|
||||
tokenizer.whitespaceChars('\n', '\n');
|
||||
tokenizer.whitespaceChars(' ', ' ');
|
||||
tokenizer.whitespaceChars('\t', '\t');
|
||||
try {
|
||||
traceBuilder = builder;
|
||||
currentTime=0;
|
||||
while (parseDefinition());
|
||||
while (parseTransition());
|
||||
return true;
|
||||
} catch (Exception exc) {
|
||||
exc.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void parseScope() throws Exception {
|
||||
nextToken(); // Scope type (ignore)
|
||||
nextToken();
|
||||
traceBuilder.enterModule(tokenizer.sval);
|
||||
match("$end");
|
||||
}
|
||||
|
||||
private void parseUpscope() throws Exception {
|
||||
match("$end");
|
||||
traceBuilder.exitModule();
|
||||
}
|
||||
|
||||
private void parseVar() throws Exception {
|
||||
nextToken(); // type
|
||||
String type = tokenizer.sval;
|
||||
nextToken(); // size
|
||||
int width = Integer.parseInt(tokenizer.sval);
|
||||
if("real".equals(type))
|
||||
width=0;
|
||||
nextToken();
|
||||
String id = tokenizer.sval;
|
||||
nextToken();
|
||||
String netName = tokenizer.sval;
|
||||
while (nextToken() && !tokenizer.sval.equals("$end")) {
|
||||
netName+=tokenizer.sval;
|
||||
}
|
||||
|
||||
Integer net = nameToNetMap.get(id);
|
||||
if (net == null) { // We've never seen this net before
|
||||
int openBracket = netName.indexOf('[');
|
||||
if(stripNetWidth){
|
||||
if (openBracket != -1) netName = netName.substring(0, openBracket);
|
||||
openBracket = -1;
|
||||
}
|
||||
if(replaceColon) {
|
||||
if (openBracket != -1) {
|
||||
netName = netName.substring(0, openBracket).replaceAll(":", ".")+netName.substring(openBracket);
|
||||
} else
|
||||
netName=netName.replaceAll(":", ".");
|
||||
}
|
||||
nameToNetMap.put(id, traceBuilder.newNet(netName, -1, width));
|
||||
} else {
|
||||
// Shares data with existing net. Add as clone.
|
||||
traceBuilder.newNet(netName, net, width);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseComment() throws Exception {
|
||||
nextToken();
|
||||
String s = tokenizer.sval;
|
||||
nextToken();
|
||||
while(!tokenizer.sval.equals("$end")){
|
||||
s+=" "+tokenizer.sval;
|
||||
nextToken();
|
||||
}
|
||||
replaceColon|=s.contains("ARTERIS Architecture");
|
||||
}
|
||||
|
||||
private void parseTimescale() throws Exception {
|
||||
nextToken();
|
||||
String s = tokenizer.sval;
|
||||
nextToken();
|
||||
while(!tokenizer.sval.equals("$end")){
|
||||
s+=" "+tokenizer.sval;
|
||||
nextToken();
|
||||
}
|
||||
switch (s.charAt(s.length() - 2)){
|
||||
case 'p': // Nano-seconds
|
||||
picoSecondsPerIncrement = 1;
|
||||
s = s.substring(0, s.length() - 2).trim();
|
||||
break;
|
||||
case 'n': // Nano-seconds
|
||||
picoSecondsPerIncrement = 1000;
|
||||
s = s.substring(0, s.length() - 2).trim();
|
||||
break;
|
||||
case 'u': // Microseconds
|
||||
picoSecondsPerIncrement = 1000000;
|
||||
s = s.substring(0, s.length() - 2).trim();
|
||||
break;
|
||||
case 'm': // Microseconds
|
||||
picoSecondsPerIncrement = 1000000000;
|
||||
s = s.substring(0, s.length() - 2).trim();
|
||||
break;
|
||||
default: // Seconds
|
||||
picoSecondsPerIncrement = 1000000000000L;
|
||||
s = s.substring(0, s.length() - 1);
|
||||
break;
|
||||
}
|
||||
picoSecondsPerIncrement *= Long.parseLong(s);
|
||||
}
|
||||
|
||||
private boolean parseDefinition() throws Exception {
|
||||
nextToken();
|
||||
if (tokenizer.sval.equals("$scope"))
|
||||
parseScope();
|
||||
else if (tokenizer.sval.equals("$var"))
|
||||
parseVar();
|
||||
else if (tokenizer.sval.equals("$upscope"))
|
||||
parseUpscope();
|
||||
else if (tokenizer.sval.equals("$timescale"))
|
||||
parseTimescale();
|
||||
else if (tokenizer.sval.equals("$comment"))
|
||||
parseComment();
|
||||
else if (tokenizer.sval.equals("$enddefinitions")) {
|
||||
match("$end");
|
||||
return false;
|
||||
} else {
|
||||
// Ignore this defintion
|
||||
do {
|
||||
if (!nextToken()) return false;
|
||||
} while (!tokenizer.sval.equals("$end"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean parseTransition() throws Exception {
|
||||
if (!nextToken()) return false;
|
||||
if (tokenizer.sval.charAt(0) == '#') { // If the line begins with a #, this is a timestamp.
|
||||
currentTime = Long.parseLong(tokenizer.sval.substring(1)) * picoSecondsPerIncrement;
|
||||
} else {
|
||||
if(tokenizer.sval.equals("$comment")){
|
||||
do {
|
||||
if (!nextToken()) return false;
|
||||
} while (!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,
|
||||
// then identifier
|
||||
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);
|
||||
id = tokenizer.sval.substring(1);
|
||||
}
|
||||
|
||||
Integer net = nameToNetMap.get(id);
|
||||
if (net == null) {
|
||||
System.out.println("unknown net " + id + " value " + value);
|
||||
return true;
|
||||
}
|
||||
|
||||
int netWidth = traceBuilder.getNetWidth(net);
|
||||
if(netWidth==0) {
|
||||
if("nan".equals(value))
|
||||
traceBuilder.appendTransition(net, currentTime, Double.NaN);
|
||||
else
|
||||
traceBuilder.appendTransition(net, currentTime, Double.parseDouble(value));
|
||||
} else {
|
||||
BitVector decodedValues = new BitVector(netWidth);
|
||||
if (value.equals("z") && netWidth > 1) {
|
||||
for (int i = 0; i < netWidth; i++)
|
||||
decodedValues.setValue(i, BitValue.Z);
|
||||
} else if (value.equals("x") && netWidth > 1) {
|
||||
for (int i = 0; i < netWidth; i++)
|
||||
decodedValues.setValue(i, BitValue.X);
|
||||
} else {
|
||||
int stringIndex = 0;
|
||||
for (int convertedIndex = netWidth -1; convertedIndex >=0; convertedIndex--) {
|
||||
if(convertedIndex<value.length()) {
|
||||
switch (value.charAt(stringIndex++)) {
|
||||
case 'z':
|
||||
decodedValues.setValue(convertedIndex, BitValue.Z);
|
||||
break;
|
||||
|
||||
case '1':
|
||||
decodedValues.setValue(convertedIndex, BitValue.ONE);
|
||||
break;
|
||||
|
||||
case '0':
|
||||
decodedValues.setValue(convertedIndex, BitValue.ZERO);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
decodedValues.setValue(convertedIndex, BitValue.X);
|
||||
break;
|
||||
|
||||
default:
|
||||
decodedValues.setValue(convertedIndex, BitValue.X);
|
||||
}
|
||||
} else {
|
||||
decodedValues.setValue(convertedIndex, BitValue.ZERO);
|
||||
}
|
||||
}
|
||||
}
|
||||
traceBuilder.appendTransition(net, currentTime, decodedValues);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void match(String value) throws Exception {
|
||||
nextToken();
|
||||
if (!tokenizer.sval.equals(value))
|
||||
throw new Exception("Line "+tokenizer.lineno()+": parse error, expected "+value+" got "+tokenizer.sval);
|
||||
}
|
||||
|
||||
private boolean nextToken() throws IOException {
|
||||
return tokenizer.nextToken() != StreamTokenizer.TT_EOF;
|
||||
}
|
||||
|
||||
};
|
@ -0,0 +1,130 @@
|
||||
/*******************************************************************************
|
||||
* 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 java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.minres.scviewer.database.HierNode;
|
||||
import com.minres.scviewer.database.ISignal;
|
||||
import com.minres.scviewer.database.IWaveform;
|
||||
import com.minres.scviewer.database.IWaveformDb;
|
||||
import com.minres.scviewer.database.IWaveformEvent;
|
||||
|
||||
public class VCDSignal<T> extends HierNode implements ISignal<T> {
|
||||
|
||||
private long id;
|
||||
|
||||
private String fullName;
|
||||
|
||||
private final String kind = "signal";
|
||||
|
||||
private final int width;
|
||||
|
||||
private final T dummy = null;
|
||||
|
||||
private IWaveformDb db;
|
||||
|
||||
private TreeMap<Long, T> values;
|
||||
|
||||
public VCDSignal(IWaveformDb db, String name) {
|
||||
this(db, 0, name, 1);
|
||||
}
|
||||
|
||||
public VCDSignal(IWaveformDb db, int id, String name) {
|
||||
this(db, id,name,1);
|
||||
}
|
||||
|
||||
public VCDSignal(IWaveformDb db, int id, String name, int width) {
|
||||
super(name);
|
||||
this.db=db;
|
||||
fullName=name;
|
||||
this.id=id;
|
||||
this.width=width;
|
||||
this.values=new TreeMap<Long, T>();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public VCDSignal(ISignal<T> other, int id, String name) {
|
||||
super(name);
|
||||
fullName=name;
|
||||
this.id=id;
|
||||
assert(other instanceof VCDSignal<?>);
|
||||
this.width=((VCDSignal<? extends IWaveformEvent>)other).width;
|
||||
this.values=((VCDSignal<T>)other).values;
|
||||
this.db=other.getDb();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id=id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWaveformDb getDb() {
|
||||
return db;
|
||||
}
|
||||
|
||||
public void addSignalChange(Long time, T value){
|
||||
values.put(time, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NavigableMap<Long, T> getEvents() {
|
||||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getWaveformValueAtTime(Long time) {
|
||||
return values.get(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getWaveformValueBeforeTime(Long time) {
|
||||
Entry<Long, T> e = values.floorEntry(time);
|
||||
if(e==null)
|
||||
return null;
|
||||
else
|
||||
return values.floorEntry(time).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean equals(IWaveform other) {
|
||||
return( other instanceof VCDSignal<?> && this.getId().equals(other.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType() {
|
||||
return dummy.getClass();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user