I have this code and I am having a problem in the product output, any ideas? I've tried a lot and it doesn't work.

  • \$\begingroup\$ Firstly why are you not displaying the values of z1, z2 and shift_val in your wave graph? Secondly please post the complete code, not just a fragment. \$\endgroup\$ – Peter Green Jan 4 '19 at 16:49
  • \$\begingroup\$ @PeterGreen Check my answer \$\endgroup\$ – Jack Sparrow Jan 4 '19 at 17:27

I think it's because you have:

mult_prod = (mult_prod << shift_val);

Remember mult_prod is a bus, not a variable but a representation of a physical set of wires. An assignment like this implies that those wires simultaneously have two different states. Try introducing an intermediate term like mult_prod_temp, like:

// 8x16 multiplier
 **mult_prod_temp** = z2*z1;

// Shifter
 mult_prod = (**mult_prod_temp** << shift_val);

val = (product + mult_prod);
product <= val;
  • \$\begingroup\$ This does work but whenever I do this, the product does not get the right values, so I tried another way but that other way gives me the 'x in the output... \$\endgroup\$ – Jack Sparrow Jan 4 '19 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.