Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > about addition operator

Reply
Thread Tools

about addition operator

 
 
jiten
Guest
Posts: n/a
 
      06-22-2005
hi,
i've found that + operator doesn't work with std_logic values.
it works only with std_logic_vector.
i've checked if a,b & c are std_logic values than
c <= a + b; gives compile time errors.
why it happens?
cann't we use + operator with single std_logic values.
regards
jitendra.

 
Reply With Quote
 
 
 
 
Bert Cuzeau
Guest
Posts: n/a
 
      06-22-2005
jiten wrote:
> hi,
> i've found that + operator doesn't work with std_logic values.
> it works only with std_logic_vector.


Not even. You'd need Synopsys' std_logic_unsigned (eg) which use
is deprecated (with reasons) against numeric_std which requires
signed or unsigned types.

> i've checked if a,b & c are std_logic values than
> c <= a + b; gives compile time errors.
> why it happens?
> cann't we use + operator with single std_logic values.
> regards
> jitendra.
>


Lots of things the VHDL Jedi needs to learn

Unlike Verilog, VHDL is strongly typed.

Btw, I think a one bit adder is just an xor, so
c <= a xor b;
is probably what you're looking for.
Alternatively, you could use one-bit vectors (0 downto 0).

Bert Cuzeau

 
Reply With Quote
 
 
 
 
Neo
Guest
Posts: n/a
 
      06-23-2005
The "+" operator works with std_logic_values but the addtions of two
single bit makes the result a vector. so you've got type mismatch
there. declaring your "c" as std_logic_vector should make it fine.

 
Reply With Quote
 
Neo
Guest
Posts: n/a
 
      06-23-2005
Jiten,
I see that you have been trying to get your vhdl right by posting to
this newsgroup. Thats fine, but, I feel you have got to know about
digital structures out of a good book like say, Mano before you try
describing hardware in HDLs. It dosent help by just learning how to
write vhdl. you need a good understanding of logic before you can apply
it effectively.

 
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
perl addition operator. query. gerry.brennan@gmail.com Perl Misc 6 04-30-2006 08:54 AM
a simple addition "+" operator question Carson VHDL 4 10-06-2005 09:01 PM
byte type and addition operator jk Java 7 02-15-2005 03:42 PM
Office Development (feature addition) Midnight Java Junkie ASP .Net 0 06-20-2004 07:24 AM
Queston about addition in Maxplus II lezah VHDL 7 03-02-2004 06:11 PM



Advertisments