2024-09-14 22:53:21 +02:00
|
|
|
package Top;
|
|
|
|
|
|
|
|
import Connectable::*;
|
|
|
|
import GetPut::*;
|
|
|
|
import ClientServer::*;
|
|
|
|
|
2024-09-15 01:40:14 +02:00
|
|
|
import Blinky::*;
|
2024-09-14 22:53:21 +02:00
|
|
|
import PackUnpack::*;
|
|
|
|
import UART::*;
|
|
|
|
import VRAM::*;
|
2024-09-19 06:31:34 +02:00
|
|
|
import Debugger::*;
|
2024-09-14 22:53:21 +02:00
|
|
|
|
|
|
|
module mkUARTDebugger(Integer clock_frequency, Integer uart_bitrate, VRAMServer mem, UART_PHY ifc);
|
2024-09-15 01:40:14 +02:00
|
|
|
UART uart <- mkUART(clock_frequency, uart_bitrate);
|
|
|
|
disableFlowControl(uart); // Can't do hardware flow control on ULX3S
|
2024-09-19 06:31:34 +02:00
|
|
|
let uart_client = toGPClient(uart.receive, uart.send);
|
2024-09-14 22:53:21 +02:00
|
|
|
|
2024-09-19 06:31:34 +02:00
|
|
|
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);
|
2024-09-14 22:53:21 +02:00
|
|
|
|
2024-09-19 06:31:34 +02:00
|
|
|
let debug <- mkDebugger();
|
|
|
|
mkConnection(debug_client, debug.server);
|
|
|
|
mkConnection(debug.vram, mem);
|
2024-09-14 22:53:21 +02:00
|
|
|
|
2024-09-15 01:40:14 +02:00
|
|
|
return uart.phy;
|
2024-09-14 22:53:21 +02:00
|
|
|
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();
|
2024-09-15 01:40:14 +02:00
|
|
|
|
|
|
|
(* always_ready *)
|
|
|
|
method Bool led();
|
2024-09-14 22:53:21 +02:00
|
|
|
endinterface
|
|
|
|
|
|
|
|
(* synthesize *)
|
|
|
|
module mkTop(Top);
|
|
|
|
////////////
|
|
|
|
// Memory
|
2024-09-19 06:31:34 +02:00
|
|
|
VRAM mem <- mkVRAM(128);
|
2024-09-14 22:53:21 +02:00
|
|
|
|
|
|
|
////////////
|
2024-09-15 01:40:14 +02:00
|
|
|
// Debugging
|
2024-09-20 06:25:04 +02:00
|
|
|
let debugger <- mkUARTDebugger(25_000_000, 1_382_400, mem.debugger);
|
2024-09-15 01:40:14 +02:00
|
|
|
let blinky <- mkBlinky(25_000_000);
|
2024-09-14 22:53:21 +02:00
|
|
|
|
2024-09-15 01:40:14 +02:00
|
|
|
////////////
|
|
|
|
// External interface
|
2024-09-14 22:53:21 +02:00
|
|
|
method debugger_rx_in = debugger.rx_in;
|
|
|
|
method debugger_tx_out = debugger.tx_out;
|
2024-09-15 01:40:14 +02:00
|
|
|
|
|
|
|
method led = blinky.led_on;
|
2024-09-14 22:53:21 +02:00
|
|
|
endmodule
|
|
|
|
|
|
|
|
endpackage
|