Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Rev 1.0 for Vivado 2017.3
  • Loading branch information
magictaler committed May 16, 2020
0 parents commit 0815b17
Show file tree
Hide file tree
Showing 61 changed files with 15,194 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# README #

RGB PWM LED Demo project running on ARTY Z7-20 hardware

Copyright (C) 2020 Magictale Electronics
http://magictale.com

Getting started:

* Build the PL code locally by executing the following commands in the:

Vivado directory:
+ Create the project file from the block diagram, wrapper and constraints file:
vivado -mode batch -source create_project_file.tcl
+ Synthesise, place & route and generate bitfile for use in SDK:
vivado -mode batch -source create_sdk_files.tcl

* Execute the following command in the SDK/rgb_pwm_led_demo directory:
+ xsdk -batch create_sdk.tcl 0

* Now the SDK can be opened with the following command:
+ xsdk -workspace .

* The boot image can be created with the following comand:
+ xsdk -batch bootgen_sdk.tcl 0
121 changes: 121 additions & 0 deletions SDK/common/shared_procs.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#
# Inserts a linked source reference into a project .project file.
# project_dir: Path to project to open
# name: Link name
# location: Path to reference
# type: Link type (1 for file, 2 for folder)
#
proc add_linked_resource {project_dir name location type} {
set link "<link><name>$name</name><type>$type</type><location>$location</location></link>"
set filename "$project_dir/.project"

# Read lines of file (name in “filename” variable) into variable “lines”
set f [open $filename "r"]
set lines [split [read $f] "\n"]
close $f

# Find linked resources group
set idx [lsearch -regexp [lreverse $lines] "^</linkedResources>"]
if {$idx < 0} {

# Add one if it doesn't exist
set idx [lsearch -regexp [lreverse $lines] "^</projectDescription>"]
if {$idx < 0} {
error "did not find insertion point for linkedResources group in $filename"
}
incr idx

set linkedresourcesgroup "<linkedResources>\n</linkedResources>"
set lines [linsert $lines end-$idx {*}$linkedresourcesgroup]
}

# Place the insertion point above linkedResources end
incr idx

# Insert the resource lines
set lines [linsert $lines end-$idx {*}$link]

# Write the lines back to the file
set f [open $filename "w"]
puts $f [join $lines "\n"]
close $f
}

#
# Inserts a linked source reference into a project's .cproject file.
# project_dir: Path to project to open
# name: Link name
# location: Path to reference
#
proc add_source_entries {project_dir name location} {
set sourceentries "<sourceEntries><entry excluding=\"$name\" flags=\"VALUE_WORKSPACE_PATH|RESOLVED\" kind=\"sourcePath\" name=\"\"/><entry flags=\"VALUE_WORKSPACE_PATH|RESOLVED\" kind=\"sourcePath\" name=\"$name\"/></sourceEntries>"
set filename "$project_dir/.cproject"

# Read lines of file (name in “filename” variable) into variable “lines”
set f [open $filename "r"]
set lines [split [read $f] "\n"]
close $f

# Find the insertion index in the reversed list
set idx [lsearch -regexp [lreverse $lines] "</folderInfo>"]
if {$idx < 0} {
error "did not find insertion point in $filename"
}

# Insert the resource lines
set lines [linsert $lines end-$idx {*}$sourceentries]

incr idx

# Find the insertion index in the reversed list
set idx [lsearch -start $idx -regexp [lreverse $lines] "</folderInfo>"]
if {$idx < 0} {
error "did not find insertion point in $filename"
}

# Insert the resource lines
set lines [linsert $lines end-$idx {*}$sourceentries]

# Write the lines back to the file
set f [open $filename "w"]
puts $f [join $lines "\n"]
close $f
}

