Jump to content
Rickta59

neo430 - msp430 compatible FPGA processor

Recommended Posts

For a long time, I have had an interest in FPGA development. You can find boards that come with a JTAG programmer on ebay for less than $20. The following ebay link shows a board similar to the one I had purchased http://www.ebay.com/itm/361568712810  I experimented with it a lot for a while and then I probably got distracted by some new TI toy :)  Occasionally, I would pick it up and try different things with it. However, the cost and form factor of the chips discourages me from doing anything real with it.  For me these things are more of an educational plaything.
 
Yesterday, I noticed the neo430 project on opencores.org. It is an msp430 compatible processor implemented in VHDL. It didn't take me long to get it installed and it actually seems to work pretty well. There are some difference between the neo430 and the msp430. ( see list below for the details ) Using the Altera Cyclone II EP2C5 board I linked above I was able to use the example code to create an msp430 like device with 4K of ROM and 4K of RAM. It runs a serial bootloader over its UART peripheral and allows you to toggle the pins using its parallel port peripheral. It has a simple timer peripheral. It has its own custom peripherals and 'C' header files setup to access those. It comes all setup to use msp430-gcc as a development tool with the device you create.
 
The instructions are pretty complete neo430 instructions  , I just followed them to get started.  For my Altera chip, I used the free web edition of quartus II 13.0.1 sp1 to convert the VHDL code into a loadable bitstream. Once you load that on to the FPGA chip using the USB-Blaster, a serial terminal is used to interact with the bootloader and upload msp430-gcc compiled files.  The provided makefiles automate the msp430 code creation process.  I'm using this on linux and I had to make a few changes to point at the directory where my msp430-gcc is installed. If you are windows user it will probably just work out of the box for you.

I'll try and post more on my experiments.  In the meantime, I thought others might find it interesting.
 
Functional Diagram:
post-190-0-15967900-1477235643_thumb.png
 
Memory Layout:
post-190-0-53969000-1477235699_thumb.png
 

Since the NEO430 is not intended as MSP430 clone. Hence, there are several crucial differences to TI's
original architecture, so existing programs must be modified and re-compiled to successfully run on the
NEO430. The major differences are:
? Completely different processor modules with different functionality (except for MAC unit)
? Maximum of 32kB IMEM and 28kB DMEM
? Specific memory map

Share this post


Link to post
Share on other sites

Here is a slightly modified version of the example blinky led program. The modifications accommodate the leds on my development board, they light up when the pin is low.

// #################################################################################################
// #  < Blinking LED example program >                                                             #
// # ********************************************************************************************* #
// #  Displays an 8-bit counter on the high-active LEDs connected to the parallel output port.     #
// # ********************************************************************************************* #
// # This file is part of the NEO430 Processor project: http://opencores.org/project,neo430        #
// # Copyright 2015-2016, Stephan Nolting: stnolting@gmail.com                                     #
// #                                                                                               #
// # This source file may be used and distributed without restriction provided that this copyright #
// # statement is not removed from the file and that any derivative work contains the original     #
// # copyright notice and the associated disclaimer.                                               #
// #                                                                                               #
// # This source file is free software; you can redistribute it and/or modify it under the terms   #
// # of the GNU Lesser General Public License as published by the Free Software Foundation,        #
// # either version 3 of the License, or (at your option) any later version.                       #
// #                                                                                               #
// # This source is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;      #
// # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     #
// # See the GNU Lesser General Public License for more details.                                   #
// #                                                                                               #
// # You should have received a copy of the GNU Lesser General Public License along with this      #
// # source; if not, download it from http://www.gnu.org/licenses/lgpl-3.0.en.html                 #
// # ********************************************************************************************* #
// #  Stephan Nolting, Hannover, Germany                                               04.03.2016  #
// #################################################################################################


// Libraries
#include <stdint.h>
#include "../../lib/neo430/neo430.h"

// Configuration
#define BAUD_RATE 19200

// Function prototypes
void delay(uint16_t t);


