Gates4
规约运算,或者拆开按位与,或,异或
module top_module(
input [3:0] in,
output out_and,
output out_or,
output out_xor
);
assign out_and = ∈ #规约运算
out_or = |in;
out_xnor = ^in;
endmodule
Vector3
比较蠢的方法,自己计算;
module top_module (
input [4:0] a, b, c, d, e, f,
output [7:0] w, x, y, z );//
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[1:0],f,2'b11};
endmodule
使用并位运算
module top_module (
input [4:0] a, b, c, d, e, f,
output [7:0] w, x, y, z );//
assign {w,x,y,z}={a,b,c,d,e,f,2'b11};
endmodule
Vectorr
最原始的方法
module top_module(
input [7:0] in,
output [7:0] out
);
assign out = {in[0],in[1],in[2],in[3],in[4],in[5],in[6],in[7]};
endmodule
Vector4
{5{1’b1}} 复制运算符,可以理解为两个并位运算符的组合,但是这才是一个正确的复制操作
module top_module (
input [7:0] in,
output [31:0] out );
assign out = {{24{in[7]}},in}; #切忌out = {24{in[7]},in}
endmodule
Vector5
其实按照上面这个图片来对这个并位就可以
module top_module (
input a, b, c, d, e,
output [24:0] out );//
assign out = ~({{5{a}},{5{b}},{5{c}},{5{d}},{5{e}}}^{5{a,b,c,d,e}});
endmodule