当前位置:网站首页>【牛客网刷题系列 之 Verilog快速入门】~ 四选一多路器
【牛客网刷题系列 之 Verilog快速入门】~ 四选一多路器
2022-06-28 04:37:00 【AI很不错呦】
0. 前言
从今天开始,决定开始新的一个板块,那就是针对牛客网上边的Verilog题目做一个完整的学习,这里有两个目的,其一是记录一下自己的学习过程;其二是为后边学习这方面的同学提供一个参考,争取做到平均每日更新一篇的准备,哈哈哈!希望可以坚持下去,欢迎大家批评指正(点赞收藏关注走一波)!!!
1. 四选一多路器
1.1 题目描述
制作一个四选一的多路选择器,要求输出定义上为线网类型.
1.1.1 状态转换
d0 11
d1 10
d2 01
d3 00
1.1.2 信号示意图


1.1.3 输入描述
输入信号 d1,d2,d3,d4 sel
类型 wire
1.1.4 输出描述
输出信号 mux_out
类型 wire
1.2 解题思路
首先,有5个输入信号,其中sel控制是哪一个数据输出,道理很简单,通过看波形就可以明白,话不多说,直接上代码!!!
1.3 代码实现
`timescale 1ns/1ns
module mux4_1(
input [1:0]d1,d2,d3,d0,
input [1:0]sel,
output[1:0]mux_out
);
//*************code***********//
reg [1:0] mux_out_temp;
always @ (*) begin
case (sel)
2'b00 : mux_out_temp = d3;
2'b01 : mux_out_temp = d2;
2'b10 : mux_out_temp = d1;
2'b11 : mux_out_temp = d0;
default : mux_out_temp = d3;
endcase
end
assign mux_out = mux_out_temp;
//*************code***********//
endmodule
1.3.1 代码说明
Q1:为什么要定义一个reg类型的2位变量呢?
A:因为always块中赋值语句必须是reg型的,wire类型是不可以的,wire相当于是一根线,而reg相当于是一个寄存器。
========================================================================
持续更新中。。。。。
边栏推荐
- UI自動化測試框架搭建 —— 編寫一個APP自動化
- Pager when importing text files from MySQL
- Difference between curdate() and now()
- 2022年最新辽宁建筑八大员(标准员)考试试题及答案
- Analysis of distributed transaction solution Seata golang
- native关键字的作用
- Database garbled
- Sword finger offer 53 - I. find the number I in the sorted array (improved bisection)
- Mise en place d'un cadre d'essai d'automatisation de l'interface utilisateur - - rédaction d'une application d'automatisation
- 论文详读:IMPROVING CONVOLUTIONAL MODELS FOR HANDWRITTEN TEXT RECOGNITION
猜你喜欢

Ppt production tips

What to do when MySQL changes the password and reports an error

2022年G3锅炉水处理复训题库模拟考试平台操作

One article explains in detail | those things about growth

Google Earth Engine(GEE)——全球洪水数据库 v1 (2000-2018年)

100+数据科学面试问题和答案总结 - 机器学习和深度学习

Pager when importing text files from MySQL

代码理解:IMPROVING CONVOLUTIONAL MODELS FOR HANDWRITTEN TEXT RECOGNITION

Excel knowledge and skills summary

How to traverse collections Ordereddict, taking it and forgetting items
随机推荐
LeetCode 88:合并两个有序数组
[matlab traffic light identification] traffic light identification [including GUI source code 1908]
Mask's miserable and inspirational childhood, who is introverted by campus violence
PHP code wechat, official account and enterprise wechat send emoticons [u+1f449]
Unity out ref params
2022年安全员-B证考试题库及答案
UI自動化測試框架搭建 —— 編寫一個APP自動化
xml  File read / write
Pager when importing text files from MySQL
学习太极创客 — MQTT 第二章(六)MQTT 遗嘱
Moonbeam integrates coin98, giving users more choices on the multi chain road
The SQL of filincdc always reports this error when there are multiple tables. How can I solve it
Role of native keyword
Sword finger offer 47 Maximum gift value (DP)
几百行代码实现一个脚本解释器
大促场景下,如何做好网关高可用防护
Severe tire damage: the first rock band in the world to broadcast live on the Internet
Play with double pointer
Annual comprehensive analysis of China's audio market in 2022
控制器的功能和工作原理