Help to SImulate Uart TX

I'm using the following code. I've managed to make it work on my fpga before. but when I try to simulate on my modelsim, it seems that it never gets into the statemachine.

I've configured the settings for a 50Mhz clock...also set the config for model sim to be 10ns 10ns for clock high and low.

How should I go about simulating this?

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

--

-- Engineer: Wojciech Powiertowski

--

-- Module Name: transmitter

-- Project Name: UART

-- Description: A VHDL UART controller

--

-- Comments:

-- If your clkFreq or baudRate values are different than you should

-- calculate proper: phase accumulator width and proper tuning word with

-- the following equations:

-- phaseAccWidth = round(log2((clkFreq/(baudRate))^2))

-- phaseAccTuning = round(baudRate*2^(phaseAccWidth+1)/clkFreq)

--

-- Example:

-- clkFreq = 100000000 -- 100MHz

-- baudRate = 115200 -- 115.2kHz

-- phaseAccWidth = 19.5233 -- round it up to 20

-- phaseAccTuning = 2415.9 -- round it up to 2416

--

-- generated baud will have frequency of 115199.99 which is only

-- 0.000005% different than ideal baud rate of 115200

--

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

library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;

entity transmitter is port( clk : in std_logic; startTxD : in std_logic; reset : in std_logic; dataTxD : in std_logic_vector (7 downto 0); TxD : out std_logic; showtick : out std_logic; busyTxD : out std_logic ); end transmitter;

architecture TxD_arch of transmitter is -- phase accumulator constants and core - see details on top of the file !!! constant phaseAccWidth : integer := 25; constant phaseAccTuning : integer := 12885; signal phaseAcc : std_logic_vector (phaseAccWidth downto 0);

-- signals in design signal dataBuffer : std_logic_vector (7 downto 0); signal baudTick : std_logic; signal state : integer range 0 to 15; begin

-- baud generator based on phase accumulator baudTickGen : process (clk) is begin if(rising_edge(clk))then phaseAcc

Reply to
Zhane
Loading thread data ...

'Never gets into the statemachine'....is that supposed to mean something? (Hint: It doesn't)

In a word, 'debug'.

Put some waveforms up to view, step through the code, look at the signals, however it is that works best for you. It's your design and testbench, it's up to you to figure out what the problem is. Debugging by newsgroup is hardly worth the effort.

KJ

Reply to
KJ

Maybe rising_edge(baudTick) isn't happening. Have a look at that wave. A better design would use clk here and make baudTick a clock enable.

What settings? I would write my own sim clock process.

I would buy a quartus license to get their oem modelsim.

-- Mike Treseler

Reply to
Mike Treseler

,

it's

I did the baudtick does changes, but it doesnt get into the

if(rising_edge(baudTick))then showtick

Reply to
Zhane

I changed the settings of the baudgen to match my 9600bps and my 50Mhz clock.

I'm noob, so trying to save some effort from recoding by using this code which I found somewhere ~_~

it did work when I try on the actual fpga...

Reply to
Zhane

Does the testbench wait for 2*12885 clk cycles per 'tick' Does the testbench drive reset back low? Good luck.

-- Mike Treseler

PS: Might want to reset showtick. Might want to strobify the MSB and sync up both counters to clk.

Reply to
Mike Treseler

hmm sorry ... i dont understand what you mean by ..

=3D_=3D!! i only put my reset up for 1 cycle only..the remaining are all low

Reply to
Zhane

If you want to understand it well enough to test it, read up on direct digital synthesis.

Good luck.

-- Mike Treseler

Reply to
Mike Treseler

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.