|
Example:
And circuit with array notation: Switch aa sw[0] '0' ZERO; Switch ba sw[1] '1' ONE; Switch ca sw[2] '1' ONE; And bb sw[0] sw[1] s[2] out; Probe bc out; |
|
|
|
|
Example: the FourBit_Adder user-defined component
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; |
Just imagine how clumsy the macro will become you had to write an adder circuit for a 32 bit number:
Define Adder32 b31 b30 b29 b28 b27 b26 b25 b24 b23 b22 b21 b20 b19 b18 b17 b16 b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 a31 a30 a29 a28 a27 a26 a25 a24 a23 a22 a21 a20 a19 a18 a17 a16 a15 a14 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 | s31 s30 s29 s28 s27 s26 s25 s24 s23 s22 s21 s20 s19 s18 s17 s16 s15 s14 s13 s12 s11 s10 s9 s8 s7 s6 s5 s4 s3 s2 s1 s0; ... Endef; |
Solution:
|
|
/home/cs355001/bin/cs355sim /home/cs355001/demo/circuits/4-bit-adder.arr |
|
Example: this format is illegal:
Define FourBit_Adder a[3] a[2] a[1] a[0] b[3] b[2] b[1] b[0] | CarryOut s[3] s[2] s[1] s[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; |