We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for
Did you mean: prakece25
Visitor
11,369 Views
Registered: ‎02-11-2010

## vhdl program

if anyone have coding for division in vhdl please do help me

Tags (2)
1 Solution

Accepted Solutions prakece25
Visitor
14,243 Views
Registered: ‎02-11-2010

## Re: vhdl program

actually i am doing program for integer division .numerator has lot more variables to be added . The denominator has only integer of 20.But xilinx is not accepting this division since it can accept only denominator should be of power of 2.

xkp00<=conv_std_logic_vector(conv_integer(fns(0))*conv_integer(xkp00)/20-8*conv_integer(xkp11)/20+48,10) ;

this is one of my coding line here only the denominator part 20 is not accepted . instead if i put 16+4  there is no error but the output is not coming properly.ie it shows all the outputs are 0.

17 Replies Historian
11,356 Views
Registered: ‎02-25-2008

## Re: vhdl program

prakece25 wrote:

if anyone have coding for division in vhdl please do help me

entity divider is

port (

divisor : in integer;

dividend : in integer;

result : out integer);

end entity divider;

architecture dothemath of divider is

begin

result <= dividend / divisor;

end architecture dothemath;

----------------------------Yes, I do this for a living. drjohnsmith
Teacher
11,331 Views
Registered: ‎07-09-2009

## Re: vhdl program

Hi

can I ask what type of division . in time ( counter ) or in maths.

Integer, fixed point, floating point, divide by a constant or a variable ?

If you have a multiplier / divider it could be easy, if you have not, then its a big tree of code, or a rom.

The question is really what do you want to divide and by what ? prakece25
Visitor
14,244 Views
Registered: ‎02-11-2010

## Re: vhdl program

actually i am doing program for integer division .numerator has lot more variables to be added . The denominator has only integer of 20.But xilinx is not accepting this division since it can accept only denominator should be of power of 2.

xkp00<=conv_std_logic_vector(conv_integer(fns(0))*conv_integer(xkp00)/20-8*conv_integer(xkp11)/20+48,10) ;

this is one of my coding line here only the denominator part 20 is not accepted . instead if i put 16+4  there is no error but the output is not coming properly.ie it shows all the outputs are 0. drjohnsmith
Teacher
11,234 Views
Registered: ‎07-09-2009

## Re: vhdl program

HI

can I ask have you looked at what hardware this is generating ?

This looks like C code.

You have defined three inputs to a multiplier,

fns(0) , ( xkp00/ 20 ) - 8, and (xkp11/20)+48

and returned the answer to 10 bits.

For the inputs, you have deifned  two divider, I assume 32 bit integers each  xkp00 / 20  and xkp11/20.

You have also defined a subtractor and an adder, probably on 64 bits.

Not the most efficient implimentaiont in hardware I guess. Historian
11,211 Views
Registered: ‎02-25-2008

## Re: vhdl program

prakece25 wrote:

actually i am doing program for integer division .numerator has lot more variables to be added . The denominator has only integer of 20.But xilinx is not accepting this division since it can accept only denominator should be of power of 2.

xkp00<=conv_std_logic_vector(conv_integer(fns(0))*conv_integer(xkp00)/20-8*conv_integer(xkp11)/20+48,10) ;

this is one of my coding line here only the denominator part 20 is not accepted . instead if i put 16+4  there is no error but the output is not coming properly.ie it shows all the outputs are 0.

You're not "doing a program." You are describing hardware. There is a significant difference. You must understand this.

----------------------------Yes, I do this for a living. prakece25
Visitor
11,186 Views
Registered: ‎02-11-2010

## Re: vhdl program

thank u drjohnsmith but for simulation can i clear the error prakece25
Visitor
11,185 Views
Registered: ‎02-11-2010

## Re: vhdl program

thank u bassman59 . i can understand a little bit . but i dont know exactly.i hav just converted my matlab coding into vhdl.. that may be of problem. can u help me in anyway? drjohnsmith
Teacher
11,179 Views
Registered: ‎07-09-2009

## Re: vhdl program

HI

significant differance.  do you want to simulate only, or do you want to generate real silicon ( synthesise ).

Seems your using std logic arith, which in most places I go to is a big no no.

anyway.

You also have to look at order of ooperation even for synthesis.

xkp00<=conv_std_logic_vector(          [ conv_integer(fns(0)) * conv_integer(xkp00)/20 ]   - [ 8 *conv_integer(xkp11)/20  ] +  48     ,10         )

I've added some brackets ( in [ ] ) just to show you what the synth is actualy doing ( it won't synth like that ).

Spliting this out

A, B, C, D and E are 32 bit integers.

A <=  conv_integer(fns(0));

B <=  conv_integer(xkp00);

C <=  B / 20;

D <= conv_integerxkp11);

E <= 8 * D / 20;

this gives a 32 bit integer result, which you thentake 10 bits of, I don't know whic 10 bits the funciton takes, I don't use it.

xkp00 <= conv_std_logic_vector ( ( A * C ) - E + 48, 10 ); -- i.e. take 10 bits

Is that the expresion you were expecting ?

A feature of MATLAB, that catches every one,

MATLAB work in floating point or integers of width X. Whilst VHDL works in integers of width Y, and preferable std_logic_vectors of width Z.

It's up to you to make certain you get the correct bits in MATLAB.

typical for something like this, the nearer your MATLAB code is like the VHDL with fixed size numbers, the better is will synthesis to good VHDL.

Message Edited by drjohnsmith on 10-03-2010 01:10 PM prakece25
Visitor
11,136 Views
Registered: ‎02-11-2010

## Re: vhdl program

thank u drjohnsmith  u hav given

A, B, C, D and E are 32 bit integers.

