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

12 months ago
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <set>
  4. #include "logger.hpp"
  5. #include "zcsv.hpp"
  6. using namespace iflytop;
  7. using namespace std;
  8. #define TAG "Main"
  9. /**
  10. * @brief
  11. *
  12. *
  13. * FPGA_PIN, DIRECTION, NAME
  14. * B5 INPUT ex_clk
  15. * E2 OUTPUT core_board_debug_led
  16. *
  17. *
  18. *
  19. * define_attribute {p:ex_clk} {PAP_IO_DIRECTION} {INPUT}
  20. * define_attribute {p:ex_clk} {PAP_IO_LOC} {B5}
  21. * define_attribute {p:ex_clk} {PAP_IO_VCCIO} {3.3}
  22. * define_attribute {p:ex_clk} {PAP_IO_STANDARD} {LVTTL33}
  23. *
  24. * define_attribute{p : core_board_debug_led } { PAP_IO_DIRECTION } { OUTPUT }
  25. * define_attribute{p : core_board_debug_led } {PAP_IO_LOC } {E2 }
  26. * define_attribute{p : core_board_debug_led } {PAP_IO_VCCIO } {3.3 }
  27. * define_attribute{p : core_board_debug_led } {PAP_IO_STANDARD } {LVCMOS33 }
  28. * define_attribute{p : core_board_debug_led } {PAP_IO_DRIVE } {4 }
  29. * define_attribute{p : core_board_debug_led } {PAP_IO_SLEW } {SLOW }
  30. *
  31. *
  32. */
  33. int _main() {
  34. shared_ptr<ZCSV> zcsv = make_shared<ZCSV>();
  35. bool suc = zcsv->parseCSV("pin.csv");
  36. if (!suc) {
  37. ZLOGE(TAG, "parse csv failed");
  38. return -1;
  39. }
  40. // string pinnum;
  41. int maxRow = zcsv->maxRowNum();
  42. string outputfilename;
  43. outputfilename = zcsv->getdata(1, 1);
  44. ofstream file;
  45. file.open(outputfilename, ios::out | ios::trunc);
  46. set<string> pins;
  47. for (uint32_t i = 1; i < maxRow - 1; i++) {
  48. string pin = zcsv->getdata(i + 1, 1);
  49. string name = zcsv->getdata(i + 1, 2);
  50. string direction = zcsv->getdata(i + 1, 3);
  51. if(pins.find(pin) != pins.end()){
  52. ZLOGE(TAG, "parse pin.csv fail, pin repeat, line num:%d,%s", i + 1, pin.c_str());
  53. return -1;
  54. }
  55. pins.insert(pin);
  56. if (direction == "INPUT") {
  57. file << "define_attribute {p:" << name << "} {PAP_IO_DIRECTION} {INPUT}" << endl;
  58. file << "define_attribute {p:" << name << "} {PAP_IO_LOC} {" << pin << "}" << endl;
  59. file << "define_attribute {p:" << name << "} {PAP_IO_VCCIO} {3.3}" << endl;
  60. file << "define_attribute {p:" << name << "} {PAP_IO_STANDARD} {LVTTL33}" << endl;
  61. } else if (direction == "OUTPUT") {
  62. file << "define_attribute {p:" << name << "} {PAP_IO_DIRECTION} {OUTPUT}" << endl;
  63. file << "define_attribute {p:" << name << "} {PAP_IO_LOC} {" << pin << "}" << endl;
  64. file << "define_attribute {p:" << name << "} {PAP_IO_VCCIO} {3.3}" << endl;
  65. file << "define_attribute {p:" << name << "} {PAP_IO_STANDARD} {LVCMOS33}" << endl;
  66. file << "define_attribute {p:" << name << "} {PAP_IO_DRIVE} {4}" << endl;
  67. file << "define_attribute {p:" << name << "} {PAP_IO_SLEW} {SLOW}" << endl;
  68. } else {
  69. ZLOGE(TAG, "parse pin.csv fail, direction error, line num:%d,%s", i + 1, direction.c_str());
  70. return -1;
  71. }
  72. }
  73. file.close();
  74. ZLOGI(TAG, "generator %s success", outputfilename.c_str());
  75. return 0;
  76. }
  77. int main(int argc, char const *argv[]) {
  78. _main();
  79. while (true) {
  80. Sleep(5000);
  81. }
  82. }