module LaserSpot (RowAddr, ColAddr, CameraBank, MonitorBank, PixelData, BrightRow, BrightCol, clk, LaserPoint) ; // // Input // input [7:0] RowAddr ; //Current row address being sent to memory input [7:0] ColAddr ; //Current column address being sent to memory input [1:0] CameraBank ; //Current Memory Bank the Camera is writing to input [1:0] MonitorBank ; //Current Memory Bank the Monitor is reading from input [7:0] PixelData ; //Current data being written to memory input clk ; // // Output // output [7:0] BrightRow ; //Brightest row corresponding to the current MonitorBank output [7:0] BrightCol ; //Brightest column corresponding to the current MonitorBank output LaserPoint ; //Is a laser point detected in this image frame // // Registered outputs and local variables // reg [7:0] BrightRow ; //reg output reg [7:0] BrightCol ; //reg output reg LaserPoint ; //reg output reg [7:0] BrightData ; //The current brightest pixel data for the current frame being written to memory reg [7:0] Row0 ; //Local data that stores the row with the brightest pixel for Memory bank 0 reg [7:0] Row1 ; //Same as above for MemoryBank 1 reg [7:0] Row2 ; //Same as above for MemoryBank 2 reg [7:0] Row3 ; //Same as above for MemoryBank 3 reg [7:0] Col0 ; //Local data that stores the column with the brightest pixel for Memory bank 0 reg [7:0] Col1 ; //Same as above for MemoryBank 1 reg [7:0] Col2 ; //Same as above for MemoryBank 2 reg [7:0] Col3 ; //Same as above for MemoryBank 3 reg Laser0 ; //Local data that stores if a laser point was detected in Memory Bank 0 reg Laser1 ; //Same as above for MemoryBank 1 reg Laser2 ; //Same as above for MemoryBank 2 reg Laser3 ; //Same as above for MemoryBank 3 // // Control logic to determine the brightest spot in the frame // being written to memory by the camera. It also determines // if the brightest spot seen so far is bright enough to be // the laser pointer (the pixel data must be > 253). // always @ (posedge clk) begin if ( (RowAddr == 0) && (ColAddr == 0) ) //We're at the beginning of a frame, so reset the BrightData counter BrightData <= 0; case (CameraBank) //Which memory bank is the camera writing to? 2'b00: //Camera Bank 0 begin if (PixelData > BrightData) //We've found a new brightest pixel begin Row0 <= RowAddr; //Save the row address Col0 <= ColAddr; //Save the column address BrightData <= PixelData; //Save the pixel data if ( (PixelData > 253) && (ColAddr < 200) ) //If the pixel data is bright enough to be the laser pointer (>253) Laser0 = 1; else //This pixel can't be the laser pointer because it isn't bright enough Laser0 = 0; end end 2'b01: //Camera Bank 1-- Do the same procedure above for CameraBank 0 begin if (PixelData > BrightData) //We've found a new brightest pixel begin Row1 <= RowAddr; Col1 <= ColAddr; BrightData <= PixelData; if ( (PixelData > 253) && (ColAddr < 200) ) Laser1 = 1; else Laser1 = 0; end end 2'b10: //Camera Bank 2-- Do the same procedure above for CameraBank 0 begin if (PixelData > BrightData) //We've found a new brightest pixel begin Row2 <= RowAddr; Col2 <= ColAddr; BrightData <= PixelData; if ( (PixelData > 253) && (ColAddr < 200) ) Laser2 = 1; else Laser2 = 0; end end 2'b11: //Camera Bank 3-- Do the same procedure above for CameraBank 0 begin if (PixelData > BrightData) //We've found a new brightest pixel begin Row3 <= RowAddr; Col3 <= ColAddr; BrightData <= PixelData; if ( (PixelData > 253) && (ColAddr < 200) ) Laser3 = 1; else Laser3 = 0; end end //default: ; //Nothing goes here because we should always fall into 1 of the 4 cases above endcase end //end always // // Control logic to determine which row, column, and laser point // variable to send to the CrossHairs block. The row and column // will be used by the CrossHairs block to write the crosshairs // on the screen IF there is a laser point in the image. // always @ (posedge clk) begin case (MonitorBank) //Which memory bank is the monitor currently reading from? 2'b00: //Monitor Bank 0 begin BrightRow = Row0; //Output the correct row information for this frame BrightCol = Col0; //Output the correct column information for this frame LaserPoint = Laser0; //Output if there is a laser spot in this frame end 2'b01: //Monitor Bank 1-- Do the same procedure above for MonitorBank 0 begin BrightRow = Row1; BrightCol = Col1; LaserPoint = Laser1; end 2'b10: //Monitor Bank 2-- Do the same procedure above for MonitorBank 0 begin BrightRow = Row2; BrightCol = Col2; LaserPoint = Laser2; end 2'b11: //Monitor Bank 3-- Do the same procedure above for MonitorBank 0 begin BrightRow = Row3; BrightCol = Col3; LaserPoint = Laser3; end //default: ; //Nothing goes here because we should always fall into 1 of the 4 cases above endcase end //end always endmodule