Skip to content

Commit

Permalink
Support strings (in quotes) as net names
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed Mar 14, 2018
1 parent 11e6c0c commit 8462ca7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/circuit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ to a named net. (Such named nets are created as needed.)
r = resistor(1000), [1] ⟷ src[+], [2] ⟷ gnd
end
```
If a net or pin specification is not just a single symbol or number, and has to
be put in quotes (e.g. `"in+"`, `"9V"`)
!!! note
Instead of `⟷` (`\\longleftrightarrow`), one can also use `==`.
"""
Expand Down Expand Up @@ -395,6 +399,9 @@ macro circuit(cdef)
return [QuoteNode(netname)]
end

extractpins(netname::String, default_element=nothing) =
extractpins(Symbol(netname), default_element)

if !isa(cdef, Expr) || cdef.head !== :block
error("@circuit must be followed by a begin/end block")
end
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ end
v_r = i*r
v_d = 25e-3 * log(i/is+1)
circ = @circuit begin
vsrc = voltagesource(v_r + v_d), [+] vcc,[-] gnd
vsrc = voltagesource(v_r + v_d), [+] "supply voltage",[-] gnd
r1 = resistor(r)
d = diode(is=is), [-] gnd, [+] r1[2]
vprobe = voltageprobe(), [-] gnd, [+] r1[2]
r1[1] vcc
r1[1] "supply voltage"
end
model = DiscreteModel(circ, 1)
y = run!(model, zeros(0, 1))
Expand Down

0 comments on commit 8462ca7

Please sign in to comment.