From: Luke Kenneth Casson Leighton Date: Sat, 28 Mar 2020 19:28:03 +0000 (+0000) Subject: add fixed arithmetic isa X-Git-Tag: convert-csv-opcode-to-binary~3037 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8f6d9969d599027c8f8c96fce54000e423b4a9c4;p=libreriscv.git add fixed arithmetic isa --- diff --git a/openpower/isa/fixedarith.mdwn b/openpower/isa/fixedarith.mdwn new file mode 100644 index 000000000..a1c87093d --- /dev/null +++ b/openpower/isa/fixedarith.mdwn @@ -0,0 +1,426 @@ +# Add Immediate + +Add Immediate Shifted + +addi RT,RA,SI + + if RA = 0 then RT <- EXTS(SI) + else RT <- (RA) + EXTS(SI) + +addis RT,RA,SI + + if RA = 0 then RT <- EXTS(SI || 160) + else RT <- (RA) + EXTS(SI || [0]*16) + +# Add PC Immediate Shifted + +addpcis RT,D + + D <- d0||d1||d2 + RT <- NIA + EXTS(D || [0]*16) + + +# Add + +add RT,RA,RB (OE=0 Rc=0) + +add. RT,RA,RB (OE=0 Rc=1) + +addo RT,RA,RB (OE=1 Rc=0) + +addo. RT,RA,RB (OE=1 Rc=1) + + RT <- (RA) + (RB) + +# Subtract From + + +subf RT,RA,RB (OE=0 Rc=0) + +subf. RT,RA,RB (OE=0 Rc=1) + +subfo RT,RA,RB (OE=1 Rc=0) + +subfo. RT,RA,RB (OE=1 Rc=1) + + RT <- ¬(RA) + (RB) + 1 + +# Add Immediate Carrying + +addic RT,RA,SI + + RT <- (RA) + EXTS(SI) + +# Add Immediate Carrying and Record + +addic. RT,RA,SI + + RT <- (RA) + EXTS(SI) + +# Subtract From Immediate Carrying + +subfic RT,RA,SI + + RT <- ¬(RA) + EXTS(SI) + 1 + +# Add Carrying + +addc RT,RA,RB (OE=0 Rc=0) + +addc. RT,RA,RB (OE=0 Rc=1) + +addco RT,RA,RB (OE=1 Rc=0) + +addco. RT,RA,RB (OE=1 Rc=1) + + RT <- (RA) + (RB) + +# Subtract From Carrying + +subfc RT,RA,RB (OE=0 Rc=0) + +subfc. RT,RA,RB (OE=0 Rc=1) + +subfco RT,RA,RB (OE=1 Rc=0) + +subfco. RT,RA,RB (OE=1 Rc=1) + + RT <- ¬(RA) + (RB) + 1 + +# Add Extended + +adde RT,RA,RB (OE=0 Rc=0) + +adde. RT,RA,RB (OE=0 Rc=1) + +addeo RT,RA,RB (OE=1 Rc=0) + +addeo. RT,RA,RB (OE=1 Rc=1) + + RT <- (RA) + (RB) + CA + +# Subtract From Extended + +subfe RT,RA,RB (OE=0 Rc=0) + +subfe. RT,RA,RB (OE=0 Rc=1) + +subfeo RT,RA,RB (OE=1 Rc=0) + +subfeo. RT,RA,RB (OE=1 Rc=1) + + RT <- ¬(RA) + (RB) + CA + +#Add to Minus One Extended + +# Subtract From Minus One Extended + +addme RT,RA (OE=0 Rc=0) + +addme. RT,RA (OE=0 Rc=1) + +addmeo RT,RA (OE=1 Rc=0) + +addmeo. RT,RA (OE=1 Rc=1) + + RT <- (RA) + CA - 1 + +subfme RT,RA (OE=0 Rc=0) + +subfme. RT,RA (OE=0 Rc=1) + +subfmeo RT,RA (OE=1 Rc=0) + +subfmeo. RT,RA (OE=1 Rc=1) + + RT <- ¬(RA) + CA - 1 + +# Add Extended using alternate carry bit + +addex RT,RA,RB,CY + + if CY=0 then RT <- (RA) + (RB) + OV + +# Subtract From Zero Extended XO-form + +subfze RT,RA (OE=0 Rc=0) + +subfze. RT,RA (OE=0 Rc=1) + +subfzeo RT,RA (OE=1 Rc=0) + +subfzeo. RT,RA (OE=1 Rc=1) + + RT <- ¬(RA) + CA + +# Add to Zero Extended + +addze RT,RA (OE=0 Rc=0) +addze. RT,RA (OE=0 Rc=1) +addzeo RT,RA (OE=1 Rc=0) +addzeo. RT,RA (OE=1 Rc=1) + + RT <- (RA) + CA + +# Negate + +neg RT,RA (OE=0 Rc=0) +neg. RT,RA (OE=0 Rc=1) +nego RT,RA (OE=1 Rc=0) +nego. RT,RA (OE=1 Rc=1) + +RT <- ¬(RA) + 1 + +# Multiply Low Immediate + +mulli RT,RA,SI + + prod[0:127] <- (RA) * EXTS(SI) + RT <- prod[64:127] + +# Multiply High Word + +mulhw RT,RA,RB (Rc=0) + +mulhw. RT,RA,RB (Rc=1) + + prod[0:63] <- (RA)[32:63] * (RB)[32:63] + RT[32:63] <- prod[0:31] + RT[0:31] <- undefined + +# Multiply Low Word + +mullw RT,RA,RB (OE=0 Rc=0) + +mullw. RT,RA,RB (OE=0 Rc=1) + +mullwo RT,RA,RB (OE=1 Rc=0) + +mullwo. RT,RA,RB (OE=1 Rc=1) + + RT <- (RA)[32:63] * (RB)[32:63] + +# Multiply High Word Unsigned + +mulhwu RT,RA,RB (Rc=0) + +mulhwu. RT,RA,RB (Rc=1) + + prod[0:63] <- (RA)[32:63] * (RB)[32:63] + RT[32:63] <- prod[0:31] + RT[0:31] <- undefined + +# Divide Word + +divw RT,RA,RB (OE=0 Rc=0) + +divw. RT,RA,RB (OE=0 Rc=1) + +divwo RT,RA,RB (OE=1 Rc=0) + +divwo. RT,RA,RB (OE=1 Rc=1) + + dividend[0:31] <- (RA)[32:63] + divisor[0:31] <- (RB) [32:63] + RT[32:63] <- dividend / divisor + RT[0:31] <- undefined + +# Divide Word Unsigned + + +divwu RT,RA,RB (OE=0 Rc=0) + +divwu. RT,RA,RB (OE=0 Rc=1) + +divwuo RT,RA,RB (OE=1 Rc=0) + +divwuo. RT,RA,RB (OE=1 Rc=1) + + dividend[0:31] <- (RA)[32:63] + divisor[0:31] <- (RB)[32:63] + RT[32:63] <- dividend / divisor + RT[0:31] <- undefined + +# Divide Word Extended + +divwe RT,RA,RB (OE=0 Rc=0) + +divwe. RT,RA,RB (OE=0 Rc=1) + +divweo RT,RA,RB (OE=1 Rc=0) + +divweo. RT,RA,RB (OE=1 Rc=1) + + dividend[0:63] <- (RA)[32:63] || [0]*32 + divisor[0:31] <- (RB)[32:63] + RT[32:63] <- dividend / divisor + RT[0:31] <- undefined + +# Divide Word Extended Unsigned + +divweu RT,RA,RB (OE=0 Rc=0) + +divweu. RT,RA,RB (OE=0 Rc=1) + +divweuo RT,RA,RB (OE=1 Rc=0) + +divweuo. RT,RA,RB (OE=1 Rc=1) + + dividend[0:63] <- (RA)[32:63] || [0]*32 + divisor[0:31] <- (RB)[32:63] + RT[32:63] <- dividend / divisor + RT[0:31] <- undefined + +# Modulo Signed Word X-form + +modsw RT,RA,RB + + dividend[0:31] <- (RA)[32:63] + divisor [0:31] <- (RB)[32:63]- + RT[32:63] <- dividend % divisor + RT[0:31 ] <- undefined + +# Modulo Unsigned Word X-form + +moduw RT,RA,RB + + dividend[0:31] <- (RA) [32:63] + divisor [0:31] <- (RB) [32:63] + RT[32:63] <- dividend % divisor + RT[0:31 ] <- undefined + + +# Deliver A Random Number + +darn RT,L + + RT <- random(L) + +# Multiply Low Doubleword + +mulld RT,RA,RB (OE=0 Rc=0) + +mulld. RT,RA,RB (OE=0 Rc=1) + +mulldo RT,RA,RB (OE=1 Rc=0) + +mulldo. RT,RA,RB (OE=1 Rc=1) + + prod[0:127] <- (RA) * (RB) + RT <- prod[64:127] + +# Multiply High Doubleword + +mulhd RT,RA,RB (Rc=0) + +mulhd. RT,RA,RB (Rc=1) + + prod[0:127] <- (RA) * (RB) + RT <- prod[0:63] + +# Multiply High Doubleword Unsigned + +mulhdu RT,RA,RB (Rc=0) + +mulhdu. RT,RA,RB (Rc=1) + + prod[0:127] <- (RA) * (RB) + RT <- prod[0:63] + +# Multiply-Add High Doubleword VA-form + +maddhd RT,RA.RB,RC + + prod[0:127] <- (RA) * (RB) + sum[0:127] <- prod + EXTS(RC) + RT <- sum[0:63] + +# Multiply-Add High Doubleword Unsigned + +maddhdu RT,RA.RB,RC + + prod[0:127] <- (RA) * (RB) + sum[0:127] <- prod + EXTZ(RC) + RT <- sum[0:63] + +# Multiply-Add Low Doubleword + +maddld RT,RA.RB,RC + + + prod[0:127] <- (RA) * (RB) + sum[0:127] <- prod + EXTS(RC) + RT <- sum[64:127] + +# Divide Doubleword + +divd RT,RA,RB (OE=0 Rc=0) + +divd. RT,RA,RB (OE=0 Rc=1) + +divdo RT,RA,RB (OE=1 Rc=0) + +divdo. RT,RA,RB (OE=1 Rc=1) + + dividend[0:63] <- (RA) + divisor[0:63] <- (RB) + RT <- dividend / divisor + +# Divide Doubleword Unsigned + +divdu RT,RA,RB (OE=0 Rc=0) + +divdu. RT,RA,RB (OE=0 Rc=1) + +divduo RT,RA,RB (OE=1 Rc=0) + +divduo. RT,RA,RB (OE=1 Rc=1) + + dividend[0:63] <- (RA) + divisor[0:63] <- (RB) + RT <- dividend / divisor + +# Divide Doubleword Extended + +divde RT,RA,RB (OE=0 Rc=0) + +divde. RT,RA,RB (OE=0 Rc=1) + +divdeo RT,RA,RB (OE=1 Rc=0) + +divdeo. RT,RA,RB (OE=1 Rc=1) + + dividend[0:127] <- (RA) || [0]*64 + divisor[0:63] <- (RB) + RT <- dividend / divisor + +# Divide Doubleword Extended Unsigned + +divdeu RT,RA,RB (OE=0 Rc=0) + +divdeu. RT,RA,RB (OE=0 Rc=1) + +divdeuo RT,RA,RB (OE=1 Rc=0) + +divdeuo. RT,RA,RB (OE=1 Rc=1) + + dividend[0:127] <- (RA) || [0]*64 + divisor[0:63] <- (RB) + RT <- dividend / divisor + +# Modulo Signed Doubleword X-form + +modsd RT,RA,RB + + dividend <- (RA) + divisor <- (RB) + RT <- dividend % divisor + +# Modulo Unsigned Doubleword X-form + +modud RT,RA,RB + + dividend <- (RA) + divisor <- (RB) + RT <- dividend % divisor +