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

Subversion Repositories alternascope

[/] [alternascope/] [trunk/] [UserInput/] [sub_UserLines.v] - Diff between revs 28 and 30

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 28 Rev 30
//==================================================================//
//==================================================================//
// File:    sub_UserLines.v                                         //
// File:    sub_UserLines.v                                         //
// Version: 0.0.0.1                                                 //
// Version: 0.0.0.1                                                 //
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//
// Copyright (C) Stephen Pickett                                    //
// Copyright (C) Stephen Pickett                                    //
//   Jun 08, 2005                                                   //
//   Jun 08, 2005                                                   //
//                                                                  //
//                                                                  //
// This program is free software; you can redistribute it and/or    //
// This program is free software; you can redistribute it and/or    //
// modify it under the terms of the GNU General Public License      //
// modify it under the terms of the GNU General Public License      //
// as published by the Free Software Foundation; either version 2   //
// as published by the Free Software Foundation; either version 2   //
// of the License, or (at your option) any later version.           //
// of the License, or (at your option) any later version.           //
//                                                                  //
//                                                                  //
// This program is distributed in the hope that it will be useful,  //
// This program is distributed in the hope that it will be useful,  //
// but WITHOUT ANY WARRANTY; without even the implied warranty of   //
// but WITHOUT ANY WARRANTY; without even the implied warranty of   //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    //
// GNU General Public License for more details.                     //
// GNU General Public License for more details.                     //
//                                                                  //
//                                                                  //
// If you have not received a copy of the GNU General Public License//
// If you have not received a copy of the GNU General Public License//
// along with this program; write to:                               //
// along with this program; write to:                               //
//     Free Software Foundation, Inc.,                              //
//     Free Software Foundation, Inc.,                              //
//     51 Franklin Street, Fifth Floor,                             //
//     51 Franklin Street, Fifth Floor,                             //
//     Boston, MA  02110-1301, USA.                                 //
//     Boston, MA  02110-1301, USA.                                 //
//                                                                  //
//                                                                  //
//------------------------------------------------------------------//
//------------------------------------------------------------------//
// Revisions:                                                       //
// Revisions:                                                       //
// Ver 0.0.0.1     Jun 08, 2005   Under Development                 //
// Ver 0.0.0.1     Jun 08, 2005   Under Development                 //
//                                                                  //
//                                                                  //
//==================================================================//
//==================================================================//
 
 
module sub_UserLines(
module sub_UserLines(
    MASTER_CLK, MASTER_RST,
    MASTER_CLK, MASTER_RST,
    LINE_VALUE_OUT,
    LINE_VALUE_OUT,
    BUTTON_RISE, BUTTON_FALL,
    BUTTON_RISE, BUTTON_FALL,
    XCOORD, YCOORD, RESET_VALUE,
    XCOORD, YCOORD, RESET_VALUE,
    LEFT, RGHT, BOT, TOP,
    LEFT, RGHT, BOT, TOP,
    SETXnY
    SETXnY
);
);
 
 
//==================================================================//
//==================================================================//
// DEFINITIONS                                                      //
// DEFINITIONS                                                      //
//==================================================================//
//==================================================================//
 
 
 
 
//==================================================================//
//==================================================================//
// VARIABLE DEFINITIONS                                             //
// VARIABLE DEFINITIONS                                             //
//==================================================================//
//==================================================================//
//----------------------//
//----------------------//
// INPUTS / OUTPUTS     //
// INPUTS / OUTPUTS     //
//----------------------//
//----------------------//
input MASTER_CLK;       // global master clock
input MASTER_CLK;       // global master clock
input MASTER_RST;       // global master reset
input MASTER_RST;       // global master reset
input XCOORD, YCOORD;   // X and Y coordinates of the current mouse
input XCOORD, YCOORD;   // X and Y coordinates of the current mouse
                        // position. See the documentation for details
                        // position. See the documentation for details
input LEFT, RGHT;       // Left and Right limits for 'InRange'
input LEFT, RGHT;       // Left and Right limits for 'InRange'
input TOP, BOT;         // Top and Bottom limits for 'InRange'
input TOP, BOT;         // Top and Bottom limits for 'InRange'
input SETXnY;           // Upon trigger, either set the 'Value' to the
input SETXnY;           // Upon trigger, either set the 'Value' to the
                        // X or Y coord.
                        // X or Y coord.
