Skip to content

Commit

Permalink
Gratuitous main types renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
galibert committed Aug 27, 2022
1 parent d6bd02c commit dc82215
Show file tree
Hide file tree
Showing 21 changed files with 236 additions and 236 deletions.
8 changes: 4 additions & 4 deletions generator/generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ struct global_data_header {
uint32_t off_dnode_drivers;
};

struct rnode_base {
rnode_t node;
struct rnode_object {
rnode_coords node;
uint8_t pattern;
uint8_t target_count;
uint8_t drivers[2];
Expand Down Expand Up @@ -197,8 +197,8 @@ int main(int argc, char **argv)
uint8_t *opos = output.data() + dh->off_rnode;
while(rparse.rn || lparse.rn) {

rnode_base rb;
rnode_t rn = rparse.rn;
rnode_object rb;
rnode_coords rn = rparse.rn;
if(!rn || rn > lparse.rn)
rn = lparse.rn;
if(!rn || rn > dparse.rn)
Expand Down
2 changes: 1 addition & 1 deletion generator/hps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ HPSLoader::HPSLoader(const P2PLoader &p2p, const P2RLoader &p2r)
data.clear();
}

void HPSLoader::lookup(pnode_t p)
void HPSLoader::lookup(pnode_coords p)
{
int t = pn2bt(p);
auto i = hpsmap.find(t);
Expand Down
2 changes: 1 addition & 1 deletion generator/hps.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class HPSLoader {
private:
std::unordered_map<int, int> hpsmap;

void lookup(pnode_t p);
void lookup(pnode_coords p);
};

#endif
6 changes: 3 additions & 3 deletions generator/inv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ InvLoader::InvLoader(const NodesReader &_nr, const std::vector<uint8_t> &_data,

while(p != e) {
const uint8_t *st = p;
rnode_t node = nr.lookup_r(p);
rnode_coords node = nr.lookup_r(p);
if(!node)
error(st, "Incorrect inverter rnode");
skipsp(p);
Expand Down Expand Up @@ -57,10 +57,10 @@ void InvLoader::error(const uint8_t *st, const char *err) const
exit(1);
}

void InvLoader::add(const P2RLoader &p2r, const P2PLoader &p2p, rnode_t node, uint32_t pos)
void InvLoader::add(const P2RLoader &p2r, const P2PLoader &p2p, rnode_coords node, uint32_t pos)
{
if(!(pos & inverter_info::DEF_MASK)) {
pnode_t pn = p2r.find_r(node);
pnode_coords pn = p2r.find_r(node);
auto pt = pn2pt(pn);
if(pn) {
switch(pn2bt(pn)) {
Expand Down
4 changes: 2 additions & 2 deletions generator/inv.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct inverter_info {
DEF_MASK = 0xf0000000,
};

rnode_t node;
rnode_coords node;
uint32_t pos_and_def;
};

Expand All @@ -31,7 +31,7 @@ class InvLoader {
private:
const NodesReader &nr;

void add(const P2RLoader &p2r, const P2PLoader &p2p, rnode_t node, uint32_t pos);
void add(const P2RLoader &p2r, const P2PLoader &p2p, rnode_coords node, uint32_t pos);
void error(const uint8_t *st, const char *err) const;
};

Expand Down
2 changes: 1 addition & 1 deletion generator/lines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void LinesParser::next()
char toto[64];
memcpy(toto, p, 63);
toto[63] = 0;
rnode_t trn = nr.lookup_r(p);
rnode_coords trn = nr.lookup_r(p);
if(!trn) {
fprintf(stderr, "[%s]\n", toto);
error(st);
Expand Down
4 changes: 2 additions & 2 deletions generator/lines.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ struct rnode_line_information {

class LinesParser {
public:
rnode_t rn;
rnode_coords rn;
rnode_line_information li;
uint16_t driver_position;
uint16_t target_count;
uint16_t target_pos[64];
union {
rnode_t rn;
rnode_coords rn;
float caps;
} targets[64];

Expand Down
8 changes: 4 additions & 4 deletions generator/nodes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <stdio.h>

const char *const rnode_type_names[] = {
const char *const rnode_coordsype_names[] = {
#define P(x) #x
#include "cv-rnodetypes.ipp"
#undef P
Expand All @@ -25,11 +25,11 @@ const char *const port_type_names[] = {
};


NodesReader::NodesReader() : rnames(rnode_type_names), bnames(block_type_names), pnames(port_type_names)
NodesReader::NodesReader() : rnames(rnode_coordsype_names), bnames(block_type_names), pnames(port_type_names)
{
}

rnode_t NodesReader::lookup_r(const uint8_t *&p) const
rnode_coords NodesReader::lookup_r(const uint8_t *&p) const
{
int t = rnames.lookup(p);
if(t == -1) {
Expand Down Expand Up @@ -66,7 +66,7 @@ rnode_t NodesReader::lookup_r(const uint8_t *&p) const
return rnode(t, x, y, z);
}

pnode_t NodesReader::lookup_p(const uint8_t *&p) const
pnode_coords NodesReader::lookup_p(const uint8_t *&p) const
{
int b = bnames.lookup(p);
if(b == -1) {
Expand Down
38 changes: 19 additions & 19 deletions generator/nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "prefixtree.h"

enum rnode_type_t {
enum rnode_coordsype_t {
#define P(x) x
#include "cv-rnodetypes.ipp"
#undef P
Expand All @@ -22,35 +22,35 @@ enum port_type_t {
#undef P
};

extern const char *const rnode_type_names[];
extern const char *const rnode_coordsype_names[];
extern const char *const block_type_names[];
extern const char *const port_type_names[];

using pos_t = uint16_t;
using rnode_t = uint32_t;
using pnode_t = uint64_t;
using rnode_coords = uint32_t;
using pnode_coords = uint64_t;

static constexpr rnode_t rnode(uint32_t type, uint32_t x, uint32_t y, uint32_t z)
static constexpr rnode_coords rnode(uint32_t type, uint32_t x, uint32_t y, uint32_t z)
{
return (type << 24) | (x << 17) | (y << 10) | z;
}

static constexpr pnode_t pnode(uint32_t bt, uint32_t x, uint32_t y, uint32_t pt, int8_t bindex, int16_t pindex) {
static constexpr pnode_coords pnode(uint32_t bt, uint32_t x, uint32_t y, uint32_t pt, int8_t bindex, int16_t pindex) {
return (uint64_t(bt) << 52) | (uint64_t(pt) << 40) | (uint64_t(bindex & 0xff) << 32) | (x << 23) | (y << 16)| (pindex & 0xffff);
}

static constexpr rnode_type_t rn2t(rnode_t rn) { return rnode_type_t(rn >> 24); }
static constexpr uint32_t rn2x(rnode_t rn) { return (rn >> 17) & 0x7f; }
static constexpr uint32_t rn2y(rnode_t rn) { return (rn >> 10) & 0x7f; }
static constexpr uint32_t rn2z(rnode_t rn) { return rn & 0x3ff; }
static constexpr rnode_coordsype_t rn2t(rnode_coords rn) { return rnode_coordsype_t(rn >> 24); }
static constexpr uint32_t rn2x(rnode_coords rn) { return (rn >> 17) & 0x7f; }
static constexpr uint32_t rn2y(rnode_coords rn) { return (rn >> 10) & 0x7f; }
static constexpr uint32_t rn2z(rnode_coords rn) { return rn & 0x3ff; }

static constexpr block_type_t pn2bt(pnode_t pn) { return block_type_t((pn >> 52) & 0xff); }
static constexpr port_type_t pn2pt(pnode_t pn) { return port_type_t((pn >> 40) & 0xfff); }
static constexpr pos_t pn2p (pnode_t pn) { return (pn >> 16) & 0x3fff; }
static constexpr uint32_t pn2x (pnode_t pn) { return (pn >> 23) & 0x7f; }
static constexpr uint32_t pn2y (pnode_t pn) { return (pn >> 16) & 0x7f; }
static constexpr int8_t pn2bi(pnode_t pn) { return (pn >> 32) & 0xff; }
static constexpr int16_t pn2pi(pnode_t pn) { return pn & 0xffff; }
static constexpr block_type_t pn2bt(pnode_coords pn) { return block_type_t((pn >> 52) & 0xff); }
static constexpr port_type_t pn2pt(pnode_coords pn) { return port_type_t((pn >> 40) & 0xfff); }
static constexpr pos_t pn2p (pnode_coords pn) { return (pn >> 16) & 0x3fff; }
static constexpr uint32_t pn2x (pnode_coords pn) { return (pn >> 23) & 0x7f; }
static constexpr uint32_t pn2y (pnode_coords pn) { return (pn >> 16) & 0x7f; }
static constexpr int8_t pn2bi(pnode_coords pn) { return (pn >> 32) & 0xff; }
static constexpr int16_t pn2pi(pnode_coords pn) { return pn & 0xffff; }

static constexpr uint32_t pos2x(pos_t xy) { return (xy >> 7) & 0x7f; }
static constexpr uint32_t pos2y(pos_t xy) { return xy & 0x7f; }
Expand All @@ -60,8 +60,8 @@ class NodesReader {
public:
NodesReader();

rnode_t lookup_r(const uint8_t *&p) const;
pnode_t lookup_p(const uint8_t *&p) const;
rnode_coords lookup_r(const uint8_t *&p) const;
pnode_coords lookup_p(const uint8_t *&p) const;

block_type_t lookup_block(const uint8_t *&p) const;
port_type_t lookup_port(const uint8_t *&p) const;
Expand Down
4 changes: 2 additions & 2 deletions generator/p2p.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ P2PLoader::P2PLoader(const NodesReader &_nr, const std::vector<uint8_t> &_data)

while(p != e) {
const uint8_t *st = p;
pnode_t s = nr.lookup_p(p);
pnode_coords s = nr.lookup_p(p);
if(!s)
error(st, "Incorrect source pnode");
skipsp(p);
pnode_t d = nr.lookup_p(p);
pnode_coords d = nr.lookup_p(p);
if(!d)
error(st, "Incorrect destination pnode");
skipsp(p);
Expand Down
4 changes: 2 additions & 2 deletions generator/p2p.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "nodes.h"

struct p2p_info {
pnode_t s;
pnode_t d;
pnode_coords s;
pnode_coords d;
};

class P2PLoader {
Expand Down
4 changes: 2 additions & 2 deletions generator/p2r.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ P2RLoader::P2RLoader(const NodesReader &_nr, const std::vector<uint8_t> &_data)
if(*p == '-')
p++;
else {
rnode_t rn = nr.lookup_r(p);
rnode_coords rn = nr.lookup_r(p);
if(!rn)
error(st, "Incorrect rnode");
data.emplace_back(p2r_info{pnode(cblock, x, y, port, minst ? inst : -1, mbit ? bit : -1), rn, 0});
Expand Down Expand Up @@ -90,7 +90,7 @@ void P2RLoader::error(const uint8_t *st, const char *err) const
exit(1);
}

pnode_t P2RLoader::find_r(rnode_t node) const
pnode_coords P2RLoader::find_r(rnode_coords node) const
{
for(const auto &n : data)
if(n.r == node)
Expand Down
6 changes: 3 additions & 3 deletions generator/p2r.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "nodes.h"

struct p2r_info {
pnode_t p;
rnode_t r;
pnode_coords p;
rnode_coords r;
uint32_t padding;
};

Expand All @@ -15,7 +15,7 @@ class P2RLoader {

P2RLoader(const NodesReader &nr, const std::vector<uint8_t> &data);

pnode_t find_r(rnode_t node) const;
pnode_coords find_r(rnode_coords node) const;

private:
const NodesReader &nr;
Expand Down
2 changes: 1 addition & 1 deletion generator/rdriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class RDriverParser {
public:
rnode_t rn;
rnode_coords rn;
uint8_t drivers[2];

RDriverParser(const NodesReader &nr, const std::vector<uint8_t> &data);
Expand Down
4 changes: 2 additions & 2 deletions generator/routes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ extern const rmux_pattern rmux_patterns[70+4];

class RoutesParser {
public:
rnode_t rn;
rnode_coords rn;
uint32_t pattern;
uint32_t fw_pos;
rnode_t sources[44];
rnode_coords sources[44];

RoutesParser(const NodesReader &nr, const std::vector<uint8_t> &data, uint32_t width);

Expand Down
12 changes: 6 additions & 6 deletions libmistral/cv-inv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int mistral::CycloneV::inv_get_default(const inverter_info &inf) const
case inverter_info::DEF_1: return 1; break;

case inverter_info::DEF_GP: {
pnode_t pnode = rnode_to_pnode(inf.node);
pnode_coords pnode = rnode_to_pnode(inf.node);
if(pn2pt(pnode) != DATAOUT && pn2pt(pnode) != OEIN)
return 0;

Expand All @@ -18,15 +18,15 @@ int mistral::CycloneV::inv_get_default(const inverter_info &inf) const
}

case inverter_info::DEF_HMC: {
pnode_t pnode = rnode_to_pnode(inf.node);
pnode_coords pnode = rnode_to_pnode(inf.node);
pnode = hmc_get_bypass(pnode);
if(!pnode)
return 0;

auto gpio = p2p_to(pnode);
if(!gpio) {
auto gpiol = p2p_from(pnode);
for(pnode_t gp : gpiol)
for(pnode_coords gp : gpiol)
if(pn2bt(gp) == GPIO) {
gpio = gp;
break;
Expand Down Expand Up @@ -75,7 +75,7 @@ void mistral::CycloneV::inv_default_set()
}
}

bool mistral::CycloneV::inv_set(rnode_t node, bool value)
bool mistral::CycloneV::inv_set(rnode_coords node, bool value)
{
for(uint32_t i = 0; i != dhead->count_inv; i++) {
const auto &inf = inverter_infos[i];
Expand All @@ -91,7 +91,7 @@ bool mistral::CycloneV::inv_set(rnode_t node, bool value)
return false;
}

mistral::CycloneV::invert_t mistral::CycloneV::rnode_is_inverting(rnode_t rn) const
mistral::CycloneV::invert_t mistral::CycloneV::rnode_is_inverting(rnode_coords rn) const
{
if(rn2t(rn) == WM)
return INV_NO;
Expand All @@ -101,7 +101,7 @@ mistral::CycloneV::invert_t mistral::CycloneV::rnode_is_inverting(rnode_t rn) co
if(inf.node == rn)
return INV_PROGRAMMABLE;
}
const rnode_base *rb = rnode_lookup(rn);
const rnode_object *rb = rnode_lookup(rn);
if(!rb)
return INV_UNKNOWN;

Expand Down
4 changes: 2 additions & 2 deletions libmistral/cv-pkg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const mistral::CycloneV::pin_info_t *mistral::CycloneV::pin_find_pos(pos_t pos,
return nullptr;
}

const mistral::CycloneV::pin_info_t *mistral::CycloneV::pin_find_pnode(mistral::CycloneV::pnode_t pn) const
const mistral::CycloneV::pin_info_t *mistral::CycloneV::pin_find_pnode(mistral::CycloneV::pnode_coords pn) const
{
if(!pn)
return nullptr;
Expand All @@ -26,7 +26,7 @@ const mistral::CycloneV::pin_info_t *mistral::CycloneV::pin_find_pnode(mistral::
auto gpio = p2p_to(pn);
if(!gpio) {
auto gpiol = p2p_from(pn);
for(pnode_t gp : gpiol)
for(pnode_coords gp : gpiol)
if(pn2bt(gp) == GPIO) {
gpio = gp;
break;
Expand Down
Loading

0 comments on commit dc82215

Please sign in to comment.