module CrossHairs (clk, BrightRow, BrightCol, ReadData, vcnt, hcnt, PixelDataOut, LaserPoint); // // Input // input clk ; input [7:0] BrightRow ; //Brightest pixel in the image is in this row input [7:0] BrightCol ; //Brightest pixel in the image is in this col input [7:0] ReadData ; //pixel data read from memory input [7:0] vcnt ; //pixel column read from memory input [7:0] hcnt ; //pixel row read from memory input LaserPoint ; // // Output // output [7:0] PixelDataOut ; // // Output registers // reg [7:0] PixelDataOut ; // // Basically, this module determines if the current row and // column being read from memory has a laser point in it. If // it does, then white cross-hairs are displayed on the image, // otherwise the white cross-hairs are not displayed. Also, this // module implements color mapping. All colors that are white // (or nearly white, i.e. >250 on a 0->255 scale) are simply // displayed directly. All other colors are mapped to be // displayed as black pixels (=0). // // Note that there is a one cycle delay from getting the data // from memory and sending the address to memory. Thus, our // row and column will be one pixel out of sync. This can be // fixed at a later date. // always @ (posedge clk) begin if (LaserPoint) //There was a laser point detected in this image begin if ((BrightRow == vcnt ) || (BrightCol == hcnt )) // If the current row == the brightest row in the image, or the current // column == the brightest column in the image, display the pixel as a // white pixel (this will create the cross hairs). PixelDataOut = 255; else // Otherwise, check to see if the original data read from memory is // bright (above a certain threshold, for this application, see if // it is white (=255) or almost white- so check for > 250). If the // pixel is white (>250), then display the pixel. Otherwise, display // the pixel as a black pixel (=0). This effectively filters out all // light except white light (which is the brightest light in the image). if (ReadData > 250) PixelDataOut = ReadData; else PixelDataOut = 0; end else begin // There is no laser point in the image, so don't display any // white pixels (this removes the purple cross hairs from being // displayed in the image). Also, perform the same check as above // to see if the pixel is white or some other (less intense) // color. Display the white pixels without modification, and // display all other colors and intensities as black pixels (=0). if (ReadData > 250) PixelDataOut = ReadData; else PixelDataOut = 0; end end //end always endmodule