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的更多相关文章

  1. Chrysler -- CCD (Chrysler Collision Detection) Data Bus

    http://articles.mopar1973man.com/general-cummins/34-engine-system/81-ccd-data-bus CCD (Chrysler Coll ...

  2. CRC 概述

    Acquired from: ftp.adelaide.edu.au:/pub/rocksoft/crc_v3.txt or ftp://ftp.rocksoft.com/papers/crc_v3. ...

  3. Common operators to overload-c++运算符重载的标准语法(全)

    Common operators to overload Most of the work in overloading operators is boiler-plate code. That is ...

  4. SpringBoot系列之集成Thymeleaf用法手册

    目录 1.模板引擎 2.Thymeleaf简介 2.1).Thymeleaf定义 2.2).适用模板 3.重要知识点 3.1).th:text和th:utext 3.2).标准表达式 3.3).Thy ...

  5. springboot web项目创建及自动配置分析(thymeleaf+flyway)

    @ 目录 源码分析 webjars thymeleaf thymeleaf语法 springmvc 启动配置原理 集成flyway插件 springboot 创建web项目只需要引入对应的web-st ...

  6. 微服务架构Day03-SpringBoot之web开发配置

    概述 SpringBoot开发: 1.创建SpringBoot应用,选中需要的场景模块. 2.SpringBoot已经默认将场景模块配置好,只需要在配置文件中指定少量的配置(数据库地址,用户名,密码) ...

  7. IEEE Standard 754 for Binary Floating-Point Arithmetic

    IEEE 754-2008 - IEEE Standard for Floating-Point Arithmetic https://standards.ieee.org/standard/754- ...

  8. [swarthmore cs75] Compiler 1 – Adder

    课程回顾 Swarthmore学院16年开的编译系统课,总共10次大作业.本随笔记录了相关的课堂笔记以及第3次大作业. 编译的过程:首先解析(parse)源代码,然后成抽象语法树(AST),再生成汇编 ...

  9. 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 ...

随机推荐

  1. 无法访问 CentOS7服务器上应用监听的端口

    无法访问 CentOS7服务器上应用监听的端口 参考资料 云主机上Centos7配置Iptables规则开启80.3306等端口https://blog.csdn.net/qq_37960007/ar ...

  2. Mybatis结果集映射问题

    之前的数据库图简单都是纯小写格式,这一次做项目为了显得正规一些,模拟实际的情况,采用了驼峰命名的规则,这时候就遇到了结果匹配的问题. 之前只要 <select id="select&q ...

  3. python学习-Day38-HTTP

    目录 HTTP简介 可以充当客户端的有哪些 HTTP 工作原理 HTTP协议 HTTP协议四大特性 数据格式 请求格式: 响应格式: HTTP 请求方法 HTTP 状态码分类 响应分为五类: HTTP ...

  4. kill -9 进程杀不掉,怎么办?

    关注「开源Linux」,选择"设为星标" 回复「学习」,有我为您特别筛选的学习资料~ 用ps和grep命令寻找僵尸进程 ps -A -ostat,ppid,pid,cmd | gr ...

  5. 【爬虫+情感判定+Top10高频词+词云图】“谷爱凌”热门弹幕python舆情分析

    一.背景介绍 最近几天,谷爱凌在冬奥会赛场上夺得一枚宝贵的金牌,为中国队贡献了自己的荣誉! 针对此热门事件,我用Python的爬虫和情感分析技术,针对小破站的弹幕数据,分析了众网友弹幕的舆论导向,下面 ...

  6. web框架的本质、MVC框架MTV框架的介绍

    1.web框架的本质 所有的Web应用本质上就是一个socket服务端,而用户的浏览器就是一个socket客户端,基于请求做出响应,客户都先请求,服务端做出对应的响应,按照http协议的请求协议发送请 ...

  7. SQL注入靶场

    靶场搭建 系统环境&工具 环境采用centos7的版本(纯命令行),采用一键部署平台,phpstudy工具,安装教程链接:https://www.xp.cn/linux.html#instal ...

  8. IDEA通用配置

    文件的自动author注释

  9. JUC自定义线程池练习

    JUC自定义线程池练习 首先上面该线程池的大致流程 自定义阻塞队列 首先定义一个双向的队列和锁一定两个等待的condition 本类用lock来控制多线程下的流程执行 take和push方法就是死等, ...

  10. 力扣算法:125-验证回文串,131-分割回文串---js

    LC 125-验证回文串 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写. 说明:本题中,我们将空字符串定义为有效的回文串. 注:回文串是正着读和反着读都一样的字符串. ...