Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

Help with external component in SOPC builder

Hi. We have to communicate with an external chip form Nios II. We have built an expansion card that we have put on the proto 2 connector. The external chip is a Phillips PDIUSBD12. We have written a driver for it in eCos and we have problems getting it to work. After some debugging it looks like there's something wrong with the i/o pins. We get a 7.3 MHz signal as noise on one of the i/o's, on a couple of others it looks like the signal is inverted and phaseshifted.

We made a verilog-file to describe the i/o's on the PDIUSBD12. I do not know verilog, so I just looked at the verilog code for the Compact Flash component that is on this forum. I just thought I'd connect the signals to the proper avalon signals, and it would work. I can connect to the chip and make it work for a little time, but then it's unstable. This is my verilog code:

module pdiusbd12 (
    usb_avalon_data_in, usb_avalon_data_out, usb_avalon_address, usb_avalon_cs_n, usb_avalon_read_n, usb_avalon_write_n,
    usb_avalon_interrupt, usb_avalon_reset_n, usb_avalon_clk,
    usb_data, usb_address, usb_cs_n, usb_read_n, usb_write_n, usb_interrupt, usb_reset_n
);
input  usb_avalon_data_in;
output  usb_avalon_data_out;
input usb_avalon_reset_n;
input usb_avalon_address;
input usb_avalon_cs_n;
input usb_avalon_read_n;
input usb_avalon_write_n;
output usb_avalon_interrupt;
input usb_avalon_clk;
inout  usb_data;
output usb_address;
output usb_cs_n;
output usb_read_n;
output usb_write_n;
input usb_interrupt;
output usb_reset_n;
assign usb_read_n = usb_avalon_read_n;
assign usb_write_n = usb_avalon_write_n;
assign usb_cs_n = usb_avalon_cs_n;
assign usb_avalon_interrupt = usb_interrupt;
// Generate bi-directional data lines
assign usb_avalon_data_out = (usb_avalon_read_n == 1'b0) ? usb_data : 8'hFF;
assign usb_data = (usb_avalon_write_n == 1'b0) ? usb_avalon_data_in : 8'hZZ;
assign usb_address = usb_avalon_address;
// Reset the card when this avalon component is reset.
assign usb_reset_n = usb_avalon_reset_n;
endmodule

Do you see anything criticallly wrong? The documentation says that I should just make a new component in SOPC and just make the signals there. But how do I then control stuff like irq, write_n and such? I can't find any way to connect the interrupt to the avalon interrupt by hand. With the above code, I think it's done. And how do I set the timings right? The PDIUSBD12 need 600 ns to register that the cs_n and wr_n has gone low and to take in the data. I just looked at the Compact Flash component and did something similar to what was done there.

Ole
No RepliesBe the first to reply