Posts Tagged ‘How To’

Recreating Nintendo Chiptunes with FPGA and the 6502 processor

Tuesday, July 12th, 2016

https://www.youtube.com/watch?v=rf_p3-8fTo0

Greetings FPGA lovers! Today’s project explores the possibility of using FPGA in combination with other processors to recreate the amazing Nintendo Chiptunes or Soundtracks that an entire generation of gamers are used to. The project uses a combination of FPGA with Verilog and the 6502 processor along with a Nesdev APU for audio generation.

The Hardware required for the project consists of the NIOS II FPGA, 6502 processor, Nesdev APU, SD card reader and a few other components needed to create the three primary blocks which are the timer block, length counter block and an envelope unit. These 3 blocks use a network of Mixers and PIOs besides the 5 channels available on the APU.

Out of the 5 channels available on the APU, only 4 channels have been used by the developers since the fifth channel (Delta Modulation Channel) is a time consuming endeavour. However the project does successfully emulate perfect chiptunes with the hardware. A detailed explanation of the Hardware used can be found here.

The coding used for this project is a combination of Verilog and C since FPGA and the 6502 are used. The Verilog Coding is used to extract Nintendo Sound Format files (.nsf) from the SD card reader onto the FPGA. The NSF files can be loaded on to the FPGA through the 6502 processor which has been coded in the C language using standard functions. NSF files can be stored on the SD card using a computer.

The NIOS II FPGA acts as an NSF player in this particular project.  It can be used to control playback, stop tracks or forward and rewind to the next or previous track.

Using just 4 channels in the APU the developers have done an amazing job and an example of the fruits of their labour (and an inspiration!) can be seen here.

 

By A. Heil and S. Zhao

Critical Tips to Build Your Own C88 Homebrew Computer with FPGA

Thursday, June 30th, 2016

https://www.youtube.com/watch?v=LP7s1XPLMyI

Greetings FPGA lovers! Today’s post is about building your own mini computer using FPGA. The project has been inspired by the first SSEM, popularly called the Manchester baby. The project resembles its inspiration in certain aspects, but being a homemade CPU with minimal components and coding, the specs are not as formidable as the SSEM.

The author has used a standard FPGA Papilo one 500k board, an 8×8 LED strip and a set of switches. The system has been designed for a total RAM of 64 bits, and the LED strip shows the RAM configuration every time data is entered at a new address. Besides this, the author has also used a rechargeable battery, charging circuit, clipper circuit to avoid excess voltage and a number of peripheral ICs.

The coding followed for FPGA is based on simple VHDL (.vhd) and being an open source project, the author has shared all VHDL code here. The CPU is programmed directly using the address and data switches. A number of values can be stored just by setting the CPU on the User mode and entering data to the addresses of the 64 bit RAM.

The system also has an adjustable clock which helps while simulating and running the code in variable clock speeds. The author has successfully demonstrated through the video that the CPU can work as a Random number Generator (from 1 to 6) and a pendulum. Besides this the CPU can also be connected to external components like an array of LEDs for clarity of output.

Though the FPGA based C88 Homebrew CPU has limited RAM and storage capabilities, it is still a great start to create experimental modules and platforms using FPGA that can host a number of applications.

Have Fun!

 

By Daniel Bailey

How to Synthesise Music with YM 2151

Thursday, June 23rd, 2016

tumblr_m9uu4ior111rsz87f

Hello FPGA lovers! Today we are going to share another instalment of our YM 2151 post series.

According to the author of the original article (in Spanish), the best way to produce sound using the YM 2151 is to use the 6809 assembler which is a cross targeting assembler seen usually in Motorola and Hitachi Devices. The author has made use of a MAME or a Multiple Arcade Machine Emulator which is the best platform for recreating arcade hardware since conventional FPGA Tools are unavailable for this project (in Spanish).

The author has simulated a project in MAME and has shared the code and registry values along with its explanation. This is more than a blessing in disguise since there is very little documentation regarding the actual simulation and synthesis of sound with the YM 2151 available on the Internet.

The Registry values, name and a short description regarding the function of each register is given in a comprehensive table by the author. The most important of these registry value combinations are:

  • Registry $60- $7F with Value $ 00 for volume.
  • Registry $20 with value $C for Left Right output control.
  • Registry $48 with value $4A for the notes and transposing it through octaves of 8 notes

