mirror of
https://gitee.com/eda-development/eda_fpga.git
synced 2025-08-06 17:22:03 +08:00
111
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.11.1, 2021-01-24T18:37:44. -->
|
<!-- Written by QtCreator 4.11.1, 2021-01-24T19:52:15. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -1,40 +1,68 @@
|
|||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
Module::Module()
|
Module::Module()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::Module(std::string name,int inputPorts,int outputPorts,int inOutPorts)
|
Module::Module(QString name,int inputPorts,int outputPorts,int inOutPorts)
|
||||||
{
|
{
|
||||||
this->name = name;
|
this->name = name;
|
||||||
int portsNum = 0;
|
this->latestNum = 0;
|
||||||
for(int i = 0;i<inputPorts;i++,portsNum++)
|
for(int i = 0;i<inputPorts;i++,this->latestNum++)
|
||||||
{
|
{
|
||||||
this->ports.push_back(Port("p"+std::to_string(portsNum),INPUT,0,1));
|
this->ports.push_back(Port("p"+QString::number(this->latestNum),INPUT,0,1,this->latestNum));
|
||||||
}
|
}
|
||||||
for(int i = 0;i<outputPorts;i++,portsNum++)
|
for(int i = 0;i<outputPorts;i++,this->latestNum++)
|
||||||
{
|
{
|
||||||
this->ports.push_back(Port("p"+std::to_string(portsNum),OUTPUT,0,1));
|
this->ports.push_back(Port("p"+QString::number(this->latestNum),OUTPUT,0,1,this->latestNum));
|
||||||
}
|
}
|
||||||
for(int i = 0;i<inOutPorts;i++,portsNum++)
|
for(int i = 0;i<inOutPorts;i++,this->latestNum++)
|
||||||
{
|
{
|
||||||
this->ports.push_back(Port("p"+std::to_string(portsNum),INOUT,0,1));
|
this->ports.push_back(Port("p"+QString::number(this->latestNum),INOUT,0,1,this->latestNum));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setCode(std::string code)
|
Port Module::getSelectedPort(int portNum)
|
||||||
|
{
|
||||||
|
for(unsigned long i = 0;i<this->ports.size();i++){
|
||||||
|
if(this->ports.at(i).getPortNum()==portNum)
|
||||||
|
return this->ports.at(i);
|
||||||
|
}
|
||||||
|
return Port();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::addPort()
|
||||||
|
{
|
||||||
|
this->ports.push_back(Port("p"+QString::number(this->latestNum),INPUT,0,1,this->latestNum));
|
||||||
|
}
|
||||||
|
void Module::deletePort(int portNum)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(this->ports[portNum].getPortType()==INPUT){
|
||||||
|
this->inputPorts--;
|
||||||
|
}else if(this->ports[portNum].getPortType()==OUTPUT) {
|
||||||
|
this->ouputPorts--;
|
||||||
|
}else{
|
||||||
|
this->inOutPorts--;
|
||||||
|
}
|
||||||
|
for(unsigned long i = 0;i<this->ports.size();i++){
|
||||||
|
if(this->ports.at(i).getPortNum()==portNum)
|
||||||
|
this->ports.erase(this->ports.begin()+i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::setCode(QString code)
|
||||||
{
|
{
|
||||||
this->code = code;
|
this->code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Module::getCode()
|
QString Module::getCode()
|
||||||
{
|
{
|
||||||
return this->code;
|
return this->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Module::generateCode()
|
QString Module::generateCode()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,22 +2,27 @@
|
|||||||
#define MODULE_H
|
#define MODULE_H
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <QString>
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
class Module
|
class Module
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string name;
|
QString name; //模块名字
|
||||||
int inputPorts;
|
int inputPorts; //输入端口数量
|
||||||
int ouputPorts;
|
int ouputPorts; //输出端口数量
|
||||||
int inOutPorts;
|
int inOutPorts; //双向端口数量
|
||||||
std::string code;
|
int latestNum; //vector标识
|
||||||
std::vector<Port> ports;
|
QString code; //code
|
||||||
|
std::vector<Port> ports; //端口类数组
|
||||||
public:
|
public:
|
||||||
Module();
|
Module();
|
||||||
Module(std::string,int,int,int);
|
Module(QString,int,int,int); //构造函数 (名字,输入端口数量,输出端口数量,双向端口数量)
|
||||||
void setCode(std::string);
|
Port getSelectedPort(int); //返回选中的Port 参数为port对象标识默认从0开始
|
||||||
std::string getCode();
|
void addPort(); //添加Port
|
||||||
std::string generateCode();
|
void deletePort(int); //删除Port
|
||||||
|
void setCode(QString);
|
||||||
|
QString getCode();
|
||||||
|
QString generateCode();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MODULE_H
|
#endif // MODULE_H
|
||||||
|
@ -5,20 +5,21 @@ Port::Port()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Port::Port(std::string name,PortType portType,bool dataType,int dataSize)
|
Port::Port(QString name,PortType portType,bool dataType,int dataSize,int portNum)
|
||||||
{
|
{
|
||||||
this->name = name;
|
this->name = name;
|
||||||
this->portType = portType;
|
this->portType = portType;
|
||||||
this->dataSize =dataSize;
|
this->dataSize =dataSize;
|
||||||
this->dataType = dataType;
|
this->dataType = dataType;
|
||||||
|
this->portNum = portNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Port::setName(std::string name)
|
void Port::setName(QString name)
|
||||||
{
|
{
|
||||||
this->name = name;
|
this->name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Port::getName()
|
QString Port::getName()
|
||||||
{
|
{
|
||||||
return this->name;
|
return this->name;
|
||||||
}
|
}
|
||||||
@ -49,3 +50,6 @@ int Port::getDataSize()
|
|||||||
{
|
{
|
||||||
return this->dataSize;
|
return this->dataSize;
|
||||||
}
|
}
|
||||||
|
int Port::getPortNum(){
|
||||||
|
return this->portNum;
|
||||||
|
}
|
||||||
|
@ -1,28 +1,29 @@
|
|||||||
#ifndef PORT_H
|
#ifndef PORT_H
|
||||||
#define PORT_H
|
#define PORT_H
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <QString>
|
||||||
enum PortType{INPUT,OUTPUT,INOUT};
|
enum PortType{INPUT,OUTPUT,INOUT};
|
||||||
|
|
||||||
class Port
|
class Port
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string name; //端口名
|
QString name; //端口名
|
||||||
PortType portType; //输入或输出 0为in 1为out
|
PortType portType; //输入或输出 0为in 1为out
|
||||||
bool dataType; //数据类型 0为wire 1为reg
|
bool dataType; //数据类型 0为wire 1为reg
|
||||||
int dataSize; //数据长度
|
int dataSize; //数据长度
|
||||||
|
int portNum; //端口标识
|
||||||
public:
|
public:
|
||||||
Port();
|
Port();
|
||||||
Port(std::string,PortType,bool,int);
|
Port(QString,PortType,bool,int,int);
|
||||||
void setName(std::string);
|
void setName(QString);
|
||||||
std::string getName();
|
QString getName();
|
||||||
void setPortType(PortType);
|
void setPortType(PortType);
|
||||||
PortType getPortType();
|
PortType getPortType();
|
||||||
void setDataType(bool);
|
void setDataType(bool);
|
||||||
bool getDataType();
|
bool getDataType();
|
||||||
void setDataSize(int);
|
void setDataSize(int);
|
||||||
int getDataSize();
|
int getDataSize();
|
||||||
|
int getPortNum();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PORT_H
|
#endif // PORT_H
|
||||||
|
Reference in New Issue
Block a user