__apotamkin
Newbie
I am writing a clock divider to get 10sec, 8sec, 3 sec from 50 Mhz clock signal.
This is my main module code :
And this is the test bench code:
This is the simulation
I set simulation time to 50 from simulation settings and when I look at the simulation, end of the diagram is 0.000000050000s as you can see. Why it doesn't look like just 50s ? How can I fix this?
This is my main module code :
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 `timescale 1s / 1s module deneme1(clock_in,red,yellow,green ); input clock_in; // input clock output reg red; // output clock after dividing the input clock by divisor output reg yellow; output reg green; reg[27:0] counter=28'd0; parameter DIVISOR = 28'd2; // The frequency of the output clocks(red,yellow,green) // = The frequency of the input clk_in divided by DIVISOR // For example: Fclk_in = 50Mhz, if you want to get 1Hz signal to blink LEDs // You will modify the DIVISOR parameter value to 28'd50.000.000 // Then the frequency of the output clk_out = 50Mhz/50.000.000 = 1Hz always @(posedge clock_in) begin counter <= counter + 28'd1; if(counter>=(DIVISOR-1)) counter <= 28'd0; red <= (counter<DIVISOR/2)?1'b1:1'b0; //if red <= (counter<DIVISOR/2) 1b'1 else 1'b0 end always @(posedge clock_in) begin counter <= counter + 28'd1; if(counter>=(DIVISOR-1)) counter <= 28'd0; yellow <= (counter<DIVISOR/2)?1'b1:1'b0; end always @(posedge clock_in) begin counter <= counter + 28'd1; if(counter>=(DIVISOR-1)) counter <= 28'd0; green <= (counter<DIVISOR/2)?1'b1:1'b0; end endmodule
And this is the test bench code:
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 `timescale 1s / 1s module deneme1tb; // Inputs reg clock_in; // Outputs wire red; wire yellow; wire green; // Instantiate the Unit Under Test (UUT) // Test the clock divider in Verilog deneme1 uut ( .clock_in(clock_in), .red(red), .yellow(yellow), .green(green) ); initial begin // Initialize Inputs clock_in = 0; // create input clock 50MHz [B]forever #5000 clock_in = ~clock_in;[/B] end endmodule
This is the simulation
I set simulation time to 50 from simulation settings and when I look at the simulation, end of the diagram is 0.000000050000s as you can see. Why it doesn't look like just 50s ? How can I fix this?
Last edited by a moderator: