Advertisement
stighemmer

ALUx8

Apr 3rd, 2015
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. def mux21x
  2. port in i0
  3. port in i1
  4. port in s
  5. port in ns
  6. port out z
  7.  
  8. net nsi0
  9. net si1
  10.  
  11. inst n1 nand ns i0 nsi0
  12. inst n2 nand s i1 si1
  13. inst n3 nand nsi0 si1 z
  14. enddef
  15.  
  16. def mux41x
  17. port in i0
  18. port in i1
  19. port in i2
  20. port in i3
  21. port in s<1:0>
  22. port in ns1
  23. port in ns0
  24. port out z
  25.  
  26. net i01
  27. net i23
  28.  
  29. inst m0 mux21x i0 i1 s<0> ns0 i01
  30. inst m1 mux21x i2 i3 s<0> ns0 i23
  31. inst m2 mux21x i01 i23 s<1> ns1 z
  32. enddef
  33.  
  34. def mux41x8
  35. port in i0<7:0>
  36. port in i1<7:0>
  37. port in i2<7:0>
  38. port in i3<7:0>
  39. port in s<1:0>
  40. port out z<7:0>
  41.  
  42. net ns0
  43. net ns1
  44.  
  45. inst n0 nand s<0> s<0> ns0
  46. inst n1 nand s<1> s<1> ns1
  47.  
  48. inst m7 mux41x i0<7> i1<7> i2<7> i3<7> s<1:0> ns1 ns0 z<7>
  49. inst m6 mux41x i0<6> i1<6> i2<6> i3<6> s<1:0> ns1 ns0 z<6>
  50. inst m5 mux41x i0<5> i1<5> i2<5> i3<5> s<1:0> ns1 ns0 z<5>
  51. inst m4 mux41x i0<4> i1<4> i2<4> i3<4> s<1:0> ns1 ns0 z<4>
  52. inst m3 mux41x i0<3> i1<3> i2<3> i3<3> s<1:0> ns1 ns0 z<3>
  53. inst m2 mux41x i0<2> i1<2> i2<2> i3<2> s<1:0> ns1 ns0 z<2>
  54. inst m1 mux41x i0<1> i1<1> i2<1> i3<1> s<1:0> ns1 ns0 z<1>
  55. inst m0 mux41x i0<0> i1<0> i2<0> i3<0> s<1:0> ns1 ns0 z<0>
  56. enddef
  57.  
  58.  
  59. def alux1
  60. port in a
  61. port in b
  62. port in ci
  63. port out s
  64. port out co
  65. port out or
  66. port out and
  67. port out nota
  68.  
  69. net nc1
  70. net nc2
  71. net a2
  72. net b2
  73. net s1
  74. net c3
  75. net s12
  76. net notb
  77.  
  78. inst n1 nand a b nc1
  79. inst n2 nand a nc1 a2
  80. inst n3 nand b nc1 b2
  81. inst n4 nand a2 b2 s1
  82. inst n5 nand ci s1 nc2
  83. inst n6 nand ci nc2 c3
  84. inst n7 nand s1 nc2 s12
  85. inst n8 nand c3 s12 s
  86. inst n9 nand nc1 nc2 co
  87. inst na nand a a nota
  88. inst nb nand b b notb
  89. inst no nand nota notb or
  90. inst nn nand nc1 nc1 and
  91. enddef
  92.  
  93. def alux1nci #No carry in
  94. port in a
  95. port in b
  96. # port in ci Always False
  97. port out s
  98. # port out co Always = "And" output
  99. port out or
  100. port out and
  101. port out nota
  102.  
  103. net nc1
  104. net nc2
  105. net a2
  106. net b2
  107. net s1
  108. net c3
  109. net s12
  110. net notb
  111.  
  112. inst n1 nand a b nc1
  113. inst n2 nand a nc1 a2
  114. inst n3 nand b nc1 b2
  115. inst n4 nand a2 b2 s
  116. # inst n5 nand ci s1 nc2
  117. # inst n6 nand ci nc2 c3
  118. # inst n7 nand s1 nc2 s12
  119. # inst n8 nand c3 s12 s
  120. # inst n9 nand nc1 nc2 co
  121. inst na nand a a nota
  122. inst nb nand b b notb
  123. inst no nand nota notb or
  124. inst nn nand nc1 nc1 and
  125. enddef
  126.  
  127. def alux1nco #No carry out.
  128. port in a
  129. port in b
  130. port in ci
  131. port out s
  132. # port out co
  133. port out or
  134. port out and
  135. port out nota
  136.  
  137. net nc1
  138. net nc2
  139. net a2
  140. net b2
  141. net s1
  142. net c3
  143. net s12
  144. net notb
  145.  
  146. inst n1 nand a b nc1
  147. inst n2 nand a nc1 a2
  148. inst n3 nand b nc1 b2
  149. inst n4 nand a2 b2 s1
  150. inst n5 nand ci s1 nc2
  151. inst n6 nand ci nc2 c3
  152. inst n7 nand s1 nc2 s12
  153. inst n8 nand c3 s12 s
  154. # inst n9 nand nc1 nc2 co
  155. inst na nand a a nota
  156. inst nb nand b b notb
  157. inst no nand nota notb or
  158. inst nn nand nc1 nc1 and
  159. enddef
  160.  
  161. def alux8
  162. port in a<7:0>
  163. port in b<7:0>
  164. port in op<1:0>
  165. port out z<7:0>
  166.  
  167. # net c1 =and<0>
  168. net c2
  169. net c3
  170. net c4
  171. net c5
  172. net c6
  173. net c7
  174. net or<7:0>
  175. net and<7:0>
  176. net not<7:0>
  177. net sum<7:0>
  178. net cout
  179.  
  180. inst a0 alux1nci a<0> b<0> sum<0> or<0> and<0> not<0>
  181. inst a1 alux1 a<1> b<1> and<0> sum<1> c2 or<1> and<1> not<1>
  182. inst a2 alux1 a<2> b<2> c2 sum<2> c3 or<2> and<2> not<2>
  183. inst a3 alux1 a<3> b<3> c3 sum<3> c4 or<3> and<3> not<3>
  184. inst a4 alux1 a<4> b<4> c4 sum<4> c5 or<4> and<4> not<4>
  185. inst a5 alux1 a<5> b<5> c5 sum<5> c6 or<5> and<5> not<5>
  186. inst a6 alux1 a<6> b<6> c6 sum<6> c7 or<6> and<6> not<6>
  187. inst a7 alux1nco a<7> b<7> c7 sum<7> or<7> and<7> not<7>
  188.  
  189. inst m1 mux41x8 sum<7:0> and<7:0> or<7:0> not<7:0> op<1:0> z<7:0>
  190. enddef
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement