新人求助!按键消抖问题
时间:10-02
整理:3721RD
点击:
本人小白一个今天在做按键消抖的实验,用的是黑金的板子,感觉代码没有问题,但是应该是分配引脚出了问题,我明明没有定义[1:0]pin_out,但是却会出现这样的警告,然后告诉我有一个引脚没有分配,请问各位大大是怎么回事?多谢啦代码:
module debounce_module
(
input clk,
input reset,
input pin_in,
output [1:0]pin_out
);
/**********************************/
parameter T10MS=19'd500_000;
//detect
reg F1,F2;
always@(posedge clk or negedge reset)
if(!reset)
{F1,F2}<=2'b00;
else
{F1,F2}<={pin_in,F1};
wire HtoL,LtoH;
assign HtoL=!F1&&F2;
assign LtoH=!F2&&F1;
//delay
reg [18:0] count_10ms;
reg [3:0] i;
reg ispress,isrelease;
always@(posedge clk or negedge reset)
if(!reset)
begin
i<=0;
count_10ms<=19'd0;
{ispress,isrelease}<=2'b00;
end
else
case(i)
3'd0:
if(HtoL)
i<=i+1'b1;
3'd1:
if(count_10ms==T10MS-1)
begin
i<=i+1'b1;
ispress<=1'b1;
count_10ms<=19'd0;
end
else
count_10ms<=count_10ms+1'b1;
3'd2:
begin
i<=i+1'b1;
ispress<=1'b0;
end
3'd3:
if(LtoH)
i<=i+1'b1;
3'd4:
if(count_10ms==T10MS-1)
begin
i<=i+1'b1;
isrelease<=1'b1;
count_10ms<=19'd0;
end
else
count_10ms<=count_10ms+1'b1;
3'd5:
begin
i<=1'b0;
isrelease<=1'b0;
end
endcase
//function
reg [1:0]rpin_out;
always@(posedge clk or negedge reset)
if(!reset)
rpin_out<=1'b0;
else if(ispress)
rpin_out[0]<=~rpin_out[0];
else if(isrelease)
rpin_out[1]<=~rpin_out[1];
assign pin_out = rpin_out;
endmodule
下面是tcl文件部分:
#复位引脚
set_location_assignment PIN_E15 -to reset
#时钟引脚
set_location_assignment PIN_E1 -to clk
#LED对应的引脚
set_location_assignment PIN_G15 -to pin_out[0]
set_location_assignment PIN_F16 -to pin_out[1]
#按键对应的引脚(KEY2
set_location_assignment PIN_E16 -to pin_in
这里是警告信息:
Warning: Ignored assignment(s) for "pin_out[0]" because "pin_out" is not a bus or array
Warning: Ignored assignment(s) for "pin_out[1]" because "pin_out" is not a bus or array
Warning: Some pins have incomplete I/O assignments. Refer to the I/O Assignment Warnings report for details
Warning: Skipped module PowerPlay Power Analyzer due to the assignment FLOW_ENABLE_POWER_ANALYZER
Critical Warning: No exact pin location assignment(s) for 1 pins of 4 total pins
Info: Pin pin_out not assigned to an exact location on the device
module debounce_module
(
input clk,
input reset,
input pin_in,
output [1:0]pin_out
);
/**********************************/
parameter T10MS=19'd500_000;
//detect
reg F1,F2;
always@(posedge clk or negedge reset)
if(!reset)
{F1,F2}<=2'b00;
else
{F1,F2}<={pin_in,F1};
wire HtoL,LtoH;
assign HtoL=!F1&&F2;
assign LtoH=!F2&&F1;
//delay
reg [18:0] count_10ms;
reg [3:0] i;
reg ispress,isrelease;
always@(posedge clk or negedge reset)
if(!reset)
begin
i<=0;
count_10ms<=19'd0;
{ispress,isrelease}<=2'b00;
end
else
case(i)
3'd0:
if(HtoL)
i<=i+1'b1;
3'd1:
if(count_10ms==T10MS-1)
begin
i<=i+1'b1;
ispress<=1'b1;
count_10ms<=19'd0;
end
else
count_10ms<=count_10ms+1'b1;
3'd2:
begin
i<=i+1'b1;
ispress<=1'b0;
end
3'd3:
if(LtoH)
i<=i+1'b1;
3'd4:
if(count_10ms==T10MS-1)
begin
i<=i+1'b1;
isrelease<=1'b1;
count_10ms<=19'd0;
end
else
count_10ms<=count_10ms+1'b1;
3'd5:
begin
i<=1'b0;
isrelease<=1'b0;
end
endcase
//function
reg [1:0]rpin_out;
always@(posedge clk or negedge reset)
if(!reset)
rpin_out<=1'b0;
else if(ispress)
rpin_out[0]<=~rpin_out[0];
else if(isrelease)
rpin_out[1]<=~rpin_out[1];
assign pin_out = rpin_out;
endmodule
下面是tcl文件部分:
#复位引脚
set_location_assignment PIN_E15 -to reset
#时钟引脚
set_location_assignment PIN_E1 -to clk
#LED对应的引脚
set_location_assignment PIN_G15 -to pin_out[0]
set_location_assignment PIN_F16 -to pin_out[1]
#按键对应的引脚(KEY2
set_location_assignment PIN_E16 -to pin_in
这里是警告信息:
Warning: Ignored assignment(s) for "pin_out[0]" because "pin_out" is not a bus or array
Warning: Ignored assignment(s) for "pin_out[1]" because "pin_out" is not a bus or array
Warning: Some pins have incomplete I/O assignments. Refer to the I/O Assignment Warnings report for details
Warning: Skipped module PowerPlay Power Analyzer due to the assignment FLOW_ENABLE_POWER_ANALYZER
Critical Warning: No exact pin location assignment(s) for 1 pins of 4 total pins
Info: Pin pin_out not assigned to an exact location on the device
可是那条严重警告说的是pin_out没有连接到实际的fpga接口上,烧到板子上不会工作的啊
嗷,问题已经解决了,查了一下,原因是我用的fpga有一个nceo引脚默认不是io,要设置一下才行,否则会出现引脚复用还是谢谢你了哈,我是个新人,以后多多关照哈