五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

【基于FPGA的圖像處理工程】邊緣檢測工程之Ascii轉(zhuǎn)十六進制模塊代碼解析

2023-08-14 09:36 作者:明德?lián)P易老師  | 我要投稿

【基于FPGA的圖像處理工程】

? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??—邊緣檢測工程:Ascii轉(zhuǎn)十六進制模塊代碼解析

本文為明德?lián)P原創(chuàng)文章,轉(zhuǎn)載請注明出處!

?Ascii轉(zhuǎn)十六進制模塊的功能:將ASCII所對應(yīng)的16進制數(shù),轉(zhuǎn)成實質(zhì)的16進制數(shù)。


?一、設(shè)計架構(gòu)


上圖是Ascii碼表對應(yīng)的數(shù)據(jù)。我們從圖中可以獲取到如下關(guān)鍵信息。

1.? ?? ??Ascii碼0~9對應(yīng)的十六進制數(shù)為8’h30~8’h39,也就是說收到ASCII碼的16進制數(shù)8’h30~8’h39時,就轉(zhuǎn)成0~9,也就是減去8’h30。

2.? ?? ?Ascii碼A~F對應(yīng)的十六進制數(shù)為8’h41~8’h46,也就是說收到ASCII碼的16進制數(shù)8’h41~8’h46時,就轉(zhuǎn)成A~F,也就是減去8’h37。

3.? ?? ?Ascii碼a~f對應(yīng)的十六進制數(shù)為8’h61~8’h66,也就是說收到ASCII碼的16進制數(shù)8’h61~8’h66時,就轉(zhuǎn)成a~f,也就是減去8’h57。


?本模塊的功能,是對ASCII碼的0~9,a~f,A~F進行轉(zhuǎn)換,其他數(shù)據(jù)不轉(zhuǎn)換,不在此范圍的,數(shù)據(jù)無效。例如:

? ?? ???當(dāng)din=8’h31(字符1),且din_vld = 1,則dout=4’h1,dout_vld=1;

? ?? ???當(dāng)din=8’h41(大寫字母A)時,且din_vld=1,則dout=4‘d10,dout_vld=1;

? ?? ???如果輸入的ASCII不在數(shù)字0~9,A~F,a~f的時候,dout_vld就輸出0。

? ?? ???當(dāng)din=8’h49(大寫字母I)時,且din_vld=1,則dout=0,dout_vld=0。



二、信號的意義



? 三、參考代碼

下面展出本模塊的設(shè)計,歡迎進一步交流,如果需要源代碼,歡迎與本人聯(lián)系。

  1. module acsii2hex(

  2. ? ? clk? ?? ?,

  3. ? ? rst_n? ? ,

  4. ? ? din? ?? ?,

  5. ? ? din_vld??,

  6. ? ?

  7. ? ? dout? ? ,

  8. ? ? dout_vld? ?

  9. ? ? );


  10. ? ? parameter? ?? ?DIN_W =? ?? ?? ?8;

  11. ? ? parameter? ?? ?DOUT_W =? ?? ???4;

  12. ? ?

  13. ? ? input? ?? ?? ?? ?? ?clk? ?? ?? ?;

  14. ? ? input? ?? ?? ?? ?? ?rst_n? ?? ? ;

  15. ? ? input [DIN_W-1:0]? ?din? ?? ?? ?;

  16. ? ? input? ?? ?? ?? ?? ?din_vld? ???;


  17. ? ? wire??[DIN_W-1:0]? ?din? ?? ?? ?;

  18. ? ? wire? ?? ?? ?? ?? ? din_vld? ???;


  19. ? ? output[DOUT_W-1:0]??dout? ?? ???;

  20. ? ? output? ?? ?? ?? ???dout_vld? ? ;


  21. ? ? reg? ?[DOUT_W-1:0]??dout? ?? ???;

  22. ? ? reg? ?? ?? ?? ?? ???dout_vld? ? ;


  23. ? ? always??@(posedge clk or negedge rst_n)begin

  24. ? ?? ???if(rst_n==1'b0)begin

  25. ? ?? ?? ?? ?dout_vld <= 0;

  26. ? ?? ???end

  27. ? ?? ???else if(din_vld&&((din>=8'd48&&din<8'd58)||(din>=8'd65&&din<8'd71)||(din>=8'd97&&din<8'd103)))begin

  28. ? ?? ?? ?? ?dout_vld <= 1;

  29. ? ?? ???end

  30. ? ?? ???else begin

  31. ? ?? ?? ?? ?dout_vld <= 0;

  32. ? ?? ???end

  33. ? ? end



  34. ? ? always@(posedge clk or negedge rst_n)begin

  35. ? ?? ???if(rst_n==1'b0)begin

  36. ? ?? ?? ?? ?dout <= 0;

  37. ? ?? ???end

  38. ? ?? ???else if(din>=8'd48&&din<8'd58) begin

  39. ? ?? ?? ?? ?dout <= din - 8'd48;

  40. ? ?? ???end

  41. ? ?? ???else if(din>=8'd65&&din<8'd71) begin

  42. ? ?? ?? ?? ?dout <= din - 8'd55;

  43. ? ?? ???end

  44. ? ?? ???else if(din>=8'd97&&din<8'd103) begin

  45. ? ?? ?? ?? ?dout <= din - 8'd87;

  46. ? ?? ???end

  47. ? ?? ???else begin

  48. ? ?? ?? ?? ?dout <= 0;

  49. ? ?? ???end? ?

  50. ? ? end


  51. ? ? endmodule


復(fù)制代碼


明德?lián)P專注FPGA研究,我司正在連載兩本書籍:《基于FPGA至簡設(shè)計法實現(xiàn)的圖像邊緣檢測系統(tǒng)》(http://www.fpgabbs.cn/forum.php?mod=viewthread&tid=691)、《ASIC和FPGA時序約束理論與應(yīng)用》(http://www.fpgabbs.cn/forum.php?mod=viewthread&tid=705),有興趣點擊觀看。


【基于FPGA的圖像處理工程】邊緣檢測工程之Ascii轉(zhuǎn)十六進制模塊代碼解析的評論 (共 條)

分享到微博請遵守國家法律
呈贡县| 北辰区| 郴州市| 朝阳区| 油尖旺区| 玉田县| 土默特左旗| 田东县| 河北省| 临猗县| 恭城| 仁寿县| 耒阳市| 樟树市| 宁夏| 东方市| 祁阳县| 深圳市| 新安县| 明溪县| 淮滨县| 洪洞县| 酒泉市| 株洲县| 桦川县| 土默特左旗| 嘉荫县| 岢岚县| 施秉县| 阿拉善盟| 苗栗县| 驻马店市| 京山县| 丰台区| 深泽县| 安国市| 桃江县| 刚察县| 长海县| 扶风县| 洮南市|