
一、利用FPGA并行执行程序的特点实现
`timescale 1ns / 1ps
//
//利用FPGA并行执行程序的特点编写程序实现流水灯功能
// Company:
// Engineer:
//
// Create Date: 2020/12/04 11:13:13
// Design Name:
// Module Name: led_liushui
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//
//采用Xilinx AX7010芯片的黑金FPGA开发板
//时钟50Mhz,计数50_000_000次为1秒,本次总共计数199_999_999次
module led_liushui(clk,rst_n,led);
input clk;
input rst_n; //复位低电平有效
output reg[3:0] led; //低电平亮,高电平熄灭
reg[31:0] timer_cout; //定义计数寄存器 timer_cout
always@(posedge clk or negedge rst_n)//计数寄存器 timer_cout 开始计数
begin
if(rst_n!=1) //rst_n复位
begin
timer_cout<=32'd0;
end
//49_999_999 50 _000 _000 200_000_000
else if(timer_cout==32'd199_999_999) //总共计数199_999_999次,
begin
timer_cout<=32'd0;
end
else
begin
timer_cout<=timer_cout+32'd1;
end
end
always@(posedge clk or negedge rst_n)
begin
if(rst_n!=1)