Class: Mux2
Overview
This class defines the 2-to-1 Multiplexer part
Instance Attribute Summary
Attributes inherited from Inst
#inputs, #name, #nodes, #outputs
Instance Method Summary collapse
-
#abelout ⇒ Object
This method defines the connections held by the ports of this object and returns the specific ABEL code to be output for this object based on the connections on its input ports.
-
#initialize(name) ⇒ Mux2
constructor
This method is called when a new object is instantiated, it takes the name of the Inst object (name) as its only argument.
Methods inherited from Inst
Constructor Details
#initialize(name) ⇒ Mux2
This method is called when a new object is instantiated, it takes the name of the Inst object (name) as its only argument. It is responsible for defining applicable nodes, then calling its superclass, Inst, to complete other tasks.
5 6 7 |
# File 'lib/Mux2.rb', line 5 def initialize(name) super(name,[0,1,2,3],[10]) end |
Instance Method Details
#abelout ⇒ Object
This method defines the connections held by the ports of this object and returns the specific ABEL code to be output for this object based on the connections on its input ports.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/Mux2.rb', line 11 def abelout # make these class variables just for consistency's sake @p0 = self.get_port("p0").connections.collect{|p| p.name}.to_s @p1 = self.get_port("p1").connections.collect{|p| p.name}.to_s @p2 = self.get_port("p2").connections.collect{|p| p.name}.to_s @p3 = self.get_port("p3").connections.collect{|p| p.name}.to_s s = "" s << "\n\"active low enabled MUX2\nWHEN (#{@p0} == 1) THEN\n\t#{self.name}p10 = 0;\n" s << "else WHEN (!#{@p0} & !#{@p1}) THEN\n\t#{self.name}p10 = #{@p2};\n" s << "else WHEN (!#{@p0} & #{@p1}) THEN\n\t#{self.name}p10 = #{@p3};\n" end |