HDLbits 刷题 -- Vector3

  " {} " 为连接操作符; 可以把几个小的向量组合成一个向量,比如:

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

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

        {4'ha, 4'd10} => 8'b10101010 // 4'ha and 4'd10 are both 4'b1010 in binary

在此方法中,需要定义其中元素的宽度,否则会出现报错 ,比如{1,2,3}则被认为是违法的;  连接操作符可以用在等式两边都可以;

练习:

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:

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

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

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

注意: 注意{}内的元素顺序

时序图如下:

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刚及格的陆拾伍

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值