Here's some Tcl code I use in an SOPC _hw.tcl file ...
# Replace the generic values (suffixed by _VAL in the template)
set params {
AWIDTH
BWIDTH
DWIDTH
CLK_FREQUENCY
WRITE_CYCLE
READ_CYCLE
AWIDTH_MINUS_1
BWIDTH_MINUS_1
DWIDTH_MINUS_1}
foreach param $params {
eval set buffer \ \$buffer\]
}
to replace the generics in a template file ...
u1: ftdi_to_avalon_mm_bridge
generic map (
CLK_FREQUENCY => CLK_FREQUENCY_VAL,
READ_CYCLE => READ_CYCLE_VAL,
WRITE_CYCLE => WRITE_CYCLE_VAL,
AWIDTH => AWIDTH_VAL,
BWIDTH => BWIDTH_VAL,
DWIDTH => DWIDTH_VAL
)
port map (
-- Reset and clock
rstN => rstN,
clk => clk,
-- FTDI interface
ftdi_rxfN => ftdi_rxfN,
ftdi_txeN => ftdi_txeN,
ftdi_rdN => ftdi_rdN,
ftdi_wr => ftdi_wr,
ftdi_dq_oe => ftdi_dq_oe,
ftdi_dq_out => ftdi_dq_out,
ftdi_dq => ftdi_dq,
-- Avalon-MM interface
avm_read => avm_read,
avm_write => avm_write,
avm_byteen => avm_byteen,
avm_addr => avm_addr,
avm_wrdata => avm_wrdata,
avm_rddata => avm_rddata,
avm_wait => avm_wait,
avm_rdvalid => avm_rdvalid
);
The generic values ending in _VAL get searched-and-replaced by the Tcl code.
You could do the same.
The other way is to simple generate the package file from Tcl, or move the configuration values into their own package, eg.. config_pkg.vhd, and generate that. Much like you would with Autotools, ./configure, to generate a config.h file.
Cheers,
Dave