HDLBits-Verilog学习记录 | Verilog Language-Modules(2)

news2025/8/18 11:13:08

文章目录

  • 25.Adder 1 | Module add
  • 26.Adder 2 | Module fadd
  • 27.Carry-select adder
  • 28.Adder-subtractor

25.Adder 1 | Module add

practice:
You are given a module add16 that performs a 16-bit addition. Instantiate two of them to create a 32-bit adder. One add16 module computes the lower 16 bits of the addition result, while the second add16 module computes the upper 16 bits of the result, after receiving the carry-out from the first adder. Your 32-bit adder does not need to handle carry-in (assume 0) or carry-out (ignored), but the internal modules need to in order to function correctly. (In other words, the add16 module performs 16-bit a + b + cin, while your module performs 32-bit a + b).
您将获得一个执行 16 位加法的模块 add16。实例化其中两个以创建 32 位加法器。一个 add16 模块计算加法结果的低 16 位,而第二个 add16 模块在收到来自第一个加法器的结转后计算结果的高 16 位。您的 32 位加法器不需要处理进入(假设为 0)或传出(忽略),但内部模块需要处理才能正常运行。(换句话说,add16 模块执行 16 位 a + b + cin,而模块执行 32 位 a + b)。
Connect the modules together as shown in the diagram below. The provided module add16 has the following declaration:

module add16 ( input[15:0] a, input[15:0] b, input cin, output[15:0] sum, output cout );
在这里插入图片描述

module top_module(
    input [31:0] a,
    input [31:0] b,
    output [31:0] sum
);
    wire cout_1;
    add16 ins_add1 ( .a(a[15:0]), .b(b[15:0]), .cin(1'b0), .sum(sum[15:0]), .cout(cout_1) );
    add16 ins_add2 ( .a(a[31:16]), .b(b[31:16]), .cin(cout_1), .sum(sum[31:16]), .cout() );

endmodule

注:(独立完成部分60%)这道题由于对题目的理解有误,实际上还是个配对问题,但我想复杂了,以为需要计算什么的,结果一直编译不通过。这里应该还是基础课程没有跟上,导致题目理解不清楚。
第二行的.cout()不写也是success!的

26.Adder 2 | Module fadd

practice:
In this exercise, you will create a circuit with two levels of hierarchy. Your top_module will instantiate two copies of add16 (provided), each of which will instantiate 16 copies of add1 (which you must write). Thus, you must write two modules: top_module and add1.
在本练习中,您将创建一个具有两个层次结构级别的线路。您的top_module将实例化 add16 的两个副本(提供),每个副本将实例化 add1 的 16 个副本(您必须编写)。因此,您必须编写两个模块:top_module 和 add1。
Like module_add, you are given a module add16 that performs a 16-bit addition. You must instantiate two of them to create a 32-bit adder. One add16 module computes the lower 16 bits of the addition result, while the second add16 module computes the upper 16 bits of the result. Your 32-bit adder does not need to handle carry-in (assume 0) or carry-out (ignored).
与module_add一样,您将获得一个执行 16 位加法的模块 add16。必须实例化其中两个才能创建 32 位加法器。一个 add16 模块计算加法结果的低 16 位,而第二个 add16 模块计算结果的高 16 位。您的 32 位加法器不需要处理进入(假设为 0)或进转(忽略)。

Connect the add16 modules together as shown in the diagram below. The provided module add16 has the following declaration:
module add16 ( input[15:0] a, input[15:0] b, input cin, output[15:0] sum, output cout );

Within each add16, 16 full adders (module add1, not provided) are instantiated to actually perform the addition. You must write the full adder module that has the following declaration:
在每个 add16 中,实例化 16 个完整的加法器(模块 add1,未提供)以实际执行加法。您必须编写具有以下声明的完整加法器模块:
module add1 ( input a, input b, input cin, output sum, output cout );

Recall that a full adder computes the sum and carry-out of a+b+cin.
回想一下,一个完整的加法器计算 a+b+cin 的总和和结转。

In summary, there are three modules in this design:

  • top_module — Your top-level module that contains two of…
  • add16, provided — A 16-bit adder module that is composed of 16 of…
  • add1 — A 1-bit full adder module.

If your submission is missing a module add1, you will get an error message that says Error (12006): Node instance “user_fadd[0].a1” instantiates undefined entity “add1”.
如果提交缺少模块 add1,您将收到一条错误消息,指出错误 (12006):节点实例“user_fadd[0].a1”实例化未定义的实体“add1”。
在这里插入图片描述
Full adder equations:
sum = a ^ b ^ cin
cout = a&b | a&cin | b&cin

在这里插入代码片

27.Carry-select adder

28.Adder-subtractor

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/940211.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

振动国标2009GB/T 19873.2-2009/ISO 13373-2:2005笔记

国标原文 1.时域,要求,采样率大于最高频率10倍(最低频率?) 2.频域,要求采样率大于最高频率2倍。 3.3.2 积分和微分,二次积分。 3.3.3 均方根。 3.4 滤波 4.1 奈奎斯特图、极坐标图、坎贝尔…

代码随想录算法训练营第四十九天|LeetCode 647,516,动态规划总结篇

目录 LeetCode 647.回文子串 动态规划五步曲: 1.确定dp[i][j]的含义 2.找出递推公式 3.初始化dp数组 4.确定遍历方向 5.打印dp数组 LeetCode 516.最长回文子序列 动态规划五步曲: 1.确定dp[i][j]的含义 2.找出递推公式 3.初始化dp数组 4.确定遍历方向 …

openssh---Windows下git安装配置gitlab

安装openssh 1. 专业版Win10/11默认自带,可以查看是否开启 1. Get-WindowsCapability -Online | Where-Object Name -like OpenSSH* 2. Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 3. Add-WindowsCapability -Online -Name OpenSSH.Serve…

智慧工地云平台源码:工地管理专家

智慧工地是目前建筑行业的热门话题之一,它代表了未来建筑施工的发展趋势。那么,智慧工地的未来,你看好吗? 从技术角度来看,智慧工地无疑是未来发展的趋势。随着人工智能、大数据、云计算等技术的飞速发展,智…

python+Appium自动化:python多线程多并发启动appium服务

Python启动Appium 服务 使用Dos命令或者bat批处理来手动启动appium服务,启动效率低下。如何将启动Appium服务也实现自动化呢? 这里需要使用subprocess模块,该模块可以创建新的进程,并且连接到进程的输入、输出、错误等管道信息&…

Ubuntu22.04安装使用Docker (参考:完成Dock中的企业微信安装)

Ubuntu22.04安装使用Docker 概述什么是Docker ?Docker 的优点 Docker的安装(1) 安装 Docker 依赖项(2) 启用 Docker 官方存储库(3) 使用 Apt 命令安装 Docker(4) 验证和测试 Docker 安装 Docker Compose1. 使用二进制文件安装 Docker Compose2. 使用 Pip 安装 Docker Compose …

2023年高教社杯 国赛数学建模思路 - 案例:ID3-决策树分类算法

文章目录 0 赛题思路1 算法介绍2 FP树表示法3 构建FP树4 实现代码 建模资料 0 赛题思路 (赛题出来以后第一时间在CSDN分享) https://blog.csdn.net/dc_sinor?typeblog 1 算法介绍 FP-Tree算法全称是FrequentPattern Tree算法,就是频繁模…

LC34. 在排序数组中查找元素的第一个和最后一个位置(JAVA)

二分查找 在排序数组中查找元素的第一个和最后一个位置二分查找 上期经典算法 在排序数组中查找元素的第一个和最后一个位置 难度 - 中等 在排序数组中查找元素的第一个和最后一个位置 给你一个按照非递减顺序排列的整数数组 nums,和一个目标值 target。请你找出给定…

unity中Game视图绘制XYZ坐标轴

Game视图显示XYZ坐标轴 功能一:仅显示XYZ坐标轴前期准备设置箭头模型的材质1、在“Assets”中,新建一个名为“Materials”文件夹,专门用于放置材质。选中“Materials”文件夹,鼠标右键->“创建”->“材质”2、重命名为“Red…

# 【三维重建】【深度学习】NeRF代码Pytorch实现--数据加载(中)

【三维重建】【深度学习】NeRF代码Pytorch实现–数据加载(中) 论文提出了一种5D的神经辐射场来作为复杂场景的隐式表示,称为NeRF,其输⼊稀疏的多⻆度带pose的图像训练得到⼀个神经辐射场模型。简单来说就是通过输入同一场景不同视角下的二维图片和相机位…

GCNet论文总结和代码实现

GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond(当非局部网络遇到挤压激励网络) 论文:GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond 源码:https://gitcode.net/mirrors/xvji…

【LeetCode】227. 基本计算器 II

227. 基本计算器 II(中等) 方法:双栈解法 思路 我们可以使用两个栈 nums 和 ops 。 nums : 存放所有的数字ops :存放所有的数字以外的操作 然后从前往后做,对遍历到的字符做分情况讨论: 空格 …

爬虫逆向实战(二十三)--某准网数据

一、数据接口分析 主页地址:某准网 1、抓包 通过抓包可以发现数据接口是api_to/search/company_v2.json 2、判断是否有加密参数 请求参数是否加密? 通过查看“载荷”模块可以发现b参数和kiv参数是加密参数 请求头是否加密? 无响应是否加…

torch.mul()函数使用说明,含高维张量实例及运行结果

torch.mul函数使用说明,含实例及运行结果 torch.mul() 函数torch.mul() 函数定义参数及功能高维数据实例解释 参考博文及感谢 torch.mul() 函数 对输入的张量或数做点积运算,如果维度不统一会想进行维度统一(广播机制)&#xff0…

PConv : Run, Don’t Walk: Chasing Higher FLOPS for Faster Neural Networks

摘要 为了设计快速的神经网络,**许多研究都集中在减少浮点运算(FLOPs)**的数量。然而,我们观察到这种FLOPs的减少并不一定会导致相同程度的延迟减少。这主要是由于浮点运算每秒效率较低的问题所致。为了实现更快的网络,我们重新审视了流行的操作算子,并证明这种低FLOPS主…

docker高级(DockerFile解析)

1、构建三步骤 编写Dockerfile文件 docker build命令构建镜像 docker run依镜像运行容器实例 2、DockerFile构建过程解析 Dockerfile内容基础知识 1:每条保留字指令都必须为大写字母且后面要跟随至少一个参数 2:指令按照从上到下,顺序执行…

异地访问Oracle数据库的解决方案:利用内网穿透实现PL/SQL远程连接的建议与步骤

文章目录 前言1. 数据库搭建2. 内网穿透2.1 安装cpolar内网穿透2.2 创建隧道映射 3. 公网远程访问4. 配置固定TCP端口地址4.1 保留一个固定的公网TCP端口地址4.2 配置固定公网TCP端口地址4.3 测试使用固定TCP端口地址远程Oracle ​ 小月糖糖主页 在强者的眼中,没有最…

SolidWorks软件安装包分享(附安装教程)

目录 一、软件简介 二、软件下载 一、软件简介 SolidWorks是一款由达索系统(Dassault Systmes)开发的三维计算机辅助设计(CAD)软件,被广泛应用于机械、电子、建筑和航空航天等领域。它以易学易用、强大的功能和良好的…

Michael.W基于Foundry精读Openzeppelin第32期——SignatureChecker.sol

Michael.W基于Foundry精读Openzeppelin第32期——SignatureChecker.sol 0. 版本0.1 SignatureChecker.sol 1. 目标合约2. 代码精读2.1 isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) 0. 版本 [openzeppelin]:v4.8.3,[for…

华为OD机试 - 云短信平台优惠活动 - 回溯(Java 2023 B卷 200分)

目录 专栏导读一、题目描述二、输入描述三、输出描述四、解题思路五、Java算法源码六、效果展示1、输入2、输出3、说明 华为OD机试 2023B卷题库疯狂收录中,刷题点这里 专栏导读 本专栏收录于《华为OD机试(JAVA)真题(A卷B卷&#…