ѧѧѧѧѧѧѧ

  • 2024-12-03
  • »Ø¸´ÁËÖ÷ÌâÌû£º ¡¾¶ÁÊé¡¿¡¶RISC-V Ìåϵ½á¹¹±à³ÌÓëʵ¼ù£¨µÚ2°æ£©¡·-- RISC-V ´æ´¢¼ÓÔØÖ¸Áѧϰ

    rars Õâ¸öÈí¼þÓÐÏÂÔØÁ´½ÓÂð´óÀÐ

  • 2024-10-11
  • »Ø¸´ÁËÖ÷ÌâÌû£º ¹ú²úTang Primer 25K²âÆÀʹÓøßÔÆSDRAMµÄipºËÇý¶¯¹Ù·½µÄSDRAMÀ©Õ¹°å Åöµ½µÄÎÊÌâ

    Jacktang ·¢±íÓÚ 2024-3-5 07:56 »³ÒÉSDRMоƬ»µÁË£¬£¬£¬ ÎÊÌâÊÇÔõô»á»µÁËÄØʲôԭÒò£¬ÒÔºó¿É±ÜÃ⣬£¬ °ïÂ¥Ö÷¶¥¶¥ ÒѾ­½â¾öÁË£¬·¢ÏÖÖ÷Òª»¹ÊÇʱÖÓµÄÎÊÌâ

  • »Ø¸´ÁËÖ÷ÌâÌû£º ¹ú²ú¸ßÔÆÈí¼þ±àÒëͨ¹ý£¬×ÛºÏÈ´±¨´í£¬È»ºóÎÞ·¨Õý³£±àÒëcstÎļþ

    123yqs ·¢±íÓÚ 2024-9-27 14:01 ÄúºÃ£¬ÄãÎÊÌâ½â¾öÁËÂ ÎÞ

  • 2024-09-23
  • »Ø¸´ÁËÖ÷ÌâÌû£º ·¢ÏÖÔÚch32v003ÉÏÅÜLinuxµÄ¿ªÔ´ÏîÄ¿£¬ÓÐʵ¼ÊÓ¦ÓüÛÖµÂð£¿

    Å£±Æ

  • 2024-07-01
  • ·¢±íÁËÖ÷ÌâÌû£º »ùÓÚ¹ú²ú¸ßÔÆFPGAµÄIPºËFIRÂ˲¨Æ÷Éè¼Æ

    # »ùÓÚ¹ú²ú¸ßÔÆFPGAµÄIPºËFIRÂ˲¨Æ÷Éè¼Æ ÊÐÃæÉÏʹÓÃFPGAÉè¼ÆµÄFIRÂ˲¨Æ÷Óкܶ࣬ÆäÖлùÓÚIPºËÉè¼ÆµÄͬÑùºÜ¶à£¬µ«ÊÇ»ùÓÚ¹ú²úFPGAÈíÓ²¼þÉè¼ÆµÄFIRÂ˲¨Æ÷ºÜÉÙ£¬ÆäÖлáÓùú²úIPµÄ¸üÉÙ£¬¶øÓøßÔƵļ¸ºõûÓУ¬ÖÁÉÙÍøÉÏ»ù±¾ÊÇÕÒ²»µ½¿ªÔ´ÏîÄ¿µÄ£¬ÓÚÊdzÃ×ÅÕâ´Î×öʵÑéµÄ»ú»áÎÒʹÓÃʹÓùú²ú¸ßÔÆFPGA¼°ÆäIPÉè¼ÆÁËÒ»¸ö¼òÒ×µÄFIRÂ˲¨Æ÷£¬ ÒòΪÁÙ½üÆÚÄ©£¬Ã»Ê²Ã´¿ÕдÌû×ÓÁË£¬ÎÒ°ÑÎҵŤ³ÌÉÏÌáµ½ÁËgithubÉÏ£¬´ó¼Ò¿ÉÒÔÈ¥githubÉÏ¿´¿´¡£ Á´½ÓÈçÏ£º  https://github.com/huangjintaoa/Gowin_FPGA_IP_FIR_filter_design **Ŀ¼½á¹¹ÈçÏÂ** # lab2_fft  ## impl ## src ## work ## doc ---- lab2_fftÎļþ¼ÐÏ°üº¬ÁË4¸öÈçÉÏËùÊöµÄ×ÓÎļþ¼Ð£¬È»ºó»¹°üº¬ÁËÆäËûµÄÎļþ£¬ÆäÖÐ.gprjÎļþʱGowinµÄ¹¤³ÌÎļþ£¬¿ÉʹÓøßÔÆFPGAÈí¼þ¿ª·¢Æ½Ì¨Ö±½Ó´ò¿ª£¬.mpfÎļþÊÇmodelsimµÄ·ÂÕ湤³ÌÎļþ£¬¿ÉÒÔʹÓÃmodesim´ò¿ª£¬Äܹ»Ö±½Ó¶Ô¸ÃFIR¹¤³Ì½øÐзÂÕæ¡£ ##### docÎļþ¼Ð ÊÇÎÒдµÄ¿Î³Ì±¨¸æ£¬ÀïÃæÎÒÕâ¸öFIRµÄÉè¼ÆÁ÷³ÌºÍ¸ßÔÆIPÅäÖÃÓÐÏêϸÃèÊö£¬srcÎļþ¼ÐÀïÔòÊǹ¤³ÌÔ´Âë,ÀïÃæµÄfir_topÊǹ¤³Ì¶¥²ãÎļþ£¬fir_tbÊǹ¤³ÌµÄtestbench£¬ÓÐÒ»¸öºó׺.mµÄÎļþÊÇmatlabʹÓÃfilter Éè¼Æ¹¤¾ßÉú³ÉFIR³éͷϵÊýÖ®ºóµ¼Èëµ½¸ßÔÆFIRÂ˲¨Æ÷Óû§ÊÖ²áÖÐËù¹æ¶¨µÄ³õʼ»¯Îļþcoeff.datÎļþµÄ½Å±¾´úÂë¡£ ##### ±¾´ÎËùʹÓõĸßÔÆIP°üÀ¨ PLL ¡¢DDS I ¡¢DDS II¡¢¸´Êý³Ë·¨Æ÷multi¡¢FIRÂ˲¨Æ÷  

  • 2024-06-25
  • »Ø¸´ÁËÖ÷ÌâÌû£º ¡¶Ê±¼äƬÂÖѯtpOS v2.00¡·È«ÍøÊ×·¢£¨¾ø¶ÔÕ𺳣©2016-02-03¸üÐÂ

    ºÃÀ÷º¦

  • »Ø¸´ÁËÖ÷ÌâÌû£º ¡¶Ç¶ÈëʽÈí¼þµÄʱ¼ä·ÖÎö¡·´ÓÊéÖе½Êµ¼ù-ʹÓÃTracealyzer½øÐÐRTOSµ÷ÊÔ·ÖÎö

    ´óÀкÃÀ÷º¦£¡Ñ§µ½ÁË  

  • »Ø¸´ÁËÖ÷ÌâÌû£º ¡¾ÕýµãÔ­×Ói.MX93¿ª·¢°å¡¿3-È˹¤ÖÇÄܵIJâÆÀ£¨AIʶ±ð£©

    ¿´ÆðÀ´ºÜ·½±ãѽ  

  • 2024-04-18
  • »Ø¸´ÁËÖ÷ÌâÌû£º ¹ú²ú¸ßÔÆÈí¼þ±àÒëͨ¹ý£¬×ÛºÏÈ´±¨´í£¬È»ºóÎÞ·¨Õý³£±àÒëcstÎļþ

    littleshrimp ·¢±íÓÚ 2024-4-18 13:19 ´úÂëÊÇ×Ô¼ºÐ´µÄÂð£¿ÊDz»ÊÇÄǸöµØ·½Ã»Ð´¶Ô£¿¼ì²éһϿ´¿´£¬»òÕ߸ø¸ßÔƼ¼ÊõÖ§³Ö´òµç»°¿´¿´¡£ ´úÂëÆäʵÊÇÔÚquartusÉÏÅܹýµÄ£¬±àÒëºÍ²¼¾Ö²¼Ï߶¼Í¨¹ý£¬µ«ÊǷŵ½gowinÉϾͻáĪÃûÆäÃ´í£¬É¾³ýÁËreg signedµÄÐźŶ¨Òå¾Í²»»á±¨´íÁË

  • ·¢±íÁËÖ÷ÌâÌû£º ¹ú²ú¸ßÔÆÈí¼þ±àÒëͨ¹ý£¬×ÛºÏÈ´±¨´í£¬È»ºóÎÞ·¨Õý³£±àÒëcstÎļþ

    ±¨´í£ºERROR  (PA2114) : Instance "n55_s1" parameter value conflict, when operand C/0 selects 0, the addition and subtraction controls corresponding to the operands can only be set as addition operations   ±¨´í¶¨Î»£º±¨´íÔÚÁ˹¤³ÌÏîÄ¿×Ô¶¯Éú³ÉµÄ.vgÎļþ£»ÎÒ±¾À´´úÂë×öµÄÊÇÒ»¸ö¸µÀïÒ¶±ä»»µÄСʵÑ飬ÔÚtang25k¿ª·¢°åÉÏ×öµÄ¡£  

  • 2024-04-01
  • »Ø¸´ÁËÖ÷ÌâÌû£º ¡¾¹ú²úTang Primer 25K²âÆÀ¡¿»ùÓÚ¸ßÔÆGOWINFPGA¿ª·¢Æ½Ì¨ÒÆÖ²RISC-VÈíºËE203

    Òä´ËÉú ·¢±íÓÚ 2024-3-10 14:54 ´óÀÐÄã¸øµÄ´úÂëÊÇ·ñÓÐÅäÖúÃjtagÄØ£¬ÎÒ²âÊÔÁ˺ܾö¼ÎÞ·¨ÓÃopenocdÁ¬½Óµ½riscv£¬Ï£ÍûÄܹ»µÃµ½´óÀÐÖ¸½Ì ÎÒÍü¼ÇÁË£¬Äã¿´¿´Òý½ÅÔ¼ÊøÎļþÀïÓÐûÓжÔjtagµÄÒý½ÅÔ¼Êø£¬TCK»¹ÐèÒªÔÚʱÖÓÔ¼ÊøÀïÉèÖ㬽¨ÒéÈ¥bÕ¾ËÑË÷½Ì³Ì”ÊÖ°ÑÊÖÒÆÖ²·äÄñe203“»òÕßÈ¥·äÄñµÄÍøÕ¾¿´¡£ÁíÍâÐèÒª·äÄñרÓõĵ÷ÊÔÆ÷£¬·äÄñ»¹ÓÐ×Ô¼º×¨ÓõıàÒëÈí¼þ

  • 2024-03-06
  • »Ø¸´ÁËÖ÷ÌâÌû£º ¹ú²úTang Primer 25K²âÆÀʹÓøßÔÆSDRAMµÄipºËÇý¶¯¹Ù·½µÄSDRAMÀ©Õ¹°å Åöµ½µÄÎÊÌâ

    viva_xin ·¢±íÓÚ 2024-3-5 22:26 ¿ÉÒÔ×ö¸öʵÑ飬дÈëµÄÊý¾ÝÖ±µ½busy±»À­ÆðÀ´Ö®Ç°Ò»Ö±±£³Ö±ä»¯£¬È»ºó¿´¿´Êµ¼Ê¶Á³öÀ´µÄ½á¹ûÈçºÎ¡£ ÔÙÎÊÒ»¾ä ... ÎÒÉÏÃæÌùµÄÄÇÖÖץȡµÄͼÓÐÕâÑùµÄÇé¿ö£¬²ÎÊýÊǹٷ½¸øµÄÒ»¸öÀý³ÌÀïµÄ²ÎÊý£¬²»¹ýÄǸöÀý³ÌûʹÓÃip£¬Ö±½ÓдµÄÇý¶¯¡£ÎÒ³¢ÊÔ¹ýʹÓùٷ½Ä¬ÈϵIJÎÊý£¬Ò²ÊÇûÓÐÓÃ

  • 2024-03-05
  • »Ø¸´ÁËÖ÷ÌâÌû£º ¹ú²úTang Primer 25K²âÆÀʹÓøßÔÆSDRAMµÄipºËÇý¶¯¹Ù·½µÄSDRAMÀ©Õ¹°å Åöµ½µÄÎÊÌâ

    littleshrimp ·¢±íÓÚ 2024-3-5 16:29 ÄãÊÇÓÃ18µÄÀý³Ì¸Ä³É25µÄ ¹ý³ÌÖÐÓпÉÄÜ»áÅäÖóö´í ¿ÉÒ԰ɸĺõÄÀý³Ì·¢³öÀ´¿´¿´ÆäËûÓÐÕâ¸ö°å×ÓµÄÍø ... SDRAM°å×ÓÓеã¹ó£¬Ñ§Éúµ³²»ÉáµÃÇáÒ×Åж¨£¬ÎÒ·¢Ò»·¢³ÌÐò  

  • 2024-03-04
  • ·¢±íÁËÖ÷ÌâÌû£º ¹ú²úTang Primer 25K²âÆÀʹÓøßÔÆSDRAMµÄipºËÇý¶¯¹Ù·½µÄSDRAMÀ©Õ¹°å Åöµ½µÄÎÊÌâ

    ±¾Ìû×îºóÓÉ Ñ§Ñ§Ñ§Ñ§Ñ§Ñ§Ñ§ ÓÚ 2024-3-4 21:36 ±à¼­ ֮ǰÁíÂòÁ˹ٷ½µÄSDRAM¿ª·¢°å£¬·¢ÏÖ¸ßÔÆÓÐSDRAMµÄIPºË£¬ÓÚÊÇ´òËãʹÓÃipºË£¬²¢ÎªËüд¸ö¿ØÖÆÆ÷Ä£¿é£¬¼òµ¥ÏÔʾһÕÅͼƬ£¬ÎÒÕâÀïÑ¡ÓÃÁËÒ»ÕŲÊÌõͼƬÀàËÆÈçÏ           È»ºóÎÒÓøßÔƹٷ½¸øµÄÀý×ӾͽøÐвâÊÔ£¬ÎÒʹÓÃSDRAM Controller GW2AR-18 RefDesign²Î¿¼Éè¼Æ¹¤³Ì½øÐмòµ¥µÄ²ÎÊýÊÊÅäºó£¬¾ÍÏÂÔؽøÐй۲죬µÃµ½²¨ÐÎͼÈçÏ£º                   ·¢ÏÖдÈëSDRAMµÄÊý¾ÝºÍ´ÓSDRAM¶Á³öµÄÊý¾Ý²»Ò»Ö£¬¶Á³öµÄÊý¾ÝÖ»ÓÐÊ×λÊý¾ÝÓëÊäÈëÊý¾ÝÒ»Ö£¬ÇÒÿ´Î´ÓSDRAM×Ô¶¯¶Á³öµÄÊý¾ÝÖ»ÓÐÒ»¸öÊý¾Ý£¬Æä³ÖÐøʱ¼äΪ×ÜÍ»·¢Êý¾Ý³¤¶È£¬Õâ¸úÎÒ¿´µÄ¸ßÔƵĵÄIPʹÓÃÊÖ²áÉϵÄÓû§¶ÁдʱÐòͼ²¢²»Ò»Ö ¸ßÔÆÓû§ÊֲᲨÐÎÈçÏ£ºÏÔÈ»²¢²»Ò»Ö£¬²¢ÇÒÏà²îÃ÷ÏÔ         IPºËµÄ²ÎÊýÎÒÉèÖÃÈçÏ£º sdram_clk  /  sdrc_clk =100MHz, CAS  = 4'd2T_WR = 4'd2 T_MRD= 4'd2 T_RP = 4'd1 T_RCD= 4'd1 T_RC = 4'd4 DATA_WIDTH = 16ROW_WIDTH = 13, COL_WIDTH = 8, BANK_WIDTH = 2, ÏÖÔÚÖ÷Òª»³ÒÉSDRMоƬ»µÁË¡£¡£¡£¡££¨ÒòΪÎÒȷʵÄԳ飬°ÑËü·´²å¹ý£©£¬»òÕß¹Ù·½µÄSDRAMµÄIPºËû·¨Çý¶¯ÐͺÅΪW9825G6KH-6µÄSDRAMоƬ£¬»òÕ߸ßÔƹٷ½µÄ²Î¿¼Àý³ÌЧ¹û±¾ÈçÎÒÏÂÔغóץȡµÄÄÇÑù£¬Ã»·¨¶ÁдÁ¬ÐøÊý¾Ý£¬ÄÇÓÖ¸ÃÈçºÎ¸Ä£¿ÎÒ³¢ÊÔÁ˸ÄÁ˼¸´Î¶¼Ã»°ì·¨¡£   ÏëÇóÖúÓÐûÓÐÅóÓÑÊÖÀïÒ²ÓÐÕâ¸ö¿ª·¢°åºÍSDRAMÀ©Õ¹°åµÄ£¿ÓÃÈí¼þץȡÊý¾Ý¿´¿´ÊÇ·ñÓëÎÒÒ»Ö£¿    

  • 2024-01-29
  • ·¢±íÁËÖ÷ÌâÌû£º ¡¾¹ú²úTang Primer 25K²âÆÀ¡¿Ò»´Îʧ°ÜµÄ³¢ÊÔÖгöÏÖµÄÎÊÌâ-SD¿¨+SDRAMͨ¹ýHDMIÏÔʾ

    ×î½ü³õ²½¿´¶®ÁËnestang25kµÄÀý³Ì£¬ÒÀ¾ÉûÏÂÊÖ£¬¿´¼ûÀïÃæ³öÏÖÁËSD¿¨ºÍSDRAMµÄÄÚÈÝ£¬ÓÚÊÇÎÒ¾ÍÈ¥Ò°»ðµÄÀý³ÌÀïËѳöÀ´ÁËÒ»¸ö×î½Ó½üµÄÀý³ÌÏëÒÆÖ²¿´¿´£¬Çø±ðÔÚÓÚÒ°»ðʹÓõÄÊÇDDR3 SDRAM£¬µ«ÊÇtang25kʹÓõÄSDRAMÐͺÅòËÆÊÇDDR1 SDRAM£¬ÕâÀïûÓÐDDR3µÄ»°Ö»ÄܽøÐиü¸Ä£¬È»ºóÎÒ¾ÍÏëÆðÀ´ÁËtang25kµÄ»î¶¯Ò³½éÉÜÀïÓÐÌáµ½DDR3 emmmm,ÕæµÄÓÐDDR3Â𣿶øÇÒÒ²²¢Ã»Óвο¼Àý³Ì´æÔÚ£¬ÄѵÀSDRAMÄ£¿éÒ²¿ÉÒÔµ±×÷DDR3Ó㿸оõÉÏÊÇд´íÁË£¬»òÕßÐèÒª×ÔÐÐÉè¼ÆÒ»¸öDDR3Ä£¿é¡£   ÑÓÐøÉÏÃæµÄ˼·£¬Ã»ÓÐDDR3£¬¾ÍÓÃÆÕͨµÄSDRAMÓ¦¸ÃÒ²Ò»Ñù£¬ÕâÀÂÇʹÓÃnestang25kÀý³ÌÖиø³öµÄsdram¿ØÖÆÆ÷»òÕ߸ßÔÆÑÐÖƵÄsdramµÄip½øÐÐÌæ»»¡£ È»ºó¾ÍÊÇSD¿¨£¬nestang25kÀý³ÌÀïÓõ½µÄSD¿¨ÊÇSDIOģʽ£¬Ò°»ðµÄSD¿¨ÓõÄÊÇSPIģʽ£¬ÕâÀïÎÒÏëʹÓÃÒ°»ðµÄSPIģʽ£¬ÒòΪÈ˼ÒÀý³Ì¶¼ÊÇÉè¼ÆºÃµÄ£¬¾¡Á¿¼õÉÙ¸ü¸ÄÒ²Äܼòµ¥Ð©¡£ ¿ªÊ¼Ð´´úÂ룺 Åöµ½µÄµÚÒ»¸öÎÊÌâÊÇ °´¼üÎÊÌ⣬PLLµÄ¸´Î»°´¼üʱÁéʱ²»ÁéÈÃÎÒºÜÄÕ»ð£¬ÏëÑо¿Ò»Ïµ½µ×Ϊʲô£¬»¨ÁË°ëÌìʱ¼ä£¬ÎÒ·¢ÏÖÁËÎÊÌ⣬ÔÚÒý½Å°ó¶¨ÖУ¬Òª¸ù¾Ý°´¼üʵ¼ÊµÄÎïÀí½ÓÏß·½Ê½£¬¶ÔÒý½ÅÔ¼ÊøΪÉÏÀ­ÏÂÀ­£¬·ñÔò°´¼üʧÁ飨һֱºöÂÔÒý½ÅÔ¼ÊøÕâ¸öÎÊÌâÊÇÒòΪÎÒÒ»Ö±ÈÏΪֻҪÎïÀí½á¹¹ÉÏÉèÖÃÁËÉÏÀ­ÏÂÀ­¾Í²»ÓÃÒý½ÅÔ¼ÊøÁË£¬Êµ¼ÊÊÇ´íÎóµÄ£©¡£     ÒÔÏÂÊÇÎÒ²âÊÔ°´¼üµÄ´úÂ룺 module led_top( input CLK_0, input s1, input reset,//ϵͳ¸´Î»£¬¸ßµçƽÓÐЧ input button1, input button2, input button3, input button4, output IO_voltage, output led1, output led2, output led3, output led4, output led5, output led6, output led7 ); //parameter Clock_frequency = 50_000_000;// 50MHZ parameter count_value = 25_000_000;// count reg[31:0] count_value_reg; reg count_value_flag; wire CLK_1; always@(posedge CLK_1)begin if(count_value_reg <=count_value)begin count_value_reg <=count_value_reg+1'b1; count_value_flag<=1'b0; end else begin count_value_reg<=32'b0; count_value_flag <=1'b1;//convert end end reg IO_voltage_reg=1'b0; always@(posedge CLK_1)begin if(count_value_flag) IO_voltage_reg<=~IO_voltage_reg; else IO_voltage_reg<=IO_voltage_reg; end assign IO_voltage = IO_voltage_reg; wire lock_o; board_input board_input_u1( .rst(s1), .clk(CLK_1), .p8_i(button1), .to_o({led6,led5}) ); wire CLK_25M; wire CLK_8M388; assign led7=button2;//²»°´µÄʱºòΪ1£¬°´ÏÂȥΪ0£¬ÒòΪledÄ£¿éÉè¼ÆÔ­Òò£¬led=1£¬Êä³öΪ0£¬ledΪ0£¬Êä³öΪ1 Gowin_PLL your_instance_name( .lock(lock_o), //output lock, .clkout0(CLK_1), //output clkout0£¬50MHz,ÏàÆ«180 .clkout1(CLK_25M), //output clkout1£¬25MHZ .clkin(CLK_0), //input clkin£¬50MHz .clkout2(CLK_8M388), //output clkout2 // .reset(1'b0) //input reset,ûÓнøÈ븴λ״̬£¬ÓÐÊä³ö£» // .reset(1'b1) //input reset,ûÓнøÈ븴λ״̬£¬Ã»Êä³ö£» .reset(reset) //input reset,ûÓнøÈ븴λ״̬£¬³õʼȡ·´Îª1£¬°´Ç°Á½Ðеóö½áÂÛÓ¦¸ÃûÓÐÊä³ö£¬Êµ¼ÊÉÏÈ´ÓÐÊä³ö ); endmodule module board_input( rst,//¸´Î» clk,//µÚ°Ë¸ö°´¼ü£¬ÓÃÀ´ÖÆ×÷Ñ¡Ôñ¸ßÖÐµÍ p8_i, to_o//Êä³öµÚ°ËλµÄÊý¾Ý ); // parameter s1=2'b01,//1 s2=2'b10,//2 s3=2'b11;//3 //input rst; input rst; input clk; input p8_i; output reg [1:0] to_o; always@(posedge clk or posedge rst) begin if(rst)begin to_o<=s3; end else if(~p8_i) begin to_o<=s1; end else if(p8_i) begin to_o<=s2; end else; end endmodule ÒÔÏÂΪÒý½ÅÔ¼Êø£ºÒ»¶¨ÒªÉèÖÃÒý½ÅÉÏÀ­ÏÂÀ­ IO_LOC "led7" E11; IO_PORT "led7" PULL_MODE=NONE DRIVE=8 BANK_VCCIO=3.3; IO_LOC "led6" A10; IO_PORT "led6" PULL_MODE=NONE DRIVE=8 BANK_VCCIO=3.3; IO_LOC "led5" A11; IO_PORT "led5" PULL_MODE=NONE DRIVE=8 BANK_VCCIO=3.3; IO_LOC "led4" L11; IO_PORT "led4" PULL_MODE=NONE DRIVE=8 BANK_VCCIO=3.3; IO_LOC "led3" K11; IO_PORT "led3" PULL_MODE=NONE DRIVE=8 BANK_VCCIO=3.3; IO_LOC "led2" K5; IO_PORT "led2" PULL_MODE=NONE DRIVE=8 BANK_VCCIO=3.3; IO_LOC "led1" L5; IO_PORT "led1" PULL_MODE=NONE DRIVE=8 BANK_VCCIO=3.3; IO_LOC "IO_voltage" E10; IO_PORT "IO_voltage" PULL_MODE=DOWN DRIVE=8 BANK_VCCIO=3.3; IO_LOC "button4" G11; IO_PORT "button4" PULL_MODE=UP DRIVE=OFF BANK_VCCIO=3.3; IO_LOC "button3" D11; IO_PORT "button3" PULL_MODE=UP DRIVE=OFF BANK_VCCIO=3.3; IO_LOC "button2" B5510; IO_PORT "button2" PULL_MODE=UP DRIVE=OFF BANK_VCCIO=3.3; IO_LOC "button1" C10; IO_PORT "button1" PULL_MODE=UP DRIVE=OFF BANK_VCCIO=3.3; IO_LOC "reset" H10; IO_PORT "reset" PULL_MODE=DOWN DRIVE=OFF BANK_VCCIO=3.3; IO_LOC "CLK_0" E2; IO_PORT "CLK_0" PULL_MODE=UP DRIVE=OFF BANK_VCCIO=3.3; IO_LOC "s1" H11; IO_PORT "s1" PULL_MODE=DOWN DRIVE=OFF BANK_VCCIO=3.3; ·¢Ïֵĵڶþ¸öÎÊÌâ¾ÍÊÇ PMODÄ£¿éÖеÄLEDÄ£¿é£¬ÆðÒòÊÇÎÒÔÚµ÷ÊÔ°´¼üµÄʱºò£¬ledµÆµÄÁÁÃð×ÜÊǸúÎÒÏëµÄ·´×ÅÀ´£¬¸ãµÃÎÒºýÍ¿£¬²é¿´ÁËÒ»ÏÂÔ­Àíͼ£¬·¢ÏÖÔ­ÀíͼÖÐFPGAÒý½Å¶ÔÓ¦µÄÊÇLEDµÆµÄÒõ¼«£¬Ò²¾ÍÊÇLEDµÆÁÁµÄʱºò£¬FPGAÒý½ÅÊä³öµÍµçƽ£»ËùÒÔΪÁË·½±ã£¬ÎÒÍƼöÓà Óï¾ä LED=~FPGA_Pin;µÄ·½Ê½½øÐÐÊä³ö¡£   µÚÈý¸öÎÊÌâÒÀ¾ÉÊÇÔÚµ÷ÊÔ°´¼üµÄʱºò·¢Ïֵģ¬PMODÖеİ´¼üÄ£¿é£¬ÎÒÔÚ½øÐжÔÆäµÄÒý½Å°ó¶¨µÄʱºò£¬Ëƺõ×ÜÊÇ»á³ö´í£¬Ò»¿ªÊ¼ÎÒÒÔΪÊÇÒòΪ¹Ù·½»­°åµÄʱºò°ÑË¿Ó¡·Å´íÁË£¬ºóÀ´·¢ÏÖÊÇÎÒ¿´·´ÁË£¬ÔÚ¶ÔPMOD¶Ë¿ÚºÍPMODÄ£¿é½øÐа󶨵Äʱºò£¬Ó¦¸Ã°´ÈçϵÄÊӽǽøÐÐÆ¥Å䣺   SD¿¨¿ØÖÆÄ£¿éµÄʧЧ£ºÊ×ÏÈÌåÏÖÁËÔÚÁ˳õʼ»¯Ä£¿éµÄʱºò¾ÍÒѾ­Ê§Ð§ÁË£¬±íÏÖÔÚ³õʼ»¯ÐźÅûÓз´Ó¦£¬Å¼¶û³õʼ»¯Ä£¿éÓз´Ó¦ÁË£¬SD¿¨µÄ¶Áдģ¿éÒ²ÒÀ¾Éû·´Ó¦¡£ÅŲéÁËһϷ¢ÏÖ¾ÓÈ»¿¨ÔÚÁËÒ»¸öcnt¼ÆÊýµÄ¼Ä´æÆ÷alwaysÀ¿´Á˺ܾõÄÂß¼­Ò²Ã»ÕûÃ÷°×Ϊʲô»á¿¨ÔÚÄÇÀï¡£ żȻ·¢ÏÖ£¬µ±ÎÒ¶ÔSD¿¨¿ØÖÆÄ£¿éµÄ¸´Î»½Ó¿Ú½øÐкúÂÒ½Ó£¬»òÕßÔÚÂß¼­¿¨×¡µÄλÖõĴúÂë¶ÎÀï¼ÓÉÏÒ»¸ö¸ù±¾Ã»ÓÐÓô¦µÄ¼Ä´æÆ÷flag²¢¸³Öµ£¬È»ºóÍâ½Óµ½¶¥²ãÄ£¿é½Óµ½LEDÏÔʾ£¬¾Í»á³öÏÖSD¿¨µÄ³õʼ»¯Ä£¿éĪÃûÆäÃî¿ÉÒÔÔËÐÐÁË£¬µ±È»ÕûÌåÒÀ¾É²»ÐС£ÓÚÊÇÎÒ¿ªÊ¼»³ÒÉÆðÊDz»ÊÇÎÒµÄSPIÒý½ÅÔ¼ÊøÓÐÎÊÌ⣬һ¶Ù¸ÄÖ®ºóÒÀ¾ÉûÓнâ¾öÎÊÌâ¡£°´µÀÀíÀ´Ëµ£¬SD¿¨¿ØÖÆÄ£¿éÒѾ­ÊǾ­¹ý¶à´ÎÑéÖ¤¹ýµÄÄ£¿é²»»á³öÎÊÌ⣬½áºÏÎÒÉÏÃæ½²µ½µÄż¶û³õʼ»¯ÄªÃû³É¹¦µÄÏÖÏó£¬ÓпÉÄÜ25kÕâÖÖ°åÉϵÄSD¿¨PMODÄ£¿é²»Ö§³ÖSPIģʽ£¿»òÕßÊÇÔÚʹÓÃSPIģʽµÄʱºò£¬50MHzµÄʱÖÓ£¬Í¨µÀ´®ÈÅ»á¸ü¼ÓÑÏÖØ£¬PMODÄ£¿éÉè¼ÆÉÏÓÐÎÊÌ⣿ÁíÍ⣬¹Ù·½µÄSD¿¨Ä£¿éËƺõ²¢Ã»ÓÐÉè¼ÆÉÏÀ­µç×裬Õâ»á²»»áÓÐÎÊÌâÄØ£¿   ÒÔÏÂÊÇSD¿¨Ä£¿éÄ£¿é£¬¶Áдģ¿é£¬³õʼ»¯Ä£¿é´úÂ룬¿´²»³öʲôÎÊÌâ `timescale 1ns/1ns //////////////////////////////////////////////////////////////////////// // Author : EmbedFire //Create Date : 2019/09/03 // Module Name : sd_ctrl // Project Name : sd_vga_pic // Target Devices: Xilinx XC6SLX16 // Tool Versions : ISE 14.7 // Description : SD¿¨¿ØÖƶ¥²ãÄ£¿é // //////////////////////////////////////////////////////////////////////// module sd_ctrl ( input wire sys_clk , //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz input wire sys_clk_shift , //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz,ÏàλƫÒÆ90¶È input wire sys_rst_n , //ÊäÈ븴λÐźÅ,µÍµçƽÓÐЧ //SD¿¨½Ó¿Ú input wire sd_miso , //Ö÷ÊäÈë´ÓÊä³öÐźŠoutput wire sd_clk , //SD¿¨Ê±ÖÓÐźŠoutput reg sd_cs_n , //ƬѡÐźŠoutput reg sd_mosi , //Ö÷Êä³ö´ÓÊäÈëÐźŠ//дSD¿¨½Ó¿Ú input wire wr_en , //Êý¾ÝдʹÄÜÐźŠinput wire [31:0] wr_addr , //дÊý¾ÝÉÈÇøµØÖ· input wire [15:0] wr_data , //дÊý¾Ý output wire wr_busy , //д²Ù×÷æÐźŠoutput wire wr_req , //дÊý¾ÝÇëÇóÐźŠ//¶ÁSD¿¨½Ó¿Ú input wire rd_en , //Êý¾Ý¶ÁʹÄÜÐźŠinput wire [31:0] rd_addr , //¶ÁÊý¾ÝÉÈÇøµØÖ· output wire rd_busy , //¶Á²Ù×÷æÐźŠoutput wire rd_data_en , //¶ÁÊý¾Ý±êÖ¾ÐźŠoutput wire [15:0] rd_data , //¶ÁÊý¾Ý output wire init_end //SD¿¨³õʼ»¯Íê³ÉÐźŠ); //********************************************************************// //****************** Parameter and Internal Signal *******************// //********************************************************************// //wire define wire init_cs_n ; //³õʼ»¯½×¶ÎƬѡÐźŠwire init_mosi ; //³õʼ»¯½×¶ÎÖ÷Êä³ö´ÓÊäÈëÐźŠwire wr_cs_n ; //дÊý¾Ý½×¶ÎƬѡÐźŠwire wr_mosi ; //дÊý¾Ý½×¶ÎÖ÷Êä³ö´ÓÊäÈëÐźŠwire rd_cs_n ; //¶ÁÊý¾Ý½×¶ÎƬѡÐźŠwire rd_mosi ; //¶ÁÊý¾Ý½×¶ÎÖ÷Êä³ö´ÓÊäÈëÐźŠ//********************************************************************// //***************************** Main Code ****************************// //********************************************************************// //sd_clk:SD¿¨Ê±ÖÓÐźŠassign sd_clk = sys_clk_shift; //SD¿¨½Ó¿ÚÐźÅÑ¡Ôñ always@(*) if(init_end == 1'b0) begin sd_cs_n <= init_cs_n; sd_mosi <= init_mosi; end else if(wr_busy == 1'b1) begin sd_cs_n <= wr_cs_n; sd_mosi <= wr_mosi; end else if(rd_busy == 1'b1) begin sd_cs_n <= rd_cs_n; sd_mosi <= rd_mosi; end else begin sd_cs_n <= 1'b1; sd_mosi <= 1'b1; end //********************************************************************// //************************** Instantiation ***************************// //********************************************************************// //------------- sd_init_inst ------------- sd_init sd_init_inst ( .sys_clk (sys_clk ), //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz .sys_clk_shift (sys_clk_shift ), //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz,ÏàλƫÒÆ90¶È .sys_rst_n (sys_rst_n ), //ÊäÈ븴λÐźÅ,µÍµçƽÓÐЧ .miso (sd_miso ), //Ö÷ÊäÈë´ÓÊä³öÐźŠ.cs_n (init_cs_n ), //Êä³öƬѡÐźŠ.mosi (init_mosi ), //Ö÷Êä³ö´ÓÊäÈëÐźŠ.init_end (init_end ) //³õʼ»¯Íê³ÉÐźŠ); //------------- sd_write_inst ------------- sd_write sd_write_inst ( .sys_clk (sys_clk ), //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz .sys_clk_shift (sys_clk_shift ), //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz,ÏàλƫÒÆ90¶È .sys_rst_n (sys_rst_n ), //ÊäÈ븴λÐźÅ,µÍµçƽÓÐЧ .miso (sd_miso ), //Ö÷ÊäÈë´ÓÊä³öÐźŠ.wr_en (wr_en && init_end ), //Êý¾ÝдʹÄÜÐźŠ.wr_addr (wr_addr ), //дÊý¾ÝÉÈÇøµØÖ· .wr_data (wr_data ), //дÊý¾Ý .cs_n (wr_cs_n ), //Êä³öƬѡÐźŠ.mosi (wr_mosi ), //Ö÷Êä³ö´ÓÊäÈëÐźŠ.wr_busy (wr_busy ), //д²Ù×÷æÐźŠ.wr_req (wr_req ) //дÊý¾ÝÇëÇóÐźŠ); //------------- sd_read_inst ------------- sd_read sd_read_inst ( .sys_clk (sys_clk ), //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz .sys_clk_shift (sys_clk_shift ), //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz,ÏàλƫÒÆ90¶È .sys_rst_n (sys_rst_n ), //ÊäÈ븴λÐźÅ,µÍµçƽÓÐЧ .miso (sd_miso ), //Ö÷ÊäÈë´ÓÊä³öÐźŠ.rd_en (rd_en & init_end ), //Êý¾Ý¶ÁʹÄÜÐźŠ.rd_addr (rd_addr ), //¶ÁÊý¾ÝÉÈÇøµØÖ· .rd_busy (rd_busy ), //¶Á²Ù×÷æÐźŠ.rd_data_en (rd_data_en ), //¶ÁÊý¾Ý±êÖ¾ÐźŠ.rd_data (rd_data ), //¶ÁÊý¾Ý .cs_n (rd_cs_n ), //ƬѡÐźŠ.mosi (rd_mosi ) //Ö÷Êä³ö´ÓÊäÈëÐźŠ); endmodule module sd_init ( input wire sys_clk , //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz input wire sys_clk_shift , //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz,ÏàλƫÒÆ90¶È input wire sys_rst_n , //ÊäÈ븴λÐźÅ,µÍµçƽÓÐЧ input wire miso , //Ö÷ÊäÈë´ÓÊä³öÐźŠoutput reg cs_n , //Êä³öƬѡÐźŠoutput reg mosi , //Ö÷Êä³ö´ÓÊäÈëÐźŠoutput reg init_end //³õʼ»¯Íê³ÉÐźŠ); //********************************************************************// //****************** Parameter and Internal Signal *******************// //********************************************************************// //parameter define parameter CMD0 = {8'h40,8'h00,8'h00,8'h00,8'h00,8'h95}, //¸´Î»Ö¸Áî CMD8 = {8'h48,8'h00,8'h00,8'h01,8'haa,8'h87}, //²éѯµçѹָÁî CMD55 = {8'h77,8'h00,8'h00,8'h00,8'h00,8'hff}, //Ó¦ÓÃÖ¸Áî¸æÖªÖ¸Áî ACMD41 = {8'h69,8'h40,8'h00,8'h00,8'h00,8'hff}; //Ó¦ÓÃÖ¸Áî parameter CNT_WAIT_MAX = 8'd100; //Éϵçºóͬ²½¹ý³ÌµÈ´ýʱÖÓ¼ÆÊý×î´óÖµ parameter IDLE = 4'b0000, //³õʼ״̬ SEND_CMD0 = 4'b0001, //CMD0·¢ËÍ״̬ CMD0_ACK = 4'b0011, //CMD0ÏìӦ״̬ SEND_CMD8 = 4'b0010, //CMD8·¢ËÍ״̬ CMD8_ACK = 4'b0110, //CMD8ÏìӦ״̬ SEND_CMD55 = 4'b0111, //CMD55·¢ËÍ״̬ CMD55_ACK = 4'b0101, //CMD55ÏìӦ״̬ SEND_ACMD41 = 4'b0100, //ACMD41·¢ËÍ״̬ ACMD41_ACK = 4'b1100, //ACMD41ÏìӦ״̬ INIT_END = 4'b1101; //³õʼ»¯Íê³É״̬ //reg define reg [7:0] cnt_wait ; //Éϵçͬ²½Ê±ÖÓ¼ÆÊýÆ÷ reg [3:0] state ; //״̬»ú״̬ reg [7:0] cnt_cmd_bit ; //Ö¸Áî±ÈÌؼÆÊýÆ÷ reg miso_dly ; //Ö÷ÊäÈë´ÓÊä³öÐźŴòÒ»ÅÄ reg ack_en ; //ÏìӦʹÄÜÐźŠreg [39:0] ack_data ; //ÏìÓ¦Êý¾Ý reg [7:0] cnt_ack_bit ; //ÏìÓ¦Êý¾Ý×Ö½Ú¼ÆÊý //********************************************************************// //***************************** Main Code ****************************// //********************************************************************// //cnt_wait:Éϵçͬ²½Ê±ÖÓ¼ÆÊýÆ÷ always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cnt_wait <= 8'd0; else if(cnt_wait >= CNT_WAIT_MAX) cnt_wait <= CNT_WAIT_MAX; else cnt_wait <= cnt_wait + 1'b1; //state:״̬»ú״̬Ìøת always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) state <= IDLE; else case(state) IDLE: if(cnt_wait == CNT_WAIT_MAX) state <= SEND_CMD0; else state <= state; SEND_CMD0: if(cnt_cmd_bit == 8'd48) state <= CMD0_ACK; else state <= state; CMD0_ACK: if(cnt_ack_bit == 8'd48) if(ack_data[39:32] == 8'h01) state <= SEND_CMD8; else state <= SEND_CMD0; else state <= state; SEND_CMD8: if(cnt_cmd_bit == 8'd48) state <= CMD8_ACK; else state <= state; CMD8_ACK: if(cnt_ack_bit == 8'd48) if(ack_data[11:8] == 4'b0001) state <= SEND_CMD55; else state <= SEND_CMD8; else state <= state; SEND_CMD55: if(cnt_cmd_bit == 8'd48) state <= CMD55_ACK; else state <= state; CMD55_ACK: if(cnt_ack_bit == 8'd48) if(ack_data[39:32] == 8'h01) state <= SEND_ACMD41; else state <= SEND_CMD55; else state <= state; SEND_ACMD41: if(cnt_cmd_bit == 8'd48) state <= ACMD41_ACK; else state <= state; ACMD41_ACK: if(cnt_ack_bit == 8'd48) if(ack_data[39:32] == 8'h00) state <= INIT_END; else state <= SEND_CMD55; else state <= state; INIT_END: state <= state; default: state <= IDLE; endcase //cs_n,mosi,init_end,cnt_cmd_bit //ƬѡÐźÅ,Ö÷Êä³ö´ÓÊäÈëÐźÅ,³õʼ»¯½áÊøÐźÅ,Ö¸Áî±ÈÌؼÆÊýÆ÷ always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) begin cs_n <= 1'b1; mosi <= 1'b1; init_end <= 1'b0; cnt_cmd_bit <= 8'd0; end else case(state) IDLE: begin cs_n <= 1'b1; mosi <= 1'b1; init_end <= 1'b0; cnt_cmd_bit <= 8'd0; end SEND_CMD0: if(cnt_cmd_bit == 8'd48) cnt_cmd_bit <= 8'd0; else begin cs_n <= 1'b0; mosi <= CMD0[8'd47 - cnt_cmd_bit]; init_end <= 1'b0; cnt_cmd_bit <= cnt_cmd_bit + 8'd1; end CMD0_ACK: if(cnt_ack_bit == 8'd47) cs_n <= 1'b1; else cs_n <= 1'b0; SEND_CMD8: if(cnt_cmd_bit == 8'd48) cnt_cmd_bit <= 8'd0; else begin cs_n <= 1'b0; mosi <= CMD8[8'd47 - cnt_cmd_bit]; init_end <= 1'b0; cnt_cmd_bit <= cnt_cmd_bit + 8'd1; end CMD8_ACK: if(cnt_ack_bit == 8'd47) cs_n <= 1'b1; else cs_n <= 1'b0; SEND_CMD55: if(cnt_cmd_bit == 8'd48) cnt_cmd_bit <= 8'd0; else begin cs_n <= 1'b0; mosi <= CMD55[8'd47 - cnt_cmd_bit]; init_end <= 1'b0; cnt_cmd_bit <= cnt_cmd_bit + 8'd1; end CMD55_ACK: if(cnt_ack_bit == 8'd47) cs_n <= 1'b1; else cs_n <= 1'b0; SEND_ACMD41: if(cnt_cmd_bit == 8'd48) cnt_cmd_bit <= 8'd0; else begin cs_n <= 1'b0; mosi <= ACMD41[8'd47 - cnt_cmd_bit]; init_end <= 1'b0; cnt_cmd_bit <= cnt_cmd_bit + 8'd1; end ACMD41_ACK: if(cnt_ack_bit < 8'd47) cs_n <= 1'b0; else cs_n <= 1'b1; INIT_END: begin cs_n <= 1'b1; mosi <= 1'b1; init_end <= 1'b1; end default: begin cs_n <= 1'b1; mosi <= 1'b1; end endcase //miso_dly:Ö÷ÊäÈë´ÓÊä³öÐźŴòÒ»ÅÄ always@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) miso_dly <= 1'b0; else miso_dly <= miso; //ack_en:ÏìӦʹÄÜÐźŠalways@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) ack_en <= 1'b0; else if(cnt_ack_bit == 8'd47) ack_en <= 1'b0; else if((miso == 1'b0) && (miso_dly == 1'b1) && (cnt_ack_bit == 8'd0)) ack_en <= 1'b1; else ack_en <= ack_en; //ack_data:ÏìÓ¦Êý¾Ý //cnt_ack_bit:ÏìÓ¦Êý¾Ý×Ö½Ú¼ÆÊý always@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) begin ack_data <= 8'b0; cnt_ack_bit <= 8'd0; end else if(ack_en == 1'b1) begin cnt_ack_bit <= cnt_ack_bit + 8'd1; if(cnt_ack_bit < 8'd40) ack_data <= {ack_data[38:0],miso_dly}; else ack_data <= ack_data; end else cnt_ack_bit <= 8'd0; endmodule module sd_read ( input wire sys_clk , //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz input wire sys_clk_shift , //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz,ÏàλƫÒÆ90¶È input wire sys_rst_n , //ÊäÈ븴λÐźÅ,µÍµçƽÓÐЧ input wire miso , //Ö÷ÊäÈë´ÓÊä³öÐźŠinput wire rd_en , //Êý¾Ý¶ÁʹÄÜÐźŠinput wire [31:0] rd_addr , //¶ÁÊý¾ÝÉÈÇøµØÖ· output wire rd_busy , //¶Á²Ù×÷æÐźŠoutput reg rd_data_en , //¶ÁÊý¾Ý±êÖ¾ÐźŠoutput reg [15:0] rd_data , //¶ÁÊý¾Ý output reg cs_n , //ƬѡÐźŠoutput reg mosi //Ö÷Êä³ö´ÓÊäÈëÐźŠ); //********************************************************************// //****************** Parameter and Internal Signal *******************// //********************************************************************// //parameter define parameter IDLE = 3'b000 , //³õʼ״̬ SEND_CMD17 = 3'b001 , //¶ÁÃüÁîCMD17·¢ËÍ״̬ CMD17_ACK = 3'b011 , //CMD17ÏìӦ״̬ RD_DATA = 3'b010 , //¶ÁÊý¾Ý״̬ RD_END = 3'b110 ; //¶Á½áÊø״̬ parameter DATA_NUM = 12'd256 ; //´ý¶ÁÈ¡Êý¾Ý×Ö½ÚÊý //wire define wire [47:0] cmd_rd ; //Êý¾Ý¶ÁÖ¸Áî //reg define reg [2:0] state ; //״̬»ú״̬ reg [7:0] cnt_cmd_bit ; //Ö¸Áî±ÈÌؼÆÊýÆ÷ reg ack_en ; //ÏìӦʹÄÜÐźŠreg [7:0] ack_data ; //ÏìÓ¦Êý¾Ý reg [7:0] cnt_ack_bit ; //ÏìÓ¦Êý¾Ý×Ö½Ú¼ÆÊý reg [11:0] cnt_data_num; //¶Á³öÊý¾Ý¸öÊý¼ÆÊý reg [3:0] cnt_data_bit; //¶ÁÊý¾Ý±ÈÌؼÆÊýÆ÷ reg [2:0] cnt_end ; //½áÊø״̬ʱÖÓ¼ÆÊý reg miso_dly ; //Ö÷ÊäÈë´ÓÊä³öÐźŴòÒ»ÅÄ reg [15:0] rd_data_reg ; //¶Á³öÊý¾Ý¼Ä´æ reg [15:0] byte_head ; //¶ÁÊý¾Ý×Ö½ÚÍ· reg byte_head_en; //¶ÁÊý¾Ý×Ö½ÚͷʹÄÜ //********************************************************************// //***************************** Main Code ****************************// //********************************************************************// //rd_busy:¶Á²Ù×÷æÐźŠassign rd_busy = (state != IDLE) ? 1'b1 : 1'b0; //cmd_rd:Êý¾Ý¶ÁÖ¸Áî assign cmd_rd = {8'h51,rd_addr,8'hff}; //miso_dly:Ö÷ÊäÈë´ÓÊä³öÐźŴòÒ»ÅÄ always@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) miso_dly <= 1'b0; else miso_dly <= miso; //ack_en:ÏìӦʹÄÜÐźŠalways@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) ack_en <= 1'b0; else if(cnt_ack_bit == 8'd15) ack_en <= 1'b0; else if((state == CMD17_ACK) && (miso == 1'b0) && (miso_dly == 1'b1) && (cnt_ack_bit == 8'd0)) ack_en <= 1'b1; else ack_en <= ack_en; //ack_data:ÏìÓ¦Êý¾Ý //cnt_ack_bit:ÏìÓ¦Êý¾Ý×Ö½Ú¼ÆÊý always@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) begin ack_data <= 8'b0; cnt_ack_bit <= 8'd0; end else if(ack_en == 1'b1) begin cnt_ack_bit <= cnt_ack_bit + 8'd1; if(cnt_ack_bit < 8'd8) ack_data <= {ack_data[6:0],miso_dly}; else ack_data <= ack_data; end else cnt_ack_bit <= 8'd0; //state:״̬»ú״̬Ìøת always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) state <= IDLE; else case(state) IDLE: if(rd_en == 1'b1) state <= SEND_CMD17; else state <= state; SEND_CMD17: if(cnt_cmd_bit == 8'd47) state <= CMD17_ACK; else state <= state; CMD17_ACK: if(cnt_ack_bit == 8'd15) if(ack_data == 8'h00) state <= RD_DATA; else state <= SEND_CMD17; else state <= state; RD_DATA: if((cnt_data_num == (DATA_NUM + 1'b1)) && (cnt_data_bit == 4'd15)) state <= RD_END; else state <= state; RD_END: if(cnt_end == 3'd7) state <= IDLE; else state <= state; default:state <= IDLE; endcase //cs_n:Êä³öƬѡÐźŠalways@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cs_n <= 1'b1; else if(cnt_end == 3'd7) cs_n <= 1'b1; else if(rd_en == 1'b1) cs_n <= 1'b0; else cs_n <= cs_n; //cnt_cmd_bit:Ö¸Áî±ÈÌؼÆÊýÆ÷ always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cnt_cmd_bit <= 8'd0; else if(state == SEND_CMD17) cnt_cmd_bit <= cnt_cmd_bit + 8'd1; else cnt_cmd_bit <= 8'd0; //mosi:Ö÷Êä³ö´ÓÊäÈëÐźŠalways@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) mosi <= 1'b1; else if(state == SEND_CMD17) mosi <= cmd_rd[8'd47 - cnt_cmd_bit]; else mosi <= 1'b1; //byte_head:¶ÁÊý¾Ý×Ö½ÚÍ· always@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) byte_head <= 16'b0; else if(byte_head_en == 1'b0) byte_head <= 16'b0; else if(byte_head_en == 1'b1) byte_head <= {byte_head[14:0],miso}; else byte_head <= byte_head; //byte_head_en:¶ÁÊý¾Ý×Ö½ÚͷʹÄÜ always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) byte_head_en <= 1'b0; else if(byte_head == 16'hfffe) byte_head_en <= 1'b0; else if((state == RD_DATA) && (cnt_data_num == 12'd0) && (cnt_data_bit == 4'd0)) byte_head_en <= 1'b1; else byte_head_en <= byte_head_en; //cnt_data_bit:¶ÁÊý¾Ý±ÈÌؼÆÊýÆ÷ always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cnt_data_bit <= 4'd0; else if((state == RD_DATA) && (cnt_data_num >= 12'd1)) cnt_data_bit <= cnt_data_bit + 4'd1; else cnt_data_bit <= 4'd0; //cnt_data_num:¶Á³öÊý¾Ý¸öÊý¼ÆÊý always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cnt_data_num <= 12'd0; else if(state == RD_DATA) if((cnt_data_bit == 4'd15) || (byte_head == 16'hfffe)) cnt_data_num <= cnt_data_num + 12'd1; else cnt_data_num <= cnt_data_num; else cnt_data_num <= 12'd0; //rd_data_reg:¶Á³öÊý¾Ý¼Ä´æ always@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) rd_data_reg <= 16'd0; else if((state == RD_DATA) && (cnt_data_num >= 12'd1) && (cnt_data_num <= DATA_NUM)) rd_data_reg <= {rd_data_reg[14:0],miso}; else rd_data_reg <= 16'd0; //rd_data_en:¶ÁÊý¾Ý±êÖ¾ÐźŠ//rd_data:¶ÁÊý¾Ý always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) begin rd_data_en <= 1'b0; rd_data <= 16'd0; end else if(state == RD_DATA) begin if((cnt_data_bit == 4'd15) && (cnt_data_num <= DATA_NUM)) begin rd_data_en <= 1'b1; rd_data <= rd_data_reg; end else begin rd_data_en <= 1'b0; rd_data <= rd_data; end end else begin rd_data_en <= 1'b0; rd_data <= 16'd0; end //cnt_end:½áÊø״̬ʱÖÓ¼ÆÊý always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cnt_end <= 3'd0; else if(state == RD_END) cnt_end <= cnt_end + 3'd1; else cnt_end <= 3'd0; endmodule module sd_write ( input wire sys_clk , //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz input wire sys_clk_shift , //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz,ÏàλƫÒÆ90¶È input wire sys_rst_n , //ÊäÈ븴λÐźÅ,µÍµçƽÓÐЧ input wire miso , //Ö÷ÊäÈë´ÓÊä³öÐźŠinput wire wr_en , //Êý¾ÝдʹÄÜÐźŠinput wire [31:0] wr_addr , //дÊý¾ÝÉÈÇøµØÖ· input wire [15:0] wr_data , //дÊý¾Ý output reg cs_n , //Êä³öƬѡÐźŠoutput reg mosi , //Ö÷Êä³ö´ÓÊäÈëÐźŠoutput wire wr_busy , //д²Ù×÷æÐźŠoutput wire wr_req //дÊý¾ÝÇëÇóÐźŠ); //********************************************************************// //****************** Parameter and Internal Signal *******************// //********************************************************************// //parameter define parameter IDLE = 3'b000 , //³õʼ״̬ SEND_CMD24 = 3'b001 , //дÃüÁîCMD24·¢ËÍ״̬ CMD24_ACK = 3'b011 , //CMD24ÏìӦ״̬ WR_DATA = 3'b010 , //дÊý¾Ý״̬ WR_BUSY = 3'b110 , //SD¿¨Ð´Ã¦×´Ì¬ WR_END = 3'b111 ; //д½áÊø״̬ parameter DATA_NUM = 12'd256 ; //´ýдÈëÊý¾Ý×Ö½ÚÊý parameter BYTE_HEAD = 16'hfffe; //дÊý¾Ý×Ö½ÚÍ· //wire define wire [47:0] cmd_wr ; //Êý¾ÝдָÁî //reg define reg [2:0] state ; //״̬»ú״̬ reg [7:0] cnt_cmd_bit ; //Ö¸Áî±ÈÌؼÆÊýÆ÷ reg ack_en ; //ÏìӦʹÄÜÐźŠreg [7:0] ack_data ; //ÏìÓ¦Êý¾Ý reg [7:0] cnt_ack_bit ; //ÏìÓ¦Êý¾Ý×Ö½Ú¼ÆÊý reg [11:0] cnt_data_num; //дÈëÊý¾Ý¸öÊý¼ÆÊý reg [3:0] cnt_data_bit; //дÊý¾Ý±ÈÌؼÆÊýÆ÷ reg [7:0] busy_data ; //æ״̬Êý¾Ý reg [2:0] cnt_end ; //½áÊø״̬ʱÖÓ¼ÆÊý reg miso_dly ; //Ö÷ÊäÈë´ÓÊä³öÐźŴòÒ»ÅÄ //********************************************************************// //***************************** Main Code ****************************// //********************************************************************// //wr_busy:д²Ù×÷æÐźŠassign wr_busy = (state != IDLE) ? 1'b1 : 1'b0; //wr_req:дÊý¾ÝÇëÇóÐźŠassign wr_req = ((cnt_data_num <= DATA_NUM - 1'b1) && (cnt_data_bit == 4'd15)) ? 1'b1 : 1'b0; //cmd_wr:Êý¾ÝдָÁî assign cmd_wr = {8'h58,wr_addr,8'hff}; //miso_dly:Ö÷ÊäÈë´ÓÊä³öÐźŴòÒ»ÅÄ always@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) miso_dly <= 1'b0; else miso_dly <= miso; //ack_en:ÏìӦʹÄÜÐźŠalways@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) ack_en <= 1'b0; else if(cnt_ack_bit == 8'd15) ack_en <= 1'b0; else if((state == CMD24_ACK) && (miso == 1'b0) && (miso_dly == 1'b1) && (cnt_ack_bit == 8'd0)) ack_en <= 1'b1; else ack_en <= ack_en; //ack_data:ÏìÓ¦Êý¾Ý //cnt_ack_bit:ÏìÓ¦Êý¾Ý×Ö½Ú¼ÆÊý always@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) begin ack_data <= 8'b0; cnt_ack_bit <= 8'd0; end else if(ack_en == 1'b1) begin cnt_ack_bit <= cnt_ack_bit + 8'd1; if(cnt_ack_bit < 8'd8) ack_data <= {ack_data[6:0],miso_dly}; else ack_data <= ack_data; end else cnt_ack_bit <= 8'd0; //busy_data:æ״̬Êý¾Ý always@(posedge sys_clk_shift or negedge sys_rst_n) if(sys_rst_n == 1'b0) busy_data <= 8'd0; else if(state == WR_BUSY) busy_data <= {busy_data[6:0],miso}; else busy_data <= 8'd0; //state:״̬»ú״̬Ìøת always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) state <= IDLE; else case(state) IDLE: if(wr_en == 1'b1) state <= SEND_CMD24; else state <= state; SEND_CMD24: if(cnt_cmd_bit == 8'd47) state <= CMD24_ACK; else state <= state; CMD24_ACK: if(cnt_ack_bit == 8'd15) if(ack_data == 8'h00) state <= WR_DATA; else state <= SEND_CMD24; else state <= state; WR_DATA: if((cnt_data_num == (DATA_NUM + 1'b1)) && (cnt_data_bit == 4'd15)) state <= WR_BUSY; else state <= state; WR_BUSY: if(busy_data == 8'hff) state <= WR_END; else state <= state; WR_END: if(cnt_end == 3'd7) state <= IDLE; else state <= state; default:state <= IDLE; endcase //cs_n:Êä³öƬѡÐźŠalways@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cs_n <= 1'b1; else if(cnt_end == 3'd7) cs_n <= 1'b1; else if(wr_en == 1'b1) cs_n <= 1'b0; else cs_n <= cs_n; //cnt_cmd_bit:Ö¸Áî±ÈÌؼÆÊýÆ÷ always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cnt_cmd_bit <= 8'd0; else if(state == SEND_CMD24) cnt_cmd_bit <= cnt_cmd_bit + 8'd1; else cnt_cmd_bit <= 8'd0; //mosi:Ö÷Êä³ö´ÓÊäÈëÐźŠalways@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) mosi <= 1'b1; else if(state == SEND_CMD24) mosi <= cmd_wr[8'd47 - cnt_cmd_bit]; else if(state == WR_DATA) if(cnt_data_num == 12'd0) mosi <= BYTE_HEAD[15 - cnt_data_bit]; else if((cnt_data_num >= 12'd1) && (cnt_data_num <= DATA_NUM)) mosi <= wr_data[15 - cnt_data_bit]; else mosi <= 1'b1; else mosi <= 1'b1; //cnt_data_bit:дÊý¾Ý±ÈÌؼÆÊýÆ÷ always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cnt_data_bit <= 4'd0; else if(state == WR_DATA) cnt_data_bit <= cnt_data_bit + 4'd1; else cnt_data_bit <= 4'd0; //cnt_data_num:дÈëÊý¾Ý¸öÊý¼ÆÊý always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cnt_data_num <= 12'd0; else if(state == WR_DATA) if(cnt_data_bit == 4'd15) cnt_data_num <= cnt_data_num + 12'd1; else cnt_data_num <= cnt_data_num; else cnt_data_num <= 12'd0; //cnt_end:½áÊø״̬ʱÖÓ¼ÆÊý always@(posedge sys_clk or negedge sys_rst_n) if(sys_rst_n == 1'b0) cnt_end <= 3'd0; else if(state == WR_END) cnt_end <= cnt_end + 3'd1; else cnt_end <= 3'd0; endmodule SDRAM¿ØÖÆÆ÷£ºÎÒʹÓÃÁ˹ٷ½µÄIP£¬µ«ÊÇÒÀ¾ÉÐèÒª¶ÔIPµÄÊäÈëÐźŵȽøÐд¦Àí£¬Õâ¾ÍÐèÒª¶îÍâÄ£¿éÁË£¬ÎÒÊÔ×Å°´¹Ù·½µÄ²Î¿¼Éè¼ÆдÁËһϣ¬¿É³ÜÆ˽ÖÁË ÕâÀïÌùһϹٷ½Àý³ÌÍøÖ·£ºGowin SDRAM Controller (gowinsemi.com.cn)£¬°üº¬ÁËÀý³ÌºÍÎĵµ£¬ÎĵµÀïÃæÓÐÒý½Å¶¨Ò壬ºÍÈçºÎ²Ù×÷µÄÏêϸ½âÊÍ£¨ÎÒÒ²ÊÇдµ½ÕâÀï²Å·¢Ïֵģ¬µÈ»á¼ÌÐø¿´¿´£©£¬ÎÒ²»Ã÷°×µÄÊÇÓû§ÐźÅÀïµÄsdrc_data_lenÊý¾Ý³¤¶ÈµÄº¬Ò壬ºÜÊÇÃÔ»ó£¬Êý¾Ý³¤¶ÈÊÇָдÈëµÄÊý¾ÝÁ¿»¹ÊÇдÈëµÄÊý¾ÝbitλÊý»¹ÊÇ10½øÖÆbitλÊý£¿ÒÔ¼°I_sdrc_addrµØÖ·ÏßµÄʹÓã¬ÎÒÃÇ´æ½øÒ»ÕÅ680*480µÄͼƬÊý¾Ý£¬ÈçºÎ¶ÔÕýÈ·ÕÒµ½µØÖ·£¿Ï£ÍûÎĵµºóÃæµÄÄÚÈÝÄܽâ´ðÒÉ»ó¡£ »¹ÓÐÒ»¸ö³õʼ»¯½Ì³ÌÉèÖãº2020-10-02_¸ßÔÆsdram-CSDN²©¿Í ÕâÀï¾Í²»ÌùÎÒдµÃÒ»ÛçмµÄ´úÂëÁË£¬ÓÐÔ´ÔÙÀ´¡£ ¹ØÓÚ¸ßÔƵÄFIFO  IPµÄÉèÖãºÈçÏÂÉèÖÃÁËÒ»¸ö¶Áд16λ¿í£¬256bitµÄfifo   ºóÃ滹»á¸üУ¬´òËã°ÑSD¿¨Ä£¿éºÍSDRAM·Ö±ðÑéÖ¤ÍêºóÔÙ×éºÏÒ»Æð¡£

  • 2024-01-27
  • »Ø¸´ÁËÖ÷ÌâÌû£º ¡¾Tang Primer25K Dock¡¿ËÄ¡ª¡ªÊýÂë¹ÜµÄ¶¯Ì¬ÏÔʾ²âÊÔ

    °´¼üÄ£¿éÄØ£¿Õâ¸ö°åµÄ°´¼üÄ£¿éÔõôʹÓð¡

  • 2024-01-24
  • »Ø¸´ÁËÖ÷ÌâÌû£º ¡¾Sipeed Tang Primer 25K¡¿Ì½Ë÷HDMIÏÔʾ

    À÷º¦

  • 2024-01-23
  • ·¢±íÁËÖ÷ÌâÌû£º ¡¾¹ú²úTang Primer 25K²âÆÀ¡¿¸ßÔÆDVI TX£¨VGAתHDMI£©ºÍROMµÄIPʹÓÃ×¢Òâµã

    ±¾Ìû×îºóÓÉ Ñ§Ñ§Ñ§Ñ§Ñ§Ñ§Ñ§ ÓÚ 2024-1-23 23:44 ±à¼­ ±¾´ÎÒÔÒ»¸öHDMI-ROMÏÔʾͼƬµÄÀý³ÌΪÀý×Ó£¬¼òµ¥¿´Ò»ÏÂÔÚTang-25K¿ª·¢°åÉÏÈçºÎÔÚ¸ßÔÆFPGA¿ª·¢Æ½Ì¨ÔËÐÐDVI TXºÍROMµÄIP£¬ÒÔ¼°ÎÒÅöµ½µÄһЩÎÊÌâ¡££¨Àý³Ì½è¼øÁËÒ°»ð¿ª·¢°åÀý³ÌÒÔ¼°ÎÒ×Ô¼ºÒÆÖ²½øÈ¥µÄһЩ´úÂ룩 Ê×ÏÈÊÇDVI TXÕâ¸öIPÀý»¯Åöµ½µÄÎÊÌ⣬ÎÒÊÇÔÚ±àÒëµÄʱºòÅöµ½µÄ ±¨´íÈçÏÂËùʾ£ºÒâ˼ÊÇ˵DVI TXÀý»¯Êä³öµÄtmds_clk_p¶Ë¿ÚÔÚÒý½ÅÔ¼ÊøÖеĵçƽÉèÖôíÎó¡£ ERROR  (CT1109) : "F:\GOWIN\Project\VGA_ROM\src\VGA_ROM.cst":11 | Illegal attribute type 'IO_TYPE = LVCMOS33D' specified on 'tmds_clk_p'   ½â¾ö°ì·¨£º°ÑIOµçƽÉèÖÃΪELVDS   µÚ¶þ¸öÊÇROMµÄIPµÄʹÓ㺠ÆäʵÎÒ±¾À´»¹ÏëʹÓÃоƬËù¼¯³ÉµÄRAM16SÕâ¸öIPµÄ£¬µ«ÊÇ×ÊÔ´²»¹»£¬Á½¸öRAMµÄIP¶¼²»ÄÜ´¢´æ³¬¹ý18KµÄͼƬÊý¾Ý£¬±¨´íÈçÏ   RAM×ÊÔ´²»¹»£¬ÄÇô¾ÍʹÓÃROMÕâ¸öIP£¬ÒÀ¾ÉÊÇ´ò¿ªIP¹ÜÀíÆ÷£¬ËÑË÷pROM£¬ÀýÈçͼƬËùʾÌîд·½Ê½£¬ÎÒ´æ´¢µÄͼƬÊý¾ÝµÄµØÖ·Ïßλ¿í(Éî¶È£©Îª14bit£¬ËùÒÔÒªÌî2µÄ14´Î·½£¬¼´16384£»Êä³öµÄÊý¾ÝÊÇ16λ¿í£¬Ö±½ÓÌî16¼´¿É¡£È»ºó½«ÓÉͼƬÉú³ÉµÄºó׺Ϊ ".mi"µÄROM³õʼ»¯Îļþ·¾¶Ìí¼Ó½øÈ¥¡£   Õë¶Ô¸ßÔƵÄROM³õʼ»¯ÒªÊ¹ÓõÄmiÎļþ£¬ÕâÀï¼òµ¥½²Ò»ÏÂÈçºÎͨ¹ýmatlab£¬½«bmpͼƬת³ÉmiÎļþ ÕâÀï³ÌÐòÖ÷Òª²Î¿¼ÁËÒ°»ðÉú³ÉcoeÎļþµÄ´úÂëºÍÒ»¸ö²©Ö÷Ëù·¢µÄÌû×Ó¸ø³öµÄ´úÂ루·¾¶£º¡¾FPGA¡¿ÈçºÎÉú³É.miÎļþ - ¸öÈËÎÄÕ - SegmentFault ˼·ñ£© ÎÒ×Ô¼º¼òµ¥¸Ä´úºóµÄmatlabÎļþ£ºÀïÃæmiÎļþºÍͼƬµÄ·¾¶Òª×¢Òâ¸ü¸Ä£¬ÒÔ¼°ËûÃǵÄÏñËØ£¬Éú³ÉmiÎļþµÄͼƬÏñËØÔÚÕâ¶Î´úÂëÀï±»ÉèÖþÖÏÞÔÚÁË100*100ÀҪעÒâÄãµÄͼƬ²»Äܳ¬¹ýÕâ¸öÏñËØ£¬·ñÔò±¨´í¡£ÁíÍâ¾ÍÊÇ£¬ÎÒÕâ¶Î´úÂëÉú³ÉµÄͼƬºó·Å½øFPGA´úÂë»áʧÕ棬»¹ÊÇÒªµ÷һϵģ¬²»¹»ÎұȽÏÀÁ¾Í¡£¡£¡£¡£ clear %ÇåÀíÃüÁîÐд°¿Ú clc %ÇåÀí¹¤×÷Çø % ʹÓÃimreadº¯Êý¶ÁȡͼƬ,²¢×ª»¯ÎªÈýά¾ØÕó %image_array = imread('logo.bmp'); image_array = imread('F:/GOWIN/TangPrimer-25K-example-main/ebf_xc6slx16_pro_tutorial_code-master/30_vga_rom_pic_jump/matlab/image2.bmp'); % ʹÓÃsizeº¯Êý¼ÆËãͼƬ¾ØÕóÈý¸öά¶ÈµÄ´óС % µÚһάΪͼƬµÄ¸ß¶È£¬µÚ¶þάΪͼƬµÄ¿í¶È£¬µÚÈýάΪͼƬά¶È [height,width,z]=size(image_array); % 100*100*3 red = image_array(:,:,1); % ÌáÈ¡ºìÉ«·ÖÁ¿£¬Êý¾ÝÀàÐÍΪuint8 green = image_array(:,:,2); % ÌáÈ¡ÂÌÉ«·ÖÁ¿£¬Êý¾ÝÀàÐÍΪuint8 blue = image_array(:,:,3); % ÌáÈ¡À¶É«·ÖÁ¿£¬Êý¾ÝÀàÐÍΪuint8 % ʹÓÃreshapeº¯Êý½«¸÷¸ö·ÖÁ¿ÖØ×é³ÉÒ»¸öһά¾ØÕó %ΪÁ˱ÜÃâÒç³ö,½«uint8ÀàÐ͵ÄÊý¾ÝÀ©´óΪuint32ÀàÐÍ r = uint32(reshape(red' , 1 ,height*width)); g = uint32(reshape(green' , 1 ,height*width)); b = uint32(reshape(blue' , 1 ,height*width)); % ³õʼ»¯ÒªÐ´Èë.COEÎļþÖеÄRGBÑÕÉ«¾ØÕó rgb=zeros(1,height*width); % µ¼ÈëµÄͼƬΪ24bitÕæ²ÊɫͼƬ,ÿ¸öÏñËØÕ¼ÓÃ24bit,RGB888 % ½«RGB888ת»»ÎªRGB565 % ºìÉ«·ÖÁ¿ÓÒÒÆ3λȡ³ö¸ß5λ,×óÒÆ11λ×÷ΪROMÖÐRGBÊý¾ÝµÄµÚ15bitµ½µÚ11bit % ÂÌÉ«·ÖÁ¿ÓÒÒÆ2λȡ³ö¸ß6λ,×óÒÆ5λ×÷ΪROMÖÐRGBÊý¾ÝµÄµÚ10bitµ½µÚ5bit % À¶É«·ÖÁ¿ÓÒÒÆ3λȡ³ö¸ß5λ,×óÒÆ0λ×÷ΪROMÖÐRGBÊý¾ÝµÄµÚ4bitµ½µÚ0bit for i = 1:height*width rgb(i) = bitshift(bitshift(r(i),-3),11)+ bitshift(bitshift(g(i),-2),5)+ bitshift(bitshift(b(i),-3),0); end %fid = fopen( 'image.mi', 'w+' ); fid = fopen( 'F:/GOWIN/TangPrimer-25K-example-main/ebf_xc6slx16_pro_tutorial_code-master/30_vga_rom_pic_jump/matlab/image.mi', 'w+' ); % .miÎļþ×Ö·û´®´òÓ¡ fprintf( fid, '#File_format=Hex\n'); fprintf( fid, '#Address_depth=16384\n'); fprintf( fid, '#Data_width=16\n'); % дÈëͼƬÊý¾Ý for i = 1:height*width if i == height*width fprintf(fid,'%04x\n',rgb(i)); %×îºóÒ»¸öÊý¾ÝºóÃæ¼Ó·ÖºÅ else if i<=5 fprintf(fid,'%04x\n',rgb(i)); else fprintf(fid,'%04x\n',rgb(i)); end end end fclose( fid ); % ¹Ø±ÕÎļþÖ¸Õë Åöµ½µÄÎÊÌâ¾Íµ½´ËΪֹÁË£¬ÕâÀï½öÌùһ϶¥²ãÎļþºÍЧ¹û£¬»áÌùÉϸ½¼þ£¬ÐèÒªµÄ»°¿ÉÒÔÏÂÔØ£¬»òÕß˽ÐÅÎÒ£¿   `timescale 1ns/1ns //////////////////////////////////////////////////////////////////////// // ³õʼÀý³ÌÀ´Ô´: Ò°»ð_̤ÀËPro_FPGA¿ª·¢°å // ÂÛ̳ : http://www.firebbs.cn //////////////////////////////////////////////////////////////////////// module vga_rom_pic_jump ( input wire sys_clk , //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ50MHz input wire sys_rst_n , //ÊäÈ븴λÐźÅ,µÍµçƽÓÐЧ // output wire hsync , //Êä³öÐÐͬ²½ÐźŠ// output wire vsync , //Êä³ö³¡Í¬²½ÐźŠ// output wire [15:0] rgb //Êä³öÏñËØÐÅÏ¢ //hdmi½Ó¿Ú output tmds_clk_p, // TMDS ʱÖÓͨµÀ output tmds_clk_n, output [2:0] tmds_d_p, // TMDS Êý¾ÝͨµÀ output [2:0] tmds_d_n ); //********************************************************************// //****************** Parameter and Internal Signal *******************// //********************************************************************// wire hsync ; //Êä³öÐÐͬ²½ÐźŠwire vsync ; //Êä³ö³¡Í¬²½ÐźŠwire [15:0] rgb ; //Êä³öÏñËØÐÅÏ¢ //wire define wire vga_clk ; //VGA¹¤×÷ʱÖÓ,ƵÂÊ25MHz wire locked ; //PLL lockedÐźŠwire rst_n ; //VGAÄ£¿é¸´Î»ÐźŠwire [9:0] pix_x ; //VGAÓÐЧÏÔʾÇøÓòXÖá×ø±ê wire [9:0] pix_y ; //VGAÓÐЧÏÔʾÇøÓòYÖá×ø±ê wire [15:0] pix_data; //VGAÏñËصãÉ«²ÊÐÅÏ¢ //rst_n:VGAÄ£¿é¸´Î»ÐźŠassign rst_n = (sys_rst_n & locked); //********************************************************************// //*************************** Instantiation **************************// //********************************************************************// Gowin_PLL clk_gen_u0( .lock (locked ), //output lock .clkout0(vga_clk ), //output clkout0 .clkin (sys_clk ), //input clkin .reset (~sys_rst_n ) //input reset ); wire vga_en; vga vga_u1( .clk (vga_clk ), .rst_n (rst_n ), .pixel_data (pix_data ), .data_req (), .posx (pix_x), .posy (pix_y), .hsync (hsync), .vsync (vsync), .vga_en (vga_en), .vga_out (rgb), .h_disp (), //HDMIÆÁˮƽ·Ö±æÂÊ .v_disp () //HDMIÆÁ´¹Ö±·Ö±æÂÊ ); wire [7:0] r_out ; //Êä³ö24λÕæÖµÐźŠwire [7:0] g_out ; wire [7:0] b_out ; assign r_out={rgb[15:11],3'b000}; assign g_out={rgb[10:5],2'b00}; assign b_out={rgb[4:0],3'b000}; //Àý»¯HDMIÇý¶¯Ä£¿é DVI_TX_Top HDMI_u2( .I_rst_n(rst_n), //input I_rst_n .I_rgb_clk(vga_clk), //input I_rgb_clk .I_rgb_vs(vsync), //input I_rgb_vs .I_rgb_hs(hsync), //input I_rgb_hs .I_rgb_de(vga_en), //input I_rgb_de .I_rgb_r(r_out), //input [7:0] I_rgb_r .I_rgb_g(g_out), //input [7:0] I_rgb_g .I_rgb_b(b_out), //input [7:0] I_rgb_b .O_tmds_clk_p(tmds_clk_p), //output O_tmds_clk_p .O_tmds_clk_n(tmds_clk_n), //output O_tmds_clk_n .O_tmds_data_p(tmds_d_p), //output [2:0] O_tmds_data_p .O_tmds_data_n(tmds_d_n) //output [2:0] O_tmds_data_n ); //------------- vga_pic_inst ------------- vga_pic vga_pic_inst( .vga_clk (vga_clk ), //ÊäÈ빤×÷ʱÖÓ,ƵÂÊ25MHz,1bit .sys_rst_n (rst_n ), //ÊäÈ븴λÐźÅ,µÍµçƽÓÐЧ,1bit .pix_x (pix_x ), //ÊäÈëVGAÓÐЧÏÔʾÇøÓòÏñËصãXÖá×ø±ê,10bit .pix_y (pix_y ), //ÊäÈëVGAÓÐЧÏÔʾÇøÓòÏñËصãYÖá×ø±ê,10bit .pix_data_out (pix_data ) //Êä³öÏñËصãÉ«²ÊÐÅÏ¢,16bit ); endmodule  

  • »Ø¸´ÁËÖ÷ÌâÌû£º ¡¾¹ú²úTang Primer 25K²âÆÀ¡¿¹ØÓÚ×î½üʹÓøßÔÆƽ̨µÄһЩÎÊÌâ

    littleshrimp ·¢±íÓÚ 2024-1-22 22:24 Ìáʾʲô´íÎó£¿Ð½¨Ò»¸öй¤³ÌÊÔÊÔ¡£ ÎÒ´ò¿ªIP¹ÜÀíÆ÷ËÑË÷PLLÊÇÕâÑùµÄÇé¿ö£¬rPLLÄǸöÑ¡ÏîÊÇ»ÒÉ«µÄ£¬²»±¨´í£¬µ«Ã»°ì·¨Í¨¹ýÕâÀï½øÐÐÉú³É  

  • 2024-01-22
  • »Ø¸´ÁËÖ÷ÌâÌû£º ¡¾¹ú²úTang Primer 25K²âÆÀ¡¿¹ØÓÚ×î½üʹÓøßÔÆƽ̨µÄһЩÎÊÌâ

    littleshrimp ·¢±íÓÚ 2024-1-22 20:50 rpllÊÇÓ²¼þÖ§³Ö ¿Ï¶¨¶¼ÓР¶àÉÙµÄÎÊÌâ 25K×î¶àÖ§³Ö6¸öPLL ÎÒÒâ˼ÊǸù±¾Ã»°ì·¨Àý»¯rPLL

ͳ¼ÆÐÅÏ¢

ÒÑÓÐ93ÈËÀ´·Ã¹ý

  • о»ý·Ö£º123
  • ºÃÓÑ£º--
  • Ö÷Ì⣺24
  • »Ø¸´£º35

ÁôÑÔ

ÄãÐèÒªµÇ¼ºó²Å¿ÉÒÔÁôÑÔ µÇ¼ | ×¢²á


ÏÖÔÚ»¹Ã»ÓÐÁôÑÔ