Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21611 Discussions

16550 UART to Avalon

Altera_Forum
Honored Contributor II
3,464 Views

hi, 

 

i am woring on a student project and need following information: 

how to connect 16550 uart to avalon interface when adding component to sopc builder. 

 

i would be proud of your response. 

 

regards
0 Kudos
11 Replies
Altera_Forum
Honored Contributor II
2,234 Views

Do you want to connect a 16550 UART chip extern to fpga or do you want to add an uart module to the sopc system?

0 Kudos
Altera_Forum
Honored Contributor II
2,234 Views

I want to connect a 16550 UART chip extern to fpga. What do you suggest me?

0 Kudos
Altera_Forum
Honored Contributor II
2,234 Views

Include in sopc builder a tristate bus and connect it to a fake component (i.e. a flash device). 

Then you will have the standard asynchronous bus interface outside of sopc module. Simply route the bus signals (data, addr, cs, wr, rd) to the pins connected to same signals of the uart device. 

 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
2,234 Views

Hi , 

 

Please I am rigth now on the first stage :adding the opencore UART 16550 vhdl code in SOPC as a module in order to instantiate it. 

Please can you give me some advice to achieve it....... 

 

Regargs,
0 Kudos
Altera_Forum
Honored Contributor II
2,234 Views

First of all you need an Avalon bus interface, because opencore modules usually interface to Wishbone bus, not Avalon. 

Anyway the Wishbone/Avalon glue logic is fairly straightforward. You can refer to this thread and the links you'll find in it: 

http://www.alteraforum.com/forum/showthread.php?t=2238 

 

The next step is building the sopc component.  

First of all read the guide http://www.altera.com/literature/hb/qts/qts_qii54004.pdf 

Then, I'd suggest you take a tcl file from another component as a template and write your own, changing what you need. IMHO this is more convenient than creating the new component from scratch in sopc builder, but you can do either. 

Remember that the tcl file must be *_hw.tcl, otherwise sopc builder won't find it when you'll refresh the component list.
0 Kudos
Altera_Forum
Honored Contributor II
2,234 Views

Thank you for your advices.It really help me to understand details relating to Wishbone_Avalon Interface: 

 

Here is my avalon_Top_file but please can you give me some advices to test it and make sure it works? 

 

I would appreciate any support 

 

Regards,
0 Kudos
Altera_Forum
Honored Contributor II
2,234 Views

I made this way in a past project: 

assign avs_s1_readdata = 24'hz; (...) .wb_rst_i (avc_c1_reset), .wb_adr_i({2'b0, avs_s1_address}), .wb_dat_i(avs_s1_writedata), .wb_dat_o(avs_s1_readdata), .wb_we_i (avs_s1_write & ~avs_s1_read), .wb_stb_i (avs_s1_chipselect & (avs_s1_write | avs_s1_read)), .wb_cyc_i (avs_s1_chipselect), .wb_ack_o (avs_s1_waitrequest_n),  

If I remember correctly I used the address remapping trick and a fake 32bit width because of a Avalon bus bug. Infact Avalon always makes 32bit accesses, even if you use 8 or 16bit macros. For example IORD_8DIRECT would actually make 4 8bit reads in order to complete a 32bit bus word. 

This can corrupt your data if you have a peripheral with FIFOs (like UART usually have) which pop a data byte for every read access to the rx register. 

 

Cris
0 Kudos
Altera_Forum
Honored Contributor II
2,234 Views

Ok thank for your advices, 

 

Do you have any suggestions for a suitable testbench to make sure it works as expected? 

 

Regards,
0 Kudos
Altera_Forum
Honored Contributor II
2,234 Views

First of all test the bus interface. 

I dont' know that uart core, but if it is 16550 compliant it should have a scratch register. Try to write some data into it and verify you can read it back,
0 Kudos
Altera_Forum
Honored Contributor II
2,234 Views

Hi Cris  

 

First of all I tested my design with an integrated sopc uart to get confidence 

with the following code: 

 

void init_uart(int BAUD) { int divi; divi = (50000000 / BAUD) + 0.5; IOWR_16DIRECT(UART_BASE, 0x14, divi); } // -- end of "init_uart()" /* static void write_uart(char x) * * Send a character to the the PC */ void write_uart(char x) { unsigned long status = 0; while((status & 0x00000040) != 0x00000040) { status = IORD_ALTERA_AVALON_UART_STATUS(UART_BASE); } IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE, x); } // -- end of "write_uart()" /* char read_uart(void) * * Receive a character from the PC */ char read_uart(void) { char x; x = IORD_ALTERA_AVALON_UART_RXDATA(UART_BASE); return x; } // -- end of "read_uart()" int main(void) { //int iTx; // initialize the Transmitter int i=0; char x='a'; //char y=0x92; char z=64; init_uart(9600); x=read_uart(); while (i<5) { write_uart(z); x=read_uart(); z=z+1; } return 0; }  

 

It worked sucessfully. 

 

Now I wanted to test in the same way my 16550 UART to Avalon by writting/reading to/from the registries. 

 

But I don't know how to start . 

 

Please I would appreciate your advices
0 Kudos
Altera_Forum
Honored Contributor II
2,234 Views

Try to search for 16550 UART devices, for example on National Semiconductor or Texas Instruments websites. Download datasheet and application notes: thoee apply to your IP core, too; you can easily start this way.

0 Kudos
Reply