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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_3/] [rtl/] [verilog/] [sync_module.v] - Diff between revs 74 and 154

Only display areas with differences | Details | Blame | View Log

Rev 74 Rev 154
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
////  File name "sync_module.v"                                   ////
////  File name "sync_module.v"                                   ////
////                                                              ////
////                                                              ////
////  This file is part of the "PCI bridge" project               ////
////  This file is part of the "PCI bridge" project               ////
////  http://www.opencores.org/cores/pci/                         ////
////  http://www.opencores.org/cores/pci/                         ////
////                                                              ////
////                                                              ////
////  Author(s):                                                  ////
////  Author(s):                                                  ////
////      - Tadej Markovic, tadej@opencores.org                   ////
////      - Tadej Markovic, tadej@opencores.org                   ////
////                                                              ////
////                                                              ////
////  All additional information is avaliable in the README.txt   ////
////  All additional information is avaliable in the README.txt   ////
////  file.                                                       ////
////  file.                                                       ////
////                                                              ////
////                                                              ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// Copyright (C) 2000 Tadej Markovic, tadej@opencores.org       ////
//// Copyright (C) 2000 Tadej Markovic, tadej@opencores.org       ////
////                                                              ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
//// later version.                                               ////
////                                                              ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// details.                                                     ////
//// details.                                                     ////
////                                                              ////
////                                                              ////
//// You should have received a copy of the GNU Lesser General    ////
//// You should have received a copy of the GNU Lesser General    ////
//// Public License along with this source; if not, download it   ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
//
//
//
//
 
 
// synopsys translate_off
// synopsys translate_off
`include "timescale.v"
`include "timescale.v"
// synopsys translate_on
// synopsys translate_on
 
 
module SYNC_MODULE
module SYNC_MODULE
(
(
                                        set_clk_in,
                                        set_clk_in,
                                        delete_clk_in,
                                        delete_clk_in,
                                        reset_in,
                                        reset_in,
                                        delete_set_out,
                                        delete_set_out,
                                        block_set_out,
                                        block_set_out,
                                        delete_in
                                        delete_in
);
);
 
 
// system inputs from two clock domains
// system inputs from two clock domains
input   set_clk_in;
input   set_clk_in;
input   delete_clk_in;
input   delete_clk_in;
input   reset_in;
input   reset_in;
// control outputs
// control outputs
output  delete_set_out;
output  delete_set_out;
output  block_set_out;
output  block_set_out;
// control input
// control input
input   delete_in;
input   delete_in;
 
 
// internal signals
// internal signals
reg             del_bit;
reg             del_bit;
wire    meta_del_bit;
wire    meta_del_bit;
reg             sync_del_bit;
reg             sync_del_bit;
reg             delayed_del_bit;
reg             delayed_del_bit;
wire    meta_bckp_bit;
wire    meta_bckp_bit;
reg             sync_bckp_bit;
reg             sync_bckp_bit;
reg             delayed_bckp_bit;
reg             delayed_bckp_bit;
 
 
 
 
// DELETE_IN input FF - when set must be active, until it is sinchronously cleared
// DELETE_IN input FF - when set must be active, until it is sinchronously cleared
always@(posedge delete_clk_in or posedge reset_in)
always@(posedge delete_clk_in or posedge reset_in)
begin
begin
        if (reset_in)
        if (reset_in)
                del_bit <= 1'b0;
                del_bit <= 1'b0;
        else
        else
        begin
        begin
                if (!delayed_bckp_bit && sync_bckp_bit)
                if (!delayed_bckp_bit && sync_bckp_bit)
                        del_bit <= 1'b0;
                        del_bit <= 1'b0;
                else if (delete_in)
                else if (delete_in)
                        del_bit <= 1'b1;
                        del_bit <= 1'b1;
        end
        end
end
end
assign  block_set_out = del_bit;
assign  block_set_out = del_bit;
 
 
// interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
// interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
synchronizer_flop       delete_sync
synchronizer_flop       delete_sync
(
(
    .data_in        (del_bit),
    .data_in        (del_bit),
    .clk_out        (set_clk_in),
    .clk_out        (set_clk_in),
    .sync_data_out  (meta_del_bit),
    .sync_data_out  (meta_del_bit),
    .async_reset    (reset_in)
    .async_reset    (reset_in)
) ;
) ;
 
 
// Final synchronization of del_bit signal to the set clock domain
// Final synchronization of del_bit signal to the set clock domain
always@(posedge set_clk_in or posedge reset_in)
always@(posedge set_clk_in or posedge reset_in)
begin
begin
        if (reset_in)
        if (reset_in)
                sync_del_bit <= 1'b0;
                sync_del_bit <= 1'b0;
        else
        else
                sync_del_bit <= meta_del_bit;
                sync_del_bit <= meta_del_bit;
end
end
 
 
// Delayed sync_del_bit signal for one clock period pulse generation
// Delayed sync_del_bit signal for one clock period pulse generation
always@(posedge set_clk_in or posedge reset_in)
always@(posedge set_clk_in or posedge reset_in)
begin
begin
        if (reset_in)
        if (reset_in)
                delayed_del_bit <= 1'b0;
                delayed_del_bit <= 1'b0;
        else
        else
                delayed_del_bit <= sync_del_bit;
                delayed_del_bit <= sync_del_bit;
end
end
 
 
assign  delete_set_out = !delayed_del_bit && sync_del_bit;
assign  delete_set_out = !delayed_del_bit && sync_del_bit;
 
 
// interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
// interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
synchronizer_flop       clear_delete_sync
synchronizer_flop       clear_delete_sync
(
(
    .data_in        (sync_del_bit),
    .data_in        (sync_del_bit),
    .clk_out        (delete_clk_in),
    .clk_out        (delete_clk_in),
    .sync_data_out  (meta_bckp_bit),
    .sync_data_out  (meta_bckp_bit),
    .async_reset    (reset_in)
    .async_reset    (reset_in)
) ;
) ;
 
 
// Final synchronization of sync_del_bit signal to the delete clock domain
// Final synchronization of sync_del_bit signal to the delete clock domain
always@(posedge delete_clk_in or posedge reset_in)
always@(posedge delete_clk_in or posedge reset_in)
begin
begin
        if (reset_in)
        if (reset_in)
                sync_bckp_bit <= 1'b0;
                sync_bckp_bit <= 1'b0;
        else
        else
                sync_bckp_bit <= meta_bckp_bit;
                sync_bckp_bit <= meta_bckp_bit;
end
end
 
 
// Delayed sync_bckp_bit signal for one clock period pulse generation
// Delayed sync_bckp_bit signal for one clock period pulse generation
always@(posedge delete_clk_in or posedge reset_in)
always@(posedge delete_clk_in or posedge reset_in)
begin
begin
        if (reset_in)
        if (reset_in)
                delayed_bckp_bit <= 1'b0;
                delayed_bckp_bit <= 1'b0;
        else
        else
                delayed_bckp_bit <= sync_bckp_bit;
                delayed_bckp_bit <= sync_bckp_bit;
end
end
 
 
 
 

powered by: WebSVN 2.1.0

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