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





沒有留言:

張貼留言

  清除項目編譯快取 執行 flutter clean 重新取得套件依賴 執行 flutter pub get 完整重新編譯並執行 flutter run 1. 新增專案套件 (pubspec.yaml) 在 Flutter 專案根目錄下的 pubspec.yaml 中,新增 ...