当前位置: 首页 > news >正文

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

文章目录

  • 9.Declaring wires | wire decl
  • 10. 7458 chip

9.Declaring wires | wire decl

problem:Implement the following circuit. Create two intermediate wires (named anything you want) to connect the AND and OR gates together. Note that the wire that feeds the NOT gate is really wire out, so you do not necessarily need to declare a third wire here. Notice how wires are driven by exactly one source (output of a gate), but can feed multiple inputs.

If you’re following the circuit structure in the diagram, you should end up with four assign statements, as there are four signals that need a value assigned.

在这里插入图片描述

`default_nettype none
module top_module(input a,input b,input c,input d,output out,output out_n   ); wire ab_out;wire cd_out;wire abcd_out;assign out = (a & b) | (c & d);assign out_n = ~((a & b) | (c & d));endmodule

注:
1、`default_nettype none 在后面Vectors中会提到
2、当运行完之后 ,突然发现定义的ab_out、cd_out、abcd_out三根线并没有用上(当时真是没用心,就是简单的循规蹈矩的去做,没做思考),我把三条语句删去之后,运行也是通过的。当然从逻辑上即使不运行这当然是通的。但这样虽然省了代码行数,但如果后面还有继续的电路图,那么这样每行代码的逻辑就会很复杂,也不符合模块化的思想。
因为期望代码行数为5,那么经过改进,如下。

`default_nettype none
module top_module(input a,input b,input c,input d,output out,output out_n   ); wire ab_out, cd_out;   //可以直接连续赋值assign ab_out = a & b;assign cd_out = c & d;assign out = ab_out | cd_out;assign out_n = ~out;endmodule

答案很不唯一,可自行多尝试

10. 7458 chip

problem:Create a module with the same functionality as the 7458 chip. It has 10 inputs and 2 outputs. You may choose to use an assign statement to drive each of the output wires, or you may choose to declare (four) wires for use as intermediate signals, where each internal wire is driven by the output of one of the AND gates. For extra practice, try it both ways.

在这里插入图片描述

问题部分说了两种方式,我们都来试一下。
然后要求的是2到10行
1、You may choose to use an assign statement to drive each of the output wires,
那就试一下,只用2行,就像上一题一样,一行直接把逻辑表达完整。

assign p1y = (p1a & p1b & p1c) | (p1f & p1e & p1d);
assign p2y = (p2a & p2b) | (p2c & p2d);

2、or you may choose to declare (four) wires for use as intermediate signals, where each internal wire is driven by the output of one of the AND gates.

	wire and1, and2, and3, and4;assign and1 = p1a & p1b & p1c;assign and2 = p1f & p1e & p1d;assign and3 = p2a & p2b;assign and4 = p2c & p2d;assign p1y = and1 | and2;assign p2y = and3 | and3;
http://www.lryc.cn/news/141543.html

相关文章:

  • Ubuntu22.0网络/网卡丢失
  • Linux 常用
  • AWS 提示证书签名过期无法自动更新
  • Git版本管理(01) 简介 基本提交相关命令
  • 解决 vue项目报错:digital envelope routines::unsupported
  • 【Java基础增强】类加载器和反射
  • 【Java】数据类型变量
  • 护目镜佩戴检测识别算法
  • NOIOLPJ2022B. 数学游戏 分析
  • android studio gradle build running慢 卡住不动 失败 原因与解决方式
  • 如何保障Facebook账号登录稳定
  • 当前目录下的excel文件的两列内容的相似度比较
  • Cookie for Mac:隐私保护工具保护您的在线隐私
  • Huggingface训练Transformer
  • IA-YOLO项目中DIP模块的初级解读
  • MathType7.4mac最新版本数学公式编辑器安装教程
  • 为Claude的分析内容做准备:提取PDF页面内容的简易应用程序
  • js中作用域的理解?
  • 机器学习基础之《分类算法(4)—案例:预测facebook签到位置》
  • 【Java】反射 之 调用方法
  • Java——单例设计模式
  • Java实现excel表数据的批量存储(结合easyexcel插件)
  • Config:客户端连接服务器访问远程
  • 【KMP算法-代码随想录】
  • 【手写promise——基本功能、链式调用、promise.all、promise.race】
  • 计算机网络-笔记-第二章-物理层
  • 前端开发中的单伪标签清除和双伪标签清除
  • 云计算中的数据安全与隐私保护策略
  • MacOS软件安装包分享(附安装教程)
  • 【linux进程概念】