Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. //SW[3:0] data inputs
  2.  
  3. //HEX0[] output display
  4.  
  5. module decoder(HEX0, SW);
  6. input [3:0] SW;
  7. output [6:0] HEX0;
  8.  
  9. hex0 h0(
  10. .c0(SW[0]),
  11. .c1(SW[1]),
  12. .c2(SW[2]),
  13. .c3(SW[3]),
  14. .m(HEX0[0])
  15. );
  16. hex1 h1(
  17. .c0(SW[0]),
  18. .c1(SW[1]),
  19. .c2(SW[2]),
  20. .c3(SW[3]),
  21. .m(HEX0[1])
  22. );
  23. hex2 h2(
  24. .c0(SW[0]),
  25. .c1(SW[1]),
  26. .c2(SW[2]),
  27. .c3(SW[3]),
  28. .m(HEX0[2])
  29. );
  30. hex3 h3(
  31. .c0(SW[0]),
  32. .c1(SW[1]),
  33. .c2(SW[2]),
  34. .c3(SW[3]),
  35. .m(HEX0[3])
  36. );
  37. hex4 h4(
  38. .c0(SW[0]),
  39. .c1(SW[1]),
  40. .c2(SW[2]),
  41. .c3(SW[3]),
  42. .m(HEX0[4])
  43. );
  44. hex5 h5(
  45. .c0(SW[0]),
  46. .c1(SW[1]),
  47. .c2(SW[2]),
  48. .c3(SW[3]),
  49. .m(HEX0[5])
  50. );
  51. hex6 h6(
  52. .c0(SW[0]),
  53. .c1(SW[1]),
  54. .c2(SW[2]),
  55. .c3(SW[3]),
  56. .m(HEX0[6])
  57. );
  58. endmodule
  59.  
  60. module hex0(c0, c1, c2, c3, m);
  61. input c0;
  62. input c1;
  63. input c2;
  64. input c3;
  65. output m;
  66.  
  67. assign m = (c3 & c2 & ~c1 & c0) | (c3 & ~c2 & c1 & c0) | (~c3 & ~c2 & ~c1 & c0) + | (~c3 & c2 & ~c1 & ~c0);
  68. endmodule
  69.  
  70. module hex1(c0, c1, c2, c3, m);
  71. input c0;
  72. input c1;
  73. input c2;
  74. input c3;
  75. output m;
  76.  
  77. assign m = (c3 & c1 & c0) | (c2 & c1 & ~c0) | (c3 & c2 & ~c0) + | (~c3 & c2 & ~c1 & c0);
  78. endmodule
  79.  
  80. module hex2(c0, c1, c2, c3, m);
  81. input c0;
  82. input c1;
  83. input c2;
  84. input c3;
  85. output m;
  86.  
  87. assign m = (c3 & c2 & ~c0) | (c3 & c2 & c1) | (~c3 & ~c2 & c1 & ~c0);
  88. endmodule
  89.  
  90. module hex3(c0, c1, c2, c3, m);
  91. input c0;
  92. input c1;
  93. input c2;
  94. input c3;
  95. output m;
  96.  
  97. assign m = (c2 & c1 & c0) | (~c3 & c2 & ~c1 & ~c0) | (c3 & ~c2 & c1 & ~c0) + | (~c2 & ~c1 & c0);
  98. endmodule
  99.  
  100. module hex4(c0, c1, c2, c3, m);
  101. input c0;
  102. input c1;
  103. input c2;
  104. input c3;
  105. output m;
  106.  
  107. assign m = (~c3 & c0) | (~c2 & ~c1 & c0) | (~c3 & c2 & ~c1);
  108. endmodule
  109.  
  110. module hex5(c0, c1, c2, c3, m);
  111. input c0;
  112. input c1;
  113. input c2;
  114. input c3;
  115. output m;
  116.  
  117. assign m = (~c3 & ~c2 & c1) | (~c3 & ~c2 & c0) | (c3 & c2 & ~c1 & c0) + | (~c3 & c1 & c0);
  118. endmodule
  119.  
  120. module hex6(c0, c1, c2, c3, m);
  121. input c0;
  122. input c1;
  123. input c2;
  124. input c3;
  125. output m;
  126.  
  127.  
  128. assign m = (~c3 & ~c2 & ~c1) | (c3 & c2 & ~c1 & ~c0) | (~c3 & c2 & c1 & c0);
  129.  
  130. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement