Class: Circuits::Component::D
Overview
Positive edge triggered D-type flip flop
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ D
constructor
A new instance of D.
-
#tick ⇒ Object
Computes the outputs based on the inputs and previous state.
Methods inherited from Base
Constructor Details
#initialize ⇒ D
Returns a new instance of D.
8 9 10 11 12 13 14 15 16 |
# File 'lib/circuits/component/d.rb', line 8 def initialize super(port_mappings: { d: { type: :input, number: 0 }, clk: { type: :input, number: 1 }, q: { type: :output, number: 0 }, not_q: { type: :output, number: 1 } }) create_sub_components link_sub_components reset end |
Instance Method Details
#tick ⇒ Object
Computes the outputs based on the inputs and previous state
19 20 21 22 23 24 |
# File 'lib/circuits/component/d.rb', line 19 def tick 3.times.each do sub_components.each(&:tick) sub_components.each(&:tock) end end |