Though there are a number of other registers given by the author of equal significance, the most important of these is the above quoted three registers as they play a pivotal role in sound production.

The author has also shared the asm 6809 assembler code. The table of registers executed in the code (in Spanish) can however produce a sound just once. To repeat these sounds and modulate frequencies to get a set of notes to play actual music might seem a bit tedious as there will be a need for repeated execution of the source code with some variations in registry values to produce different sounds.

 

By Jotego

Using the YM 2151 for Noise Generation

Tuesday, June 21st, 2016

tumblr_m9uuf0wzKx1rsz87f

Hi there FPGA lovers! Here we have another release of our series of YM2151 posts.

To recreate the YM 2151 in FPGA using VHDL, every aspect of the YM 2151 needs to be mapped on to the recreation platform. However an interesting aspect regarding the YM 2151 is that it uses random values for generation of noise (in Spanish) sound outputs like shocks, explosions and other disruptive sounds. While a general range of the signals used to generate this noise can be sampled, the YM 2151 has close to 18 bits for random signal generation which leads to a total of 218 signals.

The YM 2151 however uses a Linear Feedback Shift Register for this random sequence generation, and this considerably narrows down the possibility from more than a hundred thousand samples to a very narrow range. The output noise sequence can be predicted because of the feedback element, as every feedback signal can only have one selected output.

The MAME Source code for the emulator consists of a code for generating noise. This code has been used by the author to share a set of 256 samples. Though the samples appear to be seemingly random at first, a definitive pattern can be decoded from the samples depending upon the feedback given.

The Berlekamp- Massey Algorithm was used by the author to conclude that a definite relationship exists between the feedback and generated sequence for all bits except 0 and 4, contrary to the assumed 0 and 8 in the beginning. However the fact that the outputs after 0 and 4 cannot be predicted leads to the fact that there might be more than 218 samples. Thus from a set of more than hundred thousand random signals to generate noise in the YM 2151, the author has narrowed down the  possibility to a handful of feedback signals which can be used to create the clone of YM 2151 in Verilog for FPGA.

 

By Jotego

Understanding the YM 2151- YM 3012 Relationship

Thursday, June 16th, 2016

2015-01-03-09-57-35

Hi FPGA lovers! In our conquest to find studio quality sound, we stumbled upon the YM 2151 FM Synth Chip which has been used by Yamaha from time immemorial in a number of their electronic keyboards and arcade games. The YM 2151 has a Digital output rather than an analog output and this makes it ideal for further signal processing using DSP. However due to the absence of an on chip DAC, the YM 2151 needs a suitable DAC chip that does not add substantial noise while analog reconstruction.

Today’s post is a detailed study of the YM 2151 and its coupling with YM 3012 DAC which are almost like inseparable siblings of the Yamaha family. The YM 2151 is a 24 pin IC which gives a 16 bit output.  The first 3 bits have no significant value, whereas the next 10 bits in order are the significant bits or mantissa and the last 3 bits are the exponents. The author has conducted a number of measures for a fixed value of supply voltage and has shared the results in his post.

The 3 parameters of concern are “d”, “n” and “m” which are the value of mantissa, exponent value and size of LSB respectively. The output voltage of the chip is given by a fixed relationship between these parameters where Vout= m*d + n.

From this result, the Verilog code for YM 3012 in the post starts making sense. The code has been designed around the fact that the base voltage is Vdd/2. However no explanation was given as to why this particular voltage was chosen. From this result, we deduce that Vdd/2 is the principle value because it supports maximum swing in positive and negative directions. This way the 10 bit resolution of the mantissa can be put to full use to produce the desired harmonic frequencies of high quality and clarity.

This is the reason why the YM 3012 DAC is best for this Synth chip, because it is essentially the second half of Yamaha’s FM Synth Chip design. The chip has been broken into two parts (the 2151 and 3012) to give the benefit of getting a 16 bit Digital output for further processing before reconstruction of the analog signal.

This makes the YM 2151 perfect for creating sound boards. The YM 2151 can be used in combination with a FPGA to recreate any themes. The FPGA adds a degree of flexibility in the chip’s output since the output of the YM 2151 is digital and can be easily processed by the FPGA.

 

By Jotego

Create Studio Quality Sound with YM 2151 and FPGA

Tuesday, June 14th, 2016

https://youtu.be/JSfBxKBUdKk

