|
Previously, you saw the 4-bit-adder circuit in EDiSim code using non-array signal notation:
Define FourBit_Adder a3 a2 a1 a0 b3 b2 b1 b0 | CarryOut s3 s2 s1 s0; Full_Adder ch ZERO a0 b0 | c1 s0; Full_Adder cf c1 a1 b1 | c2 s1; Full_Adder cd c2 a2 b2 | c3 s2; Full_Adder cb c3 a3 b3 | CarryOut s3; Endef; |
It is rather cumbersome to write a long series of digits
Using the array signal notation of EDiSim, the same circuit can be re-written as:
Define FourBit_Adder a[3..0] b[3..0] | CarryOut s[3..0]; Full_Adder ch ZERO a[0] b[0] | c1 s[0]; Full_Adder cf c1 a[1] b[1] | c2 s[1]; Full_Adder cd c2 a[2] b[2] | c3 s[2]; Full_Adder cb c3 a[3] b[3] | CarryOut s[3]; Endef; |
Note that we must change a0 ⇒ a[0], a1 ⇒ a[1], ... b0 ⇒ b[0], b1 ⇒ b[1],... s0 ⇒ s[0], s1 ⇒ s[1],... inside the body of the definition !!!
(Because: a0 ≠ a[0], a1 ≠ a[1], ... b0 ≠ b[0], b1 ≠ b[1],... s0 ≠ s[0], s1 ≠ s[1],... !!!)
DEMO: /home/cs355001/demo/circuits/4-bit-adder.arr