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. 用 Flask 来写个轻博客 (19) — 以 Bcrypt 密文存储账户信息与实现用户登陆表单
  2. 【斐波那契】【前缀和】无限序列
  3. python禁用警告
  4. 一些c中常用的功能函数
  5. Go语言之进阶篇 netcat工具的使用
  6. centos7从有线切换到无线_不需要软件,如何简单实现内外网自由切换?
  7. vue2.0 + vux (四)Home页
  8. 使用ELK在DC / OS中进行日志管理
  9. java 对excel指定单元格的数据修改后并输出到指定文件夹
  10. djangobook记录
  11. 互联网公司纷纷裁员,大家都在说互联网行业进入了寒冬期
  12. 数据时代,大数据未来的发展趋势主要有哪些?
  13. 关于 Windows 不断报 脚本错误 当前页面的脚本发生错误 警告窗口的解决办法
  14. Hackintosh(黑苹果)bigsur (opencore引导)超级详细教程
  15. QT警告Slots named on_foo_bar are error prone
  16. Linux 系统如何查看文件是32位还是64位?
  17. try的动词用法_try的用法都有什么
  18. php图片不显示怎么处理,如何解决php图片因存在错误而无法显示
  19. 2021-11-12号-java面试题-北京
  20. 6.20 C语言练习(找出1至99之间的全部同构数。同构数是这样的一组数:它出现在平方数的右边。)

热门文章

  1. 切分数据集(train_test_split),思路分享及手打代码和介绍sklearn中train_test_split,适合小白入门
  2. element-ui输入框中添加按钮
  3. Golang条件编译
  4. autohotkey快捷键总结
  5. burp数据包参数详解
  6. python的各种推导式
  7. 别说996,就是9-12-6我都能干…
  8. 参数化Casper:介于去中心化/最终化时间(finality time)/开销之间的权衡
  9. 20159313网络攻击与防范第九周学习总结
  10. 7.DenseNet(Dense Convolutional Network )