Skip to content

Commit c3ce0a1

Browse files
Merge pull request #52 from AlexandreSinger/feature-parse-arch
[Parse] Added Support for Timing Tags
2 parents 291ac36 + 2c4a537 commit c3ce0a1

File tree

6 files changed

+483
-39
lines changed

6 files changed

+483
-39
lines changed

fpga_arch_parser/src/arch.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,44 @@ pub struct Segment {
371371
pub switch_points: SegmentSwitchPoints,
372372
}
373373

374+
pub enum DelayType {
375+
Max,
376+
Min,
377+
}
378+
379+
pub enum DelayInfo {
380+
Constant {
381+
min: f32,
382+
max: f32,
383+
in_port: String,
384+
out_port: String,
385+
},
386+
Matrix {
387+
delay_type: DelayType,
388+
// This matrix is [in_pin_idx][out_pin_idx]
389+
// TODO: The documentation should be more clear on this.
390+
matrix: Vec<Vec<f32>>,
391+
in_port: String,
392+
out_port: String,
393+
},
394+
}
395+
396+
pub enum TimingConstraintType {
397+
Hold,
398+
Setup,
399+
ClockToQ,
400+
}
401+
402+
pub struct TimingConstraintInfo {
403+
pub constraint_type: TimingConstraintType,
404+
// NOTE: Only ClockToQ can have two different min/max values right now.
405+
// A bit of future proofing and cleanup to split max and min here.
406+
pub min_value: f32,
407+
pub max_value: f32,
408+
pub port: String,
409+
pub clock: String,
410+
}
411+
374412
pub struct PackPattern {
375413
pub name: String,
376414
pub in_port: String,
@@ -385,6 +423,7 @@ pub struct CompleteInterconnect {
385423
// may be a single pack pattern; however, an interconnect may have many
386424
// pack patterns.
387425
pub pack_patterns: Vec<PackPattern>,
426+
pub delays: Vec<DelayInfo>,
388427
pub metadata: Option<Vec<Metadata>>,
389428
}
390429

@@ -393,6 +432,7 @@ pub struct DirectInterconnect {
393432
pub input: String,
394433
pub output: String,
395434
pub pack_patterns: Vec<PackPattern>,
435+
pub delays: Vec<DelayInfo>,
396436
pub metadata: Option<Vec<Metadata>>,
397437
}
398438

@@ -401,6 +441,7 @@ pub struct MuxInterconnect {
401441
pub input: String,
402442
pub output: String,
403443
pub pack_patterns: Vec<PackPattern>,
444+
pub delays: Vec<DelayInfo>,
404445
pub metadata: Option<Vec<Metadata>>,
405446
}
406447

@@ -433,6 +474,8 @@ pub struct PBType {
433474
pub modes: Vec<PBMode>,
434475
pub pb_types: Vec<PBType>,
435476
pub interconnects: Vec<Interconnect>,
477+
pub delays: Vec<DelayInfo>,
478+
pub timing_constraints: Vec<TimingConstraintInfo>,
436479
pub metadata: Option<Vec<Metadata>>,
437480
}
438481

fpga_arch_parser/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ mod parse_layouts;
1616
mod parse_device;
1717
mod parse_switch_list;
1818
mod parse_segment_list;
19+
mod parse_timing;
1920
mod parse_complex_block_list;
2021

2122
pub use crate::parse_error::FPGAArchParseError;
2223
pub use crate::arch::*;
2324

24-
use crate::parse_port::parse_port;
2525
use crate::parse_tiles::parse_tiles;
2626
use crate::parse_layouts::parse_layouts;
2727
use crate::parse_device::parse_device;

fpga_arch_parser/src/parse_complex_block_list.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ use xml::attribute::OwnedAttribute;
99
use crate::parse_error::*;
1010
use crate::arch::*;
1111

12-
use crate::parse_port;
12+
use crate::parse_port::parse_port;
1313
use crate::parse_metadata::parse_metadata;
14+
use crate::parse_timing::parse_delay_constant;
15+
use crate::parse_timing::parse_delay_matrix;
16+
use crate::parse_timing::parse_t_setup;
17+
use crate::parse_timing::parse_t_hold;
18+
use crate::parse_timing::parse_clock_to_q;
1419

1520
fn parse_pack_pattern(name: &OwnedName,
1621
attributes: &[OwnedAttribute],
@@ -131,6 +136,7 @@ fn parse_interconnect(name: &OwnedName,
131136
};
132137

133138
let mut pack_patterns: Vec<PackPattern> = Vec::new();
139+
let mut delays: Vec<DelayInfo> = Vec::new();
134140
let mut metadata: Option<Vec<Metadata>> = None;
135141
loop {
136142
match parser.next() {
@@ -140,14 +146,10 @@ fn parse_interconnect(name: &OwnedName,
140146
pack_patterns.push(parse_pack_pattern(&name, &attributes, parser)?);
141147
},
142148
"delay_constant" => {
143-
// TODO: Implement.
144-
// FIXME: Check that this is documented in VTR.
145-
let _ = parser.skip();
149+
delays.push(parse_delay_constant(&name, &attributes, parser)?);
146150
},
147151
"delay_matrix" => {
148-
// TODO: Implement.
149-
// FIXME: Check that this is documented in VTR.
150-
let _ = parser.skip();
152+
delays.push(parse_delay_matrix(&name, &attributes, parser)?);
151153
},
152154
"metadata" => {
153155
metadata = match metadata {
@@ -180,20 +182,23 @@ fn parse_interconnect(name: &OwnedName,
180182
input,
181183
output,
182184
pack_patterns,
185+
delays,
183186
metadata,
184187
})),
185188
"mux" => Ok(Interconnect::Mux(MuxInterconnect {
186189
name: inter_name,
187190
input,
188191
output,
189192
pack_patterns,
193+
delays,
190194
metadata,
191195
})),
192196
"complete" => Ok(Interconnect::Complete(CompleteInterconnect {
193197
name: inter_name,
194198
input,
195199
output,
196200
pack_patterns,
201+
delays,
197202
metadata,
198203
})),
199204
_ => Err(FPGAArchParseError::InvalidTag(format!("Unknown interconnect tag: {name}"), parser.position())),
@@ -376,6 +381,8 @@ fn parse_pb_type(name: &OwnedName,
376381
let mut pb_types: Vec<PBType> = Vec::new();
377382
let mut pb_modes: Vec<PBMode> = Vec::new();
378383
let mut interconnects: Option<Vec<Interconnect>> = None;
384+
let mut delays: Vec<DelayInfo> = Vec::new();
385+
let mut timing_constraints: Vec<TimingConstraintInfo> = Vec::new();
379386
let mut metadata: Option<Vec<Metadata>> = None;
380387
loop {
381388
match parser.next() {
@@ -402,29 +409,19 @@ fn parse_pb_type(name: &OwnedName,
402409
let _ = parser.skip();
403410
},
404411
"delay_constant" => {
405-
// TODO: Implement.
406-
// FIXME: Check that this is documented in VTR.
407-
let _ = parser.skip();
412+
delays.push(parse_delay_constant(&name, &attributes, parser)?);
408413
},
409414
"delay_matrix" => {
410-
// TODO: Implement.
411-
// FIXME: Check that this is documented in VTR.
412-
let _ = parser.skip();
415+
delays.push(parse_delay_matrix(&name, &attributes, parser)?);
413416
},
414417
"T_setup" => {
415-
// TODO: Implement.
416-
// FIXME: Check that this is documented in VTR.
417-
let _ = parser.skip();
418+
timing_constraints.push(parse_t_setup(&name, &attributes, parser)?);
418419
},
419420
"T_hold" => {
420-
// TODO: Implement.
421-
// FIXME: Check that this is documented in VTR.
422-
let _ = parser.skip();
421+
timing_constraints.push(parse_t_hold(&name, &attributes, parser)?);
423422
},
424423
"T_clock_to_Q" => {
425-
// TODO: Implement.
426-
// FIXME: Check that this is documented in VTR.
427-
let _ = parser.skip();
424+
timing_constraints.push(parse_clock_to_q(&name, &attributes, parser)?);
428425
},
429426
"metadata" => {
430427
metadata = match metadata {
@@ -473,6 +470,8 @@ fn parse_pb_type(name: &OwnedName,
473470
modes: pb_modes,
474471
pb_types,
475472
interconnects,
473+
delays,
474+
timing_constraints,
476475
metadata,
477476
})
478477
}

fpga_arch_parser/src/parse_tiles.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use xml::attribute::OwnedAttribute;
99
use crate::parse_error::*;
1010
use crate::arch::*;
1111

12-
use crate::parse_port;
12+
use crate::parse_port::parse_port;
1313

1414
fn parse_tile_site(name: &OwnedName,
1515
attributes: &[OwnedAttribute],

0 commit comments

Comments
 (0)