473,698 Members | 2,181 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2025
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
9104
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 distutils.core import setup import py2exe
9
2619
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 picture of a number of windows desktops connected to a database server. each desktop can potentially be used by a number of users and requires one device cal. All well and good.
0
1597
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 October 2005, Estrel Hotel & Convention Center Berlin, Germany). http://idugeurope.blogspot.com
1
2967
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 event? What about using a buffer device context to draw to, then BitBlt ing that to the screen? Thanks Ben
9
37192
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 Win32_DiskDrive, but it doesn't seem to return any information on cdrom devices. I suspect there might be a Win32 API call, but I haven't found any info yet using Google. Is there a way to achieve this in C#?
1
19349
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 computer. When it's plugged in (Firewire), it shows up in Device Manager under the "Imaging Devices" catagory. When it's not plugged in, it doesn't show up. When it's plugged in, there is a registry key that says ReferenceCount = 1, and when...
0
1231
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 scratch either as an individual or in a team. Entries must be developed in Python, during the challenge, and must incorporate some theme chosen at the start of the challenge. REGISTRATION IS NOW OPEN --
78
4591
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 excludes '*a*b*' and '*c*d*a*'. See below for details. CHALLENGE: generate an equivalent in ruby, lisp, haskell, ocaml, or in a CAS like maple or mathematica. #------------------------------------------------------------------------------- # Short...
33
3268
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 full 10 minutes every time a "register" declared variable is read from or written to. Besides this lag, everything else runs as expected. Then my compiler is still C compliant, aye? If so, then it is unwise for any programmer to ever use the...
0
8671
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8856
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.