2012年5月4日金曜日

DDC FPGAの設定用 システムコンソール

 現在ADATによるDoPの実現を目指しているDDCや、デジタルIF間のスイッチングを制御するMatirx Switch機能の設定レジスタを操作するシステムコンソールを作成しました。

 とりあえず[Dump]ボタンを押すと、各レジスタの現在値を読み出し表示し、設定を変更したいレジスタの値を書き換えて[Modify]ボタンを押すと、設定レジスタの値を書き換えるようにしました。

 ループで組んであるので、入出力ポート数の増減は、ループ数を変えるだけで対応できます。

 最終的にはFPGAの制御方法として、PCからシステムコンソール経由、NiosIIによるプログラム制御、I2Cスレーブポート経由で、Aruduinoやmbet等の外部コントローラ経由で制御の3系統での制御ができるようにするつもりで、目的に応じ、QsysにJtag to Avalon Master Bridge 、NiosII、I2C Slave Controllerを搭載することで可能にする予定です。

 そのうち、プルダウンメニューから設定したいパラメータを選択して設定したり、レジスタ値そのものではなく、値の示すモードを表示出来るようにしたいとは思っています。


システムコンソール SW Matrix Config

tclファイル

namespace eval SW_Matrix_Control {


variable dash [add_service dashboard SW_Matrix_Control "SW_Matrix_Control" "Tools/Dashboard"]


dashboard_set_property $dash self developmentMode true
dashboard_set_property $dash self itemsPerRow 1


# Config Register Modify 
 proc set_cfg {group_name} {


   variable dash
   variable set_tx_val


   set cfg_baseadd 0x00008000


   set mast [lindex [get_service_paths master] 0]
   open_service master $mast
   #ssampling rate
   set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.comcfg_rate_val text]]
   master_write_32 $mast [format "0x%08x" [expr $cfg_baseadd + 0x000 ] ] $set_tx_val

   for {set i 0} {$i < 2} {incr i} {      
      #Rx Port enable
      set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.rxcfg_enb_val${i} text]]
      master_write_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x400 ] ] $set_tx_val
      #Rx Mode
      set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.rxcfg_mode_val${i} text]]
      master_write_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x404 ] ] $set_tx_val
      #DoP mode  
      set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.rxcfg_dop_val${i} text]]
      master_write_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x408 ] ] $set_tx_val   
   } 
   for {set i 0} {$i < 2} {incr i} {      
      #Tx Port enable
      set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.txcfg_enb_val${i} text]]
      master_write_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x420 ] ] $set_tx_val
      #Buf Mode
      set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.txcfg_bufmode_val${i} text]]
      master_write_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x424 ] ] $set_tx_val
      #Tx Mode  
      set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.txcfg_mode_val${i} text]]
      master_write_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x428 ] ] $set_tx_val
      #i2s mode
      set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.txcfg_i2s_val${i} text]]
      master_write_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x42c ] ] $set_tx_val
      #Input port
      set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.txcfg_port_val${i} text]]
      master_write_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x430 ] ] $set_tx_val
      #Input TS  
      set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.txcfg_ts_val${i} text]]
      master_write_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x434 ] ] $set_tx_val 
   }   
 } 
