1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-01-17 20:02:53 +08:00
oh/stdlib/hdl/oh_rise2pulse.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

27 lines
974 B
Verilog

//#############################################################################
//# Function: Converts a rising edge to a single cycle pulse #
//#############################################################################
//# Author: Andreas Olofsson #
//# License: MIT (see LICENSE file in OH! repository) #
//#############################################################################
module oh_rise2pulse #(parameter N = 1) // data width
( input clk, // clock
input nreset, // async active low reset
input [N-1:0] in, // edge input
output [N-1:0] out // one cycle pulse
);
reg [N-1:0] in_reg;
always @ (posedge clk or negedge nreset)
if(!nreset)
in_reg[N-1:0] <= 'b0 ;
else
in_reg[N-1:0] <= in[N-1:0] ;
assign out[N-1:0] = in[N-1:0] & ~in_reg[N-1:0] ;
endmodule // oh_rise2pulse