step_example/
step_example.rs

1use cmtc::*;
2use cmtrs::*;
3use utils::setup_logger;
4
5itfc_declare! {
6  struct StepExample {
7    out: output Type::UInt(4)
8  }
9  method out () -> (out);
10  method start();
11}
12
13#[module]
14fn make_step_example() -> StepExample {
15  let io = io! {};
16
17  let r = instance!(stl::reg(&Type::UInt(4)));
18
19  let out = method!(
20    () -> (io.out) {
21      ret!(r.read())
22    }
23  );
24
25  let start = method!(
26    fsm;
27    () {
28      step!{ r.write(literal(1, &Type::UInt(4))); };
29    }
30  );
31
32  let r_default = always!(
33    () {
34      r.write(literal(0, &Type::UInt(4)));
35    }
36  );
37
38  schedule!(out, start, r_default);
39}
40
41fn main() -> anyhow::Result<()> {
42  setup_logger();
43  let step_example = make_step_example();
44  // let mut circuit = step_example.to_cmtir();
45  // FSMGenPass::new().apply_pass(&mut circuit)?;
46  // println!("{}", circuit.ir_dump());
47  elaborate(step_example, sv_config("tb/step_example/step_example.sv"))?;
48  Ok(())
49}