# Config Register Dump 
 proc read_cfg {group_name} {


   variable dash
   variable read_val


   set cfg_baseadd 0x00008000


   set mast [lindex [get_service_paths master] 0]
   open_service master $mast
   #ssampling rate 
   set read_val [master_read_32 $mast [format "0x%08x" [expr $cfg_baseadd + 0x000 ] ] 1]  
   dashboard_set_property $dash $group_name.comcfg_rate_val text [format "0x%04x" [expr ($read_val)] ]
   
   for {set i 0} {$i < 2} {incr i} {      
      #Rx Port enable
      set read_val [master_read_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x400 ] ] 1]  
      dashboard_set_property $dash $group_name.rxcfg_enb_val${i} text [format "0x%04x" [expr ($read_val)] ]
      #Rx Mode
      set read_val [master_read_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x404 ] ] 1]  
      dashboard_set_property $dash $group_name.rxcfg_mode_val${i} text [format "0x%04x" [expr ($read_val)] ]   
      #DoP mode 
      set read_val [master_read_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x408 ] ] 1]  
      dashboard_set_property $dash $group_name.rxcfg_dop_val${i} text [format "0x%04x" [expr ($read_val)] ]   
   }


   for {set i 0} {$i < 2} {incr i} {      
      #Tx Port enable
      set read_val [master_read_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x420 ] ] 1]  
      dashboard_set_property $dash $group_name.txcfg_enb_val${i} text [format "0x%04x" [expr ($read_val)] ]
      #Buf Mode
      set read_val [master_read_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x424 ] ] 1]  
      dashboard_set_property $dash $group_name.txcfg_bufmode_val${i} text [format "0x%04x" [expr ($read_val)] ]   
      #Tx Mode   
      set read_val [master_read_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x428 ] ] 1]  
      dashboard_set_property $dash $group_name.txcfg_mode_val${i} text [format "0x%04x" [expr ($read_val)] ]   
      #i2s mode
      set read_val [master_read_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x42c ] ] 1]  
      dashboard_set_property $dash $group_name.txcfg_i2s_val${i} text [format "0x%04x" [expr ($read_val)] ]
      #Input port
      set read_val [master_read_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x430 ] ] 1]  
      dashboard_set_property $dash $group_name.txcfg_port_val${i} text [format "0x%04x" [expr ($read_val)] ]   
      #Input TS   
      set read_val [master_read_32 $mast [format "0x%08x" [expr $cfg_baseadd + $i*0x40 + 0x434 ] ] 1]  
      dashboard_set_property $dash $group_name.txcfg_ts_val${i} text [format "0x%04x" [expr ($read_val)] ]   
   
   } 
   
 }  

