Skip to content

Commit

Permalink
Fix usage info
Browse files Browse the repository at this point in the history
  • Loading branch information
LeventErkok committed Feb 13, 2024
1 parent ff1b026 commit 0469220
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 30 deletions.
76 changes: 58 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,39 +80,79 @@ Satisfiable. Model:
Hex: 0xc
```

### Example: Decode two half-precision floats in two lanes
```
$ crackNum -l2 -fhp 32\'hfdc71fc6
== Lane 1 ============================================================
Satisfiable. Model:
DECODED = NaN :: FloatingPoint 5 11
1 0
5 43210 9876543210
S -E5-- ---S10----
Binary layout: 1 11111 0111000111
Hex layout: FDC7
Precision: Half (5 exponent bits, 10 significand bits.)
Sign: Negative
Exponent: 16 (Stored: 31, Bias: 15)
Classification: FP_NAN (Signaling)
Value: NaN
Note: Representation for NaN's is not unique
== Lane 0 ============================================================
Satisfiable. Model:
DECODED = 0.0075912 :: FloatingPoint 5 11
1 0
5 43210 9876543210
S -E5-- ---S10----
Binary layout: 0 00111 1111000110
Hex layout: 1FC6
Precision: Half (5 exponent bits, 10 significand bits.)
Sign: Positive
Exponent: -8 (Stored: 7, Bias: 15)
Classification: FP_NORMAL
Binary: 0b1.111100011p-8
Octal: 0o3.706p-9
Decimal: 0.0075912
Hex: 0x1.f18p-8
```

### Usage info
```
Usage: crackNum value OR binary/hex-pattern
-i N Signed integer of N-bits
-w N Unsigned integer of N-bits
-f fp Floating point format fp
-r rm Rounding mode to use. If not given, Nearest-ties-to-Even.
-h, -? --help print help, with examples
-v --version print version info
-i N Signed integer of N-bits
-w N Unsigned integer of N-bits
-f fp Floating point format fp
-r rm Rounding mode to use. If not given, Nearest-ties-to-Even.
-l lanes Number of lanes to decode
-h, -? --help print help, with examples
-v --version print version info
Examples:
Encoding:
crackNum -i4 -- -2 -- encode as 4-bit signed integer
crackNum -w4 2 -- encode as 4-bit unsigned integer
crackNum -f3+4 2.5 -- encode as float with 3 bits exponent, 4 bits significand
crackNum -f3+4 2.5 -rRTZ -- encode as above, but use RTZ rounding mode.
crackNum -fbp 2.5 -- encode as a brain-precision float
crackNum -fdp 2.5 -- encode as a double-precision float
crackNum -i4 -- -2 -- encode as 4-bit signed integer
crackNum -w4 2 -- encode as 4-bit unsigned integer
crackNum -f3+4 2.5 -- encode as float with 3 bits exponent, 4 bits significand
crackNum -f3+4 2.5 -rRTZ -- encode as above, but use RTZ rounding mode.
crackNum -fbp 2.5 -- encode as a brain-precision float
crackNum -fdp 2.5 -- encode as a double-precision float
Decoding:
crackNum -i4 0b0110 -- decode as 4-bit signed integer, from binary
crackNum -w4 0xE -- decode as 4-bit unsigned integer, from hex
crackNum -f3+4 0b0111001 -- decode as float with 3 bits exponent, 4 bits significand
crackNum -fbp 0x000F -- decode as a brain-precision float
crackNum -fdp 0x8000000000000000 -- decode as a double-precision float
crackNum -i4 0b0110 -- decode as 4-bit signed integer, from binary
crackNum -w4 0xE -- decode as 4-bit unsigned integer, from hex
crackNum -f3+4 0b0111001 -- decode as float with 3 bits exponent, 4 bits significand
crackNum -fbp 0x000F -- decode as a brain-precision float
crackNum -fdp 0x8000000000000000 -- decode as a double-precision float
crackNum -l4 -fhp 0x8000000000000000 -- decode as a double-precision float
crackNum -l4 -fhp 64'hbdffaaffdc71fc60 -- decode as half-precision floatm over 4 lanes
Notes:
- For encoding:
- Use -- to separate your argument if it's a negative number.
- For floats: You can pass in NaN, Inf, -0, -Inf etc as the argument, along with a decimal float.
- For decoding:
- Use hexadecimal (0x) or binary (0b) as input. Input must have one of these prefixes.
- Use hexadecimal (0x) binary (0b), or N'h (verilog) notation as input.
Input must have one of these prefixes.
- You can use _,- or space as a digit to improve readability for the pattern to be decoded
- With -lN parameter, you can decode multiple lanes of data.
```

VIM users: You can use the http://github.com/LeventErkok/crackNum/blob/master/crackNum.vim file to
Expand Down
28 changes: 16 additions & 12 deletions src/CrackNum/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -192,27 +192,31 @@ usage :: String -> IO ()
usage pn = putStr $ unlines [ helpStr pn
, "Examples:"
, " Encoding:"
, " " ++ pn ++ " -i4 -- -2 -- encode as 4-bit signed integer"
, " " ++ pn ++ " -w4 2 -- encode as 4-bit unsigned integer"
, " " ++ pn ++ " -f3+4 2.5 -- encode as float with 3 bits exponent, 4 bits significand"
, " " ++ pn ++ " -f3+4 2.5 -rRTZ -- encode as above, but use RTZ rounding mode."
, " " ++ pn ++ " -fbp 2.5 -- encode as a brain-precision float"
, " " ++ pn ++ " -fdp 2.5 -- encode as a double-precision float"
, " " ++ pn ++ " -i4 -- -2 -- encode as 4-bit signed integer"
, " " ++ pn ++ " -w4 2 -- encode as 4-bit unsigned integer"
, " " ++ pn ++ " -f3+4 2.5 -- encode as float with 3 bits exponent, 4 bits significand"
, " " ++ pn ++ " -f3+4 2.5 -rRTZ -- encode as above, but use RTZ rounding mode."
, " " ++ pn ++ " -fbp 2.5 -- encode as a brain-precision float"
, " " ++ pn ++ " -fdp 2.5 -- encode as a double-precision float"
, ""
, " Decoding:"
, " " ++ pn ++ " -i4 0b0110 -- decode as 4-bit signed integer, from binary"
, " " ++ pn ++ " -w4 0xE -- decode as 4-bit unsigned integer, from hex"
, " " ++ pn ++ " -f3+4 0b0111001 -- decode as float with 3 bits exponent, 4 bits significand"
, " " ++ pn ++ " -fbp 0x000F -- decode as a brain-precision float"
, " " ++ pn ++ " -fdp 0x8000000000000000 -- decode as a double-precision float"
, " " ++ pn ++ " -i4 0b0110 -- decode as 4-bit signed integer, from binary"
, " " ++ pn ++ " -w4 0xE -- decode as 4-bit unsigned integer, from hex"
, " " ++ pn ++ " -f3+4 0b0111001 -- decode as float with 3 bits exponent, 4 bits significand"
, " " ++ pn ++ " -fbp 0x000F -- decode as a brain-precision float"
, " " ++ pn ++ " -fdp 0x8000000000000000 -- decode as a double-precision float"
, " " ++ pn ++ " -l4 -fhp 0x8000000000000000 -- decode as a double-precision float"
, " " ++ pn ++ " -l4 -fhp 64'hbdffaaffdc71fc60 -- decode as half-precision floatm over 4 lanes"
, ""
, " Notes:"
, " - For encoding:"
, " - Use -- to separate your argument if it's a negative number."
, " - For floats: You can pass in NaN, Inf, -0, -Inf etc as the argument, along with a decimal float."
, " - For decoding:"
, " - Use hexadecimal (0x) or binary (0b) as input. Input must have one of these prefixes."
, " - Use hexadecimal (0x) binary (0b), or N'h (verilog) notation as input."
, " Input must have one of these prefixes."
, " - You can use _,- or space as a digit to improve readability for the pattern to be decoded"
, " - With -lN parameter, you can decode multiple lanes of data."
]

-- | Terminate early
Expand Down

0 comments on commit 0469220

Please sign in to comment.