2012年4月16日月曜日

QuartusII システムコンソール Dashboard 2

DashboardのGUIからFPGA内のレジスタアクセスする例として、I2Cコントローラのレジスタを周期モニタしてDashboardに表示させることと、Dashboardの設定用Textboxから設定する機能を作りこんでみました。

 システムコンソール Dashboard I2Cレジスタモニタ、設定画面



 "Start Mon"プッシュでレジスタを周期的に読みDashboardに表示し、TextBoxに設定値を書いて、setを押すとレジスタの内容が書きかえます。
 細かい調整や画面デザインなどはこれから。

 下記が該当部のtcl記述になります。

proc count_g3 {group_name} {

variable dash

variable prescale_val
variable control_val
variable status_val
variable transmit_val
variable receive_val
variable command_val
variable timer_val

#  reg read and display

set i2c_baseadd 0x00000000

set i2c_prescale       [format "0x%08x" [expr $i2c_baseadd + 0x0 ] ] 
set i2c_ctrl         [format "0x%08x" [expr $i2c_baseadd + 0x4 ] ] 
set i2c_status       [format "0x%08x" [expr $i2c_baseadd + 0x8 ] ] 
set i2c_transmit     [format "0x%08x" [expr $i2c_baseadd + 0xc ] ] 
set i2c_receive       [format "0x%08x" [expr $i2c_baseadd + 0x10 ] ] 
set i2c_command       [format "0x%08x" [expr $i2c_baseadd + 0x14 ] ]
set i2c_timer       [format "0x%08x" [expr $i2c_baseadd + 0x40 ] ]

   set mast [lindex [get_service_paths master] 0]
   open_service master $mast
   # prescale
   set prescale_val [master_read_32 $mast $i2c_prescale 1]  
   dashboard_set_property $dash $group_name.prer_val text [format "0x%04x" [expr ($prescale_val)] ]
   # ctrl
   set control_val [master_read_32 $mast $i2c_ctrl 1]  
   dashboard_set_property $dash $group_name.ctrl_val text [format "0x%04x" [expr ($control_val)] ]
   # status 
   set status_val [master_read_32 $mast $i2c_status 1]  
   dashboard_set_property $dash $group_name.status_val text [format "0x%04x" [expr ($status_val)] ]
   # transmit
   set transmit_val [master_read_32 $mast $i2c_transmit 1]  
   dashboard_set_property $dash $group_name.transmit_val text [format "0x%04x" [expr ($transmit_val)] ]
   # receive
   set receive_val [master_read_32 $mast $i2c_receive 1]  
   dashboard_set_property $dash $group_name.receive_val text [format "0x%04x" [expr ($receive_val)] ]
   # command
   set command_val [master_read_32 $mast $i2c_command 1]  
   dashboard_set_property $dash $group_name.command_val text [format "0x%04x" [expr ($command_val)] ]
   # timer
   set timer_val [master_read_32 $mast $i2c_timer 1]  
   dashboard_set_property $dash $group_name.timer_val text [format "0x%04x" [expr ($timer_val)] ]
   
   after 1000 i2c_Control::count_g3 $group_name
 }

 proc set_prer {group_name} {

variable dash
variable set_prescale_val

set i2c_baseadd 0x00000000
set i2c_prescale       [format "0x%08x" [expr $i2c_baseadd + 0x0 ] ] 

   set mast [lindex [get_service_paths master] 0]
   open_service master $mast
   
   set set_prescale_val [format "0x%04x" [dashboard_get_property $dash $group_name.prer_wr_val text]]
   master_write_32 $mast $i2c_prescale $set_prescale_val
 }

 proc set_tx {group_name} {

variable dash
variable set_tx_val

set i2c_baseadd 0x00000000
set i2c_transmit     [format "0x%08x" [expr $i2c_baseadd + 0xc ] ] 

   set mast [lindex [get_service_paths master] 0]
   open_service master $mast
   
   set set_tx_val [format "0x%04x" [dashboard_get_property $dash $group_name.tx_wr_val text]]
   master_write_32 $mast $i2c_transmit $set_tx_val
 }

