Monday, May 13, 2013

New Vim Builds Page

I am now making available frequently-updated 64-bit builds of Vim for Windows here: Vim 64-bit Builds.

Thursday, April 25, 2013

Build LLVM/Clang (3.3) on Windows x64

In order to get clang_complete to work on Windows x64 with Vim x64 and Python x64, libclang.dll must first be compiled from source.

Prerequisites

  • Visual Studio 2010 or 2012
  • Recent Vim x64 with Python27 support
  • Python 2.7 x64
  • CMake for Windows

Build

  1. Checkout llvm and clang using subversion. Trunk is version 3.3 at the time of this writing.
    svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
    cd llvm\tools
    svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
    
  2. Configure using cmake. Tweak the build command below to suit your system.
    cmake C:\absolute\path\to\llvm -DPYTHON_EXECUTABLE="C:\Python27\python.exe" -DSubversion_SVN_EXECUTABLE="C:\Program Files\SlikSvn\bin\svn.exe" -DCMAKE_INSTALL_PREFIX="C:\clang" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86;CppBackend -G "Visual Studio 11 Win64"
    
  3. Build using cmake.
    cmake --build . --config Release
  4. Install using cmake.
    cmake --build . --config Release --target install

Install clang_complete

  1. Use Vundle or Pathogen to install clang_complete.
  2. In your vimrc, point clang_complete to your newly-compiled libclang.dll.
    if has('win64')
        let g:clang_library_path='C:/clang/bin'
    endif
    

Tuesday, November 1, 2011

Nexys 2/Spartan 3E LED blinker and counter

Here's a verilog project I coded for the Nexys 2/Spartan 3E - a simple LED counter and multiplexed 7 segment display counter.

Download project

Monday, October 31, 2011

FT232H

FT232H - High speed USB 2.0 interface. Can communicate via high speed parallel FIFO interface at up to 40MBytes/s. Should be very easy to interface to an FPGA or MCU.

Friday, October 7, 2011

pSRAM memory test for the Nexys 2

This is a very simple pSRAM memory test for the Nexys 2 with the Spartan 3E 500 FPGA. Simply writes and reads back the memory.

Note that the RAM chip on the Nexys 2 board is the MT45W8MW16BGX in a BGA package.

module Main(
 input wire clk,
 output wire [7:0] Led,
 input wire [3:0] btn,
 output wire MemOE,
 output wire MemWR,
 output wire RamAdv,
 output wire RamCS,
 output wire RamClk,
 output wire RamLB,
 output wire RamUB,
 output wire [23:1] MemAdr,
 inout wire [15:0] MemDB
 
);

//Registers
reg [31:0] state = 0;
reg [7:0] rLed;

reg rMemOE = 1;
reg rMemWR = 1;
reg [15:0] rMemDB;
reg [23:1] rMemAdr;


//Static assignments
assign RamCS = 0; //chip select is always low (enabled)
assign RamClk = 0; //clk is disabled in asynchronous mode
assign RamAdv = 0; //address valid can always be pulled low in asynchronous mode
assign RamLB = 0; //lower byte is enabled
assign RamUB = 0; //upper byte is enabled

//Register assignments
assign MemOE = rMemOE;
assign MemWR = rMemWR;
assign MemDB[15:0] = rMemDB[15:0];
assign MemAdr[23:1] = rMemAdr[23:1];

assign Led[7:0] = rLed[7:0];

always @(posedge clk)
begin
 if(btn[0])      //btn[0] is reset/write
  state <= 0;
 else if(btn[1])    //btn[1] is read
  state <= 50;
 else if(btn[2])    //btn[2] just toggles Led[7]
  rLed[7] <= ~rLed[7]; 
 else begin
  case(state)
   0: begin
    rMemAdr <= 23'b0;  //set address to 0
    rMemDB <= 16'h0505;  //write 0x0505 to the data bus
    rMemWR <= 0;   //pull write enable low to write the data
    state <= 10;
    end
   10: begin
    rMemWR <= 1;   //pull write enable to high again
    end
 
   50: begin
    rMemDB <= 16'bzzzzzzzzzzzzzzzz;  //set the data bus to high impedance
    rMemOE <= 0;      //pull output enable low to start a read
    state <= 60;
    end
   60: begin
    rLed[3:0] <= MemDB[7:0];   //set the LEDs to show the data
    state <= 70;
    end
   70: begin
    rMemOE <= 1;      //pull output enable high again
    end
  endcase
 end
end


endmodule

Thursday, September 29, 2011

UBW32 Generic USB demo

I ported and cleaned up the generic USB demo from the Microchip application libraries. The project is designed to work with the UBW32.

Requirements:
  • UBW32 or any other pic32 microcontroller board.
  • PICKIT/ICD/REALICE to program your board, or a linker script to load with the USB bootloader.
Download

Download the project and compile/flash the firmware onto your chip. Open the USB/Device - LibUSB - Generic Driver Demo host program for your operating system. Attach your device to the host and connect.

PIC32 Timer1 example code

The following code snippet opens and uses Timer1 as an interrupt. In your initialization sequence:
//Open Timer1 with 1:8 prescaler (80MHz -> 10MHz), with period of 10, therefore tick = 1MHz.
OpenTimer1(T1_ON | T1_PS_1_8 | T1_SOURCE_INT, 10);
ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2);
INTEnableSystemMultiVectoredInt();
And the interrupt handler:
void __ISR(_TIMER_1_VECTOR, ipl2) _Timer1Handler(void) {
	mT1ClearIntFlag();
	//Your code
}