view fpga/sniffer-pps/top.v @ 57:eb4274e7f4da

simsniff-dec: decode SELECT file IDs
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 04 Oct 2023 03:54:00 +0000
parents 737579209153
children
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);

/* running clock detector */

wire SIM_CLK_running;

clk_check clk_check (CLK12, SIM_CLK_sync, SIM_CLK_running);

/* 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 = SIM_CLK_running;
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