nac3artiq: refactor timeline functions

This commit is contained in:
Sebastien Bourdeauducq 2021-10-02 23:35:28 +08:00
parent c5e731f16d
commit c429a86586
1 changed files with 103 additions and 101 deletions

View File

@ -163,19 +163,11 @@ impl Nac3 {
} }
} }
#[pymethods] // ARTIQ timeline control with now-pinning optimization.
impl Nac3 { // This is a bit of mess due to endianness issues.
#[new] // Modify gateware to make `now` little-endian, since we don't have OpenRISC anymore?
fn new(isa: &str) -> PyResult<Self> { fn timeline_builtins(primitive: &PrimitiveStore) -> Vec<(StrRef, FunSignature, Arc<GenCall>)> {
let isa = match isa { vec![(
"riscv" => Isa::RiscV,
"cortexa9" => Isa::CortexA9,
_ => return Err(exceptions::PyValueError::new_err("invalid ISA")),
};
let primitive: PrimitiveStore = TopLevelComposer::make_primitives().0;
let mut builtins = vec![];
if isa == Isa::RiscV {
builtins.push((
"now_mu".into(), "now_mu".into(),
FunSignature { FunSignature {
args: vec![], args: vec![],
@ -197,8 +189,7 @@ impl Nac3 {
} }
} }
))) )))
)); ),(
builtins.push((
"at_mu".into(), "at_mu".into(),
FunSignature { FunSignature {
args: vec![FuncArg { args: vec![FuncArg {
@ -232,8 +223,7 @@ impl Nac3 {
} }
} }
))) )))
)); ),(
builtins.push((
"delay_mu".into(), "delay_mu".into(),
FunSignature { FunSignature {
args: vec![FuncArg { args: vec![FuncArg {
@ -272,8 +262,20 @@ impl Nac3 {
} }
} }
))) )))
)); )]
} }
#[pymethods]
impl Nac3 {
#[new]
fn new(isa: &str) -> PyResult<Self> {
let isa = match isa {
"riscv" => Isa::RiscV,
"cortexa9" => Isa::CortexA9,
_ => return Err(exceptions::PyValueError::new_err("invalid ISA")),
};
let primitive: PrimitiveStore = TopLevelComposer::make_primitives().0;
let builtins = if isa == Isa::RiscV { timeline_builtins(&primitive) } else { vec![] };
let (composer, builtins_def, builtins_ty) = TopLevelComposer::new(builtins); let (composer, builtins_def, builtins_ty) = TopLevelComposer::new(builtins);
Ok(Nac3 { Ok(Nac3 {
isa, isa,