一开始看图以为要写个for比较每一位的跳变再取值
module top_module (
input clk,
input [7:0] in,
output [7:0] pedge
);
reg [7:0] state;
reg [3:0] i;
always @(posedge clk )
begin
for (i=0;i<=7;i++)
begin
state[i] <= in[i];
pedge[i] <= ~state[i]&in[i];
end
end
endmodule
写完才发现直接比不就好了(哎太菜了)
module top_module (
input clk,
input [7:0] in,
output [7:0] pedge
);
reg [7:0] state; //确立状态值方便进行比较
always @(posedge clk )
begin
state <= in;
pedge <= ~state∈
//输入 与 当前状态的取反,若有0到1的跳变, state为0,in为1,此时pedge取1;
//不能取异或,否则当in从0到1时也会使pedge取1;
end
endmodule