【iCore4 双核心板_FPGA】例程八:乘法器实验——乘法器使用

时间:2023-03-09 06:40:20
【iCore4 双核心板_FPGA】例程八:乘法器实验——乘法器使用

实验现象:

程序运行时,绿色led闪烁(目前,具体的乘法器调用请参考iCore3乘法器例程)

核心代码:

module multiplier_ctrl(
input clk_25m,
input rst_n,
output fpga_ledg
);
//--------------------clk_10hz------------------------------//
reg[:]cnt;
reg clk_10hz; always @(posedge clk_25m or negedge rst_n)
if(!rst_n)
begin
clk_10hz <= 'd0;
cnt <= 'd0;
end
else if(cnt == 'd2499_999)
begin
clk_10hz <= ~clk_10hz;
cnt <= 'd0;
end
else cnt <= cnt + 'd1;
//--------------------data_in&data_out-----------------------//
reg[:]a; always @(posedge clk_10hz or negedge rst_n)
if(!rst_n)
a <= 'd0;
else if(a == 'd250)
a <= 'd0;
else a <= a + 'd1; my_mult u1(
.dataa(a),
.datab(a),
.result(out)
); wire [:]out;
assign fpga_ledg = out[]; //--------------------endmodule----------------------------//
endmodule

源代码下载链接:

链接:http://pan.baidu.com/s/1qXW26ba 密码:h80p

iCore4链接:

【iCore4 双核心板_FPGA】例程八:乘法器实验——乘法器使用