module POSEDGE_TO_PULSE ( input CLK, input SIGNAL, output PULSE ); reg x, y; always @(posedge SIGNAL) begin x <= ~x; end always @(posedge CLK) begin y <= x; end assign PULSE = y ^ x; initialbegin x = 0; y = 0; end endmodule
ptp u_ptp ( .CLK ( CLK ), .SIGNAL ( SIGNAL ), .PULSE ( PULSE ) ); initial begin #15 SIGNAL <= 1; #50 SIGNAL <= 0; #10 SIGNAL <= 1; #50 SIGNAL <= 0; #10 $finish; end /*生成仿真所需的vcd文件*/ initialbegin $dumpfile("wave.vcd"); $dumpvars(0, tb_POSEDGE_TO_PULSE); end endmodule
SoCoco's Blog
Record some useless things
This piece of writing is an original article, utilizing theCC BY-NC-SA 4.0Agreement. For complete reproduction, please acknowledge the source as Courtesy ofSoCoco's Blog