Spin Operators * New/changed operator in P2 ** Behavioral change in P2 P2 P1 Description ----------------------------------------------------------------- ++ (pre) ++ Pre-increment -- (pre) -- Pre-decrement ?? (pre) ? ** XORO32, iterate and return pseudo-random ++ (post) ++ Post-increment -- (post) -- Post-decrement !! (post) Post-logical NOT ! (post) Post-bitwise NOT \ (post) Post-set ~ (post) ~ Post-set to 0 ~~ (post) !! Post-set to -1 ! ! Bitwise NOT, 1's complement - - Negation, 2's complement abs || * Absolute value encod >| ** Encode MSB, 31..0 decod |< * Decode, 1 << (x & $1F) bmask Bitmask, (2 << (x & $1F)) - 1 ones Count ones sqrt Square root of unsigned x qlog Unsigned to logarithm qexp Logarithm to unsigned >> >> Shift right, insert 0's << << Shift left, insert 0's sar ~> * Shift right, insert MSB's ror -> * Rotate right rol <- * Rotate left rev >< * Reverse y LSBs of x and zero-extend zerox Zero-extend above bit y signx ~, ~~ ** Sign-extend from bit y & & Bitwise AND ^ ^ Bitwise XOR | | Bitwise OR * * Signed multiply / / Signed divide, return quotient +/ Unsigned divide, return quotient // // Signed divide, return remainder +// Unsigned divide, return remainder sca Unsigned scale (x * y) >> 32 scas Signed scale (x * y) >> 30 frac Unsigned fraction {x, 32'b0} / y + + Add - - Subtract #> #> Ensure x => y, signed <# <# Ensure x <= y, signed addbits Make bitfield, (x & $1F) | (y & $1F) << 5 addpins Make pinfield, (x & $3F) | (y & $1F) << 6 < < Signed less than (returns 0 or -1) +< Unsigned less than (returns 0 or -1) <= =< * Signed less than or equal (returns 0 or -1) +<= Unsigned less than or equal (returns 0 or -1) == == Equal (returns 0 or -1) <> <> Not equal (returns 0 or -1) >= => * Signed greater than or equal (returns 0 or -1) +>= Unsigned greater than or equal (returns 0 or -1) > > Signed greater than (returns 0 or -1) +> Unsigned greater than (returns 0 or -1) <=> Signed comparison (<,=,> returns -1,0,1) !!, not not Logical NOT (x == 0, returns 0 or -1) &&, and and Logical AND (x <> 0 AND y <> 0, returns 0 or -1) ^^, xor xor Logical XOR (x <> 0 XOR y <> 0, returns 0 or -1) ||, or or Logical OR (x <> 0 OR y <> 0, returns 0 or -1) ? : If x <> 0 then choose y, else choose z := := * Set var(s) to x P2: v1,v2,... := x,y,... ' set v1 to x, v2 to y, etc. '_' = ignore Complex math functions --------------------------------------------------------------------------------------------------- var_x,var_y := rotxy(x,y,t) Rotate cartesian (x,y) by t and assign resultant (x,y) var_r,var_t := xypol(x,y) Convert cartesian (x,y) to polar and assign resultant (r,t) var_x,var_y := polxy(r,t) Convert polar (r,t) to cartesian and assign resultant (x,y)