# gen_group3
#
proc gen_group3 { { group_name "myTab.g3" } } {
variable dash

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

# read reg 
#prer reg
dashboard_add $dash $group_name.prer label $group_name
dashboard_set_property $dash $group_name.prer text "Clock Prescale"
dashboard_set_property $dash $group_name.prer preferredWidth 30

dashboard_add $dash $group_name.prer_val label $group_name
dashboard_set_property $dash $group_name.prer_val text "-"
dashboard_set_property $dash $group_name.prer_val preferredWidth 30

#ctrl reg
dashboard_add $dash $group_name.ctrl label $group_name
dashboard_set_property $dash $group_name.ctrl text "Control"
dashboard_set_property $dash $group_name.ctrl preferredWidth 30

dashboard_add $dash $group_name.ctrl_val label $group_name
dashboard_set_property $dash $group_name.ctrl_val text "-"
dashboard_set_property $dash $group_name.ctrl_val preferredWidth 30

#status reg
dashboard_add $dash $group_name.status label $group_name
dashboard_set_property $dash $group_name.status text "Status"
dashboard_set_property $dash $group_name.status preferredWidth 30

dashboard_add $dash $group_name.status_val label $group_name
dashboard_set_property $dash $group_name.status_val text "-"
dashboard_set_property $dash $group_name.status_val preferredWidth 30

#transmit reg
dashboard_add $dash $group_name.transmit label $group_name
dashboard_set_property $dash $group_name.transmit text "Transmit"
dashboard_set_property $dash $group_name.transmit preferredWidth 30

dashboard_add $dash $group_name.transmit_val label $group_name
dashboard_set_property $dash $group_name.transmit_val text "-"
dashboard_set_property $dash $group_name.transmit_val preferredWidth 30

#receive reg
dashboard_add $dash $group_name.receive label $group_name
dashboard_set_property $dash $group_name.receive text "Receive"
dashboard_set_property $dash $group_name.receive preferredWidth 30

dashboard_add $dash $group_name.receive_val label $group_name
dashboard_set_property $dash $group_name.receive_val text "-"
dashboard_set_property $dash $group_name.receive_val preferredWidth 30

#command reg 
dashboard_add $dash $group_name.command label $group_name
dashboard_set_property $dash $group_name.command text "Command"
dashboard_set_property $dash $group_name.command preferredWidth 30

dashboard_add $dash $group_name.command_val label $group_name
dashboard_set_property $dash $group_name.command_val text "-"
dashboard_set_property $dash $group_name.command_val preferredWidth 30

#timer reg
dashboard_add $dash $group_name.timer label $group_name
dashboard_set_property $dash $group_name.timer text "Timer"
dashboard_set_property $dash $group_name.timer preferredWidth 30

dashboard_add $dash $group_name.timer_val label $group_name
dashboard_set_property $dash $group_name.timer_val text "-"
dashboard_set_property $dash $group_name.timer_val preferredWidth 30

# button 
dashboard_add $dash $group_name.bstart button $group_name
dashboard_set_property $dash $group_name.bstart text "Start Mon"
dashboard_set_property $dash $group_name.bstart onClick  "i2c_Control::count_g3  $group_name"


# reg edit
#prer reg
dashboard_add $dash $group_name.prer_wr label $group_name
dashboard_set_property $dash $group_name.prer_wr text "Clock Prescale"
dashboard_set_property $dash $group_name.prer_wr preferredWidth 30

dashboard_add $dash $group_name.prer_wr_val textField $group_name
dashboard_set_property $dash $group_name.prer_wr_val preferredWidth 60
 
dashboard_add $dash $group_name.prer_set button $group_name
dashboard_set_property $dash $group_name.prer_set text "Set"
dashboard_set_property $dash $group_name.prer_set onClick  "i2c_Control::set_prer $group_name"

dashboard_add $dash $group_name.null label $group_name

#transmit reg
dashboard_add $dash $group_name.tx_wr label $group_name
dashboard_set_property $dash $group_name.tx_wr text "Transmit"
dashboard_set_property $dash $group_name.tx_wr preferredWidth 30

dashboard_add $dash $group_name.tx_wr_val textField $group_name
dashboard_set_property $dash $group_name.tx_wr_val preferredWidth 60
 
dashboard_add $dash $group_name.tx_set button $group_name
dashboard_set_property $dash $group_name.tx_set text "Set"
dashboard_set_property $dash $group_name.tx_set onClick  "i2c_Control::set_tx $group_name"

}



0 件のコメント:

コメントを投稿