Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

a question in quartus

I have some questions I have a matlab code which i want to convert it to VHDL code.

The idea in the matlab is using for loop where i compute some matrices by using some vectors I have already constructed.

for example if I have syst_bit=[1 2 3 4 5 .......], parity1=[1 2 3 4 5......] and parity2=[1 2 3 4 5......] I will use for loop as follows

for i=1:256

gamma(i)=syst_bit(i)+parity1(i);-- this is simplification to the real equation

end;

for i=1:256

alpha(i)=syst_bit(i)*gamma(i);-- this is simplification to the real equation

end;

for i=1:256

beta(i)=syst_bit(i)*gamma(i);-- this is simplification to the real equation

end;

Ofcourse in matlab there will be no problem at all since the new values of gamma, alpha or beta will be updated before moving to the next line since it's a high programming language.

This should be done for constant number of times(maybe 6 times) on VHDL while receiving the new input to construct new frames (both are done at the same time)

so my idea is creating the needed adders, multipliers, comparators ......

and using for loop in VHDL and on each loop I should put the input on the input wires of this blocks for example

for i in 0 to 255

wire1<=syst_bit(i);

wire2<=parity1(i);

gamma(i)<=wire3;

end loop;

is this right or not?

23 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    no that's not the case, i receive 4 bits in each clock where i should construct 3 vectors of length 256 so this will take 192 clocks 192=256*(3/4) where 256 length of vector 4 number of input in each clock and 3 is the number of vectors that's why 192 and sorry for any confusion

    in the point of using 32 bits i need a little help here some intialization should be done in the alpha and beta matrices by zeros while in the last state by negative infinity so in order not to saturate our calculation by infinity let's say infinity=10^5(large number) and any number which is out of this range should be normalized to get it in this range so how i can use 8 bits while still representing 10^5 in 8 bits without overflow
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You will need to think of input rate clk as half-byte clk.

    Internally you serialise your frame to one bit. Your frame is eventually 768 bits long per every 256 bits(per every 64 input clks). So internal bit clk must be 12 times faster than input clk rate. Otherwise the very act of serilisation itself will not work(add to that any processing clks needed). i.e. you must allow for the serilisation factor and any extras.

    I can't help on issue of 32 bits but if your problem is to compare a given data value with 10^5 then store 10^5 somewhere and compare other values and put result on 8 bits.