UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor mpalladino
Visitor
9,822 Views
Registered: ‎04-16-2012

FPGA Keyboard

Hi All,

 

I'm relatively new to FPGA's. With that said I wanted to embark on a project where I could take existing 8051 assembly code instantiate that into an FPGA and have it run on the existing assembly code I have.(It's a simple keyboard) At the end of the day I would like to have a USB engine in there doing all the USB stuff...a UART for a serial keyboard...probably an rs422 module and don't forget ps2. First I would like to make sure this is all possible. Meaning I can port my code relatively easily wthout losing the heart of the code? Do all this on a relatively cheap FPGA.($5-20 bucks FPGA only)

 

I assume this is a common thing to do inside an FPGA but I've only seen the 8051 code in C. Never in strictly assembly. Does anyone know any families which would be good to begin this design?

 

Do you have to pay for the 8051 or does that come with the EDK?

 

From what I understand I need the ISE, EDK, and the SDK so I can do the programming for the 8051. Is this all I need?

 

Any information people have on this I'd like to hear. I'd like to gather as much information as possible.

 

Thanks

0 Kudos
13 Replies
Advisor eilert
Advisor
9,818 Views
Registered: ‎08-14-2007

Re: FPGA Keyboard

Hi,

sorry to say so, but it seems to me that you are totally off the track regarding FPGAs.

Have you ever read a FPGA datasheet? Do you know what IP-Cores are?

Do you have any experience with HDLs? (Verilog or VHDL)

 

ISE is the main tool for Hardware synthesis and implementation inside the FPGA.

EDK and SDK offer tools and additional IP-Cores for Designs including MicroBlaze or PowerPC processor cores. (Maybe ARM too when the new ZYNC Familly is fully available.)

 

So you see, nothing 8051 here.

There may be free 8051 compatible IP cores around, e.g. via opencores.org, but creating a working system from these cores (CPU + several peripherals) will take some time. And doing USB with thge FPGA alone is no thing for newbies. Even professionals prefer to use add on chips like Cypress FX2 controller (which actually includes a 8051 compatible core ;-) ) .

 

Maybe you do some reading first.

 

Regards

  Eilert

0 Kudos
Visitor mpalladino
Visitor
9,811 Views
Registered: ‎04-16-2012

Re: FPGA Keyboard

Hello Eilert,

 

Off track?? Excuse me?

 

I feel like I have done my reading. Perhaps I was a little vague in my post. I have used the ISE with the Spartan3AN starter kit Xilinx provides along with the EDK/SDK using microblaze to say hello world in hyperterm. I have also programmed in verilog to do some simple projects with the same development board.(control the LCD..made muxes...digital music box...stuff like that...simple modules connected together to create an output) I have a baisc understanding of the verilog HDL. I haven't spend much time with VHDL but understand there are at least two main HDL's out there. I'm no pro. But please.

 

When doing my first embedded project using an FPGA I used microblaze and followed the beginner tutorial. I did that a few years ago and remember seeing an available 8051 core in that EDK. EDK version 9.2i(came with dev. board).I wasn't sure if people mainly used the 8051 core available in the EDK or something else. I understand the EDK offers other IP cores. Also, I currently have the code in assembly and wanted to know if it's possible to run 8051's inside an FPGA using only assembly. Do people mainly just use assembly for the embedded 8051 or is C a standard..or is there no stardard?

 

Essentially I"m trying to take a keyboard and put it all inside an FPGA. This means anything from USB, RS422, PS2, Serial, keyboard logic. Im doing this to try and keep costs down, manufacturability, modular design(hardware is the same only the program changes).

 

Maybe an FPGA is the wrong route. I don't know. I'm trying to research the best way of doing this. Any thoughts will help. You mention the Cypress FX2. Let me look at that.

 

 

 

0 Kudos
Advisor eilert
Advisor
9,805 Views
Registered: ‎08-14-2007

Re: FPGA Keyboard

Hi,

indeed, your post, which was your firs one here, was very vague and showed no hint whatsoever that you have done anything with FPGAs before.

Sorry if I got the wrong impression about your skills.

