0
\$\begingroup\$

The problem is to find a modulo when a three digit number is divided by its last two digits. But the three digit number is received in a binary form. So I first want to change the binary form into integer form then use the mod operator.

code

asked May 27, 2017 at 11:09
\$\endgroup\$
2
  • \$\begingroup\$ Maybe your signal definitions for divident_int (and others) should be defined as unsigned? If you convert a negative int (that starts with a MSB=1), it may be truncated to a value of 0? \$\endgroup\$ Commented May 27, 2017 at 13:48
  • 2
    \$\begingroup\$ Your process is only called once (no sensitivity list) and the value of "dividend_int" is only updated after reaching the WAIT statement. modcalc looks like a combinatorial entity (no clock). You don't need any process. Alternatively, you could use a variable for dividend_int, modulo_int and modulo_1 \$\endgroup\$ Commented May 27, 2017 at 14:15

1 Answer 1

1
\$\begingroup\$

Why do you paste your code as an image?! This makes it harder for us to help you. Please don't do that next time.

The answer is given by TEMLIB. You have two options:

1) Make a triggered process, with the internal value as variables.

begin
 process(divident)
 variable divident_int : integer;
 variable modulo_1_int : integer;
 variable modulo_int : integer;
 begin
 divident_int := to_integer(unsigned(divident));
 modulo_1_int := divident_int mod divis_1;
 modulo_int := divident_int mod modulo_1_int;
 modulo <= std_logic_vector(to_unsigned(modulo_int, modulo'length));
 end process;
end architecture;

2) leave out the process (and keep the signals)

begin
 divident_int <= to_integer(unsigned(divident));
 modulo_1 <= divident_int mod divis_1;
 modulo_int <= divident_int mod modulo_1;
 modulo <= std_logic_vector(to_unsigned(modulo_int, modulo'length));
end architecture;
answered May 28, 2017 at 19:48
\$\endgroup\$
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.