Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21584 Discussions

A trouble With Code

Altera_Forum
Honored Contributor II
1,346 Views

Hi all, 

well am a new VHDL programmer, and I was trying to write a code for a generic multiplier using a 4 bit ripple adder, the results are correct, but my design should include two modes, test mode and normal mode, when I was trying to compile the following code, an error occured as follows. 

Error (10028): Can't resolve multiple constant drivers for net "output[10]" at fast_multiplier.vhd(19) 

 

here is the code 

LIBRARY IEEE; 

USE IEEE.STD_LOGIC_1164.ALL; 

 

ENTITY fast_multiplier IS 

GENERIC (n: POSITIVE:=7); 

PORT(mode,TDI,clk_normal,clk_test:IN STD_LOGIC; 

multiplier: IN STD_LOGIC_VECTOR(n-1 DOWNTO 0); 

multiplicand: IN STD_LOGIC_VECTOR(3 DOWNTO 0); 

result: OUT STD_LOGIC_VECTOR(n+3 DOWNTO 0); 

TDO: OUT STD_LOGIC); 

END ENTITY; 

 

ARCHITECTURE simple OF fast_multiplier IS 

SIGNAL input1: STD_LOGIC_VECTOR(n-1 DOWNTO 0); 

SIGNAL input2: STD_LOGIC_VECTOR(3 DOWNTO 0); 

SIGNAL output: STD_LOGIC_VECTOR(n+3 DOWNTO 0); 

SIGNAL clk: STD_LOGIC; 

BEGIN 

g0: ENTITY WORK.multiplier_ripple(simple) GENERIC MAP(7) PORT MAP(input1,input2,output); 

g1: ENTITY WORK.my_mux(simple) PORT MAP(clk_normal,clk_test,mode,clk); 

PROCESS(mode,clk) 

BEGIN 

IF RISING_EDGE(clk) THEN 

IF mode='0' THEN 

input1<=multiplier; 

input2<=multiplicand; 

result<=output;  

ELSIF Mode='1' THEN 

input2(3 DOWNTO 0)<= (TDI & input2(3 DOWNTO 1)) ; 

input1(n-1 DOWNTO 0)<= input2(0) & input1(n-1 DOWNTO 1); 

output(n+3 DOWNTO 0)<= input1(0) & output(n+2 DOWNTO 0); 

TDO<=output(n+3); 

END IF;  

END IF; 

END PROCESS; 

END ARCHITECTURE; 

 

when mode=0 this is the normal mode 

and when mode=1 this is the test mode 

any help plz as soon as possible
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
639 Views

output is unconditionally driven by the multiplier, so it can't be driven in the process. I guess, you would want to drive result instead.

0 Kudos
Altera_Forum
Honored Contributor II
639 Views

To avoid double drive on "output" connect "temp1" to multiplier output at G0 line and assign temp2 instead of output in the line: 

output(n+3 DOWNTO 0)<= input1(0) & output(n+2 DOWNTO 0); 

 

Then create a switch: 

if ... 

output <= temp1;  

else  

output <= temp2; 

end if;
0 Kudos
Altera_Forum
Honored Contributor II
639 Views

Kaz is right i think.Because simple meaning of the this common error "multiple constant driver" is that compiler is unable to assign more than one value to that specified stuff that u wanted. 

Because your code is simultaneously assigning more than one values to output[10],so compiler always confuses out of two values,which one i should use.So it will generate an error of multiple constant driver 

To resolve this,always use intermediate variable,like "temp" for storing values and use value whenever u need it to your required output.
0 Kudos
Reply