view fpga/sniffer-pps/top.v @ 31:ab37fcb71744

fpga/sniffer-pps: add actual F/D control
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 29 Aug 2023 21:22:37 +0000
parents dc99c9962aed
children 737579209153
line wrap: on
line source

module top (CLK12, LED1, LED2, LED3, LED4, LED5, UART_TxD, UART_RxD, UART_RTS,
	    UART_CTS, UART_DTR, UART_DSR, UART_DCD, SIM_RST_in, SIM_CLK_in,
	    SIM_IO_in, SIM_IO_out);

input CLK12;
output LED1, LED2, LED3, LED4, LED5;

input UART_TxD, UART_RTS, UART_DTR;
output UART_RxD, UART_CTS, UART_DSR, UART_DCD;

input SIM_RST_in, SIM_CLK_in, SIM_IO_in;
output SIM_IO_out;

/* input synchronizers */

wire SIM_RST_sync, SIM_CLK_sync, SIM_IO_sync;

sync_inputs sync (CLK12, SIM_RST_in, SIM_RST_sync, SIM_CLK_in, SIM_CLK_sync,
		  SIM_IO_in, SIM_IO_sync);

/* character receiver */

wire Rx_strobe, Rx_error;
wire [7:0] Rx_char;
wire Rx_start_bit, Rx_parity_bit;

wire speed_enh_mode;
wire [1:0] speed_enh_mult;

sniff_rx sniff_rx (CLK12, SIM_RST_sync, SIM_CLK_sync, SIM_IO_sync,
		   Rx_strobe, Rx_error, Rx_char, Rx_start_bit, Rx_parity_bit,
		   speed_enh_mode, speed_enh_mult);

/* PPS catcher */

wire pos_PPS_resp_PPS1, pos_PPS_resp_PCK;

pps_catcher pps (CLK12, SIM_RST_sync, Rx_strobe, Rx_char,
		 pos_PPS_resp_PPS1, pos_PPS_resp_PCK);

spenh_ctrl spenh (CLK12, SIM_RST_sync, Rx_strobe, Rx_char,
		  pos_PPS_resp_PPS1, pos_PPS_resp_PCK,
		  speed_enh_mode, speed_enh_mult);

/* explicit detection of RST transitions */

wire SIM_RST_toggle;

reset_detect reset_detect (CLK12, SIM_RST_sync, SIM_RST_toggle);

/* output to the host */

wire Tx_trigger;
wire [15:0] Tx_data;

assign Tx_trigger = Rx_strobe | SIM_RST_toggle;
assign Tx_data = {SIM_RST_toggle,SIM_RST_sync,speed_enh_mode,
		  pos_PPS_resp_PCK,pos_PPS_resp_PPS1,
		  Rx_error,Rx_start_bit,Rx_parity_bit,Rx_char};

uart_tx uart_tx (CLK12, Tx_trigger, Tx_data, UART_RxD);

/* UART modem control outputs: unused */

assign UART_CTS = 1'b1;
assign UART_DSR = 1'b0;
assign UART_DCD = 1'b0;

/* board LEDs */

assign LED1 = 1'b1;
assign LED2 = 1'b0;
assign LED3 = 1'b1;
assign LED4 = 1'b0;
assign LED5 = SIM_RST_in;

/* SIM_IO_out dummy: if someone mistakenly connects an Icestick board with
 * this FPGA image in it to a cardem pod instead of the sniffing one,
 * we ensure that the 74LVC1G07 OD buffer remains off by feeding logic HIGH
 * to this buffer.
 */

assign SIM_IO_out = 1'b1;

endmodule