2013年12月27日 星期五

BCD Adder at Behavioral level Modeling

BCD Adder  at Behavioral level Modeling



l1)把 BCD 碼的資料單純地用 2 進制相加, 並做適當的補正讓結果不至於跟 BCD 碼互相矛盾

l2)2進位的相加結果如果介於0~9之間, 就直接作為 BCD 相加結果。

l3)2進位的相加結果如果大於「10, 就把結果 +6 後作為 BCD 相加結果。
C=K+Z8Z4+Z8Z2


module bcdadder(out,in1,in2,cin);
 input [3:0]in1,in2;
 input cin;
 output [3:0]out;
 
 reg [3:0]out;
 integer cout,carry;
 always @ (in1 or in2)
 begin
   {cout,out}=in1+in2+cin;
   carry=(cout|(out[3] & out[2])|(out[3] & out[1]));
   if(carry==1'b1)
      out=out+4'b0110;
   else
     out=out+4'b0000;
 end
endmodule





沒有留言:

張貼留言

2024產專班 作業2

 2024產專班 作業2   1. 系統圖       ESP32+MFRC522 組成RFID Reader 可以將RFID卡片的UID 透過 MQTT協定    上傳(發行 主題 (:topic) alex9ufo/2024/RFID/RFID_UID  ,, Payload...