||
AddressComparator地址比较器,将自身地址与下行命令中的地址相比较,若相同则输出一个VLDCMD脉冲,该脉冲是一个时钟周期,用于触发其他模块,解析下行命令寄存器,并控制电磁阀等动作。
`timescale 10us/1us
module enc;
reg reset;
reg clk;
wire va;
always #1 clk=~clk;
initial
begin
clk=0;
#1 reset=0;
#2 reset=1;
#3 reset=0;
end
tt u1(.reset(reset),.clk(clk),.valid_(va));
endmodule
module tt(reset,clk,valid_);
input reset;
input clk;
output valid_;
reg valid_;
reg[31:0] counter;
always@(posedge clk or posedge reset)
begin
if(reset) counter=0;
else
if(counter==10)
counter<=0;
else
counter<=counter+1;
end
always@(posedge clk or posedge reset)
begin
if(reset) valid_=0;
else
begin
if(valid_) valid_=0;
if(counter==10 && !valid_)
begin
valid_=1;
end
end
end
endmodule