--- tags: Fundamentals of Logic Design --- # Introduction Number Systems and Conversion ## Digital Systems and Switching Circuits  類比:任何時間都有值 數位:不是任何時間都有值 (精確度, 可靠度比較高) :memo: 為什麼數位系統比較精確度及可靠: 類比系統是追求不要有任何誤差,可是之後又一些變因可能會造成相當大的誤差。數位系統是一開始給你一個誤差(是可決定的誤差),之後就不會超過這個一開始的誤差  在數位系統中, bit 越多就越精確  類比 -> (類比轉數位)-> (DSP 數位訊號處理) -> (數位轉類比)-> 類比  這堂課主要著重在 logic level gates = 邏輯閘  由高電位區分 0 跟 1。 如果 s 接回去 v0 就是 3V ON  combinational network 組合網路 sequential network 順序網絡 ## Conversion between Number Systems 10進位轉換至2進位 * 整數部分  * 小數點的部分   像是0.7就無法使用二進制無誤差的表現出來,會無限Loop。這裡較表現出來計算機因為表示方式而產生誤差 * 來個練習吧  除法<-小數點->乘法 * 快速法  8進制和2進制差3個位元,所以就是把三個當一個單位 110 -> $2^2 \times 1 + 2^1 \times 1 + 2^0 \times 0 = 6$。 2進制和16進制差4個位元 ## Binary Arithmetic   ## Negative Numbers 以下介紹三種表示負數的方法  * sign and magnitude (sign bit) + (positive magnitude) Hard to implement in hardware * 1's complement  * 2's complement (大家比較常用的一個方法) 做完 1's complement 後,再加一  2's complement 只有正零的原因,把超出四位元的數字捨棄掉,最後就等於正零的表示法 ## Addition in 2's complement **2's complement arithmetic 運算規則:Any carry from the sign position is ignored !!!** 請記住  0101 -> n=4 bit (四個位元) 四個位元的顯示範圍 $+2^{n-1}-1 \sim -2^{n-1}$  所以加法如果超過這個範圍,需要特別處理。超過+7這個四位元的系統是無法表現的。如圖所示,+11變成 1011 是負數的表示法(2's complement arithmetic),兩個正數相加變負數是錯誤的。這個就是所謂的 ==overflow== 。 :memo: 一正一負相加絕對不會 overflow,以下圖片可以說明   Any carry from the sign position is ignored 多出來的 1 可以直接拿掉 * Summary * (+) + (+) = (-) -> overflow * (-) + (-) = (+) -> overflow * (-) + (+) = (-) or (+) -> must be ok! * (+) + (-) = (-) or (+) -> must be ok! ## Addition in 1's complement 對 carry 的處理方式與 2's complement 不一樣,需要加回來  第二題:overflow  第四題:carry 需要加到最右邊的 bit。這種carry 稱為 end-around carry ## Binary Codes 為了 IO 方便使用者觀看,選擇浪費一點記憶體,四個位元為一組代表一個數字   gray code 的特性:相鄰的數只能有一個位元不一樣。(之後會用到) Excess-3 code 的特性:8-4-2-1 全部都加3 **Summary** 
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.