mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-30 02:32:53 +08:00
2a22cd6ff8
- delay could hide bad designs.. - clock gating was hard to handle from outside
54 lines
1.3 KiB
Verilog
54 lines
1.3 KiB
Verilog
//##################################################################
|
|
//# ***DUAL DATA RATE INPUT***
|
|
//#
|
|
//# * Equivalent to "SAME_EDGE_PIPELINED" for xilinx
|
|
//# * din sampled on rising edge of clk
|
|
//# * din sampled on falling edge of clk
|
|
//# * q1 holds rising edge data
|
|
//# * q2 holds falling edge data
|
|
//#
|
|
//##################################################################
|
|
|
|
module oh_iddr (/*AUTOARG*/
|
|
// Outputs
|
|
q1, q2,
|
|
// Inputs
|
|
clk, ce, din
|
|
);
|
|
|
|
//parameters
|
|
parameter DW = 32; // width of interface
|
|
|
|
//interface
|
|
input clk; // clock
|
|
input ce; // clock enable, set to high to clock in data
|
|
input [DW-1:0] din; // data input
|
|
output [DW-1:0] q1; // iddr rising edge sampled data
|
|
output [DW-1:0] q2; // iddr falling edge sampled data
|
|
|
|
//regs("sl"=stable low, "sh"=stable high)
|
|
reg [DW-1:0] q1_sl;
|
|
reg [DW-1:0] q2_sh;
|
|
reg [DW-1:0] q1;
|
|
reg [DW-1:0] q2;
|
|
|
|
// rising edge sample
|
|
always @ (posedge clk)
|
|
if(ce)
|
|
q1_sl[DW-1:0] <= din[DW-1:0];
|
|
|
|
// falling edge sample
|
|
always @ (negedge clk)
|
|
q2_sh[DW-1:0] <= din[DW-1:0];
|
|
|
|
// pipeline for alignment
|
|
always @ (posedge clk)
|
|
begin
|
|
q1[DW-1:0] <= q1_sl[DW-1:0];
|
|
q2[DW-1:0] <= q2_sh[DW-1:0];
|
|
end
|
|
|
|
endmodule // oh_iddr
|
|
|
|
|