【iCore4 雙核心板_FPGA】例程八:乘法器實驗——乘法器使用

XiaomaGee發表於2017-08-23

實驗現象:

程式執行時,綠色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連結:

相關文章