Altera_Forum
Honored Contributor
18 years agoOk I must be an idiot :P
Hi people,
I am new to this so go easy on me. What I am trying to make is a block that has 3 inputs up, down, reset and one 12bit output. when i pulse up i want it to count up by 3, when I pulse down i want it to count down by 3, when i pulse reset I want it to reset to 250. here is my code atm:module updown (
up ,
down ,
reset ,
counter_out
); // End of port list
//-------------Input Ports-----------------------------
input up ;
input down ;
input reset ;
//-------------Output Ports----------------------------
output counter_out ;
//-------------Input ports Data Type-------------------
wire up ;
wire down ;
wire reset ;
//-------------Output Ports Data Type------------------
reg counter_out ;
//-------------Internal Variables----------------------
//------------Code Starts Here-------------------------
always @ (posedge reset or posedge up or posedge down )
begin
if (reset) begin
counter_out =# 3 250 ;
end
else if (down) begin
counter_out =# 3 counter_out - 3 ;
end
else if (up) begin
counter_out =# 3 counter_out + 3 ;
end
end
endmodule Atm reset and up work if i hit down it counts down for the entire time that down is held high. If i change up and down location in the if statement then down works and up does not.... Chris