Forum Discussion
51 Replies
- Altera_Forum
Honored Contributor
Let me suggest an easier way.
assume S1,S2 are inputs (8 bits wide each). Use two shift registers with (n) stages. Let the data S1,S2 shift through till the end and freeze the shift register then you can compare each value with others for equality and distance becomes index difference. For example if s1_shift(0) = s2_shift(3) then distance is 3-0 = 3 and so on. To code for shift register do this in a clocked process.
the code for checking equality can also be done in a loop to check say index(0) of s1 with indices 0 to n-1 of s2 then index(1) of s1 with indices 0 to n-1 of s2 and so on.s1_shift(0) <= s1; for i in 1 to n-1 loop -- n declared somewhere s1_shift(i) <= s1_shift(i-1); end loop; - Altera_Forum
Honored Contributor
Regarding those strings like asd,sdf etc. what is't and what does your tables actually mean
for example MER is 255 in table1 and is 215 in table2 then you look for MER (not the number next to it), what is it, are you clear about it, I am not - Altera_Forum
Honored Contributor
OK .... actually this table is some samples taken from user A represent in trigraphs from any text he wrote and digit behind it be the time he take to type those trigraphs such as ( acs--125 ms, asd--200 ms ........) build a sorted table1(S1) ,(sorted according to the time), consists of these data and table2 (S2) of the same trigraphs
compare between these samples and found the distance between the same trigraphs from the two samples i should make it in vhdl code , but you make me in doubt what i use ram or registers. regarding you code about register how i can find index in vhdl code. - Altera_Forum
Honored Contributor
--- Quote Start --- regarding you code about register how i can find index in vhdl code. --- Quote End --- The index of register would be the loop
you will get d(0) ~ d(n-1) as distance then you compute it further you need to get the type conversion right and test the code idea.for i in 0 to n-1 loop for j in 0 to n-1 loop if s1_shift(i) = s2_shift(j) then d(i) <= j-i; end if; end loop; end loop; - Altera_Forum
Honored Contributor
i can't do this code in memory like register
i try but failed process(addr_a) begin for i in data_a'range loop for j in data_a'range loop if data_a(i) = data_b(j) then d <= addr_a - addr_b; end if ; distance <= d; end loop; end loop; - Altera_Forum
Honored Contributor
--- Quote Start --- i can't do this code in memory like register i try but failed process(addr_a) begin for i in data_a'range loop for j in data_a'range loop if data_a(i) = data_b(j) then d <= addr_a - addr_b; end if ; distance <= d; end loop; end loop; --- Quote End --- The code I suggested was for shift register(not ram). even then you have to use d(i) not just d if you want to use ram then use two rams one for s1 and one for s2 then subtract addresses without the need for loop - Altera_Forum
Honored Contributor
if you want to use ram then use two rams one for s1 and one for s2 then subtract addresses without the need for loop
--- Quote End --- actually i use dual port ram for s1 and s2 and make this code if data_a = data_b then distance <= addr_a - addr_b; end if; the big problem is if and only if data_a = data_b at the same clock cycle not for all data index ,you understand me - Altera_Forum
Honored Contributor
use two single port rams one for s1 and one for s2 then address subtraction applies.
If you also want to write inputs to the rams then use two dual port rams again one for s1 rd/wr and one for s2 rd/wr. It really depends how you are going to get your inputs s1/s2 in the first place which you haven't told us yet. - Altera_Forum
Honored Contributor
may i said in another way,when i tried to match between every element in mem1 with every element in mem2 such as
if data_a=data_b then d<=addr_a - addr_b; it happened if data_a=data_ b in the same clock cycle not for all mem data i/p - Altera_Forum
Honored Contributor
how can i make the match between the two rams.
i search but not found any thing help me