I have a design that I write / read to / from RAM and perform some calculations on read values. In some cases, I read values โโfrom RAM locations where I haven't written anything yet. This is intentional, because in cases where this happens, uninitialized values โโdo not affect the calculation: in these cases, uninitialized values โโare multiplied by 0.
However, when multiplying an unsigned / signed type that contains the 'U' bits, the result "does not care" (that is, all the output bits of the multiplication 'X' ), even if the other operand is 0. Therefore, I cannot check the final calculation output in my test bank, because it becomes "not caring" (it seems that the "do not care" outputs are interpreted as 0).
To avoid this problem, I wrote a function that resolves any bits of 'U' or 'X' in std_logic_vector to '0' . The functions are as follows
function f(x : std_logic_vector) return std_logic_vector is variable y : std_logic_vector (x'range); begin y := x; -- pragma synthesis off for i in 0 to x'length-1 loop case x(i) is when 'U' | 'X' => y(i) := '0'; when others => y(i) := x(i); end case; end loop; -- i -- pragma synthesis on return y; end;
Now I would like to expand the function, not only setting the bits 'X' and 'U' to '0' , but randomly setting them to either '0' or '1' . I tried to use the uniform function in f . The problem is that when I define two semesters inside a function, every time the function f is called, it returns the same std_logic_vector (when it is given the same std_logic_vector ). Since I take this from the description of the uniform function, I have to pass two semesters from outside the function f , because they are changed by the uniform function for the next uniform call.
Is there any way how this can be achieved using a function?
simon source share