input BUTTON_RISE;      // Trigger has risen
input BUTTON_RISE;      // Trigger has risen
input BUTTON_FALL;      // Trigger has fallen
input BUTTON_FALL;      // Trigger has fallen
 
 
output[9:0] LINE_VALUE_OUT;    // a 10 bit register to store the X or Y value
output[9:0] LINE_VALUE_OUT;    // a 10 bit register to store the X or Y value
 
 
input[9:0] RESET_VALUE; // Reset value
input[9:0] RESET_VALUE; // Reset value
 
 
//----------------------//
//----------------------//
//        NODES         //
//        NODES         //
//----------------------//
//----------------------//
wire      MASTER_CLK, MASTER_RST;
wire      MASTER_CLK, MASTER_RST;
wire[9:0] XCOORD, YCOORD, RESET_VALUE;
wire[9:0] XCOORD, YCOORD, RESET_VALUE;
wire[9:0] LEFT, RGHT, TOP, BOT;
wire[9:0] LEFT, RGHT, TOP, BOT;
wire      SETXnY;
wire      SETXnY;
wire      BUTTON_RISE, BUTTON_FALL;
wire      BUTTON_RISE, BUTTON_FALL;
 
 
reg[9:0] LINE_VALUE_OUT;
reg[9:0] LINE_VALUE_OUT;
 
 
 
 
 
 
 
 
//==================================================================//
//==================================================================//
//                         T E S T I N G                            //
//                         T E S T I N G                            //
//==================================================================//
//==================================================================//
// NOTHING TO TEST
// NOTHING TO TEST
 
 
//==================================================================//
//==================================================================//
// FUNCTIONAL DEFINITIONS                                           //
// FUNCTIONAL DEFINITIONS                                           //
//==================================================================//
//==================================================================//
wire in_range;
wire in_range;
reg drag;
reg drag;
 
 
assign in_range = (((YCOORD >= BOT) && (YCOORD <= TOP)) && ((XCOORD >= LEFT && XCOORD <= RGHT)));
assign in_range = (((YCOORD >= BOT) && (YCOORD <= TOP)) && ((XCOORD >= LEFT && XCOORD <= RGHT)));
 
 
// the 'DRAG' state machine
// the 'DRAG' state machine
always @ (posedge MASTER_CLK or posedge MASTER_RST) begin
always @ (posedge MASTER_CLK or posedge MASTER_RST) begin
    if(MASTER_RST)
    if(MASTER_RST)
        drag <= 1'b0;
        drag <= 1'b0;
    else if(BUTTON_RISE && in_range)
    else if(BUTTON_RISE && in_range)
        drag <= 1'b1;
        drag <= 1'b1;
    else if(BUTTON_FALL)
    else if(BUTTON_FALL)
        drag <= 1'b0;
        drag <= 1'b0;
    else
    else
        drag <= drag;
        drag <= drag;
end
end
 
 
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Until this is figured out, it is bad to have the lines at 'zero'
   Until this is figured out, it is bad to have the lines at 'zero'
   (due to the comparison for 'in range')
   (due to the comparison for 'in range')
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
always @ (posedge MASTER_CLK or posedge MASTER_RST) begin
always @ (posedge MASTER_CLK or posedge MASTER_RST) begin
    if(MASTER_RST)
    if(MASTER_RST)
        LINE_VALUE_OUT <= RESET_VALUE;
        LINE_VALUE_OUT <= RESET_VALUE;
    else if(drag && SETXnY)
    else if(drag && SETXnY)
        LINE_VALUE_OUT <= XCOORD;
        LINE_VALUE_OUT <= XCOORD;
    else if(drag && !SETXnY && (YCOORD<=10'd400))
    else if(drag && !SETXnY && (YCOORD<=10'd400))
        LINE_VALUE_OUT <= YCOORD;
        LINE_VALUE_OUT <= YCOORD;
    else
    else
        LINE_VALUE_OUT <= LINE_VALUE_OUT;
        LINE_VALUE_OUT <= LINE_VALUE_OUT;
end
end
 
 
 
 
 
 
endmodule
endmodule
 
 
 
 

powered by: WebSVN 2.1.0

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