JHDL 0.3.45

| JHDL Doc Home Page | User's Manual Home Page |


Customizing the appearance of Cells

Customizing the appearance of different logic cells can make a circuit easier to understand in the schematic viewer.  Not only can you use it to show what the cell is, but you can also give other information about the cell such as it's state for more quickly following the path of signals.

For a full example, look at  myffd_o.java  and  ring.java .

In order to change the appearance, a few things are necessarry.  First of all you must import the UserDefinedNode class, and the UserDefinedSchematic interface.:

import byucc.jhdl.apps.Viewers.Schematic.UserDefinedSchemaitc;
import byucc.jhdl.apps.Viewers.Schematic.UserDefinedNode;

Then you must impliement two methods.  The first one is initUserDefinedNode.  It is used to define the size of the cell, and also to add the ports.  Note that all ports must be added, or the default schematic will drawn.  This means that even the implicit clock port (if any) must be added as an in port, and probably is named c.  All port names should be the same as the cell interface.

public void initUserDefinedNode(UserDefinedNode(UserDefinedNode udn){
    udn.setPortSeperation(3);
    udn.setSize(30,40);
    udn.addInPort(0,10,"d");
    udn.addInPort(0,20,"c");    //add an implicit clock port.
    udn.addOutPort(20,25,"q");
}
 

Next the paint method is added to draw everything else.  This is where creativity is great--you can let the circuit show what is happining inside.

public void paint(UserDefinedNode udn){
    udn.drawRect(0,0,30,40);
    //Add creative stuff--
}
 

Some other drawing commands for the UserDefinedNode include drawArc, drawLine, and drawString.

For a full list of drawing options, go to the jhdl documentations and look up the UserDefinedNode class.
 
 


| 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: $Date: 2003/04/24 14:15:10 $