hii....i really need someone to help me to check this code....i'm try to built an adder with register feedback as you can see in the diagram below. here is my code of program and the testbench code...There's no error on the code unfortunately the waveform doesn't appear as I wish...the test bench code is work cause I'd test it before with the other program..It's probably because of the code of program where there are errors which I can't detect it...kindly please check this for me because I'm out of idea...=)
wire3 <= ((wire2(2 downto 0) ) + (3)) when (wire1(3) or wire2(3)) = '1' else wire2;
the error you are getting is because you are assigning a 3bit signal (2 downto 0) to a 4 bit signal (3 downto 0)
depending on what you want to do you can either do wire3 <= (('0'&wire2(n-1 downto 0) ) + (2**n - select_mod)) when(wire1 or wire2) = '1' else wire2;
or wire3 <= '0'&((wire2(n-1 downto 0) ) + (2**n - select_mod)) when(wire1 or wire2) = '1' else wire2;
or wire3 <= ((wire2(n downto 0) ) + (2**n - select_mod)) when(wire1 or wire2) = '1' else wire2;
I have to do the VHDL code for the diagram which mean I have to convert the schematic to the VHDL code. It's a generic and modulus adder which involve a latch register feedback as you can see diagram. As example, n = 3 which it will be 3 bit signal and the mod is 5 where the program will be count from 0 --> 4 only...If let say a+b = 5, it will count to 0 back.......Ohh, sorry...I forget to label the diagram. Maybe this diagram helps to explain why I'm declaring the wire for each components as 4bits...
so whenever the total input a+b >= select_mod, it will do the value in latch will be feedback to do the second cycle of operation which it will add with 2^n-m..as example...if the total a+b is 5...in the second cycle it will add with 2^n - m which is 3...so 101 + 011 = 1000...therefore the value for the MSB will be the wire1 = 1 and the output for this will be 000....my problem is I don't know how to insert the latch code in this program...thanks again for the help...=)