电力电子技术
直播中

张清华

7年用户 177经验值
私信 关注

Verilog设计初学者例程:时序电路设计

Verilog 设计初学者例程一 时序电路设计

By 上海 无极可米

12/13/2001

---------基础-----------

1. 1/2分频器

module halfclk(reset,clkin,clkout);
input clkin,reset;
output clkout;
reg clkout; //输出设为reg

always @(posedge clkin) //上升沿触发
begin
if(!reset) clkout=0; //复位
else clkout=~clkout;
end
endmodule

得到的波形

__--__--__--__--__--__--__--__

_____-----_____-----_____-----_____

-----------提高--------------
2. 1/50分频

module f50(reset,clkin,clkout);
input clkin,reset;
output clkout;
reg clkout; //输出设为reg
reg [7:0] j; //计数器
always @(posedge clk) //上升沿触发
if(!reset) //低电平复位。
begin
clkout <= 0;
j <= 0;
end
else
begin
if(j==49) //对计数器进行判断,以确定clkout信号是否反转。
begin
j <= 0;
clkout <= ~clkout;
end
else
j <= j+1;
end
endmodule

得到的波形

__--__--... __--__--__--__--__--__

50个clk
__________________________-----------------------

------------进阶---------------

3. 设计习题
----------

------------------ -------------------
20个clk 10个clk 20个clk


提示:因为电平为1和0的时间不等,所以要用两个计数器。


  :

更多回帖

发帖
×
20
完善资料,
赚取积分