diff --git a/comdel/display/component_display.cpp b/comdel/display/component_display.cpp index cb1c102..dc77ac5 100644 --- a/comdel/display/component_display.cpp +++ b/comdel/display/component_display.cpp @@ -3,6 +3,7 @@ #include "name_dialog.h" #include "mainwindow.h" #include "application.h" +#include "single_automatic_dialog.h" #include #include @@ -225,6 +226,8 @@ namespace display { connection), component(component), bus(bus) { updateConnection(); + setCursor(Qt::CrossCursor); + setHandlesChildEvents(false); } @@ -249,23 +252,35 @@ namespace display { QMenu menu; menu.addAction("Ukloni poveznicu", [this]() {}); menu.addSeparator(); - for (int i = 0; i < this->connection->attributes.size(); i++) { - auto *attr = &this->connection->attributes[i]; - bool enabled = attr->attribute.getPopup().has_value(); - auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name), - [attr]() { - auto dialog = new AttributeDialog(attr); - dialog->exec(); - }); - action->setEnabled(enabled); + if(connection->bus->bus.getType() == domain::Bus::SINGLE_AUTOMATIC) { + auto &attributes = this->connection->attributes; + menu.addAction(QString::fromStdString("Izmjeni poveznicu"), + [&attributes]() { + auto dialog = new display::SingleAutomaticDialog(attributes); + dialog->exec(); + }); + } else { + for (int i = 0; i < this->connection->attributes.size(); i++) { + auto *attr = &this->connection->attributes[i]; + bool enabled = attr->attribute.getPopup().has_value(); + + auto action = menu.addAction(QString::fromStdString("Izmjeni " + attr->name), + [attr]() { + auto dialog = new AttributeDialog(attr); + dialog->exec(); + }); + action->setEnabled(enabled); + } } + menu.exec(event->screenPos()); } DirectConnection::DirectConnection(domain::DirectConnectionInstance *connection, ComponentGroup *first, ComponentGroup *second): connection(connection), first(first), second(second) { updateConnection(); + setCursor(Qt::CrossCursor); setHandlesChildEvents(false); } diff --git a/comdel/domain/comdel_generator.cpp b/comdel/domain/comdel_generator.cpp index 9646b4a..1096058 100644 --- a/comdel/domain/comdel_generator.cpp +++ b/comdel/domain/comdel_generator.cpp @@ -285,7 +285,11 @@ namespace domain { } else { // if no connection exists than defaults must exist for (auto &wire: *pin.getWires()) { - tempOutput << wire.stringify() << ", "; + if(wire.isType(Value::NIL)) { + tempOutput << "*, "; + } else { + tempOutput << wire.stringify() << ", "; + } } } } @@ -311,22 +315,26 @@ namespace domain { std::vector defaults; if (connection->instance->name == name && connection->connection.getComponent().pin == pin) { wires = connection->connection.getWires(); - selected = connection->attributes[0].value.asReference(); + selected = connection->attributes[0].value.asString(); defaults = *connection->instance->component.getPin(pin).getWires(); } else { wires = *connection->connection.getSecondWires(); - selected = connection->attributes[1].value.asReference(); + selected = connection->attributes[1].value.asString(); defaults = *connection->secondInstance->component.getPin(pin).getWires(); } for (int i = 0; i < wires.size(); i++) { if (wires[i].isType(Value::STRING)) { if (wires[i].asString() == selected) { - buffer << wireNames[connection->bus->name + "." + connection->bus->bus.getWires()[0].getName()] - << ", "; + auto wireName = connection->bus->name + "." + connection->bus->bus.getWires()[0].getName(); + buffer << wireNames[wireName] << ", "; + } else if(defaults[i].isType(Value::NIL)) { + buffer << "*, "; } else { - buffer << defaults[i].stringify(); + buffer << defaults[i].stringify() << ", "; } + } else if(defaults[i].isType(Value::NIL)) { + buffer << "*, "; } else { buffer << wires[i].stringify() << ", "; } diff --git a/comdel/domain/schema_creator.cpp b/comdel/domain/schema_creator.cpp index 145511b..7f57c37 100644 --- a/comdel/domain/schema_creator.cpp +++ b/comdel/domain/schema_creator.cpp @@ -736,7 +736,7 @@ namespace domain { std::optional popup; if (node.popup) { - popup = loadPopup(*node.popup, name, value.getType()); + popup = loadPopup(*node.popup, name, toType(node.type)); } pop(); @@ -958,7 +958,7 @@ namespace domain { errors.emplace_back(attr.span, "invalid value"); } - attributes.emplace_back(attribute.getName(), toType(attr.value), attribute); + attributes.emplace_back(attribute.getName(), value, attribute); } else { errors.emplace_back(attr.name.span, "unknown attribute"); } diff --git a/examples/simplified FRISC model/comdel.system b/examples/simplified FRISC model/comdel.system index e69de29..f9fa11d 100644 --- a/examples/simplified FRISC model/comdel.system +++ b/examples/simplified FRISC model/comdel.system @@ -0,0 +1,66 @@ +// Version 0.0.1 +#include "libraries\frisc\vjezba1\FRISC.cdl" +#include "libraries\frisc\vjezba1\dma.cdl" +#include "libraries\frisc\vjezba1\memory.cdl" + + + +component System +{ + clock 100MHz; + //glavnaSabirnica + wire<32> ADR; + wire<32> DATA; + wire READ; + wire WRITE; + wired_and WAIT; + wired_and INT0; + wired_and INT1; + wired_and INT2; + wired_and INT3; + wire<3> SIZE; + wire --IACK; + wire --BREQ; + wire --BACK; + + + //PIOSabirnica + wire<8> PIO_DATA; + wire READY; + wire STROBE; + + + //directRam + wire INT; + + + // components -------------------------------------------- + subcomponent Memorija memorija(ADR, DATA, READ, WRITE, SIZE, WAIT, INT, *, *, *); + subcomponent FRISC procesor(ADR, DATA, READ, WRITE, SIZE, WAIT, INT0, INT1, INT2, INT3, --IACK, 1, *, INT, *, *, *); + subcomponent DMA dma<1024>(ADR, DATA, READ, WRITE, SIZE, WAIT, INT0, --BREQ, --BACK, 0, 0, *, *); + + display { + component { x: -104; y: -102; ref: "procesor"; } + component { x: 39; y: 199; ref: "memorija"; } + component { x: -352; y: 13; ref: "dma"; } + + // glavnaSabirnica bus + + rectangle { + x: -106; y: 80; + w: 100; h: 20; + } + + + // PIOSabirnica bus + + + // directRam bus + + + line {x1:-54; y1:14; x2:-55; y2:90;} + line {x1:89; y1:183; x2:-55; y2:90;} + line {x1:-244; y1:79; x2:-55; y2:90;} + line {x1:23; y1:227; x2:12; y2:-52;} + } +} \ No newline at end of file diff --git a/examples/simplified FRISC model/frisc_library.csl b/examples/simplified FRISC model/frisc_library.csl index 51df581..f9d64a6 100644 --- a/examples/simplified FRISC model/frisc_library.csl +++ b/examples/simplified FRISC model/frisc_library.csl @@ -72,6 +72,7 @@ orientation: "right"; } } + @wires{null, null, null, null} } } @@ -214,6 +215,7 @@ orientation: "left"; } } + @wires{null, null, null, null} } } @@ -280,7 +282,7 @@ } */ pin { - x: 100; y: 50; w: 16; h: 16; + x: 100; y: 30; w: 16; h: 16; } } } @@ -290,7 +292,7 @@ @connection optional("COMDEL se ne može stvoriti. DMA nije spojen na nesto!") @display { pin { - x: 0; y: 0; w: 0; h: 0; + x: 100; y: 7; w: 16; h: 16; } } @wires { 0, 0, null, null} @@ -374,7 +376,7 @@ @wires{ADR, DATA, READ, WRITE, SIZE, WAIT, interupt, BREQ, BACK} } -@connection (DMA.glavniPin, PIOSabirnica, FRISC.glavniPin) { +@connection (DMA.dodatnaPoveznica, PIOSabirnica, FRISC.glavniPin) { @wires{PIO_DATA, READY, STROBE} @wires{PIO_DATA, READY, STROBE} } diff --git a/examples/simplified FRISC model/schema4.csl b/examples/simplified FRISC model/schema4.csl new file mode 100644 index 0000000..33e3541 --- /dev/null +++ b/examples/simplified FRISC model/schema4.csl @@ -0,0 +1,36 @@ +@source "/home/bbr/Documents/Personal/FER/schema_editor/examples/simplified FRISC model/frisc_library.csl" + +@schema { + @instance procesor FRISC { + @position (-162, -117) + @attribute _memory null + } + + @instance dma DMA { + @position (-393, -26) + @attribute pocetnaAdresa 0 + } + + @instance glavnaSabirnica glavnaSabirnica { + @position (-155, 49) + @size 100 + } + + @instance PIOSabirnica PIOSabirnica { + @position (0, 0) + @size 0 + } + + @instance PIOSabirnica PIOSabirnica { + @position (0, 0) + @size 0 + } + + @connection (dma.glavniPin, PIOSabirnica, procesor.glavniPin) { + } + @connection (dma.glavniPin, glavnaSabirnica) { + @attribute interupt 1 + } + @connection (dma.glavniPin, PIOSabirnica, procesor.glavniPin) { + } +} diff --git a/examples/simplified FRISC model/schema5.csl b/examples/simplified FRISC model/schema5.csl new file mode 100644 index 0000000..f65fc46 --- /dev/null +++ b/examples/simplified FRISC model/schema5.csl @@ -0,0 +1,49 @@ +@source "/home/bbr/Documents/Personal/FER/schema_editor/examples/simplified FRISC model/frisc_library.csl" + +@schema { + @instance procesor FRISC { + @position (-104, -102) + @attribute _memory null + } + + @instance memorija Memorija { + @position (39, 199) + @attribute sinkroniziran false + @attribute brzina 1 + @attribute kapacitet 1024 + @attribute size 8 + @attribute pocetnaAdresa 0 + } + + @instance dma DMA { + @position (-352, 13) + @attribute pocetnaAdresa 1024 + } + + @instance glavnaSabirnica glavnaSabirnica { + @position (-106, 80) + @size 100 + } + + @instance PIOSabirnica PIOSabirnica { + @position (0, 0) + @size -1 + } + + @instance directRam directRam { + @position (0, 0) + @size -1 + } + + @connection (procesor.glavniPin, glavnaSabirnica) { + } + @connection (memorija.glavniPin, glavnaSabirnica) { + } + @connection (dma.glavniPin, glavnaSabirnica) { + @attribute interupt INT0 + } + @connection (memorija.memDirect, directRam, procesor.memDirect) { + @attribute procConn "INT" + @attribute memConn "INT" + } +}