This posting examines how object-oriented typing of BitFields abstracts implementation details, and provides extensibility and simplicity. This is the second in a series of postings. The first posting provided background info on using object orientation for register specification and code generation.
With SpectaReg, one of the questions that always comes up is “how do I specify the type of register?”
How does one specify that a particular BitField is a read-only status bit, vs. a read-write flop-based control BitField vs. some other type? With the SpectaReg register generation tool…
A clarifying example:
To keep things simple, assume an SoC team only uses three types of BitFields in their register maps as defined by the following table. In reality there would be many more types.
|Type Name||Type Description|
|ExportedFlopBitField||A basic read/write control BitField. This is implemented with flip-flops and has an output wire/signal from the register module that goes into the application specific logic.|
|WatchedExportedFlopBitField||Same as the ExportedFlopBitField except this has an additional output wire/signal that goes into the application specific logic and pulses high when a write transaction is decoded.|
|ExtDrivenBitField||A basic read only status BitField. This is an input into the register module from the application specific logic.|
Now, in SpectaReg’s Specification Object Model (SOM) these types of BitFields would be mapped into the following class hierarchy, all inheriting from the BitField base class (i.e. the IP-XACT field element).
The WatchedExportedFlopBitField is a specialized type of ExportedFlopBitField, which is a type of ReadWriteBitField, which is a FlopBitField, which is a type of BitField. As is typical for object orientation, “is a” represents inheritance relationships.
Say the user wants to create a new WatchedExportedFlopBitField in an unused bit-space of an existing register. The user would create a new BitField and tag it with the specific WatchedExportedFlopBitField class using the GUI widget shown in the following screen shot.
At the code generation layer, such inheritance-based typing really simplifies things. For creating the synthesizable Verilog and VHDL RTL code, the generation layer needs to know specific class typing to create the implementation of the WatchedExportedFlopBitField. For the firmware and documentation generation, such detail is not required, so the code generation can work at a more abstract ReadWriteBitField classification level. This is the beauty of polymorphism — the code-generation templates that need specifics can get into the details whereas the ones that don’t can keep it simple. Keeping it abstract leads to more re-use and less complexity.
Of course, SpectaReg supports many different types/classes of BitFields other than those dicsussed here. What Register and BitField types do you use in your design?
A SpectaReg.com customer, generally happy with the user experience and beneficial value of the register-map tool, indicated that if we want to win more customers, we should think about improving the styling.
“It looks like an engineer styled it,” the customer said. “It needs more rounded corners.”
Being a practical engineer, all that really matters is functionality… right?
Well, not entirely. To get that first date, one needs a bit of style. Certainly, a company like Apple spends a good deal of time and money on style, and they get results. In the world of snowboarding, skateboarding, and surfboarding, style is paramount — executing the most difficult move doesn’t earn street credit without style.
“There were surfers with good style… and there were surfers that we would call cockroach style, or no style,” said Jim Muir in the legendary skateboard documentary Dogtown and Z-Boys. “If you had a bad style… right there you had one mark against you…”
Our user was telling us that we had one point against us, so a web style consultant was challenged to help improve SpectaReg’s style without requiring radical changes to the underlying code.
A little time and effort on style really made a big difference — we don’t want cockroach style and we’re improving on it more and more.