OpenCores
URL https://opencores.org/ocsvn/alternascope/alternascope/trunk

Subversion Repositories alternascope

[/] [alternascope/] [branches/] [Alpha/] [UserInput/] [d_MouseInput.v] - Diff between revs 2 and 5

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 5
Line 1... Line 1...
//==================================================================
//==================================================================//
// File:    d_MouseInput.v
// File:    d_MouseInput.v                                          //
// Version: 0.01
// Version: 0.0.0.2                                                 //
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//
// Copyright Stephen Pickett
// Copyright (C) Stephen Pickett                                    //
//   May 19, 2005
//   Jun 08, 2005                                                   //
//------------------------------------------------------------------
//                                                                  //
// Revisions:
// This program is free software; you can redistribute it and/or    //
// Ver 0.01     May 19, 2005    Initial Release
// modify it under the terms of the GNU General Public License      //
//
// as published by the Free Software Foundation; either version 2   //
//==================================================================
// of the License, or (at your option) any later version.           //
 
//                                                                  //
 
// This program is distributed in the hope that it will be useful,  //
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of   //
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    //
 
// GNU General Public License for more details.                     //
 
//                                                                  //
 
// If you have not received a copy of the GNU General Public License//
 
// along with this program; write to:                               //
 
//     Free Software Foundation, Inc.,                              //
 
//     51 Franklin Street, Fifth Floor,                             //
 
//     Boston, MA  02110-1301, USA.                                 //
 
//                                                                  //
 
//------------------------------------------------------------------//
 
// Revisions:                                                       //
 
// Ver 0.0.0.1     May   , 2005   Under Development                 //
 
// Ver 0.0.0.2     Jun 08, 2005    Modulized 'UserLines'            //
 
//                                                                  //
 
//==================================================================//
 
 
module Driver_MouseInput(
module Driver_MouseInput(
    CLK_50MHZ, MASTER_RST,
    CLK_50MHZ, MASTER_RST,
    XCOORD, YCOORD, L_BUTTON, R_BUTTON, M_BUTTON,
    XCOORD, YCOORD, L_BUTTON, R_BUTTON, M_BUTTON,
    TRIGGER_LEVEL,
    TRIGGER_LEVEL
    TEST_in_range_trig
 
    );
    );
 
 
 
 
//==================================================================//
//==================================================================//
// DEFINITIONS                                                      //
// PARAMETER DEFINITIONS                                            //
//==================================================================//
//==================================================================//
 
parameter P_trigger_clickLimit_left     = 10'd556;
 
parameter P_trigger_clickLimit_right    = 10'd558;
 
 
 
 
//==================================================================//
//==================================================================//
// VARIABLE DEFINITIONS                                             //
// VARIABLE DEFINITIONS                                             //
//==================================================================//
//==================================================================//
//----------------------//
//----------------------//
// INPUTS / OUTPUTS     //
// INPUTS / OUTPUTS     //
//----------------------//
//----------------------//
input CLK_50MHZ;            // System wide clock
input CLK_50MHZ;            // System wide clock
input MASTER_RST;           // System wide reset
input MASTER_RST;           // System wide reset
input[11:0] XCOORD;         // X coordinate of the cursor
input[9:0] XCOORD;          // X coordinate of the cursor
input[11:0] YCOORD;         // Y coordinate of the cursor
input[9:0] YCOORD;          // Y coordinate of the cursor
input L_BUTTON;             // Left Mouse Button Press
input L_BUTTON;             // Left Mouse Button Press
input R_BUTTON;             // Right Mouse Button Press
input R_BUTTON;             // Right Mouse Button Press
input M_BUTTON;             // Middle Mouse Button Press
input M_BUTTON;             // Middle Mouse Button Press
output[8:0] TRIGGER_LEVEL;  // Current Trigger Level
output[9:0] TRIGGER_LEVEL;  // Current Trigger Level
 
 
//----------------------//
//----------------------//
// WIRES / NODES        //
// WIRES / NODES        //
//----------------------//
//----------------------//
wire CLK_50MHZ, MASTER_RST;
wire CLK_50MHZ, MASTER_RST;
wire[11:0] XCOORD;
wire[9:0] XCOORD;
wire[11:0] YCOORD;
wire[9:0] YCOORD;
wire L_BUTTON, R_BUTTON, M_BUTTON;
wire L_BUTTON, R_BUTTON, M_BUTTON;
reg[8:0] TRIGGER_LEVEL;
wire[9:0] TRIGGER_LEVEL;
 
 
//----------------------//
//----------------------//
// REGISTERS            //
// REGISTERS            //
//----------------------//
//----------------------//
 
 
 
 
//----------------------//
//----------------------//
// TESTING              //
// TESTING              //
//----------------------//
//----------------------//
output TEST_in_range_Trig;
 
