Class: Dffpc
Overview
This class defines the D Flip-Flop 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) ⇒ Dffpc
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) ⇒ Dffpc
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.
6 7 8 9 10 11 12 13 |
# File 'lib/Dffpc.rb', line 6 def initialize(name) # TODO - make this cleaner, should either override the whole superclass or pass it the type of the node super(name,[0,1,2,3],[4,5],false) [4,5].each do |d| # define these nodes separately from super because they are of type reg nodes<<"#{name}p#{d}\tnode istype 'reg';\n" end 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.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/Dffpc.rb', line 17 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 @p4 = self.get_port("p4").connections.collect{|p| p.name}.to_s @p5 = self.get_port("p5").connections.collect{|p| p.name}.to_s @p4 = self.get_port("p4").connections.collect{|p| p.name}.to_s @p5 = self.get_port("p5").connections.collect{|p| p.name}.to_s s = "\n\"d-ff\n" unless @p4.empty? s << "#{self.name}p4.ap = !#{@p0};\n#{self.name}p4.ar = !#{@p3};\n#{self.name}p4.clk = #{@p1};\n" s << "#{self.name}p4 := #{@p2};\n\n" end unless @p5.empty? s << "#{self.name}p5.ap = !#{@p0};\n#{self.name}p5.ar = !#{@p3};\n#{self.name}p5.clk = #{@p1};\n" s << "#{self.name}p5 := !#{@p2};\n\n" end s end |