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

Subversion Repositories alternascope

[/] [alternascope/] [trunk/] [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 27 smpickett
    XCOORD, YCOORD, RESET_VALUE,
35 5 smpickett
    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 27 smpickett
input[9:0] RESET_VALUE; // Reset value
64
 
65 5 smpickett
//----------------------//
66
//        NODES         //
67
//----------------------//
68
wire      MASTER_CLK, MASTER_RST;
69 27 smpickett
wire[9:0] XCOORD, YCOORD, RESET_VALUE;
70 5 smpickett
wire[9:0] LEFT, RGHT, TOP, BOT;
71
wire      SETXnY;
72
wire      BUTTON_RISE, BUTTON_FALL;
73
 
74
reg[9:0] LINE_VALUE_OUT;
75
 
76
 
77
 
78
 
79
//==================================================================//
80
//                         T E S T I N G                            //
81
//==================================================================//
82
// NOTHING TO TEST
83
 
84
//==================================================================//
85
// FUNCTIONAL DEFINITIONS                                           //
86
//==================================================================//
87
wire in_range;
88
reg drag;
89
 
90
assign in_range = (((YCOORD >= BOT) && (YCOORD <= TOP)) && ((XCOORD >= LEFT && XCOORD <= RGHT)));
91
 
92
// the 'DRAG' state machine
93
always @ (posedge MASTER_CLK or posedge MASTER_RST) begin
94
    if(MASTER_RST)
95
        drag <= 1'b0;
96
    else if(BUTTON_RISE && in_range)
97
        drag <= 1'b1;
98
    else if(BUTTON_FALL)
99
        drag <= 1'b0;
100
    else
101
        drag <= drag;
102
end
103
 
104 27 smpickett
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
105
   Until this is figured out, it is bad to have the lines at 'zero'
106
   (due to the comparison for 'in range')
107
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
108 5 smpickett
always @ (posedge MASTER_CLK or posedge MASTER_RST) begin
109
    if(MASTER_RST)
110 27 smpickett
        LINE_VALUE_OUT <= RESET_VALUE;
111 5 smpickett
    else if(drag && SETXnY)
112
        LINE_VALUE_OUT <= XCOORD;
113 27 smpickett
    else if(drag && !SETXnY && (YCOORD<=10'd400))
114 5 smpickett
        LINE_VALUE_OUT <= YCOORD;
115
    else
116
        LINE_VALUE_OUT <= LINE_VALUE_OUT;
117
end
118
 
119
 
120
 
121
endmodule
122
 

powered by: WebSVN 2.1.0

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