473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Challenge: Device Register Model in C++

Be a hero and show me a good model of a hardware device register :-O

This might seem like an absurd challenge; after all, the C++ language has
been around for donkeys years now. It's a mature language and we have
powerful design patterns to simplify complex problems. However, I've never
seen, and have never been able to produce, a satisfactory model of a
register! It's not that I'm thick nor inexperienced; I just expect a lot :-)

Traditionally, and still today, you'll see most device drivers using
#defines, enums, bit-fields, global constants, structs of integer types and
so on. The resultant code is inevitably difficult to follow or error prone
or
unsafe or volumous or endian-dependent... or, often, all of the above.
Surely, it must be possible to create a model of something as fundamental as
a device register that results in simple, safe, understandable and close to,
or identical to, the efficiency of these simple minded solutions...
shouldn't it?

Consider the CSR (configuration and status register) architecture, used in
numerous busses and bus devices that we all use daily (PCI, FireWire, SCI
etc.); it's all about
registers... lots and lots of registers; read-only registers, read-write
registers, registers that have one meaning if read and another meaning if
written to, registers with reserved bits, registers with read-only bits and
bit-fields etc. etc.

Most embedded compilers these days support all of the modern features of C++
(namespaces, templates...); the code generation is usually extremely good
too. Obviously, we would want to avoid features that have run-time overhead
and/or non-deterministic behaviour down at the device driver level, but the
tools I've seen and used all support leaving out these features. Some
compilers for embedded development support the very latest standards and
allow trick like template metaprogramming (in fact until Visual Studio.net,
many had better support for templates than Microsoft's desktop efforts).

So, we have the capability to use C++, templates and design patterns in
embedded/driver development; a register model would be a great starting
place to exploit these. Have you ever seen a satisfactory class for
modelling a device register?
Tim Clacy
Jul 19 '05 #1
1 2009
Tim Clacy wrote:
extremely good too. Obviously, we would want to avoid features that
have run-time overhead and/or non-deterministic behaviour down at the
device driver level, but the tools I've seen and used all support
leaving out these features.


Specifically, I had in mind RTTI and C++ exceptions
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Giles Brown | last post by:
I'm feeling quite dumb this morning. I'm trying to build a COM server DLL using py2exe and it ain't working. Here's what ain't working... setup_dll.py based on py2exe sample: """from...
9
by: Andy Fish | last post by:
Hi, I am slightly confused about the meaning of a 'device cal' (specifically for sql server but I guess the same applies to other ms licences) In the examples about device cals, there is a...
0
by: Marcel - IDUG Europe 2005 | last post by:
Hi DB2 users, ========================================================================================= We just created a blog dedicated to our upcoming IDUG 2005 Europe Conference (24-28...
1
by: Ben Taylor | last post by:
Hi Does anybody have any code examples of using C# to draw to a window using device contexts, more specifically, erasing the entire window by painting a background color in the OnPaint / OnDraw...
9
by: Paul Steele | last post by:
I am writing a C# app that needs to periodically poll for cdroms and usb storage device insertions. I've looked at the WMI functions but haven't found anything all that useful. The closest is...
1
by: hayworth | last post by:
Does anyone have any VB.Net code to get the devices listed / enumerated in the Device Manager listing. I'm trying to figure out if a device (it's actually a digital camera) is connected to the...
0
by: richard | last post by:
The date for the second PyWeek challenge has been set: Sunday 26th March to Sunday 2nd April (00:00UTC to 00:00UTC). The PyWeek challenge invites entrants to write a game in one week from...
78
by: wkehowski | last post by:
The python code below generates a cartesian product subject to any logical combination of wildcard exclusions. For example, suppose I want to generate a cartesian product S^n, n>=3, of that...
33
by: Snis Pilbor | last post by:
With the "as if" rule in play, doesn't that effectively render the "register" keyword completely useless? Example: I make a silly compiler which creates code that goes out of its way to take a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.