import java.io.*; import byucc.jhdl.base.*; import byucc.jhdl.Xilinx.*; import byucc.jhdl.Xilinx.XC4000.*; import byucc.jhdl.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); } }