A <=  conv_integer(fns(0));

B <=  conv_integer(xkp00);

C <=  B / 20;

D <= conv_integerxkp11);

E <= 8 * D / 20;

xkp00 <= conv_std_logic_vector ( ( A * C ) - E + 48, 10 ); -- i.e. take 10 bits

if i do take the codings like this , will it work or not. i am taking here only 10 bits for my purpose drjohnsmith
Teacher
9,507 Views
Registered: ‎07-09-2009

## Re: vhdl program

Hi

just split out so it's easier to discuss.

As you can see, it's a lot of logic, so although it would synthesis, I would not want to do so.

For simulation, where you don't make silicon I can't see why it would not work.

It might also let you look at the 32 bit integers to see if your getting the intermediate values you expect.

e.g. what does B / 20 give you. is it a 32 bit answer or 64 bits ? if 64 bits, what happens to the other 32 bits if you assign it back to a 32 bit integer ?

In matlab or C etc, where everything is floating points, you ignore this,

In DSP or FPGA world, you need to know the  size of your numbers, and what happens to them

for instance, your conv_std_logic_vector functioni from synopsis.

what does this do to a 32 bit integer ?

Does it take the top 10 , bottom 10 , middle ten bits, round off / up or what ? You have to know.

and it all depends where your data is sat in the integer. If it's all at the top end, then if the convert is taking the bottom 10 bits, then your going to get 0 out of the equaiton.

put it in a simulator, step throught a few numbers and see what each of the integers are,

You might be surprised. prakece25
Visitor
9,500 Views
Registered: ‎02-11-2010

## Re: vhdl program

thank u drjohnsmith

i am taking here only the LSB 10 bits.But this coding is ok for model sim it  also shows the output  .but for implementation i need to work with xilinx. that's why i post here. but i need only 10 bit output.if i send u the coding would you clear the error? drjohnsmith
Teacher
9,495 Views
Registered: ‎07-09-2009

## Re: vhdl program

Hi

just to clarify, I don't work for xilinx.

I'm an independent  consultant, prakece25
Visitor
9,484 Views
Registered: ‎02-11-2010

## Re: vhdl program

Thank you drjohnsmith praveensimbhu_86@yahoo.co.in
Newbie
9,318 Views
Registered: ‎05-03-2010

## Re: vhdl program

hi i need the coding for scalabe encryption algorithm using fpga.. if any one have done it means please post it to praveensimbhu_86@yahoo.co.in or bprawinkumar@gmail.com... Need it urgent.. plz do the favor.. and also i did one coding in that i have got 2000 range of sliced used.. but in my existing paper for same input they got only 200 plus slices used.. plz any one tel me how to reduce the numbre of slices used from 2000 to 200 ranges...send to my mail id plzzzzzzzzzzz..

Tags (2) drjohnsmith
Teacher
9,304 Views
Registered: ‎07-09-2009

## Re: vhdl program

Hi

will it work? Yes, it's psedo code, so naturaly.

You have not answered the fundamental questions we asked you above, and until you do, it is not going to give the answer you expect !

Ok, on paper, put some numbers in for fns(0) and xkp00 and work out what you expect from xkp00 !

Can we see you results ?

Highlighted goelrahulgoel
Visitor
7,961 Views
Registered: ‎02-17-2013

## Re: vhdl program

hello i am writing a program for configuration declaration in this program i am making two architecture by one entity . in this program when i am compaling then last architectutre is compaling which is count_255. but i want execute architecture count_64k . how it can possible pls help me

---------------------------------------------------------------------

LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;

ENTITY counter1 IS
PORT(load, clear, clk : IN std_logic;
data_in : IN INTEGER;
data_out : OUT INTEGER);
END counter1;
ARCHITECTURE count_64k OF counter1 IS
BEGIN
PROCESS(clk)
VARIABLE count : INTEGER := 0;
BEGIN
IF clear = '1' THEN
count := 0;
count := data_in;
ELSE
IF (clk'EVENT) AND (clk = '1') THEN
IF (count = 65535) THEN
count := 0;
ELSE
count := count + 1;
END IF;
END IF;
END IF;
data_out <= count;
END PROCESS;
END count_64k;
ARCHITECTURE count_255 OF counter1 IS
BEGIN
PROCESS(clk)
VARIABLE count : INTEGER := 0;
BEGIN
IF (clear = '1') THEN
count := 0;
count := data_in;
ELSE
IF (clk'EVENT) AND (clk = '1')
THEN
IF (count = 255) THEN
count := 0;
ELSE
count := count + 1;
END IF;

END IF;
END IF;
data_out <= count;
END PROCESS;
END count_255;

CONFIGURATION small_count OF counter1 IS
FOR count_255
END FOR;
END small_count;
CONFIGURATION big_count OF counter1 IS
FOR count_64k
END FOR;
END big_count;

Tags (2) 7,938 Views
Registered: ‎01-21-2011

## Re: vhdl program

@bassman59 wrote:

prakece25 wrote:

actually i am doing program for integer division .numerator has lot more variables to be added . The denominator has only integer of 20.But xilinx is not accepting this division since it can accept only denominator should be of power of 2.

xkp00<=conv_std_logic_vector(conv_integer(fns(0))*conv_integer(xkp00)/20-8*conv_integer(xkp11)/20+48,10) ;

this is one of my coding line here only the denominator part 20 is not accepted . instead if i put 16+4  there is no error but the output is not coming properly.ie it shows all the outputs are 0.

You're not "doing a program." You are describing hardware. There is a significant difference. You must understand this.

They hired me  to make those FPGA alive

they call me 'software' or 'coding' engineer or similar such name

I refuse the name, but I take \$\$\$

:-)