当前位置:   article > 正文

基于FPGA的flash分区实现多功能转换(icap核)_icap ip核 flash读写

icap ip核 flash读写

1.前文提到通过硬件代码描述可以将程序固化到flas中,但是只能实现单一功能,无法实现多功能切换。本文通过调用ise的ip核,固化代码实现流水灯与呼吸灯的切换。

2.这次的联系,主要是为了下次的在线升级的多种功能综合做铺垫。如果只是为了实现这种转换,利用状态机也可以实现,icap可以将flash实现功能分离。实现多个功能不在需要下载器下载。

3.练习代码如下:

  1. module icap_ctrl(
  2. input wire sclk,
  3. input wire rst_n,
  4. input wire key_in
  5. );
  6. reg [3:0] cnt;
  7. reg ce;
  8. reg [15:0] tmp_i;
  9. wire [15:0] i_data;
  10. always@(posedge sclk or negedge rst_n) //cnt14
  11. if(!rst_n)
  12. cnt<=4'd0;
  13. else if(cnt==14)
  14. cnt<=4'd0;
  15. else if (ce==0)
  16. cnt<=cnt+1'b1;
  17. always@(posedge sclk or negedge rst_n) //ce
  18. if(!rst_n)
  19. ce<=1'b1;
  20. else if(cnt==14)
  21. ce<=1'b1;
  22. else if (key_in==1)
  23. ce<=1'b0;
  24. always@(posedge sclk or negedge rst_n)
  25. if(!rst_n)
  26. tmp_i<=16'hffff;
  27. else case(cnt)
  28. 0: tmp_i<=16'hffff;
  29. 1: tmp_i<=16'haa99;
  30. 2: tmp_i<=16'h5566;
  31. 3: tmp_i<=16'h3261;
  32. 4: tmp_i<=16'h0000; //
  33. 5: tmp_i<=16'h3281;
  34. 6: tmp_i<=16'h0300; //
  35. 7: tmp_i<=16'h32a1;
  36. 8: tmp_i<=16'h0000; //
  37. 9: tmp_i<=16'h32c1;
  38. 10: tmp_i<=16'h030b; //
  39. 11: tmp_i<=16'h30a1;
  40. 12: tmp_i<=16'h000e;
  41. 13: tmp_i<=16'h2000;
  42. 14: tmp_i<=16'hffff;
  43. default: tmp_i<=16'hffff;
  44. endcase
  45. assign i_data={tmp_i[8],tmp_i[9],tmp_i[10],tmp_i[11],tmp_i[12],tmp_i[13],tmp_i[14],tmp_i[15],
  46. tmp_i[0],tmp_i[1],tmp_i[2],tmp_i[3],tmp_i[4],tmp_i[5],tmp_i[6],tmp_i[7]};
  47. ICAP_SPARTAN6 #(
  48. .DEVICE_ID(28'h4000093), // Specifies the pre-programmed Device ID value
  49. .SIM_CFG_FILE_NAME("NONE") // Specifies the Raw Bitstream (RBT) file to be parsed by the simulation
  50. // model
  51. )
  52. ICAP_SPARTAN6_inst (
  53. .BUSY(), // 1-bit output: Busy/Ready output
  54. .O(), // 16-bit output: Configuartion data output bus
  55. .CE(ce), // 1-bit input: Active-Low ICAP Enable input
  56. .CLK(sclk), // 1-bit input: Clock input
  57. .I(i_data), // 16-bit input: Configuration data input bus
  58. .WRITE(1'b0) // 1-bit input: Read/Write control input
  59. );
  60. endmodule

 

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号