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

Subversion Repositories zet86

[/] [zet86/] [trunk/] [soc/] [aceusb/] [rtl/] [aceusb_sync.v] - Blame information for rev 53

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 52 zeus
/*
2
 * WISHBONE to SystemACE MPU + CY7C67300 bridge
3
 * Copyright (C) 2008 Sebastien Bourdeauducq - http://lekernel.net
4
 * This file is part of Milkymist.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
 
20
/* Flag synchronizer from clock domain 0 to 1
21
 * See http://www.fpga4fun.com/CrossClockDomain.html
22
 */
23
 
24
module aceusb_sync(
25
        input clk0,
26
        input flagi,
27
 
28
        input clk1,
29
        output flago
30
);
31
 
32
/* Turn the flag into a level change */
33
reg toggle;
34
initial toggle = 1'b0;
35
always @(posedge clk0)
36
        if(flagi) toggle <= ~toggle;
37
 
38
/* Synchronize the level change to clk1.
39
 * We add a third flip-flop to be able to detect level changes. */
40
reg [2:0] sync;
41
initial sync = 3'b000;
42
always @(posedge clk1)
43
        sync <= {sync[1:0], toggle};
44
 
45
/* Recreate the flag from the level change into the clk1 domain */
46
assign flago = sync[2] ^ sync[1];
47
 
48
endmodule

powered by: WebSVN 2.1.0

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