You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1 KiB

  1. * another state machine example
  2. * by Holger Vogt, July 9th, 2020
  3. * 3-bit counter in a subcircuit with 5 V analog in and out
  4. *** counter
  5. .subckt 3bcounter clock updown out_b0 out_b1 out_b2
  6. * Define a simple 3 bit up/down counter that counts clk edges.
  7. * Digital outputs are on b2 b1 b0.
  8. * inputs clock reset outputs (all digital)
  9. a0 [upd] clk n_zero [b2 b1 b0] state2
  10. * This needs to be edited: enter the absolute path of file state-3bit-count.in
  11. .model state2 d_state(state_file = "D:\Spice_general\KiCad-799\up-down-counter\state-3bit-count.in")
  12. *.model state2 d_state(state_file = "state-3bit-count.in")
  13. * Digital "one" and "zero"
  14. a1 n_one pullup1
  15. .model pullup1 d_pullup(load = 1pF)
  16. a2 n_zero pulldown1
  17. .model pulldown1 d_pulldown(load = 1pF)
  18. * Convert the digital outputs to analog
  19. a3 [b2] [out_b2] dac1
  20. a4 [b1] [out_b1] dac1
  21. a5 [b0] [out_b0] dac1
  22. .model dac1 dac_bridge(out_low = 0 out_high = 5 out_undef = 2.5)
  23. * Convert the analog inputs to digital
  24. a6 [clock] [clk] adc1
  25. a7 [updown] [upd] adc1
  26. .model adc1 adc_bridge(in_low = 0.3 in_high = 3.5)
  27. .ends
  28. *** end counter