C
Carlos Barberis
Guest
Hello,
I am trying to put together a simple one shot counter that gets trigered
once every time an input signal (Gate) the counter just counts to some
preloaded value and then just stops counting till the next time
Because I am a Verilog neophite I seem to struggle with the following error
while using Altera Quartus:
Error (10028): Can't resolve multiple constant drivers for net "temp" at
PulseWidthCounter.v(25)
Any help or sugestions will greatly appreciated!!!
The code is as follows:
************************************************** ****************
module PulseWidthCounter(clk,CountVal,counterenable,Gate, PulseOut);
parameter SIZE = 20;
input clk;
input Gate;
input counterenable;
input [SIZE - 1:0]CountVal;
output PulseOut = 0;
reg [SIZE - 1:0]CounterVal;
reg [SIZE - 1:0]clk1;
reg PulseOut;
reg temp = 0;
always @ (posedge counterenable)begin CounterVal <= CountVal; end
always @ (posedge Gate)begin temp <= 1'b1; end
always @ (posedge clk)
begin
if(temp == 1'b1)begin
clk1 <= clk1 +1;
if (clk1 < CounterVal)
PulseOut <= 1'b1;
else
PulseOut <= 1'b0; clk1 <=0; temp <= 0; end
end
endmodule
I am trying to put together a simple one shot counter that gets trigered
once every time an input signal (Gate) the counter just counts to some
preloaded value and then just stops counting till the next time
Because I am a Verilog neophite I seem to struggle with the following error
while using Altera Quartus:
Error (10028): Can't resolve multiple constant drivers for net "temp" at
PulseWidthCounter.v(25)
Any help or sugestions will greatly appreciated!!!
The code is as follows:
************************************************** ****************
module PulseWidthCounter(clk,CountVal,counterenable,Gate, PulseOut);
parameter SIZE = 20;
input clk;
input Gate;
input counterenable;
input [SIZE - 1:0]CountVal;
output PulseOut = 0;
reg [SIZE - 1:0]CounterVal;
reg [SIZE - 1:0]clk1;
reg PulseOut;
reg temp = 0;
always @ (posedge counterenable)begin CounterVal <= CountVal; end
always @ (posedge Gate)begin temp <= 1'b1; end
always @ (posedge clk)
begin
if(temp == 1'b1)begin
clk1 <= clk1 +1;
if (clk1 < CounterVal)
PulseOut <= 1'b1;
else
PulseOut <= 1'b0; clk1 <=0; temp <= 0; end
end
endmodule