34 #include <wx/listctrl.h>
35 #include <wx/radiobox.h>
36 #include <wx/spinctrl.h>
37 #include <boost/format.hpp>
125 wxDialog(parent, -1, _T(""), wxDefaultPosition, wxSize(300, 300)),
131 alwaysTrueGuard_(NULL),
132 alwaysFalseGuard_(NULL),
133 immediateExtensionBox_(NULL),
137 createContents(
this,
true,
true);
149 rfGuardList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_RF_GUARD_LIST));
150 fuGuardList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_FU_GUARD_LIST));
151 segList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_SEGMENT_LIST));
153 immediateExtensionBox_ =
154 dynamic_cast<wxRadioBox*
>(
FindWindow(ID_SI_EXTENSION));
156 dynamic_cast<wxCheckBox*
>(
FindWindow(ID_TRUE_GUARD));
158 dynamic_cast<wxCheckBox*
>(
FindWindow(ID_FALSE_GUARD));
161 wxTextValidator(wxFILTER_ASCII, &name_));
163 wxTextValidator(wxFILTER_ASCII, &newSegName_));
164 FindWindow(ID_BUS_WIDTH)->SetValidator(wxGenericValidator(&width_));
165 FindWindow(ID_SI_WIDTH)->SetValidator(wxGenericValidator(&immWidth_));
170 TransferDataToWindow();
175 segmentSizer_->Show(
false);
176 GetSizer()->SetSizeHints(
this);
199 string title = fmt.str();
272 string label = fmt.str();
293 wxListCtrl* segmentList =
294 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_SEGMENT_LIST));
295 wxListCtrl* rfGuardList =
296 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_RF_GUARD_LIST));
297 wxListCtrl* fuGuardList =
298 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_FU_GUARD_LIST));
301 string invLabel = fmt.str();
304 string nameLabel = fmt.str();
307 string indexLabel = fmt.str();
310 string portLabel = fmt.str();
313 wxLIST_FORMAT_LEFT, 280);
316 wxLIST_FORMAT_LEFT, 170);
318 wxLIST_FORMAT_LEFT, 70);
320 wxLIST_FORMAT_LEFT, 40);
323 wxLIST_FORMAT_LEFT, 40);
325 wxLIST_FORMAT_LEFT, 170);
327 wxLIST_FORMAT_LEFT, 70);
340 width_ = bus_->width();
341 immWidth_ = bus_->immediateWidth();
345 if (bus_->signExtends()) {
346 immediateExtensionBox_->SetStringSelection(
349 immediateExtensionBox_->SetStringSelection(
358 dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_BUS_WIDTH))->SetValue(width_);
359 dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_SI_WIDTH))->SetValue(immWidth_);
364 return wxWindow::TransferDataToWindow();
380 assert (rfGuard1 != NULL);
381 assert (rfGuard2 != NULL);
393 }
else if (name1 > name2) {
395 }
else if (index1 < index2) {
397 }
else if (index1 > index2) {
399 }
else if (!inverted1 && inverted2) {
401 }
else if (inverted1 && !inverted2) {
414 assert (rfGuardList_ != NULL);
415 assert (fuGuardList_ != NULL);
416 rfGuardList_->DeleteAllItems();
417 fuGuardList_->DeleteAllItems();
419 registerGuards_.clear();
422 alwaysTrueGuard_->SetValue(
false);
423 alwaysFalseGuard_->SetValue(
false);
426 for (
int i = 0; i < bus_->guardCount(); i++) {
428 Guard* guard = bus_->guard(i);
436 if (unCondGuard != NULL) {
439 alwaysFalseGuard_->SetValue(
true);
441 alwaysTrueGuard_->SetValue(
true);
443 }
else if(rfGuard != NULL) {
445 int index = registerGuards_.size();
446 registerGuards_.push_back(rfGuard);
453 rfGuardList_->SetItem(index, 2, _T(
"*"));
455 rfGuardList_->SetItem(index, 2, _T(
" "));
459 rfGuardList_->SetItemData(index, (
long)rfGuard);
460 }
else if(fuGuard != NULL) {
462 int index = portGuards_.size();
463 portGuards_.push_back(fuGuard);
466 fuGuardList_->InsertItem(index, _T(
"*"));
468 fuGuardList_->InsertItem(index, _T(
" "));
487 segList_->DeleteAllItems();
489 for (
int i = bus_->segmentCount()-1;i > -1;i--) {
490 string segmentName = bus_->segment(i)->name();
505 for (
int i = 0; i < segList_->GetItemCount(); i++) {
507 if (segList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
509 selected = bus_->segment(name);
524 item = fuGuardList_->GetNextItem(
525 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
531 assert (item <
int(portGuards_.size()));
533 return portGuards_[item];
545 item = rfGuardList_->GetNextItem(
546 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
552 assert (item <
int(registerGuards_.size()));
554 long itemData = rfGuardList_->GetItemData(item);
569 if (!TransferDataFromWindow()) {
572 assert(newSegName_ != _T(
""));
590 if (bus_->hasSegment(trimmedName)) {
597 message % trimmedName % component.str() % bus.str();
599 message % component.str();
604 new Segment(trimmedName, *bus_);
608 dynamic_cast<wxTextCtrl*
>(
609 FindWindow(ID_SEGMENT_NAME))->SetValue(_T(
""));
618 if (!TransferDataFromWindow()) {
621 wxString trimmedName = name_.Trim(
false).Trim(
true);
622 if (trimmedName == _T(
"")) {
637 bool inverted =
false;
638 wxCheckBox* checkbox = alwaysTrueGuard_;
640 if (event.GetId() == ID_FALSE_GUARD) {
642 checkbox = alwaysFalseGuard_;
645 if (!checkbox->GetValue()) {
646 for (
int i = 0; i < bus_->guardCount(); i++) {
647 Guard* guard = bus_->guard(i);
650 if (unCondGuard != NULL &&
677 if (!TransferDataFromWindow()) {
680 wxString trimmedName = newSegName_.Trim(
false).Trim(
true);
681 if (trimmedName == _T(
"")) {
694 if (segList_->GetSelectedItemCount() != 1) {
714 segList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
715 wxLIST_STATE_SELECTED);
717 wxMenu* contextMenu =
new wxMenu();
720 format button = prodeTexts->
text(
724 segList_->PopupMenu(contextMenu, event.GetPoint());
737 Segment* selected = selectedSegment();
744 onSegmentSelection(
dummy);
753 Segment* selected = selectedSegment();
754 assert (selected != NULL);
766 segList_->SetItemState(i,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
776 Segment* selected = selectedSegment();
777 assert (selected != NULL);
789 segList_->SetItemState(i,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
803 if (!TransferDataFromWindow()) {
810 bus_->machine()->instructionTemplateNavigator();
811 for (
int i = 0; i < navigator.
count(); i++) {
812 int slotWidth = navigator.
item(i)->supportedWidth(bus_->name());
813 if (slotWidth != 0 && slotWidth > width_) {
816 format message = generator->
text(
818 message % navigator.
item(i)->name();
841 if (trimmedName != bus_->name()) {
843 bus_->machine()->busNavigator();
844 if (busNavigator.
hasItem(trimmedName)) {
848 message % trimmedName;
860 bus_->machine()->immediateSlotNavigator();
861 if (immSlotNavigator.
hasItem(trimmedName)) {
865 message % trimmedName;
866 message % prodeTexts->
text(
877 bus_->setWidth(width_);
878 bus_->setImmediateWidth(immWidth_);
879 bus_->setName(trimmedName);
881 if (immediateExtensionBox_->GetStringSelection().IsSameAs(
884 bus_->setZeroExtends();
886 bus_->setSignExtends();
900 bus_->machine()->registerFileNavigator();
902 if (navigator.
count() < 1) {
926 for (
int i = 0; i < rfGuardList_->GetSelectedItemCount(); ++i) {
927 item = rfGuardList_->GetNextItem(
928 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
930 assert (item <
static_cast<int>(registerGuards_.size()));
934 long itemData = rfGuardList_->GetItemData(item);
936 if (rfGuard != NULL) {
945 onRFGuardSelection(
dummy);
979 if (rfGuardList_->GetSelectedItemCount() != 1) {
985 if (rfGuardList_->GetSelectedItemCount() < 1) {
1000 bus_->machine()->functionUnitNavigator();
1002 bool portExists =
false;
1003 for (
int i = 0; i < navigator.
count(); i++) {
1004 if (navigator.
item(i)->portCount() > 0) {
1033 delete selectedFUGuard();
1036 onFUGuardSelection(
dummy);
1049 if (guard == NULL) {
1064 wxSpinCtrl* width =
dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_BUS_WIDTH));
1065 wxSpinCtrl* siWidth =
dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_SI_WIDTH));
1066 if (siWidth->GetValue() > width->GetValue()) {
1067 siWidth->SetValue(width->GetValue());
1069 siWidth->SetRange(0, width->GetValue());
1082 if (fuGuardList_->GetSelectedItemCount() != 1) {
1101 rfGuardList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
1102 wxLIST_STATE_SELECTED);
1104 wxMenu* contextMenu =
new wxMenu();
1107 format button = prodeTexts->
text(
1109 contextMenu->Append(
1111 button = prodeTexts->
text(
1113 contextMenu->Append(
1115 rfGuardList_->PopupMenu(contextMenu, event.GetPoint());
1124 wxCommandEvent
dummy;
1125 onEditRFGuard(
dummy);
1138 fuGuardList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
1139 wxLIST_STATE_SELECTED);
1141 wxMenu* contextMenu =
new wxMenu();
1144 format button = prodeTexts->
text(
1146 contextMenu->Append(
1148 button = prodeTexts->
text(
1150 contextMenu->Append(
1152 fuGuardList_->PopupMenu(contextMenu, event.GetPoint());
1161 wxCommandEvent
dummy;
1162 onEditFUGuard(
dummy);
1180 wxFlexGridSizer *item0 =
new wxFlexGridSizer( 2, 0, 0 );
1182 wxBoxSizer *item1 =
new wxBoxSizer( wxVERTICAL );
1184 wxStaticBox *item3 =
new wxStaticBox( parent, -1, wxT(
"Bus:") );
1185 wxStaticBoxSizer *item2 =
new wxStaticBoxSizer( item3, wxVERTICAL );
1188 wxBoxSizer *item4 =
new wxBoxSizer( wxHORIZONTAL );
1190 wxStaticText *item5 =
new wxStaticText( parent, ID_LABEL_BUS_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
1191 item4->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
1193 wxTextCtrl *item6 =
new wxTextCtrl( parent, ID_BUS_NAME, wxT(
""), wxDefaultPosition, wxSize(200,-1), 0 );
1194 item4->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
1196 item2->Add( item4, 0, wxGROW|wxALL, 5 );
1198 wxBoxSizer *item7 =
new wxBoxSizer( wxHORIZONTAL );
1200 wxStaticText *item8 =
new wxStaticText( parent, ID_LABEL_BUS_WIDTH, wxT(
"Width:"), wxDefaultPosition, wxDefaultSize, 0 );
1201 item7->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
1203 wxSpinCtrl *item9 =
new wxSpinCtrl( parent, ID_BUS_WIDTH, wxT(
"1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 1024, 1 );
1204 item7->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
1206 item2->Add( item7, 0, wxGROW|wxALL, 5 );
1208 item0->Add( item2, 0, wxGROW|wxALL, 5 );
1211 wxStaticBox *item11 =
new wxStaticBox( parent, -1, wxT(
"Short Immediate:") );
1212 wxStaticBoxSizer *item10 =
new wxStaticBoxSizer( item11, wxVERTICAL );
1215 wxBoxSizer *item12 =
new wxBoxSizer( wxHORIZONTAL );
1217 wxStaticText *item13 =
new wxStaticText( parent, ID_LABEL_SI_WIDTH, wxT(
"Width:"), wxDefaultPosition, wxDefaultSize, 0 );
1218 item12->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
1220 wxSpinCtrl *item14 =
new wxSpinCtrl( parent, ID_SI_WIDTH, wxT(
"0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 1000, 0 );
1221 item12->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
1223 item10->Add( item12, 0, wxGROW|wxALL, 5 );
1230 wxRadioBox *item15 =
new wxRadioBox( parent, ID_SI_EXTENSION, wxT(
"Extension"), wxDefaultPosition, wxDefaultSize, 2, strs15, 1, wxRA_SPECIFY_ROWS );
1231 item10->Add( item15, 0, wxALL, 5 );
1233 item0->Add( item10, 0, wxGROW|wxALL, 5 );
1236 wxCheckBox *item16 =
new wxCheckBox( parent, ID_TRUE_GUARD, wxT(
"Always true guard"), wxDefaultPosition, wxDefaultSize, 0 );
1237 item1->Add( item16, 0, wxALL, 5 );
1239 wxCheckBox *item17 =
new wxCheckBox( parent, ID_FALSE_GUARD, wxT(
"Always false guard"), wxDefaultPosition, wxDefaultSize, 0 );
1240 item1->Add( item17, 0, wxALL, 5 );
1242 item0->Add( item1, 0, wxGROW|wxALL, 5 );
1244 wxStaticBox *item19 =
new wxStaticBox( parent, -1, wxT(
"Segements:") );
1245 wxStaticBoxSizer *item18 =
new wxStaticBoxSizer( item19, wxVERTICAL );
1246 segmentSizer_ = item18;
1248 wxListCtrl *item20 =
new wxListCtrl( parent, ID_SEGMENT_LIST, wxDefaultPosition, wxSize(300,160), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
1249 item18->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
1251 wxBoxSizer *item21 =
new wxBoxSizer( wxHORIZONTAL );
1253 wxStaticText *item22 =
new wxStaticText( parent, ID_LABEL_SEGMENT_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
1254 item21->Add( item22, 0, wxALIGN_CENTER|wxALL, 5 );
1256 wxTextCtrl *item23 =
new wxTextCtrl( parent, ID_SEGMENT_NAME, wxT(
""), wxDefaultPosition, wxSize(100,-1), 0 );
1257 item21->Add( item23, 0, wxALIGN_CENTER|wxALL, 5 );
1259 wxBoxSizer *item24 =
new wxBoxSizer( wxHORIZONTAL );
1261 wxButton *item25 =
new wxButton( parent, ID_SEGMENT_UP, wxT(
"Up"), wxDefaultPosition, wxSize(40,-1), 0 );
1262 item24->Add( item25, 0, wxALIGN_CENTER|wxALL, 5 );
1264 wxButton *item26 =
new wxButton( parent, ID_SEGMENT_DOWN, wxT(
"Down"), wxDefaultPosition, wxSize(50,-1), 0 );
1265 item24->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
1267 item21->Add( item24, 0, wxALL, 5 );
1269 item18->Add( item21, 0, wxGROW|wxALL, 5 );
1271 wxBoxSizer *item27 =
new wxBoxSizer( wxHORIZONTAL );
1273 wxButton *item28 =
new wxButton( parent, ID_ADD_SEGMENT, wxT(
"Add"), wxDefaultPosition, wxDefaultSize, 0 );
1274 item27->Add( item28, 0, wxALIGN_CENTER|wxALL, 5 );
1276 item27->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
1278 wxButton *item29 =
new wxButton( parent, ID_DELETE_SEGMENT, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1279 item27->Add( item29, 0, wxALIGN_CENTER|wxALL, 5 );
1281 item18->Add( item27, 0, wxALIGN_CENTER|wxALL, 5 );
1283 item0->Add( item18, 0, wxALL, 5 );
1285 wxStaticBox *item31 =
new wxStaticBox( parent, -1, wxT(
"Register File Guards:") );
1286 wxStaticBoxSizer *item30 =
new wxStaticBoxSizer( item31, wxVERTICAL );
1287 registerGuardSizer_ = item30;
1289 wxListCtrl *item32 =
new wxListCtrl( parent, ID_RF_GUARD_LIST, wxDefaultPosition, wxSize(300,120), wxLC_REPORT|wxSUNKEN_BORDER );
1290 item30->Add( item32, 0, wxALIGN_CENTER|wxALL, 5 );
1292 wxBoxSizer *item33 =
new wxBoxSizer( wxHORIZONTAL );
1294 wxButton *item34 =
new wxButton( parent, ID_ADD_RF_GUARD, wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0 );
1295 item33->Add( item34, 0, wxALIGN_CENTER|wxALL, 5 );
1297 wxButton *item35 =
new wxButton( parent, ID_EDIT_RF_GUARD, wxT(
"Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
1298 item35->Enable(
false );
1299 item33->Add( item35, 0, wxALIGN_CENTER|wxALL, 5 );
1301 wxButton *item36 =
new wxButton( parent, ID_DELETE_RF_GUARD, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1302 item36->Enable(
false );
1303 item33->Add( item36, 0, wxALIGN_CENTER|wxALL, 5 );
1305 item30->Add( item33, 0, wxALIGN_CENTER|wxALL, 5 );
1307 item0->Add( item30, 0, wxGROW|wxALL, 5 );
1309 wxStaticBox *item38 =
new wxStaticBox( parent, -1, wxT(
"Function Unit Guards") );
1310 wxStaticBoxSizer *item37 =
new wxStaticBoxSizer( item38, wxVERTICAL );
1311 portGuardSizer_ = item37;
1313 wxListCtrl *item39 =
new wxListCtrl( parent, ID_FU_GUARD_LIST, wxDefaultPosition, wxSize(300,120), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
1314 item37->Add( item39, 0, wxALIGN_CENTER|wxALL, 5 );
1316 wxBoxSizer *item40 =
new wxBoxSizer( wxHORIZONTAL );
1318 wxButton *item41 =
new wxButton( parent, ID_ADD_FU_GUARD, wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0 );
1319 item40->Add( item41, 0, wxALIGN_CENTER|wxALL, 5 );
1321 wxButton *item42 =
new wxButton( parent, ID_EDIT_FU_GUARD, wxT(
"Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
1322 item42->Enable(
false );
1323 item40->Add( item42, 0, wxALIGN_CENTER|wxALL, 5 );
1325 wxButton *item43 =
new wxButton( parent, ID_DELETE_FU_GUARD, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1326 item43->Enable(
false );
1327 item40->Add( item43, 0, wxALIGN_CENTER|wxALL, 5 );
1329 item37->Add( item40, 0, wxALIGN_CENTER|wxALL, 5 );
1331 item0->Add( item37, 0, wxGROW|wxALL, 5 );
1333 wxButton *item44 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
1334 item0->Add( item44, 0, wxALL, 5 );
1336 wxBoxSizer *item45 =
new wxBoxSizer( wxHORIZONTAL );
1338 wxButton *item46 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
1339 item45->Add( item46, 0, wxALIGN_CENTER|wxALL, 5 );
1341 wxButton *item47 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
1342 item45->Add( item47, 0, wxALIGN_CENTER|wxALL, 5 );
1344 item0->Add( item45, 0, wxALL, 5 );
1348 parent->SetSizer( item0 );
1350 item0->SetSizeHints( parent );