Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

Posted on 2010-09-09
Medium Priority
519 Views
Hey,

I had a question about programming in VHDL.  I need to write a program that will multiply two (two bit) numbers without using the * (multiplication operator).

I have figured out how to do this, we could do a bit shift to the left if we were multiplying by 2, and we could do the same and add the first number to the result if the number is being multiplied by 3.

I took a shot at writing the code, but it doesn't quite work...

Appreciate any help on this.
0
Question by:errang
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 3
• 2

LVL 39

Accepted Solution

ID: 33643201
It's been a while since I've used VHDL, but I think this will work...

When multiplying 2 2-bit numbers, the result will be 4 bits.  If you write out a truth table, you can use that to generate a formula for each of the result bits.
0

Author Comment

ID: 33643212
Yea, I thought about that, I'll have to check if that's Ok.

But... I was also wondering how we'd get the bits to make the LEDs light up.
0

LVL 39

Expert Comment

ID: 33643274
Like I said... it's been a long time.

I think if you write the formulas for each of the output bits, the voltage on the pins will change as the input voltages change.  If you have LEDs connected, they will light up.
0

Author Comment

ID: 33643290
Ah.. kk, thanks, I'll try that out when I get to the lab.
0

LVL 39

Expert Comment

ID: 33643478
Depending on the current capabilities of your chip, you may need to condition the signal before connecting it to the LEDs.
0

LVL 12

Assisted Solution

HappyCactus earned 1200 total points
ID: 33644593
You can also use a lookup table, other than the truth table (by using the boolean algebra).
To connect the LED, simply connect the results bit to a pin on your device. If you are using a dev board, you maybe already have the LED and necessary electronics to drive it. Otherwise, check the fanout capability of your device, and put a transistor driver if necessary.

0

Author Comment

ID: 33647400
I am using a standard Spartan 3E FPGA board, and it does  have LEDs.  And I do realize I need to send a 1 to the LEDs to make them light up.

My main question is, if I'm using a 4 bit std_logic_vector out1 for the output, do I simply connect out1(0) to LED0, and go about it that way?

And do I have to assign the value to out1 bit by bit?  Like out1(0) <= '1';  ?
0

LVL 12

Assisted Solution

HappyCactus earned 1200 total points
ID: 33647469
You connect each bit to each pin.
Then you can assign values to each bit or to the entire vector, as possible with vhdl (out1 <= "1001").
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, itâ€™s also â€¦
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in aâ€¦
Screencast - Getting to Know the Pipeline
###### Suggested Courses
Course of the Month8 days, 3 hours left to enroll