diff --git a/lib/rcircuit.rb b/lib/rcircuit.rb index f27078e..fa82642 100644 --- a/lib/rcircuit.rb +++ b/lib/rcircuit.rb @@ -7,3 +7,4 @@ require_relative "rcircuit/or.rb" require_relative "rcircuit/xor.rb" require_relative "rcircuit/adder.rb" require_relative "rcircuit/vcd.rb" +require_relative "rcircuit/splitter.rb" diff --git a/lib/rcircuit/port.rb b/lib/rcircuit/port.rb index 939b38c..91cd606 100644 --- a/lib/rcircuit/port.rb +++ b/lib/rcircuit/port.rb @@ -105,6 +105,17 @@ class Port def ! return NotGate.new(self).out end + + def [](*args) + if args.length == 1 + #single bit or range + bits = args[0] + else + #an array of bits, passed as multiple arguments + bits = args + end + return Splitter.new(self, bits).out + end protected