pins.rs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. use rust_hdl::core::prelude::*;
  2. pub const CLOCK_SPEED_12MHZ: u64 = 12_000_000;
  3. #[derive(LogicBlock)]
  4. pub struct InternalClock {
  5. pub clk: Signal<Out, Clock>,
  6. }
  7. impl InternalClock {
  8. pub fn new() -> Self {
  9. let clk = Signal::<Out, _>::default();
  10. Self { clk }
  11. }
  12. }
  13. impl Logic for InternalClock {
  14. fn update(&mut self) {}
  15. fn connect(&mut self) {
  16. self.clk.connect();
  17. }
  18. fn hdl(&self) -> Verilog {
  19. Verilog::Wrapper(Wrapper {
  20. code: "SB_HFOSC hfosc(.CLKHFPU(1'b1), .CLKHFEN(1'b1), .CLKHF(clk));".into(),
  21. cores: r#"
  22. module SB_HFOSC(CLKHFPU, CLKHFEN, CLKHF);
  23. input CLKHFPU;
  24. input CLKHFEN;
  25. output CLKHF;
  26. endmodule"#
  27. .into(),
  28. })
  29. }
  30. }
  31. pub fn leds() -> Signal<Out, Bits<3>> {
  32. let mut x = Signal::<Out, _>::default();
  33. for (ndx, uname) in ["39", "40", "41"].iter().enumerate() {
  34. x.add_location(ndx, uname);
  35. }
  36. x
  37. }