forked from aolofsson/oh
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoh_oddr.v
36 lines (28 loc) · 1.17 KB
/
oh_oddr.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
//#############################################################################
//# Function: Dual data rate output buffer #
//#############################################################################
//# Author: Andreas Olofsson #
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_oddr #(parameter DW = 1) // width of data inputs
(
input clk, // clock input
input [DW-1:0] din1, // data input1
input [DW-1:0] din2, // data input2
output [DW-1:0] out // ddr output
);
//regs("sl"=stable low, "sh"=stable high)
reg [DW-1:0] q1_sl;
reg [DW-1:0] q2_sl;
reg [DW-1:0] q2_sh;
//Generate different logic based on parameters
always @ (posedge clk)
begin
q1_sl[DW-1:0] <= din1[DW-1:0];
q2_sl[DW-1:0] <= din2[DW-1:0];
end
always @ (negedge clk)
q2_sh[DW-1:0] <= q2_sl[DW-1:0];
assign out[DW-1:0] = clk ? q1_sl[DW-1:0] :
q2_sh[DW-1:0];
endmodule // oh_oddr