module mojo_top ( input clk, // 50MHz clock input rst_n, // reset button (active low) output led [8], // 8 user controllable LEDs input cclk, // configuration clock, AVR ready when high output spi_miso, // AVR SPI MISO input spi_ss, // AVR SPI Slave Select input spi_mosi, // AVR SPI MOSI input spi_sck, // AVR SPI Clock output spi_channel [4], // AVR general purpose pins (used by default to select ADC channel) input avr_tx, // AVR TX (FPGA RX) output avr_rx, // AVR RX (FPGA TX) input avr_rx_busy // AVR RX buffer full ) { sig rst; // reset signal .clk(clk) { // The reset conditioner is used to synchronize the reset signal to the FPGA // clock. This ensures the entire FPGA comes out of reset at the same time. reset_conditioner reset_cond; .rst(rst){ // the avr_interface module is used to talk to the AVR for access to the USB port and analog pins avr_interface avr; dff data[8]; // flip-flops to store last character } } always { reset_cond.in = ~rst_n; // input raw inverted reset signal rst = reset_cond.out; // conditioned reset // connect inputs of avr avr.cclk = cclk; avr.spi_ss = spi_ss; avr.spi_mosi = spi_mosi; avr.spi_sck = spi_sck; avr.rx = avr_tx; avr.channel = hf; // ADC is unused so disable avr.tx_block = avr_rx_busy; // block TX when AVR is busy // connect outputs of avr spi_miso = avr.spi_miso; spi_channel = avr.spi_channel; avr_rx = avr.tx; // connect the receiver to the transmitter // to echo the data back avr.tx_data = avr.rx_data; avr.new_tx_data = avr.new_rx_data; if (avr.new_rx_data) // if new data data.d = avr.rx_data; // write it to data led = data.q; // connect the LEDs to our flip-flop } }