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"?>
|
||||
<!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>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -1,40 +1,68 @@
|
||||
#include "module.h"
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
int portsNum = 0;
|
||||
for(int i = 0;i<inputPorts;i++,portsNum++)
|
||||
this->latestNum = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
std::string Module::getCode()
|
||||
QString Module::getCode()
|
||||
{
|
||||
return this->code;
|
||||
}
|
||||
|
||||
std::string Module::generateCode()
|
||||
QString Module::generateCode()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -2,22 +2,27 @@
|
||||
#define MODULE_H
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <QString>
|
||||
#include "port.h"
|
||||
class Module
|
||||
{
|
||||
private:
|
||||
std::string name;
|
||||
int inputPorts;
|
||||
int ouputPorts;
|
||||
int inOutPorts;
|
||||
std::string code;
|
||||
std::vector<Port> ports;
|
||||
QString name; //模块名字
|
||||
int inputPorts; //输入端口数量
|
||||
int ouputPorts; //输出端口数量
|
||||
int inOutPorts; //双向端口数量
|
||||
int latestNum; //vector标识
|
||||
QString code; //code
|
||||
std::vector<Port> ports; //端口类数组
|
||||
public:
|
||||
Module();
|
||||
Module(std::string,int,int,int);
|
||||
void setCode(std::string);
|
||||
std::string getCode();
|
||||
std::string generateCode();
|
||||
Module(QString,int,int,int); //构造函数 (名字,输入端口数量,输出端口数量,双向端口数量)
|
||||
Port getSelectedPort(int); //返回选中的Port 参数为port对象标识默认从0开始
|
||||
void addPort(); //添加Port
|
||||
void deletePort(int); //删除Port
|
||||
void setCode(QString);
|
||||
QString getCode();
|
||||
QString generateCode();
|
||||
};
|
||||
|
||||
#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->portType = portType;
|
||||
this->dataSize =dataSize;
|
||||
this->dataType = dataType;
|
||||
this->portNum = portNum;
|
||||
}
|
||||
|
||||
void Port::setName(std::string name)
|
||||
void Port::setName(QString name)
|
||||
{
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
std::string Port::getName()
|
||||
QString Port::getName()
|
||||
{
|
||||
return this->name;
|
||||
}
|
||||
@ -49,3 +50,6 @@ int Port::getDataSize()
|
||||
{
|
||||
return this->dataSize;
|
||||
}
|
||||
int Port::getPortNum(){
|
||||
return this->portNum;
|
||||
}
|
||||
|
@ -1,28 +1,29 @@
|
||||
#ifndef PORT_H
|
||||
#define PORT_H
|
||||
#include <iostream>
|
||||
|
||||
#include <QString>
|
||||
enum PortType{INPUT,OUTPUT,INOUT};
|
||||
|
||||
class Port
|
||||
{
|
||||
private:
|
||||
std::string name; //端口名
|
||||
QString name; //端口名
|
||||
PortType portType; //输入或输出 0为in 1为out
|
||||
bool dataType; //数据类型 0为wire 1为reg
|
||||
int dataSize; //数据长度
|
||||
int portNum; //端口标识
|
||||
public:
|
||||
Port();
|
||||
Port(std::string,PortType,bool,int);
|
||||
void setName(std::string);
|
||||
std::string getName();
|
||||
Port(QString,PortType,bool,int,int);
|
||||
void setName(QString);
|
||||
QString getName();
|
||||
void setPortType(PortType);
|
||||
PortType getPortType();
|
||||
void setDataType(bool);
|
||||
bool getDataType();
|
||||
void setDataSize(int);
|
||||
int getDataSize();
|
||||
|
||||
int getPortNum();
|
||||
};
|
||||
|
||||
#endif // PORT_H
|
||||
|
Reference in New Issue
Block a user