wire TEST_in_range_Trig;
 
 
 
 
 
 
 
 
 
//==================================================================//
//==================================================================//
Line 65... Line 83...
//==================================================================//
//==================================================================//
 
 
//------------------------------------------------------------------//
//------------------------------------------------------------------//
// INTERMEDIATES                                                    //
// INTERMEDIATES                                                    //
//------------------------------------------------------------------//
//------------------------------------------------------------------//
 
 
 
// -- LEFT BUTTON --
wire Lrise, Lfall;
wire Lrise, Lfall;
reg  Lbuf;
reg  Lbuf;
always @ (posedge CLK_50MHZ or posedge MASTER_RST) begin
always @ (posedge CLK_50MHZ or posedge MASTER_RST) begin
    if(MASTER_RST == 1'b1)
    if(MASTER_RST == 1'b1) Lbuf <= 1'b0;
        Lbuf <= 1'b0;
    else                   Lbuf <= L_BUTTON;
    else
 
        Lbuf <= L_BUTTON;
 
end
end
 
 
assign Lrise = (!Lbuf &  L_BUTTON);
assign Lrise = (!Lbuf &  L_BUTTON);
assign Lfall = ( Lbuf & !L_BUTTON);
assign Lfall = ( Lbuf & !L_BUTTON);
 
 
//------------------------------------------------------------------//
// -- RIGHT BUTTON --
// TRIGGER                                                          //
wire Rrise, Rfall;
//------------------------------------------------------------------//
reg  Rbuf;
reg in_range_Trig;
 
reg Ldrag_Trig;
 
always @ (YCOORD or XCOORD or TRIGGER_LEVEL) begin
 
    in_range_Trig = (((YCOORD >= TRIGGER_LEVEL-1'b1) && (YCOORD <= TRIGGER_LEVEL+1'b1)) && ((XCOORD >= 10'd556 && XCOORD <= 10'd558)));
 
end
 
 
 
assign TEST_in_range_Trig = in_range_Trig;
 
 
 
always @ (posedge CLK_50MHZ or posedge MASTER_RST) begin
always @ (posedge CLK_50MHZ or posedge MASTER_RST) begin
    if(MASTER_RST)
    if(MASTER_RST == 1'b1) Rbuf <= 1'b0;
        Ldrag_Trig <= 1'b0;
    else                   Rbuf <= R_BUTTON;
    else if(Lrise && in_range_Trig)
 
        Ldrag_Trig <= 1'b1;
 
    else if(Lfall)
 
        Ldrag_Trig <= 1'b0;
 
    else
 
        Ldrag_Trig <= Ldrag_Trig;
 
end
end
 
 
 
assign Rrise = (!Rbuf &  R_BUTTON);
 
assign Rfall = ( Rbuf & !R_BUTTON);
 
 
 
 
 
// -- MIDDLE BUTTON --
 
wire Mrise, Mfall;
 
reg  Mbuf;
always @ (posedge CLK_50MHZ or posedge MASTER_RST) begin
always @ (posedge CLK_50MHZ or posedge MASTER_RST) begin
    if(MASTER_RST)
    if(MASTER_RST == 1'b1) Mbuf <= 1'b0;
        TRIGGER_LEVEL <= 9'd200;
    else                   Mbuf <= M_BUTTON;
    else if(Ldrag_Trig)
 
        TRIGGER_LEVEL <= YCOORD;
 
    else
 
        TRIGGER_LEVEL <= TRIGGER_LEVEL;
 
end
end
 
 
 
assign Mrise = (!Mbuf &  M_BUTTON);
 
assign Mfall = ( Mbuf & !M_BUTTON);
 
 
 
 
 
//------------------------------------------------------------------//
 
// USER MODIFIABLE LINES                                            //
 
//------------------------------------------------------------------//
 
sub_UserLines set_trigger(
 
        .MASTER_CLK(CLK_50MHZ), .MASTER_RST(MASTER_RST),
 
        .LINE_VALUE_OUT(TRIGGER_LEVEL),
 
        .BUTTON_RISE(Lrise),
 
        .BUTTON_FALL(Lfall),
 
        .XCOORD(XCOORD),
 
        .YCOORD(YCOORD),
 
        .LEFT(P_trigger_clickLimit_left),
 
        .RGHT(P_trigger_clickLimit_right),
 
        .BOT(TRIGGER_LEVEL-1'b1),
 
        .TOP(TRIGGER_LEVEL+1'b1),
 
        .SETXnY(1'b0)
 
        );
 
 
 
 
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.