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