时钟脉冲为20MHZ
Family - ARTIX7实验板
Device - XC7A100TFPGA芯片
Package - FGG484
Speed 为 -2L
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 23:50:39 12/17/2018
// Design Name:
// Module Name: Lab16
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module Lab16(
input [1:0] SW, //供能选择
input reset,
input CLK,
output reg OUT
);
reg [26:0] counter; //计数
always @(posedge CLK)
begin
if(reset) //初始化
begin
counter<=27'd0;
OUT<=1'b0;
end
else
begin
if(SW[1:0]== 2'b00) //分频0.5HZ
begin
if(counter == 25'd20000000)
begin
OUT <= ~OUT;
counter <= 27'd0;
end
else
counter <= counter+ 1'b1;
end
else if(SW[1:0]== 2'b01) //分频1HZ
begin
if(counter == 24'd10000000)
begin
OUT <= ~OUT;
counter <= 27'd0;
end
else
counter <= counter+ 1'b1;
end
else if(SW[1:0]== 2'b10) //分频 2HZ
begin
if(counter == 23'd5000000)
begin
OUT <= ~OUT;
counter <= 27'd0;
end
else
counter <= counter+ 1'b1;
end
else if(SW[1:0]== 2'b11) //定时6s
begin
if(counter == 27'd120000000)
begin
OUT <= ~OUT;
counter <= 27'd0;
end
else
counter <= counter+ 1'b1;
end
end
end
endmodule
管脚配置
NET "reset" IOSTANDARD = LVCMOS18 | LOC = T3;
NET "reset" CLOCK_DEDICATED_ROUTE = FALSE;
NET "SW[0]" IOSTANDARD = LVCMOS18 | LOC = U3;
NET "SW[0]" CLOCK_DEDICATED_ROUTE = FALSE;
NET "SW[1]" IOSTANDARD = LVCMOS18 | LOC = T4;
NET "SW[1]" CLOCK_DEDICATED_ROUTE = FALSE;
NET "CLK" IOSTANDARD = LVCMOS18 | LOC = H4;
NET "OUT" IOSTANDARD = LVCMOS18 | LOC = K1;
NET "reset" PULLDOWN;
NET "SW[0]" PULLDOWN;
NET "SW[1]" PULLDOWN;