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

Subversion Repositories rtf_sprite_controller

[/] [rtf_sprite_controller/] [trunk/] [rtl/] [verilog/] [edge_det.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 robfinch
// ============================================================================
2
// (C) 2007 Robert Finch
3
// All Rights Reserved.
4
//
5
//      edge_det.v
6
//
7
//
8
// This source file is free software: you can redistribute it and/or modify 
9
// it under the terms of the GNU Lesser General Public License as published 
10
// by the Free Software Foundation, either version 3 of the License, or     
11
// (at your option) any later version.                                      
12
//                                                                          
13
// This source file 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
// You should have received a copy of the GNU General Public License        
19
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
20
//                                                                          
21
//    Notes:
22
//
23
//      Edge detector
24
//      This little core detects an edge (positive, negative, and
25
//      either) in the input signal.
26
//
27
// ============================================================================
28
//
29
module edge_det(rst, clk, ce, i, pe, ne, ee);
30
input rst;              // reset
31
input clk;              // clock
32
input ce;               // clock enable
33
input i;                // input signal
34
output pe;              // positive transition detected
35
output ne;              // negative transition detected
36
output ee;              // either edge (positive or negative) transition detected
37
 
38
reg ed;
39
always @(posedge clk)
40
        if (rst)
41
                ed <= 1'b0;
42
        else if (ce)
43
                ed <= i;
44
 
45
assign pe = ~ed & i;    // positive: was low and is now high
46
assign ne = ed & ~i;    // negative: was high and is now low
47
assign ee = ed ^ i;             // either: signal is now opposite to what it was
48
 
49
endmodule

powered by: WebSVN 2.1.0

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