这个程序中如何添加一个干扰信号,来判断该程序是可以抗干扰的啊?
新手不知道怎吗入手,请大侠们帮忙解决一下,谢谢!
module io(M_KIIO, M_KCIO, M_KICS, M_BCS, SD_RST, //M_FPGARST,
M_KCCS,CLK, M_IOKCZ, FPGA_TEST,F_KIN, F_KCZ,F_KC,DYIN);
output [8:1] M_KIIO;//主板开入口
output [8:1] F_KC;//开出量
output F_KCZ;//开出总控制
output [4:1] FPGA_TEST;
input [8:1] M_KCIO;//主板开出口
input [3:1] M_KICS;//主板开入片选
input M_KCCS;//主板开出使能
input M_BCS;//主板片选
input SD_RST;//上电复位信号
/// input M_FPGARST;//FPGA复位信号
input M_IOKCZ;//主板IO口开出总控制
input [19:1] F_KIN;//开入量
input [4:1] DYIN;//电源开入口
input CLK;
reg [8:1] M_KIIO;
reg [8:1] F_KC;
wire F_KCZ;
reg [4:1] FPGA_TEST;
wire [8:1] M_KCIO;
wire [3:1] M_KICS;
wire M_KCCS;
wire M_BCS;
wire SD_RST;
wire M_FPGARST;
wire M_IOKCZ;
wire [19:1] F_KIN;
wire [4:1] DYIN;
wire FPGA_KCEN;
wire [3:1] FPGA_KIEN;
wire CLK;
reg [22:0] Count;
// wire led_clk;
always @ (posedge CLK or negedge SD_RST)//计数器Count,最大为2的22次方。
begin
if(!SD_RST)
begin
Count<=23'd0;
end
else
Count <= Count + 23'd1 ;
end
//assign led_clk = Count[22] ;
always @(posedge CLK or negedge SD_RST)
begin
if(!SD_RST)
begin
FPGA_TEST[4] = 0;
end
else
begin
FPGA_TEST[4] = Count[22] ;
end
end
/* always @(posedge led_clk )
begin
if(FPGA_TEST[4]) begin
FPGA_TEST[4] = 0;
end
else if (!FPGA_TEST[4]) begin
FPGA_TEST[4] = 1;
end
end*/
assign FPGA_KCEN = SD_RST & (~M_BCS) & M_KCCS;//~M_BCS低有效,M_KCCS高有效
assign FPGA_KIEN[1] = SD_RST & (~M_BCS) & M_KICS[1];
assign FPGA_KIEN[2] = SD_RST & (~M_BCS) & M_KICS[2];
assign FPGA_KIEN[3] = SD_RST & (~M_BCS) & M_KICS[3];
reg kc_en;
/*always @(M_KCIO or SD_RST)
begin
if(!SD_RST)
begin
kc_en = 0;
end
else if ( M_KCIO != 8'b0 ) // kc_en在M_KCIO != 8'b0 情况下为1
begin
kc_en = 1;
end
end*/
always @(posedge CLK or negedge SD_RST)
begin
if(!SD_RST)
begin
kc_en=0;
end
else if(M_KCIO!=8'b0)
begin
kc_en=1;
end
end
assign F_KCZ = SD_RST & (~M_IOKCZ ) & kc_en;//~M_IOKCZ低有效
always @(posedge CLK or negedge SD_RST)
begin
if(!SD_RST)
begin
F_KC=0;
end
else if( FPGA_KCEN)
begin
F_KC = M_KCIO;
end
else
begin
F_KC = F_KC;
end
end
/*always @( FPGA_KCEN or M_KCIO or SD_RST)
begin
if(!SD_RST)
begin
F_KC = 8'b0;
end
else if ( FPGA_KCEN)
begin
F_KC = M_KCIO;
end
else
begin
F_KC = F_KC;
end
end*/
always @(posedge CLK or negedge SD_RST)
begin
if(!SD_RST)
begin
M_KIIO[8:1] = 8'b0;
FPGA_TEST[3:1] =3'b0;
end
else if( FPGA_KIEN[1])
begin
M_KIIO[8:1] = F_KIN[8:1] ;
FPGA_TEST[3:1] = FPGA_KIEN;
end
else if ( FPGA_KIEN[2])
begin
M_KIIO[8:1] = F_KIN[16:9] ;
FPGA_TEST[3:1] = FPGA_KIEN;
end
else if ( FPGA_KIEN[3])
begin
M_KIIO[1] = F_KIN[17];
M_KIIO[2] = F_KIN[18];
M_KIIO[3] = F_KIN[19];
M_KIIO[4] = DYIN[1];
M_KIIO[5] = DYIN[2];
M_KIIO[6] = DYIN[3];
M_KIIO[7] = DYIN[4];
M_KIIO[8] = 0;
FPGA_TEST[3:1] = FPGA_KIEN;
end
else
begin
M_KIIO[8:1] = 8'bz;
FPGA_TEST[3:1] = 3'bz;
end
end
endmodule