verilog HDL 当S信号发生变化时,产生一个脉冲。

输入信号: CLK,S 输出信号: A
当S发生变化时,A输出一个脉冲信号(宽度与CLK信号一致)
求代码,谢谢啦!
最新回答
墨城

2024-09-16 06:57:01

module level2pulse(clk,s,a);
input clk,s;
output a;
reg temp_a;
always@( posedge clk)
temp_a <= s;
assign a = temp_a ^ s;//S的上升下降都会生成脉冲
//assign a = ~temp_a & s;//S的上升会生成脉冲
//assign a = temp_a & ~s;//S的下降会生成脉冲

endmodule//
久梦由你

2024-09-16 00:03:10

module pulse(
input wire CLK,
input wire S,
output wire A;
);

reg [2:0] S_dly;
always @(posedge CLK) begin
S_dly <= {S_dly[1:0], S};
end
assign A = ^S_dly[2:1];
endmodule
猫儿少女

2024-09-16 05:57:34

……
reg S_delay;
output A;
always@(posedge CLK)
S_delay <= S;

assign A = S ^ S_delay;
……