#
# Gets the processor definition (instance) from the hardware package
# hw_project_name: Name of the hardware package to use
#
proc get_processor_name {hw_project_name} {
set periphs [getperipherals $hw_project_name]
# For each line of the peripherals table
foreach line [split $periphs "\n"] {
set values [regexp -all -inline {\S+} $line]
# If the last column is "PROCESSOR", then get the "IP INSTANCE" name (1st col)
if {[lindex $values end] == "PROCESSOR"} {
return [lindex $values 0]
}
}
return ""
}

#
# Gets the processor definition (instance) from the hardware package
# hw_project_name: Name of the hardware package to use
#
proc get_second_processor_name {hw_project_name} {
set periphs [getperipherals $hw_project_name]
set first_found 0
# For each line of the peripherals table
foreach line [split $periphs "\n"] {
set values [regexp -all -inline {\S+} $line]
# If the last column is "PROCESSOR", then get the "IP INSTANCE" name (1st col)
if {[lindex $values end] == "PROCESSOR"} {
if {$first_found == 1} {
return [lindex $values 0]
}
set first_found 1
}
}
return ""
}
67 changes: 67 additions & 0 deletions SDK/rgb_pwm_led_demo/bootgen_sdk.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#*****************************************************************************************
# This script will generate the boot images for existing builds. If version_string is not set,
# the version will be set to 000
#
set demo_project_name "rgb_pwm_led_demo"

if {![info exists version_string]} {
set version_string "0_0_0_0"
}

if {![info exists build_config]} {
set build_config "all"
}

if { $argc == 0 } {
set build_number 0
} else {
set build_number [lindex $argv 0]
}

if { $argc >= 2 } {
set index 1
while {$index < $argc} {
if {[string equal [lindex $argv $index] "--config"]} {
incr index
set build_config [string tolower [lindex $argv $index]]
}
incr index
}
puts "Build config selected: $build_config"
}

# If no valid build config is selected, default to all.
if { $build_config != "all" && $build_config != "release" && $build_config != "debug"} {
puts "Invalid build config selected, defaulting to all"
set build_config "all"
}

# Get the version info from the version.c and print it
set file [open "$demo_project_name/src/version.c"]
while {[gets $file line] != -1} {
if {[regexp {VERSION_([A-Z]+).*([0-9]+)} $line matched version_part value]} {
dict set version [string tolower $version_part] $value
}
}
close $file
set version_string [dict get $version major]_[dict get $version minor]_[dict get $version bugfix]_$build_number
puts "Building version: [string map {_ .} $version_string]"

if {![info exists version_string]} {
set version_string "0_0_0_0"
}

if {![info exists build_config]} {
set build_config "all"
}

puts "Generating boot images with version $version_string , build config $build_config"

if { $build_config == "release" || $build_config == "all" } {
exec bootgen -image bootimage/${demo_project_name}.bif -arch zynq -o bootimage/${demo_project_name}_${version_string}.bin -w on -p xc7z020
}

if { $build_config == "debug" || $build_config == "all" } {
exec bootgen -image bootimage/${demo_project_name}_debug.bif -arch zynq -o bootimage/${demo_project_name}_${version_string}_debug.bin -w on -p xc7z020 -log info
}

7 changes: 7 additions & 0 deletions SDK/rgb_pwm_led_demo/bootimage/rgb_pwm_led_demo.bif
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//arch = zynq; split = false; format = BIN; zynq_key_store = efuse; key_part_name = xc7z020
the_ROM_image:
{
[bootloader]fsbl\Release\fsbl.elf
demo_hw_platform\design_1_wrapper.bit
rgb_pwm_led_demo\Release\rgb_pwm_led_demo.elf
}
7 changes: 7 additions & 0 deletions SDK/rgb_pwm_led_demo/bootimage/rgb_pwm_led_demo_debug.bif
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//arch = zynq; split = false; format = BIN; zynq_key_store = efuse; key_part_name = xc7z020
the_ROM_image:
{
[bootloader]fsbl\Debug\fsbl.elf
demo_hw_platform\design_1_wrapper.bit
rgb_pwm_led_demo\Debug\rgb_pwm_led_demo.elf
}
Loading

0 comments on commit 0815b17

Please sign in to comment.