/* 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_fsm2 extends Logic { public static CellInterface[] cell_interface = { in( "reset", 1 ), in( "match", 1 ), in( "src_dist_in", 1 ), out( "src_dist_out", 1 ) }; public char_fsm2(Node parent, Wire reset, Wire match, Wire src_dist_in, Wire src_dist_out) { super(parent); connect("reset", reset); connect("src_dist_in", src_dist_in); connect("src_dist_out", src_dist_out); connect("match", match); // Determine new value a or a+2 // Then encode source distance out in one bit. 1 if it is greater // Than the value above it in the table. 0 if it is less than. Wire next_tar_dist = wire(1, "next_tar_dist"); Wire unique = wire(1, "unique"); Wire next_src_dist = wire(1, "next_src_dist"); Wire tar_dist_in = wire(1, "tar_dist_in"); reg_o(mux(next_tar_dist,vcc(),reset),tar_dist_in); // This determines whether we should let the new value = a or a+2 // Look for the below unique case and_o(src_dist_in,tar_dist_in,not(match), unique); // compute the next source distance. or_o(not(tar_dist_in),unique,next_src_dist); // Register the next source distance, or horizontal value. reg_o(next_src_dist, src_dist_out); // Compute the next target distance, or vertical value. or_o(not(src_dist_in),unique,next_tar_dist); } }