Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. module freq_div(clk_out,clk);
  2. output clk_out;
  3. input clk;
  4. wire[18:0] c;
  5. T_FF tff01(c[0],1'b1,clk,1'b0);
  6. T_FF tff02(c[1],1'b1,c[0],1'b0);
  7. T_FF tff03(c[2],1'b1,c[1],1'b0);
  8. T_FF tff04(c[3],1'b1,c[2],1'b0);
  9. T_FF tff05(c[4],1'b1,c[3],1'b0);
  10. T_FF tff06(c[5],1'b1,c[4],1'b0);
  11. T_FF tff07(c[6],1'b1,c[5],1'b0);
  12. T_FF tff08(c[7],1'b1,c[6],1'b0);
  13. T_FF tff09(c[8],1'b1,c[7],1'b0);
  14. T_FF tff10(c[9],1'b1,c[8],1'b0);
  15. T_FF tff11(c[10],1'b1,c[9],1'b0);
  16. T_FF tff12(c[11],1'b1,c[10],1'b0);
  17. T_FF tff13(c[12],1'b1,c[11],1'b0);
  18. T_FF tff14(c[13],1'b1,c[12],1'b0);
  19. T_FF tff15(c[14],1'b1,c[13],1'b0);
  20. T_FF tff16(c[15],1'b1,c[14],1'b0);
  21. T_FF tff17(c[16],1'b1,c[15],1'b0);
  22. T_FF tff18(c[17],1'b1,c[16],1'b0);
  23. T_FF tff19(c[18],1'b1,c[17],1'b0);
  24. T_FF tff20(clk_out,1'b1,c[18],1'b0);
  25. endmodule
  26.  
  27.  
  28. module D_FF(q,d,clk,reset);
  29. output q;
  30. input d,clk,reset;
  31. reg q;
  32. always @(posedge reset or negedge clk)
  33. if (reset)
  34. q <= 1'b0;
  35. else
  36. q <= d;
  37. endmodule
  38.  
  39. module T_FF(q,t,clk,reset);
  40. output q;
  41. input t,clk,reset;
  42. wire d;
  43. xor x1(d,q,t);
  44. D_FF d1(q,d,clk,reset);
  45. endmodule
  46. module project(LED1,LED2,LED3,LEDLION,LEDBIRD,LEDSNAKE,clk,reset,lion,bird,snake/*,
  47. s0,s1,s2,s3,s4,s5,s6,s7*/);
  48. input clk,reset,lion,bird,snake;
  49. output LED1,LED2,LED3,LEDLION,LEDBIRD,LEDSNAKE/*,s0,s1,s2,s3,s4,s5,s6,s7*/;
  50.  
  51.  
  52. freq_div freq(clknew,clk);
  53. wire w_xnor1,w_xnor2,w_andfinal;
  54. //tff1
  55. T_FF t1(LED1,w_andfinal,clknew,reset);
  56.  
  57. //tff2
  58. wire not_w1;
  59. not not1(not_w1,LED1);
  60. T_FF t2(LED2,w_andfinal,not_w1,reset);
  61.  
  62. //tff3
  63. wire not_w2;
  64. not not2(not_w2,LED2);
  65. T_FF t3(LED3,1'b1,not_w2,reset);
  66.  
  67.  
  68.  
  69. xnor xnirww(w_xnor1, lion, LED1);
  70. xnor xnirwx(w_xnor2, bird, LED2);
  71. xnor xnirwy(w_xnor3, snake, LED3);
  72.  
  73. and andxx(w_andfinal, w_xnor1, w_xnor2, w_xnor3);
  74.  
  75. nand nandmore1(LEDLION,1'b1,lion);
  76. nand nandmore2(LEDBIRD,1'b1,bird);
  77. nand nandmore3(LEDSNAKE,1'b1,snake);
  78.  
  79. //Stage
  80. wire wn001,wn002,wn003;
  81. not not001(wn001, LED1);
  82. not not002(wn002, LED2);
  83. not not003(wn003, LED3);
  84. /*
  85. and ands0(s0, LED1 , LED2 , LED3);
  86. and ands1(s1, wn001 , LED2 , LED3);
  87. and ands2(s2, LED1 , wn002 , LED3);
  88. and ands3(s3, wn001 , wn002 , LED3);
  89. and ands4(s4, LED1 , LED2 , wn003);
  90. and ands5(s5, wn001 , LED2 , wn003);
  91. and ands6(s6, LED1 , wn002 , wn003);
  92. and ands7(s7, wn001 , wn002 , wn003);
  93. */
  94. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement