From 63b1ee41fb7320915378dab4bddd6723240af630 Mon Sep 17 00:00:00 2001 From: saji Date: Sun, 5 May 2024 02:36:26 -0500 Subject: [PATCH] make it execute the yosys command --- compiler/src/fitter.rs | 4 +--- compiler/src/main.rs | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/compiler/src/fitter.rs b/compiler/src/fitter.rs index ff3c6ef..ce7213c 100644 --- a/compiler/src/fitter.rs +++ b/compiler/src/fitter.rs @@ -1,13 +1,11 @@ -use std::error::Error; use std::str::from_utf8; use crate::pcf::PcfFile; use crate::yosys_parser::{ - GalInput, GalSop, GalSopParameters, Graph, NamedPort, Net, Node, NodeIdx, PortDirection, + GalSop, Graph, NamedPort, Net, Node, NodeIdx, PortDirection, }; use galette::blueprint::{Blueprint, PinMode}; use galette::chips::Chip; -use galette::errors; use log::{debug, error, info, warn}; use thiserror::Error; diff --git a/compiler/src/main.rs b/compiler/src/main.rs index f1f97c9..1a41799 100644 --- a/compiler/src/main.rs +++ b/compiler/src/main.rs @@ -7,17 +7,17 @@ use crate::pcf::{parse_pcf, PcfFile}; use crate::yosys_parser::{Graph, YosysDoc}; use anyhow::{bail, Result}; use clap::{Args, Parser, Subcommand, ValueEnum}; -use env_logger; use galette::blueprint::Blueprint; use galette::chips::Chip; use galette::gal_builder::build; use galette::writer::{make_jedec, Config}; +use log::{info, trace, warn}; use serde_json::from_slice; use std::fs::{self, File}; use std::io::Write; use std::path::PathBuf; use std::process::Command; -use log::{info, warn}; +use std::str; #[derive(Parser)] struct Cli { @@ -81,11 +81,7 @@ fn validate(v: ValidateArgs) -> Result<()> { Ok(()) } -fn load_to_graph( - netlist: &PathBuf, - pcf: &PcfFile, - chip: Chip, -) -> Result { +fn load_to_graph(netlist: &PathBuf, pcf: &PcfFile, chip: Chip) -> Result { info!("loading netlist..."); let f = fs::read(netlist).unwrap(); @@ -101,7 +97,6 @@ fn load_to_graph( } fn synth(s: SynthArgs) -> Result<()> { - // load the pcf let pcf_file = &fs::read(s.constraints)?; let pcf_string = std::str::from_utf8(pcf_file)?; @@ -109,9 +104,24 @@ fn synth(s: SynthArgs) -> Result<()> { let mut res = load_to_graph(&s.netlist, &pcf, s.chip.to_galette()); - while let Err(MappingError::SopTooBig { ref name, sop_size, wanted_size }) = res { + while let Err(MappingError::SopTooBig { + ref name, + sop_size, + wanted_size, + }) = res + { warn!("Sop too large, attempting to split {name}. cur={sop_size} want={wanted_size}"); - let yosys = Command::new("yosys").args(["split_sop.tcl"]); + let mut yosys = Command::new("yosys"); + yosys + .args(["-c", "shink_sop.tcl", "--"]) + .arg(&s.netlist) + .arg(name) + .arg(wanted_size.to_string()); + + info!("running yosys command {:?}", yosys); + + let out = yosys.output().expect("failed to execute process"); + trace!("Yosys stdout: ====== {}", str::from_utf8(&out.stdout).expect("hi")); res = load_to_graph(&s.netlist, &pcf, s.chip.to_galette()); }