当前位置:网站首页>Verilog语法基础HDL Bits训练 07
Verilog语法基础HDL Bits训练 07
2022-07-30 11:17:00 【南邮学渣】
文章目录
Circuits:Combinational Logic:Multiplexers
一、2-to-1 multiplexer

设计一个二选一多路器
- RTL代码
module top_module(
input a, b, sel,
output out );
always @(*)
case(sel)
1'b0 : out = a;
1'b1 : out = b;
endcase
endmodule
- 仿真波形图

二、2-to-1 bus multiplexer

- RTL代码
module top_module(
input [99:0] a, b,
input sel,
output [99:0] out );
always @(*)
case(sel)
1'b0 : out = a;
1'b1 : out = b;
endcase
endmodule
- 仿真波形图

三、9-to-1 multiplexer

设计一个十六选一多路器
- RTL代码
module top_module(
input [15:0] a, b, c, d, e, f, g, h, i,
input [3:0] sel,
output [15:0] out );
always @(*)
case(sel)
4'b0000 : out = a;
4'b0001 : out = b;
4'b0010 : out = c;
4'b0011 : out = d;
4'b0100 : out = e;
4'b0101 : out = f;
4'b0110 : out = g;
4'b0111 : out = h;
4'b1000 : out = i;
default : out = 16'hffff;
endcase
endmodule
- 仿真波形图

四、256-to-1 multiplexer

256个这么多的选择项,case就不能用了,使用变量索引可以完成任务,同时在使用时注意变量和向量的位宽
- RTL代码
module top_module(
input [255:0] in,
input [7:0] sel,
output out );
assign out = in[sel];
endmodule
五、256-to-1 4-bit multiplexer

使用位拼接法使选择更灵活
- RTL代码
module top_module(
input [1023:0] in,
input [7:0] sel,
output [3:0] out );
assign out = {
in[sel*4+3] , in[sel*4+2] , in[sel*4+1] , in[sel*4]};
endmodule
边栏推荐
猜你喜欢
随机推荐
I built another wheel: GrpcGateway
Typroa alternative tool marktext
Oracle中SQL语言和分页rownum分析
IP池设计思考(面试点)[通俗易懂]
ansible学习笔记01
程序环境和预处理(详解)
数据库性能系列之索引(上)
【数据库基础】redis使用总结
基于MySQL数据库,Redis缓存,MQ消息中间件,ES搜索引擎的高可用方案解析
AB test summary
单片机开发之LCD1602显示实验
mysql与redis 区别
Database transactions, JDBC operations and data types
电压继电器HDY-A/1-220VAC-1
Assembly to implement bubble sort
[Database basics] redis usage summary
eric6教程(电脑的配置基本知识)
xshell使用技巧(赚分享平台怎么样)
明德扬FPGA开发板XILINX-K7核心板Kintex7 XC7K325 410T工业级
Log4j有哪几种日志级别呢?









