# [Libre-soc-bugs] [Bug 656] add v3.0B BCD instructions to simulator

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Sat Jul 31 18:53:42 BST 2021

```https://bugs.libre-soc.org/show_bug.cgi?id=656

--- Comment #17 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
Spec Appendix B p 787 states:

which supports the representation of decimal integers
of arbitrary length. Translation operates on three
Binary Coded Decimal (BCD) digits at a time com-
pressing the 12 bits into 10 bits with an algorithm that
can be applied or reversed using simple Boolean oper-
ations. In the following examples, a 3-digit BCD num-
ber is represented as (abcd)(efgh)(ijkm), a 10-bit DPD
number is represented as (pqr)(stu)(v)(wxy), and the
Boolean operations, & (AND), | (OR), and Â¬ (NOT) are
used.

therefore, in the "Translation" boolean stuff, let us assume that
the input (val) is 12 bits:

def BCD_TO_DPD(val):
# first digit, let us assume (guess) that the digits are in
# left-is-Most-significant, right-is-least-significant order
# i.e it is:
#      ....represented as (abcd)(efgh)(ijkm)
#                         Top   Middle Least significant digit
# therefore:

# top BCD digit
a = val # MSB0 order
b = val ...
c = val
d = val
...
# least-significant BCD digit
i = val
j = val
k = val
l = val

and that likewise p q r .... are similarly ordered such that
* p is MSB0-ordered bit zero (0)
* q is MSB0-ordered bit one
* ...
* y is MSB0-ordered bit nine (9)

that should be sufficient to complete the function *WHICH MUST BE IN
PSEUDOCODE NOT CONVERTED TO PYTHON*.

repeat: the PSEUDOCODE from section B.1 shall be placed into a
markdown file.

NOT, repeat, NOT: "take the pseudocode and waste time converting it
by hand to a python function".

--
You are receiving this mail because:
You are on the CC list for the bug.
```