Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module licznik(CLK, CLR, OUT, CE);
  2. input CLK, CLR, CE;
  3. output [3:0]OUT;
  4.  
  5. reg [3:0]OUT;
  6.  
  7. always @(posedge CLK or negedge CLR)
  8. begin
  9.  
  10. if(!CLR)
  11. OUT <= 4'b0000;
  12. else
  13.     if(CE)
  14.         OUT<=OUT+1;
  15. end
  16.  
  17. endmodule
  18.  
  19. ////////////////////////////////////////////////////////////////////////////////
  20. module preskaler(CLK,CLR,CE,Q,CEO);
  21. input CLK, CLR, CE;
  22. output reg [27:0] Q;
  23. output CEO;
  24.  
  25. always @(posedge CLK or negedge CLR)
  26. begin
  27. if(!CLR)
  28. Q <= 28'd0;
  29. else
  30. if(CE)
  31. if(Q != 28'd99999999)
  32. Q <= Q + 1;
  33. else
  34. Q <= 28'd0;
  35. end
  36.  
  37. assign CEO = CE & (Q == 28'd99999999);
  38.  
  39. endmodule
  40. ///////////////////////////////////////////////////////////////////////////////
  41. module polaczenie(CLK, CLR, CE, Q, CEO, OUT);
  42.  
  43. input CLK, CLR, CE;
  44. output [27:0]Q;
  45. output [3:0]OUT;
  46. output CEO;
  47.  
  48. //module preskaler(CLK,CLR,CE,Q,CEO);
  49. preskaler dzielnik(CLK, CLR, 1'b1, Q, CEO);
  50.  
  51. //module licznik(CLK, CLR, OUT, CE);
  52. licznik licz(CLK, CLR, OUT, CEO);
  53.  
  54. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement