We must first import our Chisel dependencies:
import $file.^.source.load_ivy
Similarly we can define a sub
method that will be added
Adding the methods to our skeleton module:
implicit def call will add the methods of the RHS classes to the implicit def parameter:ALUSkeleton class.Note the name
includeAdd
does not matter as it won't be called again, but is good practice to give it a clear name of what it is doing (i.e includAdd <=> include the Add class' methods)
Summary
While this includes a few more steps than simply implementing everything directly into an Operator module, it can actually save some headaches when building much larger moudules. The best case for developing this way is if you're defining a specific arithmetic implmentation, which this example was meant to outline. For example a multiplier may require many sub methods to implement, and these implementation details can be hidden from the module using it. Also working like this puts you in the mindset of pulling out independent pieces of logic to write functions for that can later be reused in other modules.
class LotsOfApply(a: Int) {}
object LotsOfApply {
def apply: LotsOfApply = new LotsOfApply(1)
def apply(a: Int): LotsOfApply = new LotsOfApply(a)
}