forked from aolofsson/oh
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoh_iddr.v
40 lines (32 loc) · 1.29 KB
/
oh_iddr.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//#############################################################################
//# Function: Dual data rate input buffer (2 cycle delay) #
//#############################################################################
//# Author: Andreas Olofsson #
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_iddr #(parameter DW = 1 // width of data inputs
)
(
input clk, // clock
input ce, // clock enable, set to high to clock in data
input [DW-1:0] din, // data input sampled on both edges of clock
output reg [DW-1:0] q1, // iddr rising edge sampled data
output reg [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;
// 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