forked from p_lusterinc_xsync/xsync_fpge
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.0 KiB
94 lines
3.0 KiB
#include <windows.h>
|
|
|
|
#include <iostream>
|
|
#include <set>
|
|
|
|
#include "logger.hpp"
|
|
#include "zcsv.hpp"
|
|
|
|
using namespace iflytop;
|
|
using namespace std;
|
|
#define TAG "Main"
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
*
|
|
* FPGA_PIN, DIRECTION, NAME
|
|
* B5 INPUT ex_clk
|
|
* E2 OUTPUT core_board_debug_led
|
|
*
|
|
*
|
|
* 输入引脚模板
|
|
* define_attribute {p:ex_clk} {PAP_IO_DIRECTION} {INPUT}
|
|
* define_attribute {p:ex_clk} {PAP_IO_LOC} {B5}
|
|
* define_attribute {p:ex_clk} {PAP_IO_VCCIO} {3.3}
|
|
* define_attribute {p:ex_clk} {PAP_IO_STANDARD} {LVTTL33}
|
|
* 输出引脚模板
|
|
* define_attribute{p : core_board_debug_led } { PAP_IO_DIRECTION } { OUTPUT }
|
|
* define_attribute{p : core_board_debug_led } {PAP_IO_LOC } {E2 }
|
|
* define_attribute{p : core_board_debug_led } {PAP_IO_VCCIO } {3.3 }
|
|
* define_attribute{p : core_board_debug_led } {PAP_IO_STANDARD } {LVCMOS33 }
|
|
* define_attribute{p : core_board_debug_led } {PAP_IO_DRIVE } {4 }
|
|
* define_attribute{p : core_board_debug_led } {PAP_IO_SLEW } {SLOW }
|
|
*
|
|
*
|
|
*/
|
|
int _main() {
|
|
shared_ptr<ZCSV> zcsv = make_shared<ZCSV>();
|
|
bool suc = zcsv->parseCSV("pin.csv");
|
|
if (!suc) {
|
|
ZLOGE(TAG, "parse csv failed");
|
|
return -1;
|
|
}
|
|
|
|
// string pinnum;
|
|
int maxRow = zcsv->maxRowNum();
|
|
|
|
string outputfilename;
|
|
outputfilename = zcsv->getdata(1, 1);
|
|
|
|
ofstream file;
|
|
file.open(outputfilename, ios::out | ios::trunc);
|
|
|
|
set<string> pins;
|
|
|
|
for (uint32_t i = 1; i < maxRow - 1; i++) {
|
|
string pin = zcsv->getdata(i + 1, 1);
|
|
string name = zcsv->getdata(i + 1, 2);
|
|
string direction = zcsv->getdata(i + 1, 3);
|
|
if(pins.find(pin) != pins.end()){
|
|
ZLOGE(TAG, "parse pin.csv fail, pin repeat, line num:%d,%s", i + 1, pin.c_str());
|
|
return -1;
|
|
}
|
|
pins.insert(pin);
|
|
|
|
if (direction == "INPUT") {
|
|
file << "define_attribute {p:" << name << "} {PAP_IO_DIRECTION} {INPUT}" << endl;
|
|
file << "define_attribute {p:" << name << "} {PAP_IO_LOC} {" << pin << "}" << endl;
|
|
file << "define_attribute {p:" << name << "} {PAP_IO_VCCIO} {3.3}" << endl;
|
|
file << "define_attribute {p:" << name << "} {PAP_IO_STANDARD} {LVTTL33}" << endl;
|
|
} else if (direction == "OUTPUT") {
|
|
file << "define_attribute {p:" << name << "} {PAP_IO_DIRECTION} {OUTPUT}" << endl;
|
|
file << "define_attribute {p:" << name << "} {PAP_IO_LOC} {" << pin << "}" << endl;
|
|
file << "define_attribute {p:" << name << "} {PAP_IO_VCCIO} {3.3}" << endl;
|
|
file << "define_attribute {p:" << name << "} {PAP_IO_STANDARD} {LVCMOS33}" << endl;
|
|
file << "define_attribute {p:" << name << "} {PAP_IO_DRIVE} {4}" << endl;
|
|
file << "define_attribute {p:" << name << "} {PAP_IO_SLEW} {SLOW}" << endl;
|
|
} else {
|
|
ZLOGE(TAG, "parse pin.csv fail, direction error, line num:%d,%s", i + 1, direction.c_str());
|
|
return -1;
|
|
}
|
|
}
|
|
file.close();
|
|
|
|
ZLOGI(TAG, "generator %s success", outputfilename.c_str());
|
|
return 0;
|
|
}
|
|
|
|
int main(int argc, char const *argv[]) {
|
|
_main();
|
|
while (true) {
|
|
Sleep(5000);
|
|
}
|
|
}
|