News

Component Polymoprhism

A polymorphic component is one that can manipulate different data types depending upon how it is instantiated in the system. It is a very powerful concept for modeling since many different designs often use similar components with differing data types. For example, processor microarchitectures use many components that consist of tables, queues, or queues that are also like tables. The differences in the functionality arises in how the structures handle timing, a bit of custom logic based on the data stored, and the actual data type of the values stored.

Polymorphism can be provided through different mechanisms. The most common method is via generics. In traditional programming languages, generic components can be instantiated with different data types facilitating reuse of the code in many different environments. In the same way, a hardware modeling system can benefit from polymorphic components.

Consider the common components across many designs. The obvious ones are queues and table like structures. It makes sense that there be a generic queue element that can be instantiated to store, for example, instructions or packets on an on-chip network. While this use of polymorphism seems limited, polymorphism along with Component Computation Customization work synergistically to provide a very powerful mode of reuse.

Although a generics mechanism on the components suffices to provide polymorphism, repeated specification of data types can be tedious and annoying, especially when the desired type is obvious. As a result, it disinclines creation of reusable modules. As a result, in addition to component polymorphism, a type inference mechanism to determine the types for a polymorphic component is recommended.

Synergies and Interactions

Polymorphism and Component Computation Customization (CCC) work synergistically to provide a powerful reuse mechanism. Polymorphism is used to construct a component instance with the correct data types. Then CCC can be used to "teach" that component how to use the new data types. For example, a table module can be made to behave like a multiprocessor cache array by instantiating the table module with a data type that has the bits for the state machine on each line. Then, the table can provide a mechanism to manipulate each cell based on some custom code. The means to specify this code is the CCC. Our experience with the Liberty Simulation Environment shows that this is a tremendous asset for rapid model construction and modular reuse.

Polymorphism can interact with the type system used for data abstraction if type inference is used or if user-defined subtype creation is permitted (e.g. via subclassing).