Forum: FPGA, VHDL & Verilog Help with VHDL

Author: Jaden (Guest)
Posted on:

Rate this post
0 useful
not useful

I'm quite new to VHDL and trying to create a simple UART transmission in 
VHDL code.

This is my code:
entity UART is 
  port ( din  : in bit_vector( 7 downto 0) ;
       send : in std_logic ;
       tx  : out bit ) ;
end UART;

architecture arc_UART of UART is
    constant bit_time : time := 8680 ns ;  -- 1/115200 [baud]
    tx <= '1' ;                -- idle state  
    wait until falling_edge(send) ;       -- wait until send
    tx <= '0' ; wait for bit_time ;       -- start bit
    for i in 0 to 7 loop
      tx <= din(i) ; wait for bit_time ; -- send 8 data bits
    end loop ;
    tx <= '1' ; wait for bit_time ;       -- stop bit
  end process;
end arc_UART;

But the problem is that when I run a Model-sim simulation, it doesn't 
work as expected.

What could be the problem here?

Thank you

Author: Lothar M. (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Jaden wrote:
> it doesn't work as expected.
What do you expect and what happens instead?

> What could be the problem here?
You know that "wait for" is not synthesizable on real hardware like a 

Author: U.G. L. (dlchnr)
Posted on:

Rate this post
0 useful
not useful
I suppose you need something like a loadable shift register plus a 
baudrate generator (clock divider),
which generates the shift clock (sclk) from your system clock.
ShiftRegister : process                                                                         
  wait until rising_edge(sclk);                                                          
  if (load = '1') then
    sr(7 downto 0) <= din(7 downto 0);
    tx <= '0';
    sr(6 downto 0) <= sr(7 downto 1);
    sr(7) <= '1';                                                  
    tx <= sr(0);                                                                          
  end if;                                                                                    
end process;


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]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.