ShiftRegister
Newbie level 1
I am trying to build a block that ouputs a certain value initially (10) , and increments or decrements this value when input signals UP or DOWN are asserted (these are active low signals in my design). It just doesnt seem to work the way I want, although the code synthesizes on Quartus II.
Here is the code
it seems to work for DOWN, but not for UP! or to consecutive DOWNs.
Can someone explain this mystery? [/code]
Here is the code
Code:
module Threshold_Set(
input UP,
input DOWN,
input clock,
input tset, //hardware generated or external active low signal to set theshold value
output restart,
output [3:0] threshold
);
assign restart = UP & DOWN;
reg [3:0] t_reg;
reg [2:0] counter;
assign threshold = t_reg;
always@(negedge UP or negedge DOWN or negedge tset)
begin
if(tset==1'b0)
begin
t_reg <= 4'b1010;
end
else
begin
if(UP == 1'b0) //Why is UP signal taking it to unknown state?
begin
t_reg <= t_reg + 1;
end
else
begin
t_reg <= t_reg - 1;
end
end
end
endmodule
it seems to work for DOWN, but not for UP! or to consecutive DOWNs.
Can someone explain this mystery? [/code]