HDLBits->Circuits->Arithmetic Circuitd->3-bit binary adder
Verilog实例数组
对于一个定义好的简单module,例如加法器之类,如果我们要对其进行几十次几百次的例化,并且这些例化基本都是相同的形式,那么我们肯定不能一个个的单独对其进行例化,此时我们就可以使用一种例化数组的方式进行快速的例化。
举个例子,如果我们要实现的功能如下:
Now that you know how to build a full adder, make 3 instances of it to create a 3-bit binary ripple-carry adder. The adder adds two 3-bit numbers and a carry-in to produce a 3-bit sum and carry out. To encourage you to actually instantiate full adders, also output the carry-out from each full adder in the ripple-carry adder. cout[2] is the final carry-out from the last full adder, and is the carry-out you usually see.
给出的端口定义如下
module Adder3(
input [2:0] a, b,
input cin,
output [2:0] cout,
output [2:0] sum );
那么我们可以先定义一个一位带进位的加法模块
module Adder1(
input a, b, cin,
output cout, sum );
assign {cout,sum} = a + b + cin;
endmodule
然后使用实例化数组语法
module Adder3(
input [2:0] a, b,
input cin,
output [2:0] cout,
output [2:0] sum );
Adder1 Adder1[2:0](//将我们例化的模块写成一个一位加法器的三倍位宽
.a(a),//每一个端口的位宽都是原来一位加法器的三倍位宽
.b(b),
.cin({cout[1:0],cin}),
.cout(cout),
.sum(sum)
);
上面这段例化实际是例化了三个add模块,名字分别为 add_3[0], add_3[1], add_3[2];
从原理图我们就可以看出确实是例化了三个Adder1模块.

HDLBits->Circuits->Arithmetic Circuitd->3-bit binary adder的更多相关文章
- Chrysler -- CCD (Chrysler Collision Detection) Data Bus
http://articles.mopar1973man.com/general-cummins/34-engine-system/81-ccd-data-bus CCD (Chrysler Coll ...
- CRC 概述
Acquired from: ftp.adelaide.edu.au:/pub/rocksoft/crc_v3.txt or ftp://ftp.rocksoft.com/papers/crc_v3. ...
- Common operators to overload-c++运算符重载的标准语法(全)
Common operators to overload Most of the work in overloading operators is boiler-plate code. That is ...
- SpringBoot系列之集成Thymeleaf用法手册
目录 1.模板引擎 2.Thymeleaf简介 2.1).Thymeleaf定义 2.2).适用模板 3.重要知识点 3.1).th:text和th:utext 3.2).标准表达式 3.3).Thy ...
- springboot web项目创建及自动配置分析(thymeleaf+flyway)
@ 目录 源码分析 webjars thymeleaf thymeleaf语法 springmvc 启动配置原理 集成flyway插件 springboot 创建web项目只需要引入对应的web-st ...
- 微服务架构Day03-SpringBoot之web开发配置
概述 SpringBoot开发: 1.创建SpringBoot应用,选中需要的场景模块. 2.SpringBoot已经默认将场景模块配置好,只需要在配置文件中指定少量的配置(数据库地址,用户名,密码) ...
- IEEE Standard 754 for Binary Floating-Point Arithmetic
IEEE 754-2008 - IEEE Standard for Floating-Point Arithmetic https://standards.ieee.org/standard/754- ...
- [swarthmore cs75] Compiler 1 – Adder
课程回顾 Swarthmore学院16年开的编译系统课,总共10次大作业.本随笔记录了相关的课堂笔记以及第3次大作业. 编译的过程:首先解析(parse)源代码,然后成抽象语法树(AST),再生成汇编 ...
- Binary Prefix Divisible By 5 LT1018
Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted as a bi ...
随机推荐
- Ubuntu 安装cmake
Ubuntu 安装 cmake 官网 https://cmake.org 下载地址 https://cmake.org/download/ 参考文档 -<ubuntu下更新cmake版本> ...
- Model, HttpServletRequest, ModelMap区别
看了spring mvc的底层会发现,model数据最终还是写到HttpServletRequest属性中,只是model的写法更体现了MVC思想减少各层间耦合 写法: 1.request.setAt ...
- C# 中托管内存与非托管内存之间的转换
c#有自己的内存回收机制,所以在c#中我们可以只new,不用关心怎样delete,c#使用gc来清理内存,这部分内存就是managed memory,大部分时候我们工作于c#环境中,都是在使用托管内存 ...
- Apache Doris ODBC外表之Postgresql使用指南
Apache Doris 社区 2022 年的总体规划,包括待开展或已开展.以及已完成但需要持续优化的功能.文档.社区建设等多方面,我们期待有更多的小伙伴参与进来讨论.同时也希望多多关注Doris,给 ...
- 异步请求与中断 ( XHR,Axios,Fetch对比 )
随着AJAX技术的诞生,前端正式进入了局部刷新和前后端分离的新时代,最初的服务请求技术是XHR,随着技术发展和ES6的诞生,jquery ajax,axios,fetch 等技术的产生让前端的异步请求 ...
- python学习-Day36
目录 进程 进程间通信 队列(multiprocess.Queue) 概念 Queue的实例q具有以下方法: 消息队列 生产者消费者模型 实现生产者消费者模型三要素: 线程理论 线程概念 线程存在的意 ...
- [AcWing 68] 0到n-1中缺失的数字
点击查看代码 class Solution { public: int getMissingNumber(vector<int>& nums) { if (nums.empty() ...
- 开发一款让我们慢慢变好的微信小程序
1. 前言 朋友,你还记得你想学编程最初的目的是什么吗? 先说说我的吧,我最初想学编程的目的只有一点,感觉编程很酷,会写代码的人很厉害!.随着后面参加工作,我马上产生了让我能够在编程这条路上继续走下去 ...
- [笔记] Slope Trick:解决一类凸代价函数的DP优化问题
原理 当序列 DP 的转移代价函数满足 连续: 凸函数: 分段线性函数. 时,可以通过记录分段函数的最右一段 \(f_r(x)\) 以及其分段点 \(L\) 实现快速维护代价的效果. 如:$ f(x) ...
- 基本命令学习 -(4)链接文件:ln命令
关注「开源Linux」,选择"设为星标" 回复「学习」,有我为您特别筛选的学习资料~ 前言 在Windows系统中,快捷方式是指向原始文件的一个链接文件,原文件一旦被删除或剪切到其 ...