1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-01-30 02:32:53 +08:00
oh/common/hdl/oh_reg1.v
Andreas.Olofsson 126f859908 Adding clock enable for register
-Removing the ASIC CFG as well...have to rethink that concept, not really working
2020-07-14 13:48:42 -04:00

31 lines
1.0 KiB
Verilog

//#############################################################################
//# Function: Rising Edge Sampled Register #
//#############################################################################
//# Author: Andreas Olofsson #
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_reg1 #(parameter DW = 1 // data width
)
( input nreset, //async active low reset
input clk, // clk
input en, // write enable
input [DW-1:0] in, // input data
output [DW-1:0] out // output data (stable/latched when clk=1)
);
reg [DW-1:0] out_reg;
always @ (posedge clk or negedge nreset)
if(!nreset)
out_reg[DW-1:0] <= 'b0;
else if(en)
out_reg[DW-1:0] <= in[DW-1:0];
assign out[DW-1:0] = out_reg[DW-1:0];
endmodule // ohr_reg1