Skip to content

Commit b193587

Browse files
committed
Libarchfpga: add 'edge' attribute to <port> under <model>
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
1 parent 590a572 commit b193587

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

libs/libarchfpga/src/logic_types.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,20 @@ enum PORTS {
2525
ERR_PORT
2626
};
2727

28+
enum TriggeringEdge {
29+
RISING_EDGE,
30+
FALLING_EDGE,
31+
DONT_CARE,
32+
ERROR_EDGE
33+
};
34+
2835
struct t_model_ports {
2936
enum PORTS dir = ERR_PORT; /* port direction */
3037
char* name = nullptr; /* name of this port */
3138
int size = 0; /* maximum number of pins */
3239
int min_size = 0; /* minimum number of pins */
3340
bool is_clock = false; /* clock? */
41+
enum TriggeringEdge trigg_edge = DONT_CARE; /* triggering edge of the clock port */
3442
bool is_non_clock_global = false; /* not a clock but is a special, global, control signal (eg global asynchronous reset, etc) */
3543
std::string clock; /* The clock associated with this pin (if the pin is sequential) */
3644
std::vector<std::string> combinational_sink_ports; /* The other ports on this model which are combinationally driven by this port */

libs/libarchfpga/src/physical_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ struct t_physical_pin {
787787
* Data members:
788788
* name: name of the port
789789
* is_clock: whether or not this port is a clock
790+
* trigg_edge: triggering edge of the clock port
790791
* is_non_clock_global: Applies to top level pb_type, this pin is not a clock but
791792
* is a global signal (useful for stuff like global reset signals,
792793
* perhaps useful for VCC and GND)
@@ -803,6 +804,7 @@ struct t_physical_tile_port {
803804
char* name;
804805
enum PORTS type;
805806
bool is_clock;
807+
enum TriggeringEdge trigg_edge;
806808
bool is_non_clock_global;
807809
int num_pins;
808810
PortEquivalence equivalent;
@@ -1035,6 +1037,7 @@ struct t_interconnect {
10351037
* name: name of the port
10361038
* model_port: associated model port
10371039
* is_clock: whether or not this port is a clock
1040+
* trigg_edge: triggering edge of the clock port
10381041
* is_non_clock_global: Applies to top level pb_type, this pin is not a clock but
10391042
* is a global signal (useful for stuff like global reset signals,
10401043
* perhaps useful for VCC and GND)
@@ -1050,6 +1053,7 @@ struct t_port {
10501053
t_model_ports* model_port;
10511054
enum PORTS type;
10521055
bool is_clock;
1056+
enum TriggeringEdge trigg_edge;
10531057
bool is_non_clock_global;
10541058
int num_pins;
10551059
PortEquivalence equivalent;

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ std::string inst_port_to_port_name(std::string inst_port);
267267
static bool attribute_to_bool(const pugi::xml_node node,
268268
const pugi::xml_attribute attr,
269269
const pugiutil::loc_data& loc_data);
270+
static TriggeringEdge attribute_to_trigg_edge(const pugi::xml_node node,
271+
const pugi::xml_attribute attr,
272+
const pugiutil::loc_data& loc_data);
270273
int find_switch_by_name(const t_arch& arch, std::string switch_name);
271274

272275
e_side string_to_side(std::string side_str);
@@ -2314,6 +2317,9 @@ static void ProcessModelPorts(pugi::xml_node port_group, t_model* model, std::se
23142317
} else if (attr.name() == std::string("is_clock")) {
23152318
model_port->is_clock = attribute_to_bool(port, attr, loc_data);
23162319

2320+
} else if (attr.name() == std::string("edge")) {
2321+
model_port->trigg_edge = attribute_to_trigg_edge(port, attr, loc_data);
2322+
23172323
} else if (attr.name() == std::string("is_non_clock_global")) {
23182324
model_port->is_non_clock_global = attribute_to_bool(port, attr, loc_data);
23192325

@@ -4787,6 +4793,20 @@ static bool attribute_to_bool(const pugi::xml_node node,
47874793
return false;
47884794
}
47894795

4796+
static TriggeringEdge attribute_to_trigg_edge(const pugi::xml_node node,
4797+
const pugi::xml_attribute attr,
4798+
const pugiutil::loc_data& loc_data) {
4799+
if (attr.value() == std::string("rising")) {
4800+
return TriggeringEdge::RISING_EDGE;
4801+
} else if (attr.value() == std::string("falling")) {
4802+
return TriggeringEdge::FALLING_EDGE;
4803+
} else {
4804+
bad_attribute_value(attr, node, loc_data, {"rising", "falling"});
4805+
}
4806+
4807+
return ERROR_EDGE;
4808+
}
4809+
47904810
int find_switch_by_name(const t_arch& arch, std::string switch_name) {
47914811
for (int iswitch = 0; iswitch < arch.num_switches; ++iswitch) {
47924812
const t_arch_switch_inf& arch_switch = arch.Switches[iswitch];

0 commit comments

Comments
 (0)