我是靠谱客的博主 暴躁高跟鞋,这篇文章主要介绍HDL bits笔记Circuits----Combinational Logic前言一、题目(multiplexers-256-4)二、解决总结,现在分享给大家,希望可以做个参考。

Circuits----Combinational Logic

文章目录

  • Circuits----Combinational Logic
  • 前言
  • 一、题目(multiplexers-256-4)
  • 二、解决
    • 1.我(错误)
    • 2.常规
    • 3.!!!
  • 总结


前言

一、题目(multiplexers-256-4)

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.

二、解决

1.我(错误)

代码如下(示例):

module top_module( 
    input [1023:0] in,
    input [7:0] sel,
    output [3:0] out );
    assign out=in[sel*4+3 : sel*4];
endmodule

2.常规

代码如下(示例):

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

按bit进行选取然后进行拼接

3.!!!

代码如下(示例):

module top_module( 
    input [1023:0] in,
    input [7:0] sel,
    output [3:0] out );
    assign out=assign out=(in >> ({2'b0,sel} << 2));
endmodule

{2’b0,sel} << 2
相当于4*sel


总结

最后

以上就是暴躁高跟鞋最近收集整理的关于HDL bits笔记Circuits----Combinational Logic前言一、题目(multiplexers-256-4)二、解决总结的全部内容,更多相关HDL内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(108)

评论列表共有 0 条评论

立即
投稿
返回
顶部