Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > multiplier with one fixed value other user defined

Reply
Thread Tools

multiplier with one fixed value other user defined

 
 
xiibweb@hotmail.com
Guest
Posts: n/a
 
      04-23-2005
Hi,,
I am interested to write a code in VHDL where one input is user defined
and the
other input is fixed to some value....

for example

0X2=0
1X2=2
2X2=4
3X2=6

here two in fixed (which I want to define as fixed). and 0 , 1, 2 , 3
user defined.

This code is generated using Xilinx webpack...

================================================== ==============
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity multo is
Port ( p1 : in std_logic_vector(1 downto 0);
w1 : in std_logic_vector(1 downto 0);
ou : out std_logic_vector(3 downto 0));
end multo;

architecture Behavioral of multo is

begin

ou <= w1 * p1;

end Behavioral;

================================================== ==============

the code works fine.. but in a final result I hv to make a schmatic
symbol for the code.. and I want to keep the fixed input hidden. So the
user just can change the other input and see the results... but with
existing code user cn c both inputs and requires to define both.

anybody with an answer... help me out...

thanks

John

 
Reply With Quote
 
 
 
 
Mohammed A khader
Guest
Posts: n/a
 
      04-23-2005

Hi John,

To have a fixed input it must be a constant (not a input port). So you
have to change your code to
================================================== ==============
> library IEEE;
> use IEEE.STD_LOGIC_1164.ALL;
> use IEEE.STD_LOGIC_ARITH.ALL;
> use IEEE.STD_LOGIC_UNSIGNED.ALL;
>
> entity multo is
> Port ( w1 : in std_logic_vector(1 downto 0);


> ou : out std_logic_vector(3 downto 0));
> end multo;
>
> architecture Behavioral of multo is

constant p1 : std_logic_vector(1 downto 0):= "10";
> begin
>
> ou <= w1 * p1;
>
> end Behavioral;
>
> ================================================== ==============



There are other things to correct in code. You have included the
package for unsigned and arithmetic but have not used it. When you do
some arithmetic opearation then it is good to define operators by
either unsigned or signed But dont use std_logic_vector. I assume you
want to do unsgined multiplication , so use unsigned type rather then
std_logic_vector.

Hence your declarations must be

w1 : in unsigned(1 downto 0); .....

-- Mohammed A Khader.

 
Reply With Quote
 
 
 
 
xiibweb@hotmail.com
Guest
Posts: n/a
 
      04-23-2005
well the problem is not solved......... i cannot hide the input
still... or keep it defined...
thanks.

 
Reply With Quote
 
xiibweb@hotmail.com
Guest
Posts: n/a
 
      04-23-2005
Well thanks very much for the reply...
i am getting following errors when i try to do compilation...

ERROR:HDLParsers:800 - "C:/Projects/AndNN/multhree.vhd" Line 14. Type
of p1 is incompatible with type of 10 .
ERROR:HDLParsers:808 - "C:/Projects/AndNN/multhree.vhd" Line 17. * can
not have such operands in this context

and i hv no idea how figure these out....

thanks again

 
Reply With Quote
 
xiibweb@hotmail.com
Guest
Posts: n/a
 
      04-23-2005
THANKS A LOOOOOOOOOOOOOOOOOOOOT........... NOW THE CODE IS WORKING
FINEEEEEEEEEEEEEEE

THANKS AGAIN

John

 
Reply With Quote
 
info_
Guest
Posts: n/a
 
      04-24-2005
Mohammed A khader wrote:

> Hi John,
>
> To have a fixed input it must be a constant (not a input port). So you
> have to change your code to
> ================================================== ==============
>
>>library IEEE;
>>use IEEE.STD_LOGIC_1164.ALL;
>>use IEEE.STD_LOGIC_ARITH.ALL;
>>use IEEE.STD_LOGIC_UNSIGNED.ALL;
>>
>>entity multo is
>> Port ( w1 : in std_logic_vector(1 downto 0);

>
>
>> ou : out std_logic_vector(3 downto 0));
>>end multo;
>>
>>architecture Behavioral of multo is

>
> constant p1 : std_logic_vector(1 downto 0):= "10";
>
>>begin
>>
>> ou <= w1 * p1;
>>
>>end Behavioral;
>>
>>================================================ ================

>
>
>
> There are other things to correct in code. You have included the
> package for unsigned and arithmetic but have not used it.


Yes he did !
that's what std_logic_unsigned is about :
it treats std_logic_vectors as unsigned.

>
> Hence your declarations must be
>
> w1 : in unsigned(1 downto 0); .....
>
> -- Mohammed A Khader.
>


Not necessary. see above.

But I think everyone should give up synopsys arith packages and
switch to numeric_std instead.

Bert Cuzeau
 
Reply With Quote
 
Mohammed A khader
Guest
Posts: n/a
 
      04-25-2005

Mohammed said ....
>> You have included the
>> package for unsigned and arithmetic but have not used it.


Bert Said....
> that's what std_logic_unsigned is about :
> it treats std_logic_vectors as unsigned.


Sorry I wrote unsigned as well as arithmetic . * operator for
std_lgoic_vector is defined in unsigned .So no need of arithmetic
package since it is not used.

> But I think everyone should give up synopsys arith packages and
> switch to numeric_std instead.


Yes I agree with it.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Very less resource fixed point 32x32 bit multiplier and 32/32divider Kevin Neilson VHDL 3 08-25-2008 06:50 PM
#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) Oodini C Programming 1 09-27-2005 07:58 PM
multiplier one fixed value other user defined xiibweb@hotmail.com VHDL 1 04-23-2005 04:14 PM
EOS 1ds and other no-focal-length multiplier cams JRS Digital Photography 9 06-01-2004 09:13 AM
fixed point multiplier in VHDL Viswan VHDL 9 02-11-2004 09:00 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57