首页|嵌入式系统|显示技术|模拟IC/电源|元件与制造|其他IC/制程|消费类电子|无线/通信|汽车电子|工业控制|医疗电子|测试测量
首页 > 分享下载 > 消费类电子 > Verilog 130例

Verilog 130例

资料介绍
本文档是Verilog的常见的130例,对于学习FPGA的人有很大帮助




【例 3.1】4 位全加器
module adder4(cout,sum,ina,inb,cin);
output[3:0] sum;
output cout;
input[3:0] ina,inb;
input cin;
assign {cout,sum}=ina+inb+cin;
endmodule


【例 3.2】4 位计数器
module count4(out,reset,clk);
output[3:0] out;
input reset,clk;
reg[3:0] out;
always @(posedge clk)
begin
王金明:《Verilog HDL 程序设计教程》
if (reset) out<=0; //同步复位
else
end
endmodule
out<=out+1; //计数


【例 3.3】4 位全加器的仿真程序
`timescale 1ns/1ns
`include "adder4.v"
module adder_tp; //测试模块的名字
reg[3:0] a,b;
reg cin;
wire[3:0] sum;
wire cout;
integer i,j;
//测试输入信号定义为 reg 型

//测试输出信号定义为 wire 型


标签:verilogFPGA数电
Verilog 130例
本地下载

评论