Home Verilog Digital Design Digital Basics Python RF Basics

Legal Disclaimer

Chip Designing for ASIC/ FPGA Design engineers and Students
Digital-logic Design...  Dream for many students… start learning front-end…
Custom Search

Feedback ? Send it to admin@fullchipdesign.com or join me at fullchip@gmail.com

Verilog Initial stmts IF-ELSE Case stms Readmemh Function Testbench Binary to Gray Clock Crossing Half-adder Full-adder Tristate buffer Adder tb Counter_enable Blocking Operators Shift LSR Random Nos Sync RAM Verilog Tutorial

Legal Disclaimer

Topics @TYH :- 4G LTE Tutorial, GVIM editor, Smart-Phone, Cloud Computing
Previous Next
Verilog Tutorial.
Digital Basics Tutorial.

Verilog code for clock domain crossing

Verilog RTL code for  synchronization logic to implement clock domain crossing circuit:-

module clk_2_cross ( clock1, clock2, rst_n, data_in, data_out);

input clock1;

input clock2;

input rst_n;

output data_out;

input  data_in;

reg data_out_meta;

reg [1:0] data_out_reg;

// Assign statements

assign data_out = data_out_reg[1];

// Always block to declare  synchronous logic from source clock domain 

always @ (posedge clock1)


 data_out_meta <= data_in;


// Always block to declare synchronous logic in destination clock domain


always @ (posedge clock2 or negedge rst_n)


 if (! rst_n)

     data_out_reg <= 'b0;


  // Implement shift register for two flops.   

  data_out_reg <= {data_out_reg[0], data_out_meta};



// Note: Above shift register can also be implemented // like below:

// data_out_reg[0] <= data_out_meta;

// data_out_reg[1] <= data_out_reg[0];

Following block diagram can used to implement clock domain crossing for phase offset clocks in digital design.

Discussion on clock domain crossing

Verilog - learn with examples
Interview questions and hints
Digital Design
Interview questions and hints