Skip to content

Instantly share code, notes, and snippets.

@staticfloat
Last active December 10, 2015 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save staticfloat/646a973ef132ee0f7c0a to your computer and use it in GitHub Desktop.
Save staticfloat/646a973ef132ee0f7c0a to your computer and use it in GitHub Desktop.
Minispartan3 UART debugging
#include <stdio.h>
#include <stdlib.h>
#include <xio.h>
#include <xiomodule.h>
#include <xparameters.h>
XIOModule xio;
int main()
{
// Start GPIO
XIOModule_Initialize(&xio, XPAR_IOMODULE_0_DEVICE_ID);
microblaze_register_handler(XIOModule_DeviceInterruptHandler, XPAR_IOMODULE_0_DEVICE_ID);
XIOModule_Start(&xio);
// Turn on LEDs to show we are alive
XIOModule_DiscreteWrite(&xio, 1, 0x3);
// Print out a status message,
xil_printf("Hello World!\r\n");
while( true ) {
unsigned char cmd = XIOModule_RecvByte(STDIN_BASEADDRESS);
xil_printf("CMD: 0x%x\r\n", cmd);
}
}
NET "CLK_32MHZ" LOC = P85;
NET "LEDS<0>" LOC = P20;
NET "LEDS<1>" LOC = P19;
NET "LEDS<2>" LOC = P16;
NET "UART_RX" LOC = P88;
NET "UART_TX" LOC = P86;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity top is
port (
-- LED outputs
LEDS : out std_logic_vector(2 downto 0);
-- Built-in oscillator
CLK_32MHz : in std_logic;
-- UART pins to talk to FT2232D chip, which sends over USB
UART_RX : in std_logic;
UART_TX : out std_logic
);
end top;
architecture Behavioral of top is
component softcore
port (
Clk : in std_logic;
Reset : in std_logic;
UART_Rx : in std_logic;
UART_Tx : out std_logic;
GPO1 : out std_logic_vector(31 DOWNTO 0)
);
end component;
-- Signal to link GPO1 to LEDs
signal GPO1 : std_logic_vector(31 downto 0);
begin
-- Instantiate our softcore
mcs : softcore
port map (
Clk => CLK_32MHz,
UART_Rx => UART_RX,
UART_Tx => UART_TX,
RESET => '0',
GPO1 => GPO1
);
-- Tie GPO1 signal to LEDs
LEDS <= GPO1(2 downto 0);
end Behavioral;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment