" {} " 为连接操作符; 可以把几个小的向量组合成一个向量,比如:
{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
注意: 注意{}内的元素顺序
时序图如下: