JuliaMath / JuliaMath/FixedPointNumbers.jl

[Suggestion] This package may be highly benefitted from SystemC fixed-point arithmetics

Open
#252 15 comments 0 reactions 0 assignees View on GitHub
add-on enhancement
Dominant language
Julia
Stars
95
Forks
38
Avg merge
13m
Merged PRs (30d)
2

Description

I've been using SystemC for modelling systems with fixed-point arithmetics for a while. It focuses on describing hardware systems with C++ language and it's been pretty mature, with an IEEE Standard (https://standards.ieee.org/standard/1666-2011.html)

Section 7.10 of the standard approaches fixed-point types and their characteristics. In general, a fixed-point number can be represented and used as:
```cpp
sc_fixed_fast<8, 1, SC_RND, SC_SAT> x = 0.5; //round and saturate
sc_fixed_fast<9, 2, SC_TRN, SC_WRAP> y = 0.5; //truncate and wraparound overflow
```
One of the useful applications of this type system is you can have 'wide' variables to do a series of calculations and store a given value, then create a <8, 1> type to round and saturate the input to your interface. The error from converting a wide type (for example, <32, 8> storing some multiplication) to a smaller type is expected and is part of the whole analysis for the system application.

Apparently, sc_fixed_fast types always store 32/64 bit numbers, but only operate on their given number of bits. They are fast because they don't try to store and odd number of bits (such as 9) in the memory, although they obviously use more memory than necessary.

A bunch of useful operations are defined, such as bitwise AND and OR and bitshift operators (<<, >>, <<<, >>>).

Although this type system from SystemC is pretty useful, I think Julia could offer a much wider world of opportunities.

If all this sounds reasonable, I'd be glad to help. If it's not the scope of the project, it's understandable.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.