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

Subversion Repositories alternascope

[/] [alternascope/] [tags/] [Devel/] [UserInput/] [sub_UserLines.v] - Blame information for rev 30

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 smpickett
//==================================================================//
2
// File:    sub_UserLines.v                                         //
3
// Version: 0.0.0.1                                                 //
4
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//
5
// Copyright (C) Stephen Pickett                                    //
6
//   Jun 08, 2005                                                   //
7
//                                                                  //
8
// This program is free software; you can redistribute it and/or    //
9
// modify it under the terms of the GNU General Public License      //
10
// as published by the Free Software Foundation; either version 2   //
11
// of the License, or (at your option) any later version.           //
12
//                                                                  //
13
// This program is distributed in the hope that it will be useful,  //
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of   //
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    //
16
// GNU General Public License for more details.                     //
17
//                                                                  //
18
// If you have not received a copy of the GNU General Public License//
19
// along with this program; write to:                               //
20
//     Free Software Foundation, Inc.,                              //
21
//     51 Franklin Street, Fifth Floor,                             //
22
//     Boston, MA  02110-1301, USA.                                 //
23
//                                                                  //
24
//------------------------------------------------------------------//
25
// Revisions:                                                       //
26
// Ver 0.0.0.1     Jun 08, 2005   Under Development                 //
27
//                                                                  //
28
//==================================================================//
29
 
30
module sub_UserLines(
31
    MASTER_CLK, MASTER_RST,
32
    LINE_VALUE_OUT,
33
    BUTTON_RISE, BUTTON_FALL,
34
    XCOORD, YCOORD,
35
    LEFT, RGHT, BOT, TOP,
36
    SETXnY
37
);
38
 
39
//==================================================================//
40
// DEFINITIONS                                                      //
41
//==================================================================//
42
 
43
 
44
//==================================================================//
45
// VARIABLE DEFINITIONS                                             //
46
//==================================================================//
47
//----------------------//
48
// INPUTS / OUTPUTS     //
49
//----------------------//
50
input MASTER_CLK;       // global master clock
51
input MASTER_RST;       // global master reset
52
input XCOORD, YCOORD;   // X and Y coordinates of the current mouse
53
                        // position. See the documentation for details
54
input LEFT, RGHT;       // Left and Right limits for 'InRange'
55
input TOP, BOT;         // Top and Bottom limits for 'InRange'
56
input SETXnY;           // Upon trigger, either set the 'Value' to the
57
                        // X or Y coord.
58
input BUTTON_RISE;      // Trigger has risen
59
input BUTTON_FALL;      // Trigger has fallen
60
 
61
output[9:0] LINE_VALUE_OUT;    // a 10 bit register to store the X or Y value
62
 
63
//----------------------//
64
//        NODES         //
65
//----------------------//
66
wire      MASTER_CLK, MASTER_RST;
67
wire[9:0] XCOORD, YCOORD;
68
wire[9:0] LEFT, RGHT, TOP, BOT;
69
wire      SETXnY;
70
wire      BUTTON_RISE, BUTTON_FALL;
71
 
72
reg[9:0] LINE_VALUE_OUT;
73
 
74
 
75
 
76
 
77
//==================================================================//
78
//                         T E S T I N G                            //
79
//==================================================================//
80
// NOTHING TO TEST
81
 
82
//==================================================================//
83
// FUNCTIONAL DEFINITIONS                                           //
84
//==================================================================//
85
wire in_range;
86
reg drag;
87
 
88
assign in_range = (((YCOORD >= BOT) && (YCOORD <= TOP)) && ((XCOORD >= LEFT && XCOORD <= RGHT)));
89
 
90
// the 'DRAG' state machine
91
always @ (posedge MASTER_CLK or posedge MASTER_RST) begin
92
    if(MASTER_RST)
93
        drag <= 1'b0;
94
    else if(BUTTON_RISE && in_range)
95
        drag <= 1'b1;
96
    else if(BUTTON_FALL)
97
        drag <= 1'b0;
98
    else
99
        drag <= drag;
100
end
101
 
102
 
103
always @ (posedge MASTER_CLK or posedge MASTER_RST) begin
104
    if(MASTER_RST)
105
        LINE_VALUE_OUT <= 10'd200;
106
    else if(drag && SETXnY)
107
        LINE_VALUE_OUT <= XCOORD;
108
    else if(drag && !SETXnY)
109
        LINE_VALUE_OUT <= YCOORD;
110
    else
111
        LINE_VALUE_OUT <= LINE_VALUE_OUT;
112
end
113
 
114
 
115
 
116
endmodule
117
 

powered by: WebSVN 2.1.0

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