1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-01-17 20:02:53 +08:00
oh/common/hdl/oh_oddr.v
Andreas Olofsson 2a22cd6ff8 Removing delay + clock gating
- delay could hide bad designs..
- clock gating was hard to handle from outside
2016-02-25 14:41:30 -05:00

49 lines
1.2 KiB
Verilog

//##################################################################
//# ***DUAL DATA RATE OUTPUT***
//#
//# * Equivalent to "SAME_EDGE" for xilinx
//# * din1/din2 presented together on rising edge of clk
//# * din1 follows rising edge
//# * din2 follows falling edge
//##################################################################
module oh_oddr (/*AUTOARG*/
// Outputs
out,
// Inputs
clk, ce, din1, din2
);
//parameters
parameter DW = 32;
//signals
input clk; // clock input
input ce; // clock enable 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)
if (ce)
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