# gen_group4 --
#
proc gen_group4 { { group_name "myTab.g4" } } {
   variable dash

   dashboard_add $dash $group_name  group myTab
   dashboard_set_property $dash $group_name itemsPerRow 2


   # Common config reg
   dashboard_add $dash G_com_cfg  group $group_name 
   dashboard_set_property $dash G_com_cfg title "Common Config Register"
   dashboard_set_property $dash G_com_cfg itemsPerRow 2
   #ssampling rate
   dashboard_add $dash $group_name.comcfg_rate label G_com_cfg
   dashboard_set_property $dash $group_name.comcfg_rate text "Sampling rate"
   dashboard_set_property $dash $group_name.comcfg_rate preferredWidth 60


   dashboard_add $dash $group_name.comcfg_rate_val textField G_com_cfg
   dashboard_set_property $dash $group_name.comcfg_rate_val preferredWidth 60
   
   dashboard_add $dash G_com_comment  group $group_name 
   dashboard_set_property $dash G_com_comment title ""
   dashboard_set_property $dash G_com_comment itemsPerRow 1


   dashboard_add $dash $group_name.comcfg_comment1 label G_com_comment
   dashboard_set_property $dash $group_name.comcfg_comment1 text "Sampling rate: 0:44.1k 1:88.2k 2:176.4k 3:352.8k"
   dashboard_set_property $dash $group_name.comcfg_comment1 preferredWidth 200
   
   # Rx port config reg 
   dashboard_add $dash G_Rx_cfg  group $group_name 
   dashboard_set_property $dash G_Rx_cfg title "Rx Config Register"
   dashboard_set_property $dash G_Rx_cfg itemsPerRow 4


   dashboard_add $dash $group_name.rxcfg_port label G_Rx_cfg
   dashboard_set_property $dash $group_name.rxcfg_port text "Port#"
   dashboard_set_property $dash $group_name.rxcfg_port preferredWidth 50


   dashboard_add $dash $group_name.rxcfg_enb label G_Rx_cfg
   dashboard_set_property $dash $group_name.rxcfg_enb text "Enable"
   dashboard_set_property $dash $group_name.rxcfg_enb preferredWidth 60


   dashboard_add $dash $group_name.rxcfg_mode label G_Rx_cfg
   dashboard_set_property $dash $group_name.rxcfg_mode text "Rx mode"
   dashboard_set_property $dash $group_name.rxcfg_mode preferredWidth 60


   dashboard_add $dash $group_name.rxcfg_dop label G_Rx_cfg
   dashboard_set_property $dash $group_name.rxcfg_dop text "DoP mode"
   dashboard_set_property $dash $group_name.rxcfg_dop preferredWidth 60


   for {set i 0} {$i < 2} {incr i} {


      dashboard_add $dash $group_name.port_no label G_Rx_cfg
      dashboard_set_property $dash $group_name.port_no text "Port \#$i"
      dashboard_set_property $dash $group_name.port_no preferredWidth 50


      #Rx Port enable
      dashboard_add $dash $group_name.rxcfg_enb_val${i} textField G_Rx_cfg
      dashboard_set_property $dash $group_name.rxcfg_enb_val${i} preferredWidth 60  
      #Rx Mode
      dashboard_add $dash $group_name.rxcfg_mode_val${i} textField G_Rx_cfg
      dashboard_set_property $dash $group_name.rxcfg_mode_val${i} preferredWidth 60
      #DoP mode
      dashboard_add $dash $group_name.rxcfg_dop_val${i} textField G_Rx_cfg
      dashboard_set_property $dash $group_name.rxcfg_dop_val${i} preferredWidth 60
   }


   # Tx port config reg 
   dashboard_add $dash G_Tx_cfg  group $group_name 
   dashboard_set_property $dash G_Tx_cfg title "Tx Config Register"
   dashboard_set_property $dash G_Tx_cfg itemsPerRow 7


   dashboard_add $dash $group_name.txcfg_port label G_Tx_cfg
   dashboard_set_property $dash $group_name.txcfg_port text "Port#"
   dashboard_set_property $dash $group_name.txcfg_port preferredWidth 50


   dashboard_add $dash $group_name.txcfg_enb label G_Tx_cfg
   dashboard_set_property $dash $group_name.txcfg_enb text "Enable"
   dashboard_set_property $dash $group_name.txcfg_enb preferredWidth 60


   dashboard_add $dash $group_name.txcfg_bufmode label G_Tx_cfg
   dashboard_set_property $dash $group_name.txcfg_bufmode text "Buf mode"
   dashboard_set_property $dash $group_name.txcfg_bufmode preferredWidth 60


   dashboard_add $dash $group_name.txcfg_mode label G_Tx_cfg
   dashboard_set_property $dash $group_name.txcfg_mode text "Tx mode"
   dashboard_set_property $dash $group_name.txcfg_mode preferredWidth 60


   dashboard_add $dash $group_name.txcfg_i2s label G_Tx_cfg
   dashboard_set_property $dash $group_name.txcfg_i2s text "i2s mode"
   dashboard_set_property $dash $group_name.txcfg_i2s preferredWidth 60


   dashboard_add $dash $group_name.txcfg_port label G_Tx_cfg
   dashboard_set_property $dash $group_name.txcfg_port text "Input Port"
   dashboard_set_property $dash $group_name.txcfg_port preferredWidth 60


   dashboard_add $dash $group_name.txcfg_ts label G_Tx_cfg
   dashboard_set_property $dash $group_name.txcfg_ts text "Input Timeslot"
   dashboard_set_property $dash $group_name.txcfg_ts preferredWidth 60


   for {set i 0} {$i < 2} {incr i} {


      dashboard_add $dash $group_name.port_no label G_Tx_cfg
      dashboard_set_property $dash $group_name.port_no text "Port \#$i"
      dashboard_set_property $dash $group_name.port_no preferredWidth 50


      #Tx Port enable
      dashboard_add $dash $group_name.txcfg_enb_val${i} textField G_Tx_cfg
      dashboard_set_property $dash $group_name.txcfg_enb_val${i} preferredWidth 60  
      #Buf Mode
      dashboard_add $dash $group_name.txcfg_bufmode_val${i} textField G_Tx_cfg
      dashboard_set_property $dash $group_name.txcfg_bufmode_val${i} preferredWidth 60
      #Tx Mode
      dashboard_add $dash $group_name.txcfg_mode_val${i} textField G_Tx_cfg
      dashboard_set_property $dash $group_name.txcfg_mode_val${i} preferredWidth 60
      #i2s mode
      dashboard_add $dash $group_name.txcfg_i2s_val${i} textField G_Tx_cfg
      dashboard_set_property $dash $group_name.txcfg_i2s_val${i} preferredWidth 60
      #Input port
      dashboard_add $dash $group_name.txcfg_port_val${i} textField G_Tx_cfg
      dashboard_set_property $dash $group_name.txcfg_port_val${i} preferredWidth 60
      #Input TS
      dashboard_add $dash $group_name.txcfg_ts_val${i} textField G_Tx_cfg
      dashboard_set_property $dash $group_name.txcfg_ts_val${i} preferredWidth 60
   }
   # Rx Config Comment
   dashboard_add $dash G_Rx_comment  group $group_name 
   dashboard_set_property $dash G_Rx_comment title ""
   dashboard_set_property $dash G_Rx_comment itemsPerRow 1
 
   dashboard_add $dash $group_name.rxcfg_comment1 label G_Rx_comment
   dashboard_set_property $dash $group_name.rxcfg_comment1 text "Enable: 1:enable 0:disable"
   dashboard_set_property $dash $group_name.rxcfg_comment1 preferredWidth 400
   dashboard_add $dash $group_name.rxcfg_comment2 label G_Rx_comment
   dashboard_set_property $dash $group_name.rxcfg_comment2 text "Rx mode: 0:ADAT 2:AES 16:i2s 1e:DSD"
   dashboard_add $dash $group_name.txcfg_comment3 label G_Rx_comment
   dashboard_set_property $dash $group_name.txcfg_comment3 text "DoP mode: 0:Off 2:DSD64 4:DSD128_L 5:DSD128_R 8:Auto_L 9:Auto_R"


   # Tx Config Comment
   dashboard_add $dash G_Tx_comment  group $group_name 
   dashboard_set_property $dash G_Tx_comment title ""
   dashboard_set_property $dash G_Tx_comment itemsPerRow 1
 
   dashboard_add $dash $group_name.txcfg_comment1 label G_Tx_comment
   dashboard_set_property $dash $group_name.txcfg_comment1 text "Enable: 1:enable 0:disable"
   dashboard_set_property $dash $group_name.txcfg_comment1 preferredWidth 400
   dashboard_add $dash $group_name.txcfg_comment2 label G_Tx_comment
   dashboard_set_property $dash $group_name.txcfg_comment2 text "Buf mode: 0:es_mode 1:sdb_mode 2:sdmc_mode "
   dashboard_add $dash $group_name.txcfg_comment3 label G_Tx_comment
   dashboard_set_property $dash $group_name.txcfg_comment3 text "Tx mode: 0:ADAT 2:AES 16:i2s e:DSD"
   dashboard_add $dash $group_name.txcfg_comment4 label G_Tx_comment
   dashboard_set_property $dash $group_name.txcfg_comment4 text "i2s mode: 0:rj24 1:i2s24 2:lj24 3:i2s32 4:dsd"
   dashboard_add $dash $group_name.txcfg_comment5 label G_Tx_comment
   dashboard_set_property $dash $group_name.txcfg_comment5 text "Rx Port: (15:12)(11:8)(7:4)(3:0) Rx port No.   44.1k 4ch 88.2k 2ch 176.4k 1ch"
   dashboard_add $dash $group_name.txcfg_comment6 label G_Tx_comment
   dashboard_set_property $dash $group_name.txcfg_comment6 text "Rx TS:   (7:6)(5:4)(3:2)(1:0) Rx Time Slot No. 44.1k 4ch 88.2k 2ch 176.4k 1ch"


   dashboard_add $dash G_Rx_cfg_action  group $group_name 
   dashboard_set_property $dash G_Rx_cfg_action title "Config Register Action"
   dashboard_set_property $dash G_Rx_cfg_action itemsPerRow 1
   
   # Dump Button
   dashboard_add $dash $group_name.rxcfg_read button G_Rx_cfg_action
   dashboard_set_property $dash $group_name.rxcfg_read text "Dump"
   dashboard_set_property $dash $group_name.rxcfg_read onClick  "SW_Matrix_Control::read_cfg $group_name"
   # Modify Button
   dashboard_add $dash $group_name.rxcfg_set button G_Rx_cfg_action
   dashboard_set_property $dash $group_name.rxcfg_set text "Modify"
   dashboard_set_property $dash $group_name.rxcfg_set onClick  "SW_Matrix_Control::set_cfg $group_name"  


}
# tabbedGroup
dashboard_add $dash myTab tabbedGroup self
dashboard_set_property $dash myTab preferredWidth 1024
dashboard_set_property $dash myTab preferredHeight 500


# Create Grourps
gen_group4 "MatrixSW_Config"


}





0 件のコメント:

コメントを投稿