![JAR search and dependency download from the Maven repository](/logo.png)
com.sun.electric.tool.simulation.SweptSample Maven / Gradle / Ivy
/* -*- tab-width: 4 -*-
*
* Electric(tm) VLSI Design System
*
* File: SweptSample.java
*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*
* Electric(tm) is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Electric(tm) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Electric(tm); see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, Mass 02111-1307, USA.
*/
package com.sun.electric.tool.simulation;
import com.sun.electric.database.geometry.PolyBase;
import com.sun.electric.tool.user.waveform.Panel;
import com.sun.electric.tool.user.waveform.WaveSignal;
import com.sun.electric.tool.user.waveform.Panel.WaveSelection;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;
import java.util.HashSet;
import java.util.List;
import java.util.TreeMap;
/**
* A sweep of many Signal is represented as a single
* Signal>.
*/
public class SweptSample implements Sample
{
private final Sample[] vals;
public SweptSample(Sample[] vals)
{
this.vals = new Sample[vals.length];
for(int i=0; i)) return false;
SweptSample> bo = (SweptSample>)o;
if (bo.vals.length != vals.length) return false;
for(int i=0; i)) throw new RuntimeException("tried to call SweptSample.lub("+s.getClass().getName()+")");
SweptSample> ds = (SweptSample>)s;
if (ds.vals.length != vals.length) throw new RuntimeException("tried to call lub() on SweptSamples of different width");
Sample[] ret = new Sample[vals.length];
for(int i=0; i(ret);
}
public Sample glb(Sample s)
{
if (!(s instanceof SweptSample>)) throw new RuntimeException("tried to call SweptSample.glb("+s.getClass().getName()+")");
SweptSample> ds = (SweptSample>)s;
if (ds.vals.length != vals.length) throw new RuntimeException("tried to call glb() on SweptSamples of different width");
Sample[] ret = new Sample[vals.length];
for(int i=0; i(ret);
}
public double getMinValue()
{
double min = Double.MAX_VALUE;
for(int i=0; i> */
public static Signal> createSignal(SignalCollection sc, Stimuli sd,
String signalName, String signalContext, int width)
{
/*
final Unboxed> unboxer = new Unboxed>() {
public int getSize() { return 1; }
public DigitalSample deserialize(byte[] buf, int ofs) { return fromByteRepresentation(buf[ofs]); }
public void serialize(DigitalSample v, byte[] buf, int ofs) { buf[ofs] = v.getByteRepresentation(); }
public int compare(byte[] buf1, int ofs1, byte[] buf2, int ofs2) { return (buf1[ofs1]&0xff)-(buf2[ofs2]&0xff); }
};
Signal ret =
new BTreeSignal(an, signalName, signalContext, BTreeSignal.getTree(unboxer, latticeOp)) {
public boolean isAnalog() { return true; }
};
an.addSignal(ret);
return ret;
*/
throw new RuntimeException("not implemented");
}
/** create a Signal> from preexisting Signal's */
public static Signal> createSignal(SignalCollection sc, Stimuli sd,
String signalName, String signalContext, boolean digital, final Signal[] subsignals)
{
final String scName = sc.getName();
return new Signal>(sc, sd, signalName, signalContext, digital)
{
public boolean isEmpty() { for(Signal sig : subsignals) if (!sig.isEmpty()) return false; return true; }
public Signal.View>> getRasterView(final double t0, final double t1, final int numPixels)
{
final Signal.View>[] subviews = new Signal.View[subsignals.length];
for(int i=0; i (exists j such that subviews[i].getTime(j)==t)
TreeMap> tm = new TreeMap>();
for (int i=0; i> view = subviews[i];
for(int j=0; j hs = tm.get(t);
if (hs==null) tm.put(t, hs = new HashSet());
hs.add(i);
}
}
// now we know, for each point in time, which signals changed at that point
final double[] times = new double[tm.size()];
final RangeSample>[] vals = new RangeSample[tm.size()];
int i = 0;
int[] event = new int[subviews.length];
SS[] minvals = (SS[])new Sample[subviews.length];
SS[] maxvals = (SS[])new Sample[subviews.length];
for(double t : tm.keySet())
{
times[i] = t;
HashSet hs = tm.get(t);
for(int v : hs)
{
assert subviews[v].getTime(event[v])==t; // sanity check
RangeSample rs = subviews[v].getSample(event[v]);
if (rs != null)
{
minvals[v] = rs.getMin();
maxvals[v] = rs.getMax();
}
event[v]++;
}
//for(int j=0; j>>>>>>>>>>>>>> MINVALS["+j+"] NULL (ARRAY IS "+subviews.length+" LONG)"); debug = true; }
// if (maxvals[j] == null)
// { System.out.println(">>>>>>>>>>>>>>> MAXVALS["+j+"] NULL (ARRAY IS "+subviews.length+" LONG)"); debug = true; }
// if (debug)
// {
// System.out.println(" TIMES FOUND:");
// for(double tt : tm.keySet())
// {
// System.out.print(" " + tt + " IN");
// HashSet hss = tm.get(t);
// for(int vv : hss) System.out.print(" " + vv);
// System.out.println();
// }
// System.out.println();
// }
//}
vals[i] = new RangeSample>( new SweptSample(minvals), new SweptSample(maxvals) );
i++;
}
return new Signal.View>>()
{
public int getNumEvents() { return times.length; }
public double getTime(int event) { return times[event]; }
public RangeSample> getSample(int event) { return vals[event]; }
};
}
public Signal.View> getExactView()
{
final Signal.View[] subviews = new Signal.View[subsignals.length];
for(int i=0; i (exists j such that subviews[i].getTime(j)==t)
TreeMap> tm = new TreeMap>();
for (int i=0; i view = subviews[i];
for(int j=0; j hs = tm.get(t);
if (hs == null) tm.put(t, hs = new HashSet());
hs.add(i);
}
}
// now we know, for each point in time, which signals changed at that point
final double[] times = new double[tm.size()];
final SweptSample[] vals = new SweptSample[tm.size()];
int i = 0;
int[] event = new int[subviews.length];
SS[] sampleVals = (SS[])new Sample[subviews.length];
for(double t : tm.keySet())
{
times[i] = t;
HashSet hs = tm.get(t);
for(int v : hs)
{
assert subviews[v].getTime(event[v])==t; // sanity check
SS rs = subviews[v].getSample(event[v]);
if (rs != null) sampleVals[v] = rs;
event[v]++;
}
vals[i] = new SweptSample(sampleVals);
i++;
}
return new Signal.View>()
{
public int getNumEvents() { return times.length; }
public double getTime(int event) { return times[event]; }
public SweptSample getSample(int event) { return vals[event]; }
};
}
public double getMinTime()
{
double min = Double.MAX_VALUE;
for(Signal sig : subsignals) min = Math.min(min, sig.getMinTime());
return min;
}
public double getMaxTime()
{
double max = -Double.MAX_VALUE;
for(Signal sig : subsignals) max = Math.max(max, sig.getMaxTime());
return max;
}
public double getMinValue()
{
double min = Double.MAX_VALUE;
for(Signal sig : subsignals) min = Math.min(min, sig.getMinValue());
return min;
}
public double getMaxValue()
{
double max = -Double.MAX_VALUE;
for(Signal sig : subsignals) max = Math.max(max, sig.getMaxValue());
return max;
}
public void plot(Panel panel, Graphics g, WaveSignal ws, Color light, List forPs,
Rectangle2D bounds, List selectedObjects, Signal> xAxisSignal)
{
for(int i=0; i)subsignals[i], panel, g, ws, light, forPs, bounds, selectedObjects, xAxisSignal);
}
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy