P
Pedro Lazaro
Guest
Greetings,
I would be grateful if you could help me on this problem.
FIRST,
I have this code below:
--------------------------------------------
module timer(
input clk,
input reset,
output reg signal // <--- PROBLEMATIC SIGNAL
);
always@(posedge clk or posedge reset)
begin
if(reset)
signal <= 1;
else
signal <= 0;
end
endmodule
--------------------------------------------
and this testbench, which was executed on modelsim:
--------------------------------------------
`timescale 1ns / 1ps
`define PERIOD 20
module timer_tb;
logic clk;
logic reset;
logic signal;
timer inst(
.clk(clk),
.reset(reset),
.signal(signal)
);
initial
begin
clk = 0;
forever clk = #(`PERIOD/2) ~clk;
end
initial
begin
reset = 0; //<--- RESET STARTS CLEANED.
#(`PERIOD)
reset = 1;
#(`PERIOD)
reset = 0;
#(`PERIOD*3)
reset = 1;
#(`PERIOD)
reset = 0;
#(`PERIOD*3)
$display("End of the simulation");
$stop;
end
endmodule
------------------------------------------------------
SO, THE PROBLEM:
=========
Output reg "signal" starts HIGH but in the code, this reg depends of reset, and the reset starts DOWN.
I don't understand why "signal" register is HIGH in the beginning of the simulation as the reset starts surely DOWN.
I need the "signal" starting DONW and only be set up IF reset go to 1 (condition posedge reset just like my code).
=========
Please take a look on this print of the waveform for clear understanding of my problem:
WAVEFORM ON MODELSIM IMAGE: http://postimg.org/image/5wktylub9/
Thank you for your attention.
Pedro
I would be grateful if you could help me on this problem.
FIRST,
I have this code below:
--------------------------------------------
module timer(
input clk,
input reset,
output reg signal // <--- PROBLEMATIC SIGNAL
);
always@(posedge clk or posedge reset)
begin
if(reset)
signal <= 1;
else
signal <= 0;
end
endmodule
--------------------------------------------
and this testbench, which was executed on modelsim:
--------------------------------------------
`timescale 1ns / 1ps
`define PERIOD 20
module timer_tb;
logic clk;
logic reset;
logic signal;
timer inst(
.clk(clk),
.reset(reset),
.signal(signal)
);
initial
begin
clk = 0;
forever clk = #(`PERIOD/2) ~clk;
end
initial
begin
reset = 0; //<--- RESET STARTS CLEANED.
#(`PERIOD)
reset = 1;
#(`PERIOD)
reset = 0;
#(`PERIOD*3)
reset = 1;
#(`PERIOD)
reset = 0;
#(`PERIOD*3)
$display("End of the simulation");
$stop;
end
endmodule
------------------------------------------------------
SO, THE PROBLEM:
=========
Output reg "signal" starts HIGH but in the code, this reg depends of reset, and the reset starts DOWN.
I don't understand why "signal" register is HIGH in the beginning of the simulation as the reset starts surely DOWN.
I need the "signal" starting DONW and only be set up IF reset go to 1 (condition posedge reset just like my code).
=========
Please take a look on this print of the waveform for clear understanding of my problem:
WAVEFORM ON MODELSIM IMAGE: http://postimg.org/image/5wktylub9/
Thank you for your attention.
Pedro