Skip to content

Instantly share code, notes, and snippets.

@arjenroodselaar
Last active March 23, 2021 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arjenroodselaar/d1300b6c0d888b53cefb837f51c95bf3 to your computer and use it in GitHub Desktop.
Save arjenroodselaar/d1300b6c0d888b53cefb837f51c95bf3 to your computer and use it in GitHub Desktop.
BSC internal clocking of interface methods
(* always_enabled, always_ready *)
interface Top;
method Bit#(1) led();
method Action btn(Bit#(6) val);
endinterface
interface Foo;
method Bit#(1) status();
method Action do_something_with_btn_input(Bit#(6) val);
...
endinterface
(* synthesize, no_default_clock, no_default_reset *)
module mkTop ((* osc="clk_25mhz" *) Clock clk_25mhz, (* reset="rst" *) Reset rst, Top ifc);
PLL pll <- mkPLL(clocked_by clk_25mhz);
MakeResetIfc init_reset <- mkReset(2, True, pll.clkout0, clocked_by clk_25mhz, reset_by rst);
Foo foo <- mkModuleWithLotsOfLogic(clocked_by pll.clkout0, reset_by init_reset.new_rst);
ReadOnly#(Bit#(1)) status_25mhz <- mkNullCrossingWire(noClock, foo.status);
Wire#(Bit#(6)) btn_25mhz <- mkWire(clocked_by clk25_mhz, reset_by rst);
ReadOnly#(Bit#(6)) btn_100mhz <- mkNullCrossingWire(noClock, btn_25mhz);
rule do_something;
foo.do_something_with_btn_input(btn_next_100mhz);
endrule
method led = foo.status_25mhz;
method Action btn(Bit#(6) val);
btn_25mhz <= val;
endmethod
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment