实验现象:
程序运行时,绿色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)beginclk_10hz <= 1'd0;cnt <= 23'd0;endelse if(cnt == 23'd2499_999)beginclk_10hz <= ~clk_10hz;cnt <= 23'd0;endelse 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链接: