From 718bcb41e5d7617594bd130d2b7fd37e95f3ec62 Mon Sep 17 00:00:00 2001 From: Charlie Date: Wed, 18 Jul 2018 21:05:55 -0700 Subject: [PATCH] Adds for splitter --- lib/rcircuit.rb | 1 + lib/rcircuit/port.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) 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