/* ------------------------------------------------------------
* INFO Main function
* ------------------------------------------------------------ */
int main(void) {

  // setup UART
  uart_set_baud(BAUD_RATE);
  USI_CT = (1<<USI_CT_EN_C)  | (5<<USI_CT_SPIPRSC0_C) | (63<<USI_CT_SPICS0_C);

  // intro text
  uart_br_print("\nBlinking LED demo program\n");

  // check if PIO unit was synthesized, exit if no PIO is available
  if (!(SYS_FEATURES & (1<<SYS_PIO_EN_C))) {
    uart_br_print("Error! No PIO unit synthesized!");
    return 1;
  }

  pio_port_set((1<<0|1<<1|1<<2)); // deactivate all LEDs

  uint16_t i = 0; // init counter
  while (1) {
    pio_port_set(~(0x00FF & i++)); // set output port and increment counter
    uart_br_print(".");
    delay(10); // wait some time
  }

  return 0;
}


/* ------------------------------------------------------------
* INFO Stupid delay subroutine
* PARAM t delay
* ------------------------------------------------------------ */
void delay(uint16_t t) {

  volatile uint16_t i = 0;
  while (t--) {
    for (i=0; i<0xFFFF; i++)
      asm volatile ("nop");
  }
}

Here is the terminal output showing the bootloader process:
post-190-0-99203100-1477243300_thumb.png
 
-rick

Share this post


Link to post
Share on other sites

One major thing I forgot to mention was the resources consumed on the EP2C5. With all features enabled it only used about 30% of the logic elements on the chip. The memory sizes you configure determines how many of the M4K ram blocks are actually used. Here I used 4K for RAM and 4K for Code.

 

Flow Status Successful - Sun Oct 23 13:12:09 2016
Quartus II 32-bit Version 13.0.1 Build 232 06/12/2013 SP 1 SJ Web Edition
Revision Name neo430_top
Top-level Entity Name neo430_top
Family Cyclone II
Device EP2C5T144C8
Timing Models Final
Total logic elements 1,393 / 4,608 ( 30 % )
Total combinational functions 1,234 / 4,608 ( 27 % )
Dedicated logic registers 640 / 4,608 ( 14 % )
Total registers 640
Total pins 45 / 89 ( 51 % )
Total virtual pins 0
Total memory bits 86,400 / 119,808 ( 72 % )
Embedded Multiplier 9-bit elements 2 / 26 ( 8 % )
Total PLLs 0 / 2 ( 0 % )

Share this post


Link to post
Share on other sites

I had put neo430 down for almost a year and I'm coming back to it with renewed vigor.  I came across this wiki that provides some useful information about getting started with the $15 altera ep2c5 board you find on ebay/aliexpress.

http://land-boards.com/blwiki/index.php?title=Cyclone_II_EP2C5_Mini_Dev_Board

The most useful info information there might be the tip about setting the default pin state to input with a weak pull up so you don't heat overload the 3.3 regulator.  I had noticed the regulator getting hot and didn't realize it was because of some zero ohm resistors on the board that are only used if you are using an ep2c8 model.

I cloned the neo430 github project and plan on adding a branch that has changes that are specific to the ep2c5 mini dev board.  I plan to upload a Quartus II preconfigured project for neo430. I'll also add a minor change I made to the gpio peripheral which allows you to toggle a pin with a single set statement. No more XORin the existing GPIO value, just set it.  This is something I always wished I had on real msp430 chips. Now I can add that stuff myself. Yay me!  See my comments on the issue https://github.com/stnolting/neo430/issues/1  

BTW: I can now toggle one or more pins with a single asm statement this yield a ~4MHz frequency when used in the tight toggle code below when running the ep2c5 at 100MHz.

... this code ...
  while (1) {
    GPIO_TOGGLE  = 0b111;
  }

... becomes this ...
<.L10>:
  be:   6c 4d           mov.b   @r13,   r12     ;
  c0:   0c 93           cmp     #0,     r12     ;r3 As==00
  c2:   1e 20           jnz     $+62            ;abs 0x100
  c4:   b2 40 05 00     mov     #5,     &0xffb2 ;
  c8:   b2 ff 
  ca:   7c 40 07 00     mov.b   #7,     r12     ; initial value of the GPIO port

000000ce <.L15>:
  ce:   82 4c b4 ff     mov     r12,    &0xffb4 ;  this is the GPIO_TOGGLE=0b111; statement
  d2:   30 40 ce 00     br      #0x00ce         ;

000000d6 <.L3>:
...

-rick

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...