Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tapasco
tapasco
Commits
7a96aa1a
Commit
7a96aa1a
authored
Oct 25, 2017
by
Jens Korinth
Browse files
Implement LED plugin for PyNQ platform
parent
4889992d
Changes
2
Hide whitespace changes
Inline
Side-by-side
platform/pynq/plugins/leds.tcl
View file @
7a96aa1a
...
...
@@ -23,25 +23,57 @@
namespace eval leds
{
set default_led_pins
[
list
"/uArch/irq_0"
]
proc get_led_inputs
{
inputs
}
{
if
{[
llength $inputs
]
> 6
}
{
puts
" WARNING: can only connect up to 6 LEDs, additional inputs will be discarded"
proc get_width
{
input
}
{
set l
[
get_property LEFT $input
]
set r
[
get_property RIGHT $input
]
return
[
expr $l - $r + 1
]
}
proc calc_total_width
{
inputs
}
{
set w 0
foreach i $inputs
{
incr w
[
get_width $i
]
}
return $w
}
proc split_input
{
input
}
{
set width
[
get_width $input
]
set name
[
get_property NAME $input
]
set pins
{}
set old_inst
[
current_bd_instance .
]
set cell
[
create_bd_cell -type hier
"
${name}
_splitter"
]
current_bd_instance $cell
for
{
set i 0
}
{
$i
< $width
}
{
incr i
}
{
set slice
[
tapasco::createSlice $
{
name
}
_$i $width $i
]
connect_bd_net $input
[
get_bd_pins -of_objects $slice -filter
{
DIR == I
}]
lappend pins
[
get_bd_pins -of_objects $slice -filter
{
DIR == O
}]
}
current_bd_instance $old_inst
return $pins
}
proc get_led_inputs
{
inputs
}
{
set rlist
[
list
]
for
{
set i 0
}
{
$i
< 6 &&
[
llength $inputs
]
> $i
}
{
incr i
}
{
set pin
[
lindex $inputs $i
]
puts
" LED
$i:
$pin
"
lappend rlist
[
get_bd_pins $pin
]
foreach i $inputs
{
set pin
[
get_bd_pins $i
]
set width
[
get_width $pin
]
puts
" LED:
$pin
\[
width:
$width
\]
"
if
{
$width
> 1
}
{
set split_pins
[
split_input $pin
]
foreach p $split_pins
{
lappend rlist $p
}
}
else
{
lappend rlist
[
get_bd_pins $pin
]
}
}
if
{[
llength $inputs
]
< 6
}
{
set total_width
[
calc_total_width $rlist
]
if
{
$total
_width < 6
}
{
# create tie-off constant one
set one
[
tapasco::createConstant one 1 0
]
set onepin
[
get_bd_pins -of_objects $one -filter
{
DIR ==
"O"
}]
for
{}
{
$i
< 6
}
{
incr i
}
{
lappend rlist $onepin
}
for
{
set i $total_width
}
{
$i
< 6
}
{
incr i
}
{
lappend rlist $onepin
}
}
if
{
$total
_width > 6
}
{
puts
" WARNING: can only connect up to 6 LEDs, additional inputs will be discarded"
}
puts
"rlist =
$rlist
"
return $rlist
}
...
...
@@ -51,6 +83,10 @@ namespace eval leds {
if
{[
llength $inputs
]
== 0
}
{
set inputs $default_led_pins
}
set old_inst
[
current_bd_instance .
]
set cell
[
create_bd_cell -type hier
"LEDs"
]
current_bd_instance $cell
set inputs
[
get_led_inputs $inputs
]
puts
" Inputs:
$inputs
"
set led_concat
[
tapasco::createConcat led_concat 6
]
...
...
@@ -66,6 +102,8 @@ namespace eval leds {
connect_bd_net
[
get_bd_pins -of_objects $led_concat -filter
{
DIR == O
}]
$led
read_xdc
"
$::env
(TAPASCO_HOME)/platform/pynq/plugins/leds.xdc"
current_bd_instance $old_inst
return $led_concat
}
...
...
@@ -84,4 +122,4 @@ namespace eval leds {
}
}
tapasco::register_plugin
"platform::leds::create_leds"
"p
ost-platform
"
tapasco::register_plugin
"platform::leds::create_leds"
"p
re-wrapper
"
platform/pynq/plugins/leds.xdc
View file @
7a96aa1a
set_property -dict { PACKAGE_PIN G17 IOSTANDARD LVCMOS33 } [get_ports { led[4] }]; #IO_L16P_T2_35 Sch=led4_g
set_property -dict { PACKAGE_PIN L14 IOSTANDARD LVCMOS33 } [get_ports { led[5] }]; #IO_L22P_T3_AD7P_35 Sch=led5_g
set_property -dict { PACKAGE_PIN R14 IOSTANDARD LVCMOS33 } [get_ports { led[0] }]; #IO_L6N_T0_VREF_34 Sch=led[0]
set_property -dict { PACKAGE_PIN P14 IOSTANDARD LVCMOS33 } [get_ports { led[1] }]; #IO_L6P_T0_34 Sch=led[1]
set_property -dict { PACKAGE_PIN N16 IOSTANDARD LVCMOS33 } [get_ports { led[2] }]; #IO_L21N_T3_DQS_AD14N_35 Sch=led[2]
set_property -dict { PACKAGE_PIN M14 IOSTANDARD LVCMOS33 } [get_ports { led[3] }]; #IO_L23P_T3_35 Sch=led[3]
set_property -dict {PACKAGE_PIN G17 IOSTANDARD LVCMOS33} [get_ports {led[4]}]
set_property -dict {PACKAGE_PIN L14 IOSTANDARD LVCMOS33} [get_ports {led[5]}]
set_property -dict {PACKAGE_PIN R14 IOSTANDARD LVCMOS33} [get_ports {led[0]}]
set_property -dict {PACKAGE_PIN P14 IOSTANDARD LVCMOS33} [get_ports {led[1]}]
set_property -dict {PACKAGE_PIN N16 IOSTANDARD LVCMOS33} [get_ports {led[2]}]
set_property -dict {PACKAGE_PIN M14 IOSTANDARD LVCMOS33} [get_ports {led[3]}]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment