From b3a13e5845b92ae9520b93113c4030114b2d6331 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Mon, 6 Jun 2022 13:27:42 -0700 Subject: Automatically define a method for ICs. --- library.rb | 4 ++-- test.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library.rb b/library.rb index bddcdea..71377dc 100644 --- a/library.rb +++ b/library.rb @@ -26,7 +26,7 @@ $ic = "TSSOP" def define_ic(name, value, pincount, *subparts, &automatic) parts = [] - proc do + define_singleton_method(name, lambda do if parts.size < 1 ic = comp("U", "#{$ic}-#{pincount}", name, value) automatic.call(ic) @@ -46,7 +46,7 @@ def define_ic(name, value, pincount, *subparts, &automatic) end end parts.shift - end + end) end def stock_ic(name, value, &automatic) diff --git a/test.rb b/test.rb index 269c9d0..d462053 100755 --- a/test.rb +++ b/test.rb @@ -7,13 +7,13 @@ nl = Lace::Netlist.new do vcc = net("vcc") gnd = net("gnd") - define_singleton_method(:inverter, stock_ic("inverter", "CD74HC04") do | ic | + stock_ic("inverter", "CD74HC04") do | ic | vcc - ic[14] - c("100nF") - ic[7] - gnd - end) + end - define_singleton_method(:nand, stock_ic("nand", "CD74HC00") do | ic | + stock_ic("nand", "CD74HC00") do | ic | vcc - ic[14] - c("100nF") - ic[7] - gnd - end) + end g = net("g") o = net("o") -- cgit v1.2.3