Your second post gives some valuable information to help you with your project.

 

--will continue this post tomorrow--

 

Regards

  Eilert

0 Kudos
Visitor mpalladino
Visitor
9,806 Views
Registered: ‎04-16-2012

Re: FPGA Keyboard

Agreed. Sorry to be so vague. After re-reading my post I am quite guilty. Thanks for your help!

0 Kudos
Historian
Historian
9,795 Views
Registered: ‎02-25-2008

Re: FPGA Keyboard


@mpalladino wrote:

Hi All,

 

I'm relatively new to FPGA's. With that said I wanted to embark on a project where I could take existing 8051 assembly code instantiate that into an FPGA and have it run on the existing assembly code I have.(It's a simple keyboard) At the end of the day I would like to have a USB engine in there doing all the USB stuff...a UART for a serial keyboard...probably an rs422 module and don't forget ps2. First I would like to make sure this is all possible. Meaning I can port my code relatively easily wthout losing the heart of the code? Do all this on a relatively cheap FPGA.($5-20 bucks FPGA only)

 

I assume this is a common thing to do inside an FPGA but I've only seen the 8051 code in C. Never in strictly assembly. Does anyone know any families which would be good to begin this design?

 

Do you have to pay for the 8051 or does that come with the EDK?

 

From what I understand I need the ISE, EDK, and the SDK so I can do the programming for the 8051. Is this all I need?

 

Any information people have on this I'd like to hear. I'd like to gather as much information as possible.

 

Thanks


There are a handful of 8051 cores available. Check OpenCores, for example. Also, Actel provides a free 8051 core, which works well enough, and the tools are free.

 

I suppose the question to ask is: why embed a processor in an FPGA when you can buy a Silicon Labs 8051 for five bucks and it'll run faster than one embedded in an FPGA, it will have MUCH better debug support, and it supports programming in C using all of the usual compilers (SDCC, Keil, etc) and assembly?

 

Voice of experience here: Unless you have a specific Real Good Reason to put a micro in an FPGA, don't bother.

----------------------------Yes, I do this for a living.
Advisor eilert
Advisor
9,786 Views
Registered: ‎08-14-2007

Re: FPGA Keyboard

Hi,

Ok, now let's start from scratch and see what you are about to do.

 

You wrote that you have some existing 8051 Assembly code and that you need a bunch of interfaces (USB, RS422, PS2 etc.) and some Keyboard is involved (something special or standard PC keyboard, which interface?)

 

What was the original hardware that program was running on?

Assembly code can be very hardware dependent, so even changing to a different compatible microcontroller can render your code useless.

Is the function of that code so complex that you can't reengineer it e.g. in C and use some different hardware?

The effort spent for the recoding might be saved later by easing up the hardware design process.

 

If that code is really complex and even moving to some actual 8051 compatible microcontroller would not work without complicated code adaptions then you still could try to build a hardware inside an FPGA that emulates the controller or system the code was running on originally. That means to do it register compatible for all I/Os too. Not a simple task.

Do you have the specification of the original hardware (datasheets, schematics etc.?)

 

The main problem here seems to be to find out the way that has the best ballance of effort and price. Are you going for a single device or will this be some higher volume series? Asking the price for a chip makes no sense for a solitary installation. Every hour of your work is more expensive than that and the whole project might take a little more than a weekend. ;-)

 

Hope this helps to make up your mind on which way you will go with your project.

If you provide some more informations we can discuss this in more deepth.

 

Regards

  Eilert

 

 

Visitor mpalladino
Visitor
9,773 Views
Registered: ‎04-16-2012

Re: FPGA Keyboard


@eilert wrote:

Hi,

Ok, now let's start from scratch and see what you are about to do.

 

You wrote that you have some existing 8051 Assembly code and that you need a bunch of interfaces (USB, RS422, PS2 etc.) and some Keyboard is involved (something special or standard PC keyboard, which interface?)

 

Essentially what I have is a keyboard which under almost all circumstances interfaces with a computer(Windows/Linux). It's software is strictly assembly code running on Atmel's 89S52(8051). The scanning of the keys is all done by the 8051. Essentially using Port 0 it branches out to specific hardware to capacitively sense a key. All the 8051 knows that it bangs some port pins and when a certain line goes high it matched a key and therefore someone pressed that key down. Once sensed it transmits the code to another micro on the PCB which strictly does USB and sends the data upstream to the host. Now this was the case for USB. For RS422 we populate another chip to do the RS422 driving, same with PS2 and even RS232. Those chips are just hardware and don't require any programming.

 

 

What was the original hardware that program was running on?

 

Atmel's 89S52 which is based off the 8051

 

 

Assembly code can be very hardware dependent, so even changing to a different compatible microcontroller can render your code useless.

 

I have a feeling you are correct.

 

 

Is the function of that code so complex that you can't reengineer it e.g. in C and use some different hardware?

The effort spent for the recoding might be saved later by easing up the hardware design process.

 

If I had my way. I would have ported the code to C years ago. This would make it so if a chip went obsolete I could easily port it over so some other chip. Sadly I don't have that luxury. The people upstairs want to keep the "legacy" code because they say it has 15 years of proven goodness. I say grow a pair, go to C, and call it a day. I would like to come up with a really really good reason to start over in C but haven't come up with one yet. I agree re-coding is the better way to go.

 

If that code is really complex and even moving to some actual 8051 compatible microcontroller would not work without complicated code adaptions then you still could try to build a hardware inside an FPGA that emulates the controller or system the code was running on originally. That means to do it register compatible for all I/Os too. Not a simple task.

Do you have the specification of the original hardware (datasheets, schematics etc.?)

 

I have schematics and that's it.

 

The main problem here seems to be to find out the way that has the best ballance of effort and price. Are you going for a single device or will this be some higher volume series? Asking the price for a chip makes no sense for a solitary installation. Every hour of your work is more expensive than that and the whole project might take a little more than a weekend. ;-)

 

This will hopefully be put into production and could potentially make it into 2,000-4,000 products a year.

 

Hope this helps to make up your mind on which way you will go with your project.

Yes! Thanks

 

If you provide some more informations we can discuss this in more deepth.

 

What else would you like to know?

 

Regards

  Eilert

 

 


 

0 Kudos
Teacher eteam00
Teacher
9,764 Views
Registered: ‎07-21-2009

Re: FPGA Keyboard

Please re-read bassman's post in this thread, he makes a good suggestion.  An off-the-shelf 8051-compatible controller (or an ARM-compatible controller) might easily have all the interfaces and capabilities you need, for less work.

 

For example, what is this device missing that you would otherwise get from using an FPGA?  Catalogue 2K qty pricing from Digi-Key is around $2US.

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Advisor eilert
Advisor
9,760 Views
Registered: ‎08-14-2007

Re: FPGA Keyboard

Hi,

I agree to Bobs suggestion.

For your application a microcontroller is cheaper and means probably less work.

If you had a ATMEL device before, there's a small chance that there might be some migration path between the old and some actual device. Maybe ATMEL offers some support (papers etc.) for this. If not you are free to choose any actual 8051 compatible controller that suits your hardware needs best.

 

What's that other chip that does the USB stuff? Some FTDI USB-serial converter?

Are you intending to integrate that function in the new Controller to save chips?

If so, you need some new software for this task, because the old assembler code just forwarded the data to the USB-chip via some other interface.

 

So actually, there's a lot of assembler code that needs rework, and some code yet unwritten for the USB stuff.

How about writing the new code parts in C and include/link the reworked assembly code with this.

So the code change is limited to the absolute minimum and the new functionality can be added more conveniently and based on existing proven(?)  C code too.

 

Regards

  Eilert

 

 

 

0 Kudos
Visitor mpalladino
Visitor
4,751 Views
Registered: ‎04-16-2012

Re: FPGA Keyboard

Hi Eilert,

 

Some great advice here.

 

The chip that does USB is Microchips PIC18F2450. Why they don't do all the keyboarding inside the single USB chip and throw away the 8051 is beyond me and is legacy stuff that was before my time. Pretty sure it gets back to the fact that they don't want to change any code. I'm trying to pick up the mess of this design. It works great but having two micros on there is a bit frustrating and has annoyed me the past couple years. At the end of the day "we are just keyboard" and having two micros seems silly. Right?

 

