Boost logo

Boost Users :

From: Perry Smith (pedz_at_[hidden])
Date: 2006-02-16 13:43:55


Before I jump off and re-invent the wheel -- is there a boost library
to help with manipulating hardware registers?

What I'm hoping to come up with (somehow) is something like:

class dev_registers {
   reg<uint32_t> reg0;
   bit<reg0, 0> b0;
   bit<reg0, 1> b1;

   reg<uint32_t> reg1;
   bit<reg1, 0> b3;
   bit<reg1, 1> b4;
};

(The 0 and 1 are bit offsets. Integer masks like 0x0010 would work
as well)

The result would be a private members of type uint32_t called reg0,
and reg1 (actually they can be called anything since they are
private). And a set of public methods to set, clear, and test the
bits. e.g.

dev_registers sample;

sample.b0.set();
sample.b3.clr();

It would be nice if the registers had a global clr like:

sample.reg0.clr();

There are lots of alternative approaches like:

sample.b0.assign(true); // set b0 to true (1)
int val = sample.b0(); // test value of b0

The goal has a lot of constraints. The registers would need to be
laid out properly without any extra overhead (assuming that I do not
bump into normal C padding problems). It would also be nice if
everything inline'd so the compiler could optimize things down to
simple bit operations.

Does boost have anything like that? I looked for "bit" and only
found references to bitset. I also looked for "hardware" and "flag"
and did not see anything.

Thanks,
Perry


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net