1、调用ip(IP catalog→multipliers→multiplier),双击multiplier确认
2、修改数据位宽
3、然后创建顶层文件调用ip,实现乘方运算
module sqaure_top(
input [3:0]a,
input clk,
output [7:0]b
);
mult_gen_0 m1(
.CLK(clk),
.A(a),
.B(a),
.P(b)
);
endmodule
4、编辑仿真文件,进行行为仿真
module square_sim(
);
reg clk;
reg [3:0]a;
wire [7:0]b;
mult_gen_0 m2(
.CLK(clk),
.A(a),
.B(a),
.P(b)
);
initial begin
clk=0;
end
always begin
#50 clk=!clk;
end
initial
begin
#0
a=4'b0000;
#100
a=4'b0001;
#100
a=4'b0010;
#100
a=4'b0011;
#100
a