sed 's,@CXX@,$(CXX),; s,@CXXFLAGS@,$(CXXFLAGS),; s,@LDFLAGS@,$(LDFLAGS),; s,@LDLIBS@,$(LDLIBS),;' < yosys-config.in > yosys-config
chmod +x yosys-config
-yosys-svgviewer: libs/svgviewer/*
- cd libs/svgviewer && qmake && make
- cp libs/svgviewer/svgviewer yosys-svgviewer
+yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp
+ -cd libs/svgviewer && qmake-qt4 && make
+ -cp libs/svgviewer/svgviewer yosys-svgviewer
test: yosys
cd tests/simple && bash run-test.sh
install: yosys
install yosys /usr/local/bin/yosys
install yosys-config /usr/local/bin/yosys-config
- install yosys-svgviewer /usr/local/bin/yosys-svgviewer
+ -install yosys-svgviewer /usr/local/bin/yosys-svgviewer
install yosys-filterlib /usr/local/bin/yosys-filterlib
clean:
log(" show [options] [selection]\n");
log("\n");
log("Create a graphviz DOT file for the selected part of the design and compile it\n");
- log("to a postscript file.\n");
+ log("to a graphics file (usually SVG or PostScript).\n");
log("\n");
- log(" -viewer <command>\n");
- log(" Also run the specified command with the postscript file as parameter.\n");
+ log(" -viewer <viewer>\n");
+ log(" Run the specified command with the graphics file as parameter.\n");
+ log("\n");
+ log(" -format <format>\n");
+ log(" Generate a graphics file in the specified format.\n");
+ log(" Usually <format> is 'svg' or 'ps'.\n");
log("\n");
log(" -lib <verilog_or_ilang_file>\n");
log(" Use the specified library file for determining whether cell ports are\n");
log(" stretch the graph so all inputs are on the left side and all outputs\n");
log(" (including inout ports) are on the right side.\n");
log("\n");
- log("The generated output files are `yosys-show.dot' and `yosys-show.ps'.\n");
+ log("When no <format> is specified, SVG is used. When no <format> and <viewer> is\n");
+ log("specified, 'yosys-svgviewer' is used to display the schematic.\n");
+ log("\n");
+ log("The generated output files are 'yosys-show.dot' and 'yosys-show.<format>',\n");
+ log("unless another prefix is specified using -prefix <prefix>.\n");
log("\n");
}
virtual void execute(std::vector<std::string> args, RTLIL::Design *design)
log_header("Generating Graphviz representation of design.\n");
log_push();
+ std::string format;
std::string viewer_exe;
std::string prefix = "yosys-show";
std::vector<std::string> libfiles;
colorSeed = atoi(args[++argidx].c_str());
continue;
}
+ if (arg == "-format" && argidx+1 < args.size()) {
+ format = atoi(args[++argidx].c_str());
+ continue;
+ }
if (arg == "-width") {
flag_width= true;
continue;
log_header("Continuing show pass.\n");
std::string dot_file = stringf("%s.dot", prefix.c_str());
- std::string ps_file = stringf("%s.ps", prefix.c_str());
+ std::string out_file = stringf("%s.%s", prefix.c_str(), format.empty() ? "svg" : format.c_str());
log("Writing dot description to `%s'.\n", dot_file.c_str());
FILE *f = fopen(dot_file.c_str(), "w");
- if (f == NULL)
+ if (f == NULL) {
+ for (auto lib : libs)
+ delete lib;
log_cmd_error("Can't open dot file `%s' for writing.\n", dot_file.c_str());
+ }
ShowWorker worker(f, design, libs, colorSeed, flag_width, flag_stretch);
fclose(f);
+ for (auto lib : libs)
+ delete lib;
+
if (worker.page_counter == 0)
log_cmd_error("Nothing there to show.\n");
- std::string cmd = stringf("dot -Tps -o '%s' '%s'", ps_file.c_str(), dot_file.c_str());
+ std::string cmd = stringf("dot -T%s -o '%s' '%s'", format.empty() ? "svg" : format.c_str(), out_file.c_str(), dot_file.c_str());
log("Exec: %s\n", cmd.c_str());
if (system(cmd.c_str()) != 0)
log_cmd_error("Shell command failed!\n");
if (!viewer_exe.empty()) {
- cmd = stringf("%s '%s' &", viewer_exe.c_str(), ps_file.c_str());
+ cmd = stringf("%s '%s' &", viewer_exe.c_str(), out_file.c_str());
+ log("Exec: %s\n", cmd.c_str());
+ if (system(cmd.c_str()) != 0)
+ log_cmd_error("Shell command failed!\n");
+ } else
+ if (format.empty()) {
+ cmd = stringf("fuser -s '%s' || yosys-svgviewer '%s' &", out_file.c_str(), out_file.c_str());
log("Exec: %s\n", cmd.c_str());
if (system(cmd.c_str()) != 0)
log_cmd_error("Shell command failed!\n");
}
- for (auto lib : libs)
- delete lib;
-
log_pop();
}
} ShowPass;
#include "mainwindow.h"
#include <QtGui>
+#include <QFileSystemWatcher>
#include "svgview.h"
MainWindow::MainWindow()
: QMainWindow()
, m_view(new SvgView)
+ , m_watcher(NULL)
+ , m_filehandle(NULL)
{
QMenu *fileMenu = new QMenu(tr("&File"), this);
QAction *openAction = fileMenu->addAction(tr("&Open..."));
else
fileName = path;
+ if (m_watcher) {
+ delete m_watcher;
+ m_watcher = NULL;
+ }
+ if (m_filehandle) {
+ fclose(m_filehandle);
+ m_filehandle = NULL;
+ }
+
if (!fileName.isEmpty()) {
QFile file(fileName);
if (!file.exists()) {
return;
}
+ m_watcher = new QFileSystemWatcher(this);
+ m_watcher->addPath(fileName);
+ connect(m_watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(reloadFile()));
+
+ // just keep the file open so this process is found using 'fuser'
+ m_filehandle = fopen(fileName.toAscii(), "r");
+
m_view->openFile(file);
if (!fileName.startsWith(":/")) {
m_outlineAction->setEnabled(true);
m_backgroundAction->setEnabled(true);
- resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
+ // resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
}
}
+void MainWindow::reloadFile()
+{
+ openFile(m_currentPath);
+}
+
void MainWindow::setRenderer(QAction *action)
{
#ifndef QT_NO_OPENGL