8.Verilog的for循环语句使用

FPGA教程目录

MATLAB教程目录

---------------------------------------------------------------------------------------

在Verilog中,对于循环功能的实现,主要通过for语句来实现。

在verilog中,for循环的主要功能用于赋值和延迟两个功能,下面对这两个功能的实现进行介绍。

1.赋值功能

首先来看一个例子:

`timescale 1ns / 1ps
 

module count(
input i_clk,
input i_rst,
output reg[9:0]o_count1,
output reg[9:0]o_count2,
output reg[9:0]o_count3
);

reg[7:0]tmps;
integer i;
reg[7:0]men_delay[16:1]; 
always @(posedge i_clk or posedge i_rst)
begin
     if(i_rst)
     begin
         tmps<=8'd0;
         for(i=1;i<=16;i=i+1)
         begin
         men_delay[i]<=8'd0;
         end
     end
e

你可能感兴趣的:(★教程2:fpga入门100例,fpga开发,verilog,for循环)