【verilog】四位全加器


文章目录


前言

进行 FPGA 全加器 实验


一、实验原理

go 复制代码
module adder(ain,bin,cin,cout,s);
input ain,bin,cin;
output cout,s;
assign cout=ain&bin | ain&cin | bin&cin;
assign s=ain^bin^cin;
endmodule




`timescale 1ns/1ns
module adder_tst();
reg ain,bin,cin;
wire cout,s;
initial begin
ain=1'b0;bin=1'b0;cin=1'b0;
#20 ain=1'b0;bin=1'b0;cin=1'b1;
#20 ain=1'b0;bin=1'b1;cin=1'b0;
#20 ain=1'b0;bin=1'b1;cin=1'b1;
#20 ain=1'b1;bin=1'b0;cin=1'b0;
#20 ain=1'b1;bin=1'b0;cin=1'b1;
#20 ain=1'b1;bin=1'b1;cin=1'b0;
#20 ain=1'b1;bin=1'b1;cin=1'b1;
end
adder u0(.ain(ain),
      .bin(bin),
      .cin(cin),
      .cout(cout),
      .s(s));
endmodule



module adder4(ain,bin,cin,s,cout);
input[3:0] ain,bin;
input cin;
output[3:0] s;
output cout;
wire cout1,cout2,cout3;
adder u0(.ain(ain[0]),
      .bin(bin[0]),
      .cin(cin),
      .cout(cout1),
      .s(s[0]));
adder u1(.ain(ain[1]),
      .bin(bin[1]),
      .cin(cout1),
      .cout(cout2),
      .s(s[1]));
adder u2(.ain(ain[2]),
      .bin(bin[2]),
      .cin(cout2),
      .cout(cout3),
      .s(s[2]));
adder u3(.ain(ain[3]),
      .bin(bin[3]),
      .cin(cout3),
      .cout(cout),
      .s(s[3]));
endmodule

二、实验过程

三、实验结果


参考文献

[1]

相关推荐
电棍2332 小时前
verilog笔记
笔记·fpga开发
ZxsLoves14 小时前
【【Systemverilog学习参考 简单的加法器验证-含覆盖率】】
学习·fpga开发
Ronin-Lotus15 小时前
嵌入式硬件篇---数字电子技术中的触发器
嵌入式硬件·fpga开发·触发器·数字电子技术·上位机知识
ehiway1 天前
FPGA+GPU+CPU国产化人工智能平台
人工智能·fpga开发·硬件工程·国产化
蓑衣客VS索尼克1 天前
什么是逻辑分析仪?
arm开发·人工智能·fpga开发
Terasic友晶科技2 天前
第29篇 基于ARM A9处理器用C语言实现中断<五>
c语言·fpga开发·定时器中断
9527华安2 天前
FPGA实现GTY光口视频转USB3.0传输,基于FT601+Aurora 8b/10b编解码架构,提供2套工程源码和技术支持
fpga开发·音视频·aurora·gty·usb3.0·ft601
博览鸿蒙3 天前
FPGA开发要学些什么?如何快速入门?
fpga开发
@晓凡3 天前
FPGA中利用fifo时钟域转换---慢时钟域转快时钟域
fpga开发
乘风~&3 天前
fpga助教面试题
fpga开发