I mentioned this briefly at the end of a previous post, but I thought I’d expand on it.
Signal objects can be assigned values. Those values can be of various different types like Bit or even just plain old Integers. In RHDL we’d like the assignment semantics to look a lot like using the built-in = operator (at least at first glance). However, Ruby’s = operator cannot be redefined (and that’s a good thing). So we need some other operator that can be used to indicate assignment of a value to a Signal object. Initially I was using <<, but the problem with that is that << has higher operator precedence than the bitwise logic operators (&,^,| ) which requires that all equations using them be wrapped in parens.
So, I’m moving to using the <= operator for assignement because it has lower operator precedence than the bitwise logic operators. But that solution still isn’t perfect as this is the less-than-equal operator which could cause a problem with mixing-in Comparable into Signal for example.
And if I want to test if the value of a Signal object is less-than-or-equal some other object, I’ll need to introduce another function for that (lte – and in order to by smmetrical I’ll need to also introduce gte ).
It would be nice if there were a special assignment operator set asside in Ruby for this very purpose. The := operator wouldn’t need to have any special meaning in Ruby other than as an operator that the programmer could define for these purposes. It would ideally have the same operator precedence as the = operator.