2016-04-11 11:58:54 -04:00
|
|
|
//#############################################################################
|
|
|
|
//# Function: Latch data when clk=0 #
|
|
|
|
//#############################################################################
|
|
|
|
//# Author: Andreas Olofsson #
|
|
|
|
//# License: MIT (see LICENSE file in OH! repository) #
|
|
|
|
//#############################################################################
|
|
|
|
|
2016-08-17 15:06:01 +01:00
|
|
|
module oh_lat0 #(parameter DW = 1 // data width
|
2016-06-24 20:34:32 -04:00
|
|
|
)
|
2016-04-11 11:58:54 -04:00
|
|
|
( input clk, // clk, latch when clk=0
|
2016-06-24 20:34:32 -04:00
|
|
|
input [DW-1:0] in, // input data
|
|
|
|
output [DW-1:0] out // output data (stable/latched when clk=1)
|
2016-04-11 11:58:54 -04:00
|
|
|
);
|
2016-08-17 15:06:01 +01:00
|
|
|
|
2020-02-04 23:04:52 -05:00
|
|
|
|
|
|
|
`ifdef CFG_ASIC
|
|
|
|
asic_lat0 ilat [DW-1:0] (.clk(clk),
|
|
|
|
.in(in[DW-1:0]),
|
2016-06-25 00:04:25 -04:00
|
|
|
.out(out[DW-1:0]));
|
2020-02-04 23:04:52 -05:00
|
|
|
`else
|
|
|
|
reg [DW-1:0] out_reg;
|
|
|
|
always @ (clk or in)
|
|
|
|
if (!clk)
|
|
|
|
out_reg[DW-1:0] <= in[DW-1:0];
|
|
|
|
assign out[DW-1:0] = out_reg[DW-1:0];
|
|
|
|
`endif
|
|
|
|
|
2015-11-30 13:45:49 -05:00
|
|
|
endmodule // oh_lat0
|
|
|
|
|
2016-04-11 11:58:54 -04:00
|
|
|
|