I am picking up what you guys are laying down in regards to the FPGA path. I guess I'm not all the surprised that the FPGA path could require more work, money, and in the end isn't the best usage of technology for my application. I"m pretty sure Bob said it above the best. "What does using and FPGA gain in your design".......not much in my application sadly. Although it would have been fun to use the Porsche of electronics. FPGA's are really cool devices....well for the geeky EE anyway :) I guess I'll have to stuck with messing around with them for home projects.

 

Your last paragraph is very interesting. I think that may be the best path. Here is what I"m thinking. Correct me if something seems weird.

 

1. See if there is any documentation from Atmel for a migration path from the 89S52(8051) to another device.

 

2. Find a chip or use the one from step 1 and modify the existing assembly code to work with my new chip. Also write the new stuff in C to make changes easy.

 

Does anyone know of chips which may be a good choice for me? I'm going to paw around the web but figured I"d ask anyway. Essentially I'd like to have an 8051 core, usb, RS422, PS2, RS232(not required), and perhaps PWM for our backlighting.

 

-mike

 

 

 

 

 

 

0 Kudos
Teacher eteam00
Teacher
4,745 Views
Registered: ‎07-21-2009

Re: FPGA Keyboard

Does anyone know of chips which may be a good choice for me? I'm going to paw around the web but figured I"d ask anyway. Essentially I'd like to have an 8051 core, usb, RS422, PS2, RS232(not required), and perhaps PWM for our backlighting.

 

  • You can start at digikey.com.  This distributor has an excellent online catalogue and search engine.  Search for "ic usb pwm".
  • You will find 8051 core controllers, but I would recommend flexibility on this -- you will likely end up re-writing most of the source code anyway.
  • RS-422 can be an off-chip transceiver/translator, with a UART on the controller.
  • There are a number of ways to implement PS/2 interface, including bit-banging.  If you support 5V signaling, this will likely require two off-chip FETs for level translation, but there are controllers with PS/2 controllers and 5V signaling.

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Advisor eilert
Advisor
4,736 Views
Registered: ‎08-14-2007

Re: FPGA Keyboard

Hi Mike,

maybe your project leaders should do a little reading. e.g. something like this:

http://agilemindstorm.com/2011/06/20/dead-horse-and-agile/

 

:-)

 

Now this is funny.

The PIC should be capable of doing all the work (or is there some limitation in HW ressources?).

What's the big deal about the keyboards core function in the 8051 code?

Scanning a key matrix and assigning key codes from a table doesn't seem to be such a big thing that one has to cling to som assembler code, while the neccessary changes to the I/O section , even if done with some 8051 compatible processor, require much more and really errorprone changes to the code.

Have you made some analysis what ammount of code would need rework if you would move to some other 8051 controller?

How much of the code actually deals with the core function of coding the keys?

Are your project leaders aware, that when moving between two different microcontrollers the actual CPU core is the least thing to worry about? All CPUs can do the arithmetic-logical-branch stuff more or less efficient. But the attached I/O cores are always very different in the way they need to be controlled. That's the true minefield one is going to step in on a migration path.

 

Yes, you got my points very good. One can see the C language as some sort of advanced macro assembler. 

From linking to inline assembler coding there are several ways to merge these, depending on the actual tool used.

 

Regards

  Eilert

 

 

4,714 Views
Registered: ‎04-09-2012

Re: FPGA Keyboard

Doesn't atmel have newer 8051 chips with USB? Their avr's and arm chips have quite similar peripherals to some of their 8051 chips. They used to have a suggested migration path. Though Silabs 50/100MHz single cycle 8051's are sexier ( for 8051's) But you won't be able to use your old asm code Rewrite in c also allows you to move to arm/arm cortex if needed. Could rewrite in vhdl but more work , more risk , higher cost. Would be interesting to see how much of your old asm would be useable with a 8051 soft core. Probably not much , have to rewrite all the peripheral code?
0 Kudos