Hello FPGA lovers! Today’s post is about making real studio quality music rather than the monotone buzzers from conventional circuits. FPGAs can be used to create monotone sounds such as beeps by using the right combination of DACs and buzzers. However these devices cannot be used to create studio quality sound that not only plays over a harmonic range of frequencies but also sounds professional to hear. The YM 2151 FM Synth chip is one chip that can be coupled with the FPGA to create great sound and even tweak it to an extent by using the YM 2151- FPGA combination for driving the chip.

The Project in focus is the sound board of the arcade version of the popular game Double Dragon. The schematic for this project has been given by the author in the first post. The YM 2151 is a chip that outputs digital data, and as a result a DAC chip will be necessary before coupling the output to a speaker.

However, this digital output is a blessing in disguise since the output from the IC can be filtered for noise, adjusted for pitch variations and converted to almost any desired form with the FPGA. A Papilio Plus FPGA Board, a bread board, jumper wires, Arcade Mega Shield for Interfacing, PS2 Keyboard Controller, VGA Controller, Hexy module and the YM 2151 are the main hardware components you will need for this project besides a few other peripherals seen in the schematic.

The coding follows conventional VHDL (.vhd) for the Papilo FPGA that can be executed in Xilinx or similar software.  The code execution has been explained in detail in the second post in the thread along with 3 screenshots that shows the code execution and necessary plots. The code is available towards the end of the article.

No more excuses to keep playing with just beeps…!

By Alex

How to Build an Automated Intelligent Room Lighting System with FPGA

Thursday, June 9th, 2016

https://youtu.be/k5gNt69FuBU

Hello FPGA lovers! The project in focus today is aimed at creating an Intelligent Room Lighting System with FPGA, where you can bid adieu to the use of switches! The system is powered by an FPGA board connected to a set of LEDs that turn on depending on the number of people in the room. This project has been designed for 8 LEDs, hence 8 people, and when there is no one in the room, the LEDs switch off themselves in 60 seconds.

The materials used for the project are a FPGA Board, 7 LEDs, 7 Resistors, Jumper wires, a micro USB cable and a breadboard. This implementation is a miniaturized model of the actual project, and the things you will need for that are relays, bulbs instead of LEDs, and sensors to detect the number of people in the room.

The author has divided the entire project into 5 modules, whose significance and role have been explained thoroughly from Step 3 to Step 8. This implementation uses the 7 segment display on the FPGA Board used by the author for the 60 second countdown. This saves the cost on buying and interfacing an additional 7 segment display on other FPGA boards, so you may need it. The project uses switches on the FPGA for determining the number of people in the room. This can be replaced with sensors for real scenario cases.

The author has attached a zip file containing the code for the project in Step 9. The code is written in VHDL (.vhd) and has been broken down into modules just like the steps in the project. The code logic is relatively simple to follow and can be easily modified to incorporate sensors and increase or decrease the number of lights in the room.

With the successful implementation of this project in reality, you can light up your room depending on the number of people in it, and completely forget about turning the lights on and off!

By RichardNLe

9 Steps to Create a LED FSM to Measure Power with FPGA

Tuesday, June 7th, 2016

F8F6Q5PIHS3RPMB.MEDIUM

Hi there FPGA geeks! Power monitoring is a big step when it comes to analysis and subsequent models used for power conservation. The project for today is building an FSM (finite state machine) with a LED as its output and FPGA as its core to measure the power output by the LED when it is active. The IR sensor detects motion and switches on an LED, whose power is measured by the board. This FPGA LED FSM project can be extended to real life scenarios such as measuring the power of fans and other individual electric components in the house to control and conserve power consumption.

The Hardware requirements for this miniaturized model are an IR motion sensor, a LED, a transistor, a FPGA Board and jumper wires. The black box diagram for the project is given in Step3. The wiring instructions are given in Step 8, and the description for the many modules used in this project have been given in the preceding step.

The code has been segregated into modules and has been written using VHDL (.vhd). The VHDL files are available for download from Step 5 along with the XDC master file necessary for the FPGA Board Port Map implementation, you may need to adapt this to your own needs. The code has been written in modules, and can be modified to measure power of any device connected to the board provided its consumption per second is known.

This project can only be used to measure the power consumption of a device for 15 seconds due to circuit limitations. However additional displays and clocks can be used to extend this time frame provided the code has been tweaked on properly.

By harlowchris