Simplify logic and translate to verilog