EmbDev.net

Forum: FPGA, VHDL & Verilog verilog/vhdl code for programmable parallel to serial converter


Author: anjali komalapati (Company: iqi labs) (anjali)
Posted on:

Rate this post
0 useful
not useful
can any 1 help me in writing a code for 6 to 16 bit programmable 
parallel to serial converter.......

Author: Lothar Miller (lkmiller) (Moderator) Flattr this
Posted on:

Rate this post
0 useful
not useful
> can any 1 help me in writing a code for 6 to 16 bit programmable
> parallel to serial converter.......
Maybe. What do you have already done? Show your work and then ask your 
questions.

> for 6 to 16 bit programmable parallel to serial converter.
Is that a simple loadable shift register?
Draw a picture or just add more information.

> ......
You should have a close look on your dot key. Maybe its stuck.

Author: anjali komalapati (Company: iqi labs) (anjali)
Posted on:
Attached files:

Rate this post
0 useful
not useful
i attatched my code what i have written so plz check it out and say me 
where should i modify

Author: Lothar Miller (lkmiller) (Moderator) Flattr this
Posted on:

Rate this post
0 useful
not useful
A loop is the totally wrong way.
A loop in VHDL implements several instances of the described part inside 
the loop in parallel. It does something completely different than a 
loop in C. What you need is a counter and a schift register...


This here is a little bit tricky:
process( clk)
variable x : integer := 6;
begin
  if DataReady = '1' then    -- DataReady is missing in the sensitivity list
     if (clk'event and clk = '1') then
This you should write that way (as anyone else in the world does):
process( clk)
variable x : integer := 6;
begin
  if (clk'event and clk = '1') then   -- FIRST there has to be a clock!
     if DataReady = '1' then          
And: you will not need a variable for this simple task.
A variable also does not do that what you expect...


BTW: attach your code as a *.vhdl file (not as *.txt) and you will see a 
little magic...

Author: anjali komalapati (Company: iqi labs) (anjali)
Posted on:
Attached files:

Rate this post
0 useful
not useful
so plzzzz help me still where should i modify the code to get the 
appropriate result without using a variable.....

Author: Lothar Miller (lkmiller) (Moderator) Flattr this
Posted on:

Rate this post
0 useful
not useful
Let me say its a fairly simple task.
I'm really astonished about your problems....  :-o

Try to understand this:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;


entity P2S is
port ( Serial_out     : out std_logic;
       clk            : in std_logic;
       Parallel_data  : in std_logic_vector(15 downto 0);
       DataReady      : in std_logic);
   
end P2S;

architecture Behavioral of P2S is

signal OldReady : std_logic := '0';
signal Shreg    : std_logic_vector( 15 downto 0);

begin

  process (clk) begin
    if (clk'event and clk = '1') then
      Shreg <= '0' & Shreg(15 downto 1);     -- shift it left to right
      if DataReady='1' and OldReady='0' then -- rising edge = new data
        Shreg <= parallel_data;              -- load it
      end if;
    end if;
  End process;

  Serial_out <= Shreg(0);

end Behavioral;
I use a little trick so that its not necessary for me to check the 
length: if all of the bits are transmitted, with evere clock a '0' is 
shifted out.

Author: anjali komalapati (Company: iqi labs) (anjali)
Posted on:

Rate this post
0 useful
not useful
ya it is fine but nw here if we get 16 bit data dat is geting serialized 
but sometimes i may get 6 bit r 8 bit r 10 bit r etc at dat time dat can 
get into serialized. How this can be known according to ur logic........

Author: Lothar Miller (lkmiller) (Moderator) Flattr this
Posted on:

Rate this post
0 useful
not useful
> How this can be known according to ur logic...
Nobody can know that. Because there is no information how much of the 16 
bits contain "real" data. Lets take the word "0000_1001_0011_0001". Is 
it 12 bits or 16 bits long?
Lets transmit 6 bit like this: "110011"? How will it look like?
clk  _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
data _______________----____----_____________
Where does the frame start?
Whats the difference to a 8 bit word like "00110011"? How does this look 
like? Tahke this:
clk  _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
data _______________----____----_____________
You see: you cannot see a difference!

So usually you will need a frme signal that tells you, when a telegram 
starts and when it ends. Then you can easily seen how long the data 
telegram is:
clk  _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
data _______________----____----_____________
frame __________----------------_____________  
This was 8 bits.
clk  _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
data _______________----____----_____________
frame ______________------------_____________  
And this was 8 bits.

The whole thing is realized like a SPI interface.

Author: anjali komalapati (Company: iqi labs) (anjali)
Posted on:

Rate this post
0 useful
not useful
so wt ever the length of the data we get, that will get serialized 
according to this logic and but here you took 16 bit if i get the data 
of 8 r 10 bit length of data so that many bits get serialized and gives 
the output?

Author: Lothar Miller (lkmiller) (Moderator) Flattr this
Posted on:

Rate this post
0 useful
not useful
Did not get your question...  :-/

> if i get the data of 8 r 10 bit length
What would you input to the P2S unit?
The input port has 16 bit witdh:
entity P2S is
port ( ....
       Parallel_data  : in std_logic_vector(15 downto 0);
How do you go into this unit with 8 or 10 bits?

Author: anjali komalapati (Company: iqi labs) (anjali)
Posted on:

Rate this post
0 useful
not useful
ya input is fixed length of 16 bit but this parallel to serial converter 
logic should be programmable when ever the data will arrive then dat 
should get serialized. For example 1st i got the data of 6 bit length at 
that time that data should be latched then it should get serialized. 
Similarly some other time when i get the data of length10 bit even in 
same way that should get serialized. This means our logic should be 1 
time programmed instead of runtime programmable......... I think u got 
my point

Author: anjali komalapati (Company: iqi labs) (anjali)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Iam attatching one more file it is nt simulating i have written this 
type also so Once check this also compare my previous reply  and say me 
plzzzz........

Author: Lothar Miller (lkmiller) (Moderator) Flattr this
Posted on:

Rate this post
0 useful
not useful
> For example 1st i got the data of 6 bit length at
> that time that data should be latched then it should get serialized.
> Similarly some other time when i get the data of length10 bit even in
> same way that should get serialized.
Thats exactly, what my previously posted code does...

> 1st i got the data of 6 bit length
> some other time when i get the data of length10 bit even in same way
And HOW can cou see this difference of 4 bits on a 16 bit vector?
How can you KNOW the witdh of the actual vector?

> I think u got my point
Yes, i do, but not vice versa.
Draw a picture with different parallel input vectors and how the have to 
occur on the serial output...

EDIT:
> it is nt simulating
Why? Whats the problem?
>  counter<=counter+1;
Counter is an integer. And an integer can get much higher values than 
the index here will be allowed to:
> Serial_out<=Parallel_data(counter);

Author: anjali komalapati (Company: iqi labs) (anjali)
Posted on:

Rate this post
0 useful
not useful
ya if we get 6 bit data at that time as we have given fixed length is 16 
bit in that it takes 6 bit of data and remaining will send as zeros 
without affecting the data. This way it will happen  na?

Author: Lothar Miller (lkmiller) (Moderator) Flattr this
Posted on:

Rate this post
0 useful
not useful
> This way it will happen  na?
Yes. Try it with a simulation...

Author: anjali komalapati (Company: iqi labs) (anjali)
Posted on:

Rate this post
0 useful
not useful
Thank you so much for your support. your posts are helped me alot

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.