af_map.tcl 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #yosys -TQd -v 1 -L map.log -c map.tcl
  2. yosys -import
  3. set verilogs {}
  4. foreach arg $argv {
  5. set arg [string trim $arg "\"\{\'\t \n"]
  6. if { [string index $arg 0] == "@" } {
  7. set cmd [string range $arg 1 1000]
  8. eval $cmd
  9. } else {
  10. lappend verilogs $arg
  11. }
  12. }
  13. if { ! [info exists RETIMING] } {
  14. set RETIMING "100"
  15. }
  16. if { $RETIMING == "true" } {
  17. set RETIMING "100"
  18. } elseif { $RETIMING == "false" } {
  19. set RETIMING "None"
  20. }
  21. if { ! [info exists IOPAD] } {
  22. set IOPAD true
  23. }
  24. if { [info exists DESIGN] && ! [info exists TOP_MODULE] } {
  25. set TOP_MODULE "$DESIGN"
  26. }
  27. if { ! [info exists DESIGN] } {
  28. set DESIGN "test_uart"
  29. }
  30. if { ! [info exists TOP_MODULE] } {
  31. set TOP_MODULE "test_uart"
  32. }
  33. clock format [clock seconds] -format "%a %b %d %T %Y"
  34. if { [file exists [file join . ${DESIGN}.pre_map.asf]] } {
  35. puts "Using pre_map-ASF file ${DESIGN}.pre_map.asf."
  36. source [file join . ${DESIGN}.pre_map.asf]
  37. }
  38. if { [ llength $verilogs ] == 0 } {
  39. set verilogs { "test_uart.v" "multi_uart_ip.v" "multi_uart_ip/baud_gen.v" "multi_uart_ip/multi_uart.v" "multi_uart_ip/sync_fifo.v" "multi_uart_ip/uart_regs.v" "multi_uart_ip/uart_rx.v" "multi_uart_ip/uart_tx.v" }
  40. }
  41. if { [ llength $verilogs ] == 0 } {
  42. set verilogs [list ./${DESIGN}.v]
  43. }
  44. foreach verilog $verilogs {
  45. read_verilog -sv -overwrite -DALTA_SYN "$verilog"
  46. }
  47. #family:
  48. read_verilog -DALTA_LIB -sv -lib +/agm/rodina/cells_sim.v
  49. read_verilog -DALTA_SYN -sv +/agm/common/m9k_bb.v
  50. read_verilog -DALTA_SYN -sv +/agm/common/altpll_bb.v
  51. read_verilog -DALTA_LIB -sv -lib +/agm/rodina/alta_sim.v
  52. read_verilog -DALTA_SYN -sv +/agm/rodina/alta_sim.v
  53. read_verilog -DALTA_SYN -sv +/agm/common/alta_bb.v
  54. hierarchy -check -top $TOP_MODULE -DALTA_SYN -libdir "multi_uart_ip" -libdir .
  55. #flatten:
  56. #yosys proc
  57. flatten
  58. tribuf -logic
  59. deminout
  60. set alta_ips {alta_bram alta_bram9k alta_sram alta_wram alta_pll alta_pllx alta_pllv alta_pllve alta_boot alta_osc alta_mult alta_multm alta_ufm alta_ufms alta_ufml alta_i2c alta_spi alta_irda alta_mcu alta_mcu_m3 alta_saradc alta_adc alta_dac alta_cmp}
  61. select -none
  62. foreach alta_ip $alta_ips {
  63. select -add */t:$alta_ip
  64. }
  65. select -set keep_cells %
  66. select -clear
  67. setattr -set keep 1 @keep_cells
  68. #coarse:
  69. synth -run coarse -top $TOP_MODULE
  70. for {set nn 0} {$nn < 10} {incr nn} {
  71. proc_dff
  72. }
  73. #map_bram:
  74. memory_libmap -lib +/agm/common/brams_m9k.txt
  75. techmap -autoproc -map +/agm/common/brams_map_m9k.v
  76. yosys proc
  77. read_verilog -DALTA_SYN -sv +/agm/rodina/alta_sim.v
  78. hierarchy -check -top $TOP_MODULE
  79. flatten
  80. #map_ffram:
  81. opt -fast -mux_undef -fine
  82. memory_map
  83. opt -fine
  84. techmap -autoproc -map +/agm/rodina/arith_map.v
  85. techmap -autoproc -map +/techmap.v
  86. yosys proc
  87. opt -undriven -fine
  88. yosys rename -wire -suffix _reg t:$*DFF*
  89. clean -purge
  90. setundef -undriven -zero
  91. if { $RETIMING != "None" } {
  92. abc -markgroups -dff -D $RETIMING
  93. }
  94. #map_ffs:
  95. dfflegalize -cell \$_DFFE_????_ 0 -cell \$_SDFFCE_????_ 0 -cell \$_DLATCH_?_ x -cell \$_ALDFFE_???_ 0
  96. techmap -autoproc -map +/agm/common/ff_map.v
  97. yosys proc
  98. opt -fine
  99. clean -purge
  100. setundef -undriven -zero
  101. abc -markgroups -dff -D 1
  102. agm_dffeas
  103. ##opts:
  104. opt_expr -mux_undef -undriven -full
  105. opt_merge
  106. opt_clean
  107. autoname
  108. #map_luts:
  109. abc -lut 4
  110. clean
  111. #map_cells:
  112. if { $IOPAD } {
  113. iopadmap -bits -outpad \$__outpad I:O -inpad \$__inpad O:I -toutpad \$__toutpad E:I:O -tinoutpad \$__tinoutpad E:O:I:IO
  114. }
  115. techmap -autoproc -map +/agm/rodina/cells_map.v
  116. clean -purge
  117. autoname
  118. #check:
  119. hierarchy -check
  120. stat
  121. check -noinit
  122. blackbox =A:whitebox
  123. #vqm:
  124. write_verilog -simple-lhs -bitblasted -attr2comment -defparam -decimal -renameprefix syn_ ${DESIGN}.vqm
  125. if { [file exists [file join . ${DESIGN}.post_map.asf]] } {
  126. puts "Using post_map-ASF file ${DESIGN}.post_map.asf."
  127. source [file join . ${DESIGN}.post_map.asf]
  128. }
  129. clock format [clock seconds] -format "%a %b %d %T %Y"