HDL—Verilog Language—Vectors—Vector concatenation operator

Given several input vectors, concatenate them together then split them up into several output vectors. There are six 5-bit input vectors: a, b, c, d, e, and f, for a total of 30 bits of input. There are four 8-bit output vectors: w, x, y, and z, for 32 bits of output. The output should be a concatenation of the input vectors followed by two 1 bits:

给定几个输入向量,将它们连接在一起,然后将它们拆分为几个输出向量。有六个5位输入矢量:a、b、c、d、e和f,总共30位输入。有四个8位输出矢量:w、x、y和z,用于32位输出。输出应该是输入向量的级联,后面跟着两个1位

图片画的还是很清楚的,就是用拼接运算符将这些拼接起来

拼接运算符  { },可以将里面的信号拼接成一个更宽的信号

{3'b111, 3'b000} => 6'b111000

{1'b1, 1'b0, 3'b101} => 5'b10101

{4'ha, 4'd10} => 8'b10101010 //这里4‘ha实际上是4’b1010,4‘d10实际是4’b1010

注意放在里面的信号必须是确定位数的,不能直接随便丢个数字进去,

{1,2,3}这种就不行

可以是{1’b1,2'b10,2'b11}

解释完就很简单了,就把信号拼接起来

module top_module (
    input [4:0] a, b, c, d, e, f,
    output [7:0] w, x, y, z );//

    // assign { ... } = { ... };
    assign w = {a,b[4:2]};
    assign x = {b[1:0],c,d[4]};
    assign y = {d[3:0],e[4:1]};
    assign z = {e[0],f,2'b11};
endmodule

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值