RAVINDRA SINGH
Newbie level 6
hello everyone, i have a question that popped up during the design of vector to integer code. Leaving asides the use of variables inside the process statement , if we use an inout signal and update it as in the following code, i thought it would work, however it's giving unexpected results. although i have a theory for that, i don't know if it's correct or not, so please shed some light on the unexpected results.
code:
My thought of it:
well, i tried various methods and found that whenever there are multiple statements for driving a signal in the sequential manner, then the latest signal driver only drives the signal and hence the value assigned to the signal depends on the last signal driver. So, here ,in this example, due to the loop , multiple driver statements for the signal b are being created and its value is updated only by the last signal driving statement. Use of the inputs : "00000011" , "00000001" , "10000001" , "11000001" , "01000000" gives the results -0 , 0 , 128 , 256, 256 respectively. Please, shed some light on this, if i am going correctly about it.:idea:
code:
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 entity inout_sig is Port ( a : in bit_vector(7 downto 0); b : inout integer:= 0); end inout_sig; architecture arch_iosig of inout_sig is begin process(a) variable x :integer; begin for i in 0 to 7 loop if a(i)='1' then x:=1; else x:=0; end if; b<= b + x*(2**i); end loop; end process; end arch_iosig;
My thought of it:
well, i tried various methods and found that whenever there are multiple statements for driving a signal in the sequential manner, then the latest signal driver only drives the signal and hence the value assigned to the signal depends on the last signal driver. So, here ,in this example, due to the loop , multiple driver statements for the signal b are being created and its value is updated only by the last signal driving statement. Use of the inputs : "00000011" , "00000001" , "10000001" , "11000001" , "01000000" gives the results -0 , 0 , 128 , 256, 256 respectively. Please, shed some light on this, if i am going correctly about it.:idea:
Last edited by a moderator: