Clean codes

This commit is contained in:
Xifan Tang 2018-09-14 13:16:26 -06:00
parent 0bfbc9b0aa
commit c7783575d9
1 changed files with 0 additions and 356 deletions

View File

@ -1,356 +0,0 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Getting Started with Jupyter and FPGA-SPICE on Linux\n",
"\n",
"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": [
"The repository contains a submodule, so you need to get it as well:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Build the VPR tool with the FPGA-SPICE functionality:"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Wait for make to finish with a return code of 0.\n"
]
},
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import os\n",
"# 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",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"# set this to the location of the vpr executable file\n",
"fpga_spice = \"~/OpenFPGA/tangxifan-eda-tools/branches/vpr7_rram/vpr/vpr\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define an architecture file and a circuit file:"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"arch = \"./tutorial/example_arch.xml\"\n",
"circuit = \"./tutorial/example_circuit.blif\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Run vpr:"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"command_line = fpga_spice + \" \" + arch + \" \" + circuit\n",
"os.system(command_line)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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",
"\n",
"To run VPR without the display, use the command `-nodisp`"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"command_line_nodisp = command_line + \" -nodisp\"\n"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"os.system(command_line_nodisp)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now open the file \"OpenFPGA/tutorial/example_arch.xml\" in a text editor. Go to line 5 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:"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"os.system(command_line_nodisp)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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",
"\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."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Changing the Architecture\n",
"We'll make some changes to the architecture file and see how the output changes. To begin, set up the location of the vpr executable, the input files, and the vpr options. Then run the tool:"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# set this to the location of the vpr executable file\n",
"vpr = \"~/vtr-verilog-to-routing/vpr/vpr\"\n",
"arch = \"~/OpenFPGA/tutorial/v8_example_arch.xml\"\n",
"circuit = \"~/OpenFPGA/tutorial/example_circuit.blif\"\n",
"# turn on the graphic display\n",
"options = \"--disp on\"\n",
"# set up the command line\n",
"command_line = vpr + \" \" + arch + \" \" + circuit + \" \" + options\n",
"\n",
"import os\n",
"os.system(command_line)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"That will bring up a display of the FPGA and how the circuit was laid out. Press `Proceed` twice to step through the complete tool cycle, or just press `Exit` to quit.\n",
"\n",
"You can see that there are I/O blocks around the perimeter of the layout and a 2x2 grid of complex logic blocks (clb) in the center. Currently, each I/O block only allows for one connection in or out. Our circuit `example_circuit.blif` specifies 3 inputs and 4 outputs, so we should be able to reduce the number of I/O blocks by enabling more that one input or output on each block.\n",
"\n",
"Open the architecture file `~/OpenFPGA/tutorial/v8_example_arch.xml`, go to line 58 and change `capacity=1` to `capacity=3`. Run the tool again."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.system(command_line)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now the I/O blocks around the perimeter have 3 slots for an input or 3 slots for an output. \n",
"\n",
"Currently, the architecture only has one basic logic element (ble) in each clb. Let's change the architecture to put four bles in a clb. Go to line 111 and change `<output name=\"O\" num_pins=\"1\"/>` to `<output name=\"O\" num_pins=\"4\"/>`. That will change the number of ouput pins in the clb.\n",
"\n",
"At line 117 change `<pb_type name=\"ble4\" num_pb=\"1\">` to `<pb_type name=\"ble4\" num_pb=\"4\">`. That puts 4 bles in the clb. Note that the ble is named `ble4` and continue to the `<interconnect>` section on lines 162-168.\n",
"\n",
"In the `<interconnect>` on lines 161-167 change all instances of `ble4[0:0]` to `ble4[3:0]`. That wires up all four of the bles inside the clb.\n",
"\n",
"Run the tool again."
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import os\n",
"os.system(command_line)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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
}