Krystian102

Untitled

Apr 9th, 2020
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module zad4(
  2.     input CLOCK_50,
  3.     output [7:0] LEDR);
  4.    
  5.     timer(CLOCK_50,LEDR);
  6.    
  7. endmodule
  8.  
  9. module timer(
  10.     input CLOCK,
  11.     output reg [7:0] out);
  12.    
  13.     wire clk_0_1, clk_0_25, clk_0_5, clk_0_8, clk_1_2, clk_1_5, clk_1_8, clk_2_0;
  14.    
  15.     counter_to_make_delay0_1sek ex1(CLOCK,1, clk_0_1);
  16.     counter_to_make_delay0_25sek ex2(CLOCK,1, clk_0_25);
  17.     counter_to_make_delay0_5sek ex3(CLOCK,1, clk_0_5);
  18.     counter_to_make_delay0_8sek ex4(CLOCK,1, clk_0_8);
  19.     counter_to_make_delay1_2sek ex5(CLOCK,1, clk_1_2);
  20.     counter_to_make_delay1_5sek ex6(CLOCK,1, clk_1_5);
  21.     counter_to_make_delay1_8sek ex7(CLOCK,1, clk_1_8);
  22.     counter_to_make_delay2sek ex8(CLOCK,1, clk_2_0);
  23.    
  24.     always@(posedge clk_0_1)
  25.         if(clk_0_1)
  26.             out[0]=~out[0];
  27.    
  28.     always@(posedge clk_0_25)
  29.         if(clk_0_25)
  30.             out[1]=~out[1];
  31.            
  32.     always@(posedge clk_0_5)
  33.         if(clk_0_5)
  34.             out[2]=~out[2];
  35.    
  36.     always@(posedge clk_0_8)
  37.         if(clk_0_8)
  38.             out[3]=~out[3];
  39.            
  40.     always@(posedge clk_1_2)
  41.         if(clk_1_2)
  42.             out[4]=~out[4];
  43.            
  44.     always@(posedge clk_1_5)
  45.         if(clk_1_5)
  46.             out[5]=~out[5];
  47.            
  48.     always@(posedge clk_1_8)
  49.         if(clk_1_8)
  50.             out[6]=~out[6];
  51.            
  52.     always@(posedge clk_2_0)
  53.         if(clk_2_0)
  54.             out[7]=~out[7];
  55.        
  56. endmodule
  57.  
  58. module counter_to_make_delay2sek(
  59.     input clk, aclr,
  60.     output reg clockTact);
  61.    
  62.     reg [28:0] i;
  63.    
  64.     always@(posedge clk, negedge aclr)
  65.         if(!aclr)
  66.             begin
  67.                 i<=0;
  68.                 clockTact<=0;
  69.             end
  70.         else
  71.             begin
  72.                 if(i==100000000)
  73.                     begin
  74.                         i<=0;
  75.                         clockTact<=1;
  76.                     end
  77.                 else
  78.                     begin
  79.                         i<=i+1;
  80.                         clockTact<=0;
  81.                     end
  82.             end
  83.    
  84. endmodule
Advertisement
Add Comment
Please, Sign In to add comment