OpenFPGA/jupyter_example.ipynb

276 lines
7.6 KiB
Plaintext
Raw Normal View History

2018-06-27 12:54:00 -05:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-07-06 14:36:55 -05:00
"# Getting Started with Jupyter and FPGA-SPICE on Linux\n",
"\n",
2018-06-27 12:54:00 -05:00
"1. Install Anaconda: https://conda.io/docs/user-guide/install/linux.html \n",
"2. Run anaconda-navigator: `~/anaconda-navigator`\n",
"3. Launch jupyter notebook from anaconda navigator\n",
"\n",
"In the jupyter interface, navigate to the location of a notebook and view it."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-06-29 14:24:18 -05:00
"The repository contains a submodule, so you need to get it as well:"
2018-06-29 12:16:13 -05:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-06-29 14:24:18 -05:00
"Build the VPR tool with the FPGA-SPICE functionality:"
2018-06-29 12:16:13 -05:00
]
},
{
"cell_type": "code",
2018-07-03 16:04:09 -05:00
"execution_count": 38,
"metadata": {
"scrolled": true
},
2018-06-29 12:16:13 -05:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2018-06-29 14:24:18 -05:00
"Wait for make to finish with a return code of 0.\n"
2018-06-29 12:16:13 -05:00
]
},
{
"data": {
"text/plain": [
"0"
]
},
2018-07-03 16:04:09 -05:00
"execution_count": 38,
2018-06-29 12:16:13 -05:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2018-06-29 14:24:18 -05:00
"import os\n",
2018-06-29 12:16:13 -05:00
"# move to the directory with the Makefile\n",
"os.chdir(\"./tangxifan-eda-tools/branches/vpr7_rram/vpr/\")\n",
"# run make\n",
"print (\"Wait for make to finish with a return code of 0.\")\n",
"os.system(\"make\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To run FPGA-SPICE, define its location:"
]
},
{
"cell_type": "code",
2018-07-03 16:04:09 -05:00
"execution_count": 39,
2018-06-29 12:16:13 -05:00
"metadata": {},
2018-06-27 12:54:00 -05:00
"outputs": [],
"source": [
2018-06-28 13:47:59 -05:00
"# set this to the location of the vpr executable file\n",
2018-06-29 12:16:13 -05:00
"fpga_spice = \"~/OpenFPGA/tangxifan-eda-tools/branches/vpr7_rram/vpr/vpr\""
2018-06-27 12:54:00 -05:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define an architecture file and a circuit file:"
]
},
{
"cell_type": "code",
2018-07-03 16:04:09 -05:00
"execution_count": 40,
2018-06-27 12:54:00 -05:00
"metadata": {},
"outputs": [],
"source": [
2018-07-03 16:04:09 -05:00
"arch = \"./tutorial/example_arch.xml\"\n",
"circuit = \"./tutorial/example_circuit.blif\""
2018-06-27 12:54:00 -05:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Run vpr:"
]
},
{
"cell_type": "code",
2018-07-03 16:04:09 -05:00
"execution_count": 41,
2018-06-27 12:54:00 -05:00
"metadata": {},
2018-06-29 14:24:18 -05:00
"outputs": [
{
"data": {
"text/plain": [
2018-07-03 16:04:09 -05:00
"256"
2018-06-29 14:24:18 -05:00
]
},
2018-07-03 16:04:09 -05:00
"execution_count": 41,
2018-06-29 14:24:18 -05:00
"metadata": {},
"output_type": "execute_result"
}
],
2018-06-27 12:54:00 -05:00
"source": [
2018-06-29 12:16:13 -05:00
"\n",
2018-06-27 12:54:00 -05:00
"command_line = fpga_spice + \" \" + arch + \" \" + circuit\n",
"os.system(command_line)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-07-02 12:12:28 -05:00
"This will bring up a graphical display of how the circuit is being placed on the FPGA. Press the `Proceed` button to step to the final placement, press `Proceed` again to step to the routing. Press the `Exit` button to exit the display.\n",
2018-06-27 12:54:00 -05:00
"\n",
"To run VPR without the display, use the command `-nodisp`"
]
},
{
"cell_type": "code",
2018-07-03 16:04:09 -05:00
"execution_count": 23,
2018-06-27 12:54:00 -05:00
"metadata": {},
"outputs": [],
"source": [
"command_line_nodisp = command_line + \" -nodisp\"\n"
]
},
{
"cell_type": "code",
2018-07-03 16:04:09 -05:00
"execution_count": 36,
2018-06-27 12:54:00 -05:00
"metadata": {},
2018-06-29 14:24:18 -05:00
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
2018-07-03 16:04:09 -05:00
"execution_count": 36,
2018-06-29 14:24:18 -05:00
"metadata": {},
"output_type": "execute_result"
}
],
2018-06-27 12:54:00 -05:00
"source": [
"os.system(command_line_nodisp)"
]
2018-06-29 14:24:18 -05:00
},
2018-07-03 16:04:09 -05:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-07-06 14:36:55 -05:00
"When you ran the tool, a number of text output files are created that report on what the tool did. Open the file \"OpenFPGA/tutorial/example_circuit.place\" in a text editor and note on line 2: \n",
"\n",
"> `Array size: 2 x 2 logic blocks`\n",
"\n",
"This is a report that when the tool placed and routed the logic, it ended up in a 2 x 2 grid."
2018-07-03 16:04:09 -05:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now open the file \"OpenFPGA/tutorial/example_arch.xml\" in a text editor. Go to line 51 and change:\n",
"\n",
"<pb_type name=\"io\" capacity=\"1\">\n",
"\n",
"to:\n",
"\n",
"<pb_type name=\"io\" capacity=\"3\">\n",
"\n",
"Now, instead of each input/output block only having 1 input or output, they can have 3 inputs or outputs.\n",
"\n",
"Run the tool again:"
]
},
2018-06-29 14:24:18 -05:00
{
"cell_type": "code",
2018-07-03 16:04:09 -05:00
"execution_count": 34,
2018-06-29 14:24:18 -05:00
"metadata": {},
2018-07-03 16:04:09 -05:00
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"os.system(command_line_nodisp)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2018-07-06 14:36:55 -05:00
"Re-open the file \"OpenFPGA/tutorial/example_circuit.place\" in a text editor and note that the logic is now placed in one block:\n",
"\n",
"> `Array size: 1 x 1 logic blocks`\n",
2018-07-03 16:04:09 -05:00
"\n",
"The simple change to the number of inputs or outputs per I/O block let the placement and routing tool use less space on the FPGA for the circuit."
]
2018-07-06 14:36:55 -05:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The Architecture format\n",
"An FPGA architecture is specified in an XML file and is wrapped in an `<architecture>` tag. `example_arch.xml` defines a simple FPGA.\n",
"\n",
"Line 18 has the `<models>` tag which would describe `BLIF` circuit model names that the FPGA accepts. This architecture is simple enough to not need any additional models beyond the default `.names .latch .input .output`.\n",
"\n",
"Line 23 has the `<layout>` tag which specifies how the FPGA grid will be laid out. For this example: `<layout auto=\"1.000000\"/>` specifies an automatic grid with an aspect ratio of 1.0. A specific width and heigh could be specified instead of the automatic layout.\n",
"\n",
"Line 24 begins the `<device>` tag which characterizes the components of the FPGA. `<sizing>` specifies the resistance of the minimum-width nmos and pmos transistors. `<area grid_logic_tile_area>` is used as an estimate of the size of one grid tile.\n",
"\n",
"Line 28 is the `<chan_width_distr>` section which sets the relative widths of the routing channels in various parts of the FPGA. Here, all channels are set to be distrubuted uniformly.\n",
"\n",
"Line 33 is the `<switch_block>` tag which specifies the pattern of the switches used to connect the block routing segments. \n",
"\n",
"Line 35 is the `<switchlist>` section which specifies the switches used to connect wires and pins together. Resistance, in/out capacitance, delay through the switch, and component size.\n",
"\n",
"Line 38 is the `<segmentlist>` section that specifies kinds of wire segments and their properties such as resistance and capacitance. `<sb type=\"pattern\">1 1</sb>` describes a pattern on a 1-length wire where there is a switch box between each grid element. `<cb type=\"pattern\">1</cb>` describes a pattern on a 1-length wire where there is a connection box at each grid element.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
2018-06-27 12:54:00 -05:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}