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

实验现象:

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

核心代码:

module multiplier_ctrl(
    input clk_25m,
    input rst_n,
    output fpga_ledg
);
//--------------------clk_10hz------------------------------//
reg[22:0]cnt;
reg clk_10hz;

always @(posedge clk_25m or negedge rst_n)
    if(!rst_n)
        begin
            clk_10hz <= 1'd0;
            cnt <= 23'd0;
        end
    else if(cnt == 23'd2499_999)
        begin
            clk_10hz <= ~clk_10hz;
            cnt <= 23'd0;
        end
    else cnt <= cnt + 1'd1;
//--------------------data_in&data_out-----------------------//
reg[7:0]a;

always @(posedge clk_10hz or negedge rst_n)
    if(!rst_n)
        a <= 8'd0;
    else if(a == 8'd250)
        a <= 8'd0;
    else a <= a + 1'd1;
        
my_mult  u1(
    .dataa(a),
    .datab(a),
    .result(out)
);

wire [15:0]out;
assign fpga_ledg = out[6];

//--------------------endmodule----------------------------//
endmodule

源代码下载链接:

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

iCore4链接:

原文地址:https://www.cnblogs.com/xiaomagee/p/7416651.html