Understanding and new language feature proposal

Sumit Adhikari sumit.adhikari at gmail.com
Sun Jan 5 21:41:34 PST 2014


The birth and evolution of d language is to provide a modern and
better alternative to C++! If I look at C++ then C++ is a systems
programming language. The use cases of C++ is OS and embedded
systems writing.  Why? C++ claims to extract last drop out of HW. 
If I
look correctly rarely C++ is used and C is the commonly used 
language.
The abstraction provided by C++ is often ignored as useful 
feature. D
being a systems programming language competes and the use area is 
in
embedded systems and indirectly competes plain C.

What is more challenging in embedded systems? It is low level 
detail!
And the programmer is so much overwhelmed with it and spends so 
much
time to do it correctly that she/he cannot afford to look at 
abstract
feature of the language. Let me elaborate the problem! Let us 
consider
two unsigned 3 bit addition (C++ syntax):

unsigned char a ;
unsigned char b ;

unsigned char result = a + b ;
               result = result & 7 ;


Consider we need to add two 179 bits wide numbers. How will be the
effort. But how about if there is a way like as follows available:


unsigned bits(179:0) a ;
unsigned bits(179:0) b ;
unsigned bits(179:0) result = a + b ;

Looks familiar? remember verilog ?

Where is the use case ? DSP, Protocol stack and driver writing. 
In DSP
most unusual bit widths are used. In protocol stack very often
calculation are with unusual bitwidth (crc, parity, status, ....).
Consider following case when you want to do some operations by
checking 5th and 6th bit of a register.


unsigned bits(7:0) m_reg ;
unsigned bits(7:0) sts_reg ;

if(m_reg(6:5) == 2) sts_reg(2) = false ;

How convenient is this ?

Want to create a signed 3-bit adder ?


bits(2:0) a ;
bits(2:0) b ;
bits(2:0) y = a * b ;

The use cases are lot. Ask me who is a VLSI SoC architect.

Therefore I would like to propose inclusion of arbitrary bit-width
(native to D) data-type in D language for providing a better way 
to deal
signal processing, protocol stack, driver writing and lot more.

I completely understand these kind of libraries exists and they 
are
JUST LIBRARIES.

Regards, Sumit







More information about the Digitalmars-d mailing list