So you found some cool VHDL/Verilog code on the Internet and want to use it with DesignLab? Have no fear, this will get you sorted!
Step 1 – Define Your Chip
In this example, we came across a code of a chip that converts a keyboard to a joystick. In this code, if you connect a keyboard to the PS/2 connector and hit the up arrow, it is going to fire up the joystick up, and so on. To use this chip in DesignLab:
Create a New Design Library
Go to DesignLab and create a new DesignLab Library from the Papilio menu. Give it a name (here we name it hamster_keyboard).
This will open a library
Create a New VHDL file
Open the chip designer. To bypass the existing templates and add the VHDL files, right click anywhere and choose “New Source” from the menu.
Choose VHDL Module and give it a name (Here “KeyboradJoystick.vhd), then click Next.
A screen will appear that asks you to define the ports. Click next to skip, as the ports are already defined in the code.
Then click Finish
Now you can see the VHDL file in the Designer.
Copy the Code to the VHDL File
Go to the webpage and copy the code, Then paste it in the VHDL file you’ve just created. Make sure you overwrite the code in the VHDL file with the copied code. Save the file.
Turn the VHDL File into A Schematic Symbol
At the bottom left of the screen, chose “Create Schematic Symbol”
Go to “Symbols” tab, select the library you’ve just created, then drag the KeboardJoystick chip and drop it in the workspace.
Step 2 – Define Your Circuit
Create an Example Circuit that Uses the Chip
Click on the DUO circuit
Click on the Papilio DUO Circuit
Go to the “Symbols” tab and choose the chip and drag it.
Connect the Circuit
First, take a look at the online reference of the computing shield connect to the Papilio DUO, to find out which pins the PS/2 connected to.
From the table, the second PS/2 CLK is connected to the Arduino pin D39.
Go to “Design” tab, and click on Utility.
To pick up the Arduino_39 pin:
1. Click on the “Name” icon.
2. Choose “Pick name by clicking”.
3. Click on the “Arduino_39” pin
Go back to the circuit,and add I/O markers to the connectors.
Delete the I/O marker connected to the Button (won’t be used).
Click on the “Name” icon to get the name that you picked earlier.
Click on the CLK connector to connect it to Arduino_39.
Repeat the pick up and rename steps for all of the other connectors. For now connect the joystick outputs to LEDs on the computing shield. Refer to the LED table in the reference to connect each LED to the corresponding Arduino pin.
To add the clock connector, Pick its name from “Misc Pins”.
The final chip will look as follows:
Step 3 – Generate Programming File
Go to the “Design” tab, choose the Papilio DUO circuit, then click on “Generate Programming File” to create the bit file.
Step 4 – Create a pdf Export of the Circuit
From the File menu, choose print, and print the schematic as a pdf file using any third party pdf writer.
Example of How to Use the Symbol and the Circuit
Create a new blank circuit.
Change the board to the Papilio DUO, to see it correct.
If you change the word “blank” to “hamster_keyboard” then click “View”, you will see the circuit you’ve just created.
Full Video Walkthrough