【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

相关推荐
szxinmai主板定制专家19 小时前
RK3568 + CODESYS+实时系统运动控制器PLC,支持 AI 视觉目标检测,预测性维护,混合多系统部署,多路模拟量采集
arm开发·人工智能·嵌入式硬件·fpga开发
GateWorld21 小时前
LCD显示技术完全指南:原理·制造·驱动·FPGA实现之驱动二
fpga开发·lcd显示·fpga点亮屏幕·minilvds
GateWorld1 天前
LCD显示技术完全指南:原理·制造·驱动·FPGA实现之驱动一
fpga开发·lcd显示·minilvds·fpga点屏
XMAIPC_Robot1 天前
深度无人机自动驾驶仪,中小型无人机硬件在环仿真飞行
运维·arm开发·人工智能·fpga开发·无人机·边缘计算
小眼睛FPGA2 天前
【紫光HiYou开源入门轻量级PCIE开发板PG2L25G】实验例程1-基于紫光FPGA 的LED 流水灯
fpga开发
不会武功的火柴2 天前
SystemVerilog语法(8)-有限状态机(FSM)
嵌入式硬件·fpga开发·自动化·ic验证·rtl·uvm方法学
Kent Gu2 天前
Lattice FPGA选型
fpga开发
Terasic友晶科技2 天前
答疑解惑|为DE25-Nano开发板配置Linux kernel时.config文件没有起作用是什么原因?
linux·服务器·fpga开发·linux kernel·de25-nano
8K超高清2 天前
CCBN展会多图回顾
人工智能·算法·fpga开发·接口隔离原则·智能硬件
小眼睛FPGA2 天前
【紫光HiYou开源入门轻量级PCIE开发板PG2L25G】实验例程5-DDR3 读写实验例程
fpga开发