| JHDL Doc Home Page | User's
Manual Home Page |
// Called each time the simulator resets public void reset(); // Called each clock cycle after the circuit settles public void update(); // Called each time the JHDL system deems a refresh of all // GUI elements is warranted public void refresh();
///////////////////////////////////////////////////////////////////////
import byucc.jhdl.base.*;
import byucc.jhdl.Logic.*;
// Class name is TestObservable. It implements the Observable interface...
public class TestObservable extends Logic implements Observable {
public static CellInterface[] cell_interface = {
out ( "q", "WID" ),
param ("WID", INTEGER),
};
Wire q;
// This is just the constructor as normal
public TestObservable(
Node parent,
Wire q,
String instanceName
) {
super(parent, instanceName);
bind("WID", q.getWidth());
this.q = connect("q", q);
// Build a simple counter...
Wire s = wire(q.getWidth(), "sum");
add_o(q, constant(q.getWidth(), 1), s, "addn");
reg_o( s, q, "cntOut");
}
// The Observable interface stuff follows
int cycle; // Current cycle
public void reset() {
cycle = 0;
}
public void refresh() {
}
// Print results to screen as well
public void update() {
System.out.println("Cycle = " + cycle + ": " + q.get(this));
cycle++;
}
}
///////////////////////////////////////////////////////////////////////
What is being done is that the update() method is being used to
print out the current state of the circuit. The simulator will call this
method every cycle after the circuit has stabilized. The cycle variable
is used to count clock cycles.
This same capability has been successfully to do complex validation of stream-based DSP designs that would be extremely difficult to do by looking at waveforms. For example, consider a system where data arrives infrequently and must be converted from serial to parallel format before any other meaningful processing occurs. The update() method can test the circuit's internal signals each clock cycle and print out key circuit values only on clock cycles when something of interest occurs (a conversion has completed). In addition, this output can be printed in a format that a tool such as Matlab could read in and post-process or plot. It often makes sense to also convert the bits in the circuit to their equivalent floating point representations for viewing (the Jab tools have only integer types available for display).
// The Observable interface stuff follows
int cycle; // Current cycle
TestFrame tf; // Frame to hold cycle count in GUI
public void reset() {
// Create a testFrame if one doesn't exist yet
if (tf != null)
tf.dispose();
tf = new TestFrame();
cycle = 0;
}
// Update information in TestFrame
public void refresh() {
tf.updateValues(q.get(this));
}
// Print results to screen as well
public void update() {
System.out.println("Cycle = " + cycle + ": " + q.get(this));
cycle++;
}
}
Assuming a graphical viewer class named TestFrame has been defined,
this code will create the frame on reset and then update it with new values
by calling its updatevalues() method each cycle. When running in
single step mode in Jab, the TestFrame will then be updated with a new
value each cycle.
| JHDL Doc Home Page | User's Manual Home Page |
Copyright (c) 1998-2003 Brigham Young University. All rights reserved.
Reproduction in whole or in part in any form or medium without express
permission of Brigham Young University is prohibited.
Documentation Revision: 19 Mar, 2001