/*
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 char_slice2 extends Logic {
  
  public static CellInterface[] cell_interface = {
    in( "reset", 1 ),
    in( "char_in", 4 ),
    in( "src_dist_in", 1 ),
    out( "reset_out", 1 ),
    out( "char_out", 4 ),
    out( "src_dist_out", 1 )
  };
 
  public char_slice2(Node parent, Wire reset, Wire char_in,
		     Wire src_dist_in, Wire reset_out,
		     Wire char_out, Wire src_dist_out, char target) {
    super(parent); 

    connect("reset", reset);
    connect("reset_out", reset_out);
    connect("src_dist_in", src_dist_in);
    connect("src_dist_out", src_dist_out);
    connect("char_in", char_in);
    connect("char_out", char_out);

    Wire match = wire(1, "match");

    // Pass reset through
    reg_o(reset,reset_out);

    // This is a character comparator, if char_in matches the target char
    // it will assert match.  It also passes char_in to char_out.
    new charcomp2(this, char_in, match, char_out, target);

    /* This finite state machine uses the source distance in, match, and state
       to determine the source distance out. */
    new char_fsm2(this, reset, match, src_dist_in, src_dist_out);
  }
}




