Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to define Memory Mapped values as a function in Tcl script?

Status
Not open for further replies.

msdarvishi

Full Member level 4
Joined
Jul 30, 2013
Messages
230
Helped
1
Reputation
2
Reaction score
1
Trophy points
18
Activity points
2,349
Dear all,


I have a Tcl file that generates a design including Microblaze and BRAM module. In the last part of my code as you see below, I have mapped the different address to a location. Can anyone tell me how can I define the memory locations as a function and call those funcyions in another Tcl file that sources this current Tcl file?

For more clarification, instead of the predefined memory addresses, I want to let the user to allocate his/her own memory addresses later when he/she runs a Tcl file that calls (source) this current Tcl script.

Code:
#--------- Memory Address Assignments for hierarchy
#
#----- ublazePCIe_hier/axi_pcie_0
assign_bd_address [get_bd_addr_segs {M00_AXI_0/Reg }]
set_property offset 0xC2000000 [get_bd_addr_segs {ublazePCIe_hier/axi_pcie_0/M_AXI/SEG_M00_AXI_0_Reg}]
set_property range 8K [get_bd_addr_segs {ublazePCIe_hier/axi_pcie_0/M_AXI/SEG_M00_AXI_0_Reg}]
#
#
#----- ublazePCIe_hier/microblaze_0
#----------- Data ------------------
#-- SLMB
set_property offset 0x40000000 [get_bd_addr_segs {ublazePCIe_hier/microblaze_0/Data/SEG_dlmb_bram_if_cntlr_Mem}]
set_property range 32K [get_bd_addr_segs {ublazePCIe_hier/microblaze_0/Data/SEG_dlmb_bram_if_cntlr_Mem}]
#
#-- CTL0
assign_bd_address [get_bd_addr_segs {ublazePCIe_hier/axi_pcie_0/S_AXI_CTL/CTL0 }]
set_property offset 0x10000000 [get_bd_addr_segs {ublazePCIe_hier/microblaze_0/Data/SEG_axi_pcie_0_CTL0}]
set_property range 8K [get_bd_addr_segs {ublazePCIe_hier/microblaze_0/Data/SEG_axi_pcie_0_CTL0}]
#
#-- BAR0
assign_bd_address [get_bd_addr_segs {ublazePCIe_hier/axi_pcie_0/S_AXI/BAR0 }]
set_property range 8K [get_bd_addr_segs {ublazePCIe_hier/microblaze_0/Data/SEG_axi_pcie_0_BAR0}]
set_property offset 0x80000000 [get_bd_addr_segs {ublazePCIe_hier/microblaze_0/Data/SEG_axi_pcie_0_BAR0}]
#
#-- M00_AXI_1
assign_bd_address [get_bd_addr_segs {M00_AXI_1/Reg }]
set_property offset 0xB0000000 [get_bd_addr_segs {ublazePCIe_hier/microblaze_0/Data/SEG_M00_AXI_1_Reg}]
set_property range 8K [get_bd_addr_segs {ublazePCIe_hier/microblaze_0/Data/SEG_M00_AXI_1_Reg}]
#
#----------- Instruction -----------------
#-- SLMB
set_property offset 0x00000000 [get_bd_addr_segs {ublazePCIe_hier/microblaze_0/Instruction/SEG_ilmb_bram_if_cntlr_Mem}]
set_property range 32K [get_bd_addr_segs {ublazePCIe_hier/microblaze_0/Instruction/SEG_ilmb_bram_if_cntlr_Mem}]

For example, how can I define the address 0xC2000000 as in a function??


Kind replies are in advance appreciated.


Regards,
 
Last edited by a moderator:

I'm not sure I understand the question!

You could have the value as an environment variable then use the tcl script to extract environment variable instead of a "function"

--in environment
set ENV_VAR ublazePCIe_hier/axi_pcie_0/M_AXI
set ENV_VAR2 0xC2000000
--in tcl
set path $::env(ENV_VAR)
set address $::env(ENV_VAR2)

set_property offset $address [get_bd_addr_segs {$path/SEG_M00_AXI_0_Reg}]

- - - Updated - - -

Further more you could let them include arguments to the tcl call.

file.tcl option1 option2

Then substitute option1 and 2 where needed
 

I'm not sure I understand the question!

You could have the value as an environment variable then use the tcl script to extract environment variable instead of a "function"

--in environment
set ENV_VAR ublazePCIe_hier/axi_pcie_0/M_AXI
set ENV_VAR2 0xC2000000
--in tcl
set path $::env(ENV_VAR)
set address $::env(ENV_VAR2)

set_property offset $address [get_bd_addr_segs {$path/SEG_M00_AXI_0_Reg}]

- - - Updated - - -

Further more you could let them include arguments to the tcl call.

file.tcl option1 option2

Then substitute option1 and 2 where needed


Dear @wesleytaylor,

Thanks for your reply. For more clarification, the lines that I have inserted in my first post are the memory allocation in Xilinx Vivado when we do a Block Design. Instead of allocating memory addresses manually in my current Tcl file, I would like to use another tcl file that calls (sources) my firrst tcl file and there the user is able to set the desired memory addresses. Hence, I have to define the memory addresses as a function, variable, parameter or etc. (I exactly don't know which one!) to be able to allocate them an address later in another Tcl file.

Here, I did some trials and I do not know is it correct or not?! I appreciate you to have a look on that and let me know your opinion.

First Tcl file:
address_mapping.tcl

Code:
proc memory_map {* * *} {

global addr1 addr2 addr3

}


main Tcl file (that calls the address_mapping.tcl file):
main.tcl\
Code:
source address_mapping.tcl

set value {62500000  1255211225   966999696}
memory_map {*}$value


foreach {addr1 addr2 addr3} $value {
	memory_map $addr1 $addr1 $addr1
	break
}


puts "First  address is  : $addr1"
puts "Second address is  : $addr2"
puts "Third  address is  : $addr3"

I am not sure that the current addresses are really allocated to the arguments of memory_map function in memory_mapping.tcl function or not !!!

Your comments and helps are in advance appreciated!

Regards,
 

What about using auto assignment in the Vivado's Address Editor?
Adress_Editor.png
You can read more about it here:
https://www.xilinx.com/support/documentation/sw_manuals/xilinx2017_2/ug994-vivado-ip-subsystems.pdf (page 67)
 

What about using auto assignment in the Vivado's Address Editor?
View attachment 148253
You can read more about it here:
https://www.xilinx.com/support/documentation/sw_manuals/xilinx2017_2/ug994-vivado-ip-subsystems.pdf (page 67)

Thanks for your reply. This is exactly I have done at the beginning, but now I want to have an automated Tcl script that generates a design with all settings without any extra manual effort. Do you have any idea how to solve the problem?

Regards,
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top