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::*;
|
|
|
|
|
|
|
|
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-14 22:53:21 +02:00
|
|
|
|
2024-09-15 01:40:14 +02:00
|
|
|
Server#(Bit#(8), VRAMRequest) decode <- mkUnpacker();
|
|
|
|
Server#(VRAMResponse, Bit#(8)) encode <- mkPacker();
|
2024-09-14 22:53:21 +02:00
|
|
|
|
2024-09-15 01:40:14 +02:00
|
|
|
mkConnection(uart.receive, decode.request);
|
|
|
|
mkConnection(decode.response, mem.request);
|
|
|
|
mkConnection(mem.response, encode.request);
|
|
|
|
mkConnection(encode.response, uart.send);
|
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-15 01:40:14 +02:00
|
|
|
VRAM mem <- mkVRAM(4);
|
2024-09-14 22:53:21 +02:00
|
|
|
|
|
|
|
////////////
|
2024-09-15 01:40:14 +02:00
|
|
|
// Debugging
|
2024-09-14 22:53:21 +02:00
|
|
|
let debugger <- mkUARTDebugger(25_000_000, 115_200, 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
|