Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

icepack: Allow setting frequency range #332

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions icepack/icepack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct FpgaConfig
void write_bits(std::ostream &ofs) const;

// icebox i/o
void read_ascii(std::istream &ifs, bool nosleep);
void read_ascii(std::istream &ifs, bool nosleep, const std::string& freqrange);
void write_ascii(std::ostream &ofs) const;

// netpbm i/o
Expand Down Expand Up @@ -612,15 +612,15 @@ void FpgaConfig::write_bits(std::ostream &ofs) const
write_byte(ofs, crc_value, file_offset, 0x00);
}

void FpgaConfig::read_ascii(std::istream &ifs, bool nosleep)
void FpgaConfig::read_ascii(std::istream &ifs, bool nosleep, const std::string& freqrange)
{
debug("## %s\n", __PRETTY_FUNCTION__);
info("Parsing ascii file..\n");

bool got_device = false;
this->cram.clear();
this->bram.clear();
this->freqrange = "low";
this->freqrange = freqrange;
this->warmboot = "enabled";

bool reuse_line = true;
Expand Down Expand Up @@ -1361,6 +1361,9 @@ void usage(const char *cmd)
log(" -B0, -B1, -B2, -B3\n");
log(" only include the specified bank in the netpbm file\n");
log("\n");
log(" -Fl, -Fm, -Fh\n");
log(" set the frequency range of the internal oscillator (low, medium, high)\n");
log("\n");
log(" -n\n");
log(" skip initializing BRAM\n");
log("\n");
Expand Down Expand Up @@ -1391,6 +1394,7 @@ int main(int argc, char **argv)
bool skip_bram_initialization = false;
int netpbm_banknum = -1;
int checkerboard_m = 1;
std::string freqrange = "low";

for (int i = 0; argv[0][i]; i++)
if (string(argv[0]+i) == "iceunpack")
Expand Down Expand Up @@ -1425,6 +1429,16 @@ int main(int argc, char **argv)
log_level++;
} else if (arg[i] == 'n') {
skip_bram_initialization = true;
} else if (arg[i] == 'F') {
char speed = arg[++i];
if (speed == 'l')
freqrange = "low";
else if (speed == 'm')
freqrange = "medium";
else if (speed == 'h')
freqrange = "high";
else
usage(argv[0]);
} else
usage(argv[0]);
continue;
Expand Down Expand Up @@ -1462,14 +1476,14 @@ int main(int argc, char **argv)

FpgaConfig fpga_config;

fpga_config.skip_bram_initialization = skip_bram_initialization;
fpga_config.skip_bram_initialization = skip_bram_initialization;

if (unpack_mode) {
fpga_config.read_bits(*isp);
if (!netpbm_mode)
fpga_config.write_ascii(*osp);
} else {
fpga_config.read_ascii(*isp, nosleep_mode);
fpga_config.read_ascii(*isp, nosleep_mode, freqrange);
if (!netpbm_mode)
fpga_config.write_bits(*osp);
}
Expand Down