This is 目录

  • Mux2to
  • Mux2to1v
  • Mux9to1v
  • Mux256to1
  • Mux256to1v

Mux2to

Create a one-bit wide, 2-to-1 multiplexer. When sel=0, choose a. When sel=1, choose b.

二选一用一个条件语句即可解决

//成功代码
module top_module( input a, b, sel,output out ); assign out = (!sel)?a:b;
endmodule

波形

Mux2to1v

Create a 100-bit wide, 2-to-1 multiplexer. When sel=0, choose a. When sel=1, choose b.

只是把位宽扩展到100位。

//成功代码
module top_module( input [99:0] a, b,input sel,output [99:0] out );assign out = (sel)?b:a;
endmodule

波形

Mux9to1v

Create a 16-bit wide, 9-to-1 multiplexer. sel=0 chooses a, sel=1 chooses b, etc. For the unused cases (sel=9 to 15), set all output bits to ‘1’.

一个case-endcase语句可以解决

//成功代码
module top_module( input [15:0] a, b, c, d, e, f, g, h, i,input [3:0] sel,output [15:0] out );always @(*)begincase (sel)4'd0:out=a;4'd1:out=b;4'd2:out=c;4'd3:out=d;4'd4:out=e;4'd5:out=f;4'd6:out=g;4'd7:out=h;4'd8:out=i;default:out=16'hffff;endcaseend
endmodule

波形

Mux256to1

Create a 1-bit wide, 256-to-1 multiplexer. The 256 inputs are all packed into a single 256-bit input vector. sel=0 should select in[0], sel=1 selects bits in[1], sel=2 selects bits in[2], etc.

Hint:With this many options, a case statement isn’t so useful.
Vector indices can be variable, as long as the synthesizer can figure out that the width of the bits being selected is constant. In particular, selecting one bit out of a vector using a variable index will work.

根据提示可以知道:
矢量索引可以是可变的,只要合成器能够计算出所选位的宽度是恒定的。特别是使用可变索引从向量中选择一位将起作用。

//成功代码
module top_module( input [255:0] in,input [7:0] sel,output out );assign out = in[sel];
endmodule

Mux256to1v

Create a 4-bit wide, 256-to-1 multiplexer. The 256 4-bit inputs are all packed into a single 1024-bit input vector. sel=0 should select bits in[3:0], sel=1 selects bits in[7:4], sel=2 selects bits in[11:8], etc.

Expected solution length: Around 1–5 lines.

Hint:
With this many options, a case statement isn’t so useful.
Vector indices can be variable, as long as the synthesizer can figure out that the width of the bits being selected is constant. It’s not always good at this. An error saying “… is not a constant” means it couldn’t prove that the select width is constant. In particular, in[ sel4+3 : sel4 ] does not work.
Bit slicing (“Indexed vector part select”, since Verilog-2001) has an even more compact syntax.

//成功代码
module top_module( input [1023:0] in,input [7:0] sel,output [3:0] out );assign out = {in[4*sel+3], in[4*sel+2], in[4*sel+1], in[4*sel]};
endmodule

HDLBits刷题-Multiplexers相关推荐

  1. 【HDLBits 刷题】所有答案直达链接汇总

    写在前面 以下为HDLBits全部答案,有些题的解法不唯一,我的也许不是最优解,欢迎提出更好的想法,HDLBits总的来说比较适合初学者. HDLBits 答案汇总 Language [HDLBits ...

  2. 【HDLBits 刷题 9】Circuits(5)Finite State Manchines 1-9

    目录 写在前面 Finite State Manchines Fsm1 Fsm1s Fsm2 Fsm2s Fsm3comb Fsm3onehot Fsm3 Fsm3s Design a Moore F ...

  3. 【HDLBits 刷题 10】Circuits(6)Finite State Manchines 10-17

    目录 写在前面 Finite State Manchines Lemmings1 Lemmings2 Lemmings3 Lemmings4 Fsm onehot Fsm ps2 Fsm ps2dat ...

  4. 【HDLBits 刷题 11】Circuits(7)Finite State Manchines 18-26

    目录 写在前面 Finite State Manchines Fsm serialdata Fsm serialdp Fsm hdlc Design a Mealy FSM ece241 2014 q ...

  5. 【HDLBits 刷题 12】Circuits(8)Finite State Manchines 27-34

    目录 写在前面 Finite State Manchines 2014 q3c m2014 q6b m2014 q6c m2014 q6 2012 q2fsm 2012 q2b 2013 q2afsm ...

  6. HDLBits刷题合集—9 Arithmetic Circuits

    HDLBits刷题合集-9 Arithmetic Circuits HDLBits-66 Hadd Problem Statement 创建一个半加器.半加器将两个输入(不带低位的进位)相加产生和和向 ...

  7. HDLBits刷题全记录(五)

    文章目录 Finite State Machines Simple FSM 1_1(asynchronous reset) Simple FSM 1_2(synchronous reset) Simp ...

  8. 【小罗的hdlbits刷题笔记2】补码运算中溢出的问题(Exams/ece241 2014 q1c)

    关于补码运算中进位溢出的问题及延伸,hdlbits中Exams/ece241 2014 q1c给出了很好的解释,首先来看问题: Assume that you have two 8-bit 2's c ...

  9. 【小罗的hdlbits刷题笔记3】从Edgedetect对阻塞赋值和非阻塞赋值的思考

    今天题目刷到Edgedetect时,发现根本看不懂这个题目描述的是什么,先给大家放题来体会一下: For each bit in an 8-bit vector, detect when the in ...

最新文章

  1. c语言括号匹配的检验,检验括号匹配的算法
  2. 适合初学者的数据结构_数据结构101:图-初学者的直观介绍
  3. 必须要懂得的密码技术
  4. vue.js 多图上传,并可预览
  5. BZOJ2118墨墨的等式[数论 最短路建模]
  6. 在Linux下怎样让top命令启动之后就按内存使用排序(或CPU使用排序)?
  7. 笔记-高项案例题-2015年下-计算题
  8. linux字符设备移动硬盘,Red Hat Enterprise Linux 7.5挂载NTFS移动硬盘
  9. noip2017d2t2
  10. Segment-based Disparity Refinement with Occlusion Handling for Stereo Matching翻译和理解
  11. Android从无知到有知——NO.6
  12. C++之printf格式
  13. C++(多态实现原理)函数重写,重载,重定义
  14. 关于JqueryEasyUI插件—Tab,默认选中某个面板 如果不明显指定的话,第一个就是被选中的...
  15. Css选择器权重排序详解+权重计算
  16. PS2019渐变工具、油漆桶工具、3D材质拖放工具
  17. T156基于51单片机LCD12864指针时钟Proteus设计、keil程序、c语言、源码、ds1302,电子时钟,62256
  18. HTML5-简易Canvas绘图板
  19. 你所不知道的Win键
  20. Event Sourcing和CQRS实现

热门文章

  1. 15. Python 程序运行速度如何提高十倍?第一遍滚雪球学 Python 收工
  2. 给Win10重新装上“磁盘碎片整理”组件,修复精简系统压缩卷功能
  3. 视觉残差函数及雅可比公式推导
  4. 第8课:网页 HTML 分析
  5. 审核 -链接 - 发布证书
  6. 360chunqiu2017_smallest —— 从例题理解SROP
  7. Echarts 多仪表盘(汽车仪表盘,动态刷新)
  8. 导数能不能通过除法 dy/dx 的求出?
  9. Apache POI 实现word(doc/docx)浏览器预览
  10. 【思维导图】数据库知识框架