1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-02-07 06:44:09 +08:00
oh/stdlib/hdl/oh_clockmux.v
aolofsson de63dfd907 Major reorg!
-stdcells moved to asiclib, doesn't make sense to be vectorized
-common is a stupid name, renamed as stdlib
2021-07-29 11:20:44 -04:00

34 lines
1.2 KiB
Verilog

//#############################################################################
//# Function: Parametrized clock mux (N to 1) #
//#############################################################################
//# Author: Andreas Olofsson #
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_clockmux
#(parameter N = 2, // number of clock inputs)
parameter SYN = "TRUE", // synthesizable (or not)
parameter TYPE = "DEFAULT" // implementation type
)
(
input [N-1:0] en, // one hot enable vector (needs to be stable!)
input [N-1:0] clkin, // one hot clock inputs (only one is active!)
output clkout // clock output
);
generate
if(SYN == "TRUE") begin
assign clkout = |(clkin[N-1:0] & en[N-1:0]);
end
else begin
asic_clockmux #(.TYPE(TYPE),
.N(N))
asic_clockmux(// Outputs
.clkout (clkout),
// Inputs
.en (en[N-1:0]),
.clkin (clkin[N-1:0]));
end
endgenerate
endmodule