Modeling, design and fabrication of waveguide gratings for optical signal processing