gary/hardware/ulx3s/Top.bsv

61 lines
1.5 KiB
Plaintext
Raw Normal View History

package Top;
import Connectable::*;
import GetPut::*;
import ClientServer::*;
import Blinky::*;
import PackUnpack::*;
import UART::*;
import VRAM::*;
import Debugger::*;
module mkUARTDebugger(Integer clock_frequency, Integer uart_bitrate, VRAMServer mem, UART_PHY ifc);
UART uart <- mkUART(clock_frequency, uart_bitrate);
disableFlowControl(uart); // Can't do hardware flow control on ULX3S
let uart_client = toGPClient(uart.receive, uart.send);
Server#(Bit#(8), DebugRequest) decode <- mkUnpacker();
Server#(DebugResponse, Bit#(8)) encode <- mkPacker();
let bytes_server = toGPServer(decode.request, encode.response);
let debug_client = toGPClient(decode.response, encode.request);
mkConnection(uart_client, bytes_server);
let debug <- mkDebugger();
mkConnection(debug_client, debug.server);
mkConnection(debug.vram, mem);
return uart.phy;
endmodule
interface Top;
(* always_enabled,prefix="debug" *)
method Action debugger_rx_in((* port="serial_in" *) bit b);
(* always_ready,result="debug_serial_out" *)
method bit debugger_tx_out();
(* always_ready *)
method Bool led();
endinterface
(* synthesize *)
module mkTop(Top);
////////////
// Memory
VRAM mem <- mkVRAM(128);
////////////
// Debugging
let debugger <- mkUARTDebugger(25_000_000, 1_382_400, mem.debugger);
let blinky <- mkBlinky(25_000_000);
////////////
// External interface
method debugger_rx_in = debugger.rx_in;
method debugger_tx_out = debugger.tx_out;
method led = blinky.led_on;
endmodule
endpackage