Solved

Question about VHDL programming

Posted on 2010-09-09
8
508 Views
Last Modified: 2012-05-10
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
Comment
Question by:errang
  • 3
  • 3
  • 2
8 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 200 total points
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

by:errang
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

by:Adam314
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

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

Expert Comment

by:Adam314
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

by:HappyCactus
HappyCactus earned 300 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

by:errang
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

by:HappyCactus
HappyCactus earned 300 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now