woodde123
Newbie level 2
Hi I have a verilog coding problem:
The following is what I want to do:
Once I press a button to load a number, the content of Value_1 is moved to Value_2, the content of Current_Value is moved to Value_1, and the content of input_data is move to Current_Value.
However, after executing the following code, Value_1 and Value_2 store the same value as Current_Value. How to fix the code? How can I get the statement executed in the specified sequential order?
Please help.
...
input [1:0] input_data;
reg [1:0] Value_2, Value_1, Current_Value, Current_Value_Temp;
always @ (posedge clk)
begin
if (reset) //active high
begin
Value_2 = 2'b0;
Value_1 = 2'b0;
Current_Value = 2'b0;
end
else if (load) //active high
begin
Value_2 = Value_1;
Value_1 = Current_Value;
Current_Value = input_data;
end
end
...
The following is what I want to do:
Once I press a button to load a number, the content of Value_1 is moved to Value_2, the content of Current_Value is moved to Value_1, and the content of input_data is move to Current_Value.
However, after executing the following code, Value_1 and Value_2 store the same value as Current_Value. How to fix the code? How can I get the statement executed in the specified sequential order?
Please help.
...
input [1:0] input_data;
reg [1:0] Value_2, Value_1, Current_Value, Current_Value_Temp;
always @ (posedge clk)
begin
if (reset) //active high
begin
Value_2 = 2'b0;
Value_1 = 2'b0;
Current_Value = 2'b0;
end
else if (load) //active high
begin
Value_2 = Value_1;
Value_1 = Current_Value;
Current_Value = input_data;
end
end
...