Skip to content

Commit

Permalink
Generate verilog_output folder if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
VonTum committed Aug 2, 2024
1 parent daaf064 commit 34977cf
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ mod to_string;
mod typing;
mod value;

//#[cfg(feature = "codegen")]
mod codegen_fallback;

mod dev_aid;
mod linker;

mod compiler_top;

use std::error::Error;
use std::path::PathBuf;
use std::{error::Error, fs};
use std::fs::File;
use std::io::Write;
use std::ops::Deref;
Expand All @@ -45,22 +45,26 @@ fn codegen_instance(inst: &InstantiatedModule, md: &Module, out_file: &mut File)
println!("Instantiating success: {inst_name}");
let code = gen_verilog_code(md, &inst, true);
write!(out_file, "// {inst_name}\n{code}").unwrap();
}

//println!("Generating Verilog for {module_name}:");
// gen_ctx.to_circt();
fn make_output_file(name : &str) -> File {
let mut path = PathBuf::new();
path.push("verilog_output");
fs::create_dir_all(&path).unwrap();
path.push(name);
path.set_extension("sv");
File::create(path).unwrap()
}

fn codegen_to_file(md: &Module) {
let module_name = md.link_info.name.deref();
let mut out_file = File::create(format!("verilog_output/{module_name}.sv")).unwrap();
let mut out_file = make_output_file(md.link_info.name.deref());
md.instantiations.for_each_instance(|_template_args, inst| {
codegen_instance(inst.as_ref(), md, &mut out_file)
});
}

fn codegen_with_dependencies(linker: &Linker, md: &Module, file_name: &str) {
let mut out_file = File::create(format!("verilog_output/{file_name}.sv")).unwrap();

let mut out_file = make_output_file(file_name);
let mut top_level_instances: Vec<Rc<InstantiatedModule>> = Vec::new();
md.instantiations.for_each_instance(|_template_args, inst| {
top_level_instances.push(inst.clone());
Expand Down

0 comments on commit 34977cf

Please sign in to comment.