Home Verilog Digital Design Digital Basics Python RF Basics

Legal Disclaimer

Chip Designing for ASIC/ FPGA Design engineers and Students
FULLCHIPDESIGN
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

Previous Next
Verilog 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 [7:0] data_out;

input  [7:0] data_in;

reg [7:0] data_out_meta;

reg [7:0] data_out_reg;

reg [7:0] data_out_reg_r;

wire[7:0] data_out;

 

// Assign statements

assign data_out = data_out_reg_r;

 

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

always @ (posedge clock1)

begin

 data_out_meta <= data_in;

end

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

 

always @ (posedge clock2 or negedge rst_n)

begin

 if (! rst_n)

  begin

     data_out_reg <= 'b0;

     data_out_reg_r <= 'b0;

 end

else

begin

  data_out_reg <= data_out_meta;

  data_out_reg_r <= data_out_reg;

end

end

endmodule

 

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