This file is designed to help users become familiar with the UserDefinedSchematic interface and how to create custom glyphs for circuits. In order to create a userdefined schematic, two things are required. first, your class must implement the interface UserDefinedSchematic. This interface contains a single method that you must overload called paint. Here is some code showing how this is used // alu32bit.java // 7/21/98 // Tim Wheeler // Purpose: The 32-bit alu used in the MIPS processor // These are needed for circuit construction and simulation import byucc.jhdl.base.*; import byucc.jhdl.Logic.*; import byucc.jhdl.Xilinx.XC4000.*; import byucc.jhdl.Xilinx.XC4000.carryLogic.*; import Schematic.*; // This is the 32-bit alu. It instantiates 16 2-bit alu modules and combines // them with other logic to make thet 32-bit alu. It extends Logic, which is // similar to Structural, but with added functionality. public class alu32bit extends Logic implements UserDefinedSchematic { ////////// Global declarations ///////////////////////////////////////////// // Port interface, which is necessary in all modules except the testbench public static final String[] portnames = { "i0", "i1", "aluop", "result", "cout", "zero" }, portwidths = { "32", "32", "3", "32", "1", "1" }, portios = { "in", "in", "in", "out", "out", "out" }; public String cellname = "ALU32BIT"; //////////////////////////////////////////////////////////////////////////// public void paint( UserDefinedNode udn ) { udn.setSize( 40, 60 ); udn.drawLine( 0, 0, 0, 20 ); udn.drawLine( 0, 20, 5, 25 ); udn.drawLine( 5, 25, 0, 30 ); udn.drawLine( 0, 30, 0, 50 ); udn.drawLine( 0, 50, 40, 40 ); udn.drawLine( 40, 40, 40, 10 ); udn.drawLine( 40, 10, 0, 0 ); udn.drawLine( 20, 45, 20, 60 ); udn.drawLine( 7, 25, 17, 25 ); udn.drawLine( 12, 20, 12, 30 ); udn.addInPort( 0, 10, "i0" ); udn.addInPort( 0, 40, "i1" ); udn.addInPort( 20, 60, "aluop" ); udn.addOutPort( 40, 25, "result" ); udn.addOutPort( 40, 15, "cout" ); udn.addOutPort( 40, 35, "zero" ); } UserDefinedNode, the object passed into the paint routine, contains a number of methods that will allow the user to create their own schematic. public void drawLine( int x1, int y1, int x2, int y2 ) this draws a line from point 1 to point 2 public void drawRect( int x, int y, int width, int height ) this creates a rectangle where the upper left corner is located at (x,y) public void drawArc( int x, int y, int width, int height, int startAngle, int rotateAngle ) this draws an arc inside of a rectangle specified by the first 4 arguments. the startAngle argument specifies where the arc will start. 0 is pointing to the right and it rotates clockwise. (i.e. 90 is pointing down ). the rotate angle specifies how many degress to rotate the arc in the clockwise direction. ( 360 for rotateAngle will create a circle or ellipse ) public void drawText( int x, int y, String text ) draws text at (x,y) (*note portnames and cellname is automatically added) public void setSize( int width, int height ) sets the size of the glyph public void addInPort( int x, int y, String name ) places the in port specified by name at location (x,y) public void addOutPort( int x, int y, String name ) places the out port specified by name at location (x,y) public void addCellName( String name ) changes default cell name to name. If this function is not called the schematic will use the name specified by the instance.