/*
Copyright: (C) 2002 Brigham Young University

This program is free software; you can redistribute it and/or modify it
under the terms of the Open Source Software License Agreement for JHDL.

You should have received a copy of the Open Source Software License for
JHDL along with this program.  If you have not, download the License
Agreement at http://www.jhdl.org/license.html or write to:

Brad Hutchings
459 Clyde Bldg
Brigham Young University
Provo, UT 84602


*/


import byucc.jhdl.base.CellInterface;
import byucc.jhdl.base.Node;
import byucc.jhdl.base.Wire;
 
import byucc.jhdl.Logic.Logic;

public class mod4count2 extends Logic {
  
  public static CellInterface[] cell_interface = {
    in( "reset", 1 ),
    in( "mod4", 1 ),
    out( "total_count", "wid" ),
    param( "wid", INTEGER )
  };

  public mod4count2(Node parent, int length, Wire reset,
		    Wire mod4, Wire total_count) {

    super(parent); 

    int i;
    int width = total_count.getWidth();

    bind( "wid", width);
    connect("reset", reset);
    connect("mod4", mod4);
    connect("total_count", total_count);

    Wire addem = or(mod4,reset);
    // Count up if addem is asserted.  count down otherwise.
    new upDownCounter(this, reset, constant(width,length),
		      addem, vcc(), total_count); 
  }
}
