You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
393 lines
14 KiB
393 lines
14 KiB
`include "config.v"
|
|
`timescale 1ns / 1ns
|
|
module Top (
|
|
input ex_clk,
|
|
input ex_rst_n,
|
|
|
|
/*******************************************************************************
|
|
* genlock *
|
|
*******************************************************************************/
|
|
input genlock_in_hsync,
|
|
input genlock_in_vsync,
|
|
input genlock_in_fsync,
|
|
output genlock_in_state_led,
|
|
|
|
/*******************************************************************************
|
|
* GENLOCK_OUTPUT *
|
|
*******************************************************************************/
|
|
|
|
output [9:0] genlock_out_dac,
|
|
output genlock_out_dac_clk,
|
|
output genlock_out_dac_state_led,
|
|
|
|
/*******************************************************************************
|
|
* TTL_IN *
|
|
*******************************************************************************/
|
|
|
|
input sync_ttl_in1,
|
|
output sync_ttl_in1_state_led,
|
|
|
|
input sync_ttl_in2,
|
|
output sync_ttl_in2_state_led,
|
|
|
|
input sync_ttl_in3,
|
|
output sync_ttl_in3_state_led,
|
|
|
|
input sync_ttl_in4,
|
|
output sync_ttl_in4_state_led,
|
|
|
|
|
|
/*******************************************************************************
|
|
* TTL_OUT *
|
|
*******************************************************************************/
|
|
|
|
output sync_ttl_out1,
|
|
output sync_ttl_out1_state_led,
|
|
|
|
output sync_ttl_out2,
|
|
output sync_ttl_out2_state_led,
|
|
|
|
output sync_ttl_out3,
|
|
output sync_ttl_out3_state_led,
|
|
|
|
output sync_ttl_out4,
|
|
output sync_ttl_out4_state_led,
|
|
|
|
/*******************************************************************************
|
|
* TIMECODE_IN *
|
|
*******************************************************************************/
|
|
input timecode_headphone_in,
|
|
output timecode_headphone_in_state_led,
|
|
input timecode_bnc_in,
|
|
output timecode_bnc_in_state_led,
|
|
|
|
/*******************************************************************************
|
|
* TIMECODE_OUTPUT *
|
|
*******************************************************************************/
|
|
|
|
output timecode_out_bnc,
|
|
output timecode_out_bnc_select,
|
|
output timecode_out_bnc_state_led,
|
|
|
|
output timecode_out_headphone,
|
|
output timecode_out_headphone_select,
|
|
output timecode_out_headphone_state_led,
|
|
|
|
/*******************************************************************************
|
|
* STM32_IF *
|
|
*******************************************************************************/
|
|
output stm32if_camera_sync_out,
|
|
output stm32if_timecode_sync_out,
|
|
output stm32if_start_signal_out,
|
|
output [3:0] stm32if_timecode_add,
|
|
output [3:0] stm32if_timecode_data,
|
|
|
|
//SPI 串行总线1
|
|
input wire spi1_cs_pin,
|
|
input wire spi1_clk_pin,
|
|
input wire spi1_rx_pin,
|
|
output wire spi1_tx_pin,
|
|
|
|
//SPI 串行总线2
|
|
input wire spi2_cs_pin,
|
|
input wire spi2_clk_pin,
|
|
input wire spi2_rx_pin,
|
|
output wire spi2_tx_pin,
|
|
|
|
/*******************************************************************************
|
|
* debug_signal_output *
|
|
*******************************************************************************/
|
|
output [15:0] debug_signal_output,
|
|
|
|
/*******************************************************************************
|
|
* CODE_BOARD *
|
|
*******************************************************************************/
|
|
output wire core_board_debug_led
|
|
);
|
|
|
|
localparam HARDWARE_TEST_MODE = 1;
|
|
|
|
|
|
|
|
|
|
SPLL spll (
|
|
.clkin1(ex_clk), // input
|
|
.pll_lock(pll_lock), // output
|
|
.clkout0(sys_clk_25m), // output
|
|
.clkout1(sys_clk_10m), // output
|
|
.clkout2(sys_clk_5m) // output
|
|
);
|
|
assign sys_clk = sys_clk_10m;
|
|
assign sys_rst_n = ex_rst_n & pll_lock;
|
|
localparam SYS_CLOCK_FREQ = 10000000;
|
|
|
|
// zutils_reset_sig_gen reset_sig_gen_inst (
|
|
// .clk(sys_clk),
|
|
// .rst_n(rst_n),
|
|
// .rst_n_out(sys_rst_n)
|
|
// );
|
|
|
|
|
|
/*******************************************************************************
|
|
* DEBUG_LED *
|
|
*******************************************************************************/
|
|
// zutils_debug_led #(
|
|
// .PERIOD_COUNT(10000000)
|
|
// ) core_board_debug_led_inst (
|
|
// .clk(sys_clk),
|
|
// .rst_n(sys_rst_n),
|
|
// .debug_led(core_board_debug_led)
|
|
// );
|
|
|
|
/*******************************************************************************
|
|
* SPIREADER *
|
|
*******************************************************************************/
|
|
|
|
wire [31:0] reg_reader_bus_addr;
|
|
wire [31:0] reg_reader_bus_wr_data;
|
|
wire reg_reader_bus_wr_en;
|
|
wire [31:0] reg_reader_bus_rd_data;
|
|
spi_reg_reader spi_reg_reader_inst (
|
|
.clk (sys_clk),
|
|
.rst_n(sys_rst_n),
|
|
|
|
.addr(reg_reader_bus_addr),
|
|
.wr_data(reg_reader_bus_wr_data),
|
|
.wr_en(reg_reader_bus_wr_en),
|
|
.rd_data(reg_reader_bus_rd_data),
|
|
//
|
|
.spi_cs_pin(spi2_cs_pin),
|
|
.spi_clk_pin(spi2_clk_pin),
|
|
.spi_rx_pin(spi2_rx_pin),
|
|
.spi_tx_pin(spi2_tx_pin)
|
|
);
|
|
|
|
wire [31:0] stm32_rd_data;
|
|
wire [31:0] fpga_test_rd_data;
|
|
wire [31:0] control_sensor_rd_data;
|
|
wire [31:0] ttlin1_rd_data;
|
|
wire [31:0] ttlin2_rd_data;
|
|
wire [31:0] ttlin3_rd_data;
|
|
wire [31:0] ttlin4_rd_data;
|
|
wire [31:0] timecode_in_rd_data;
|
|
wire [31:0] genlock_in_rd_data;
|
|
wire [31:0] ttlout1_rd_data;
|
|
wire [31:0] ttlout2_rd_data;
|
|
wire [31:0] ttlout3_rd_data;
|
|
wire [31:0] ttlout4_rd_data;
|
|
wire [31:0] timecode_out_rd_data;
|
|
wire [31:0] genlock_out_rd_data;
|
|
wire [31:0] stm32_if_rd_data;
|
|
wire [31:0] debuger_rd_data;
|
|
|
|
|
|
/*******************************************************************************
|
|
* TEST_SPI_REG *
|
|
*******************************************************************************/
|
|
zutils_register16 #(
|
|
.REG_START_ADD(`REG_ADD_OFF_FPGA_TEST),
|
|
.REG0_INIT(31'h0000_0000_0000_0001),
|
|
.REG1_INIT(31'h0000_0000_0000_0010),
|
|
.REG2_INIT(31'h0000_0000_0000_0100),
|
|
.REG3_INIT(31'h0000_0000_0000_1000),
|
|
.REG4_INIT(31'h0000_0000_0001_0000),
|
|
.REG5_INIT(31'h0000_0000_0010_0000),
|
|
.REG6_INIT(31'h0000_0000_0100_0000),
|
|
.REG7_INIT(31'h0000_0000_1000_0000),
|
|
.REG8_INIT(31'h0000_0001_0000_0000),
|
|
.REG9_INIT(31'h0000_0010_0000_0000),
|
|
.REGA_INIT(31'h0000_0100_0000_0000),
|
|
.REGB_INIT(31'h0000_1000_0000_0000),
|
|
.REGC_INIT(31'h0001_0000_0000_0000),
|
|
.REGD_INIT(31'h0010_0000_0000_0000),
|
|
.REGE_INIT(31'h0100_0000_0000_0000),
|
|
.REGF_INIT(31'h1000_0000_0000_0000)
|
|
) test_reg (
|
|
.clk(sys_clk),
|
|
.rst_n(sys_rst_n),
|
|
.addr(reg_reader_bus_addr),
|
|
.wr_data(reg_reader_bus_wr_data),
|
|
.wr_en(reg_reader_bus_wr_en),
|
|
.rd_data(fpga_test_rd_data)
|
|
);
|
|
|
|
/*******************************************************************************
|
|
* 信号源 *
|
|
*******************************************************************************/
|
|
// level0 = 0, // 0
|
|
// level1 = 1, // 1
|
|
wire ttlin1_module_raw_sig; // ttl1输入模块原始信号 2
|
|
wire ttlin1_module_sig_divide; // ttl1输入模块分频信号 3
|
|
wire ttlin2_module_raw_sig; // ttl2输入模块原始信号 4
|
|
wire ttlin2_module_sig_divide; // ttl2输入模块分频信号 5
|
|
wire ttlin3_module_raw_sig; // ttl3输入模块原始信号 6
|
|
wire ttlin3_module_sig_divide; // ttl3输入模块分频信号 7
|
|
wire ttlin4_module_raw_sig; // ttl4输入模块原始信号 8
|
|
wire ttlin4_module_sig_divide; // ttl4输入模块分频信号 9
|
|
wire genlockin_module_freq_sig; // genlock输入模块频率信号 10
|
|
wire timecodein_module_trigger_sig; // timecode输入模块触发信号 11
|
|
wire internal_camera_sync_sig; // 内部相机同步信号 12
|
|
wire internal_timecode_trigger_sig; // 内部timecode触发信号 13
|
|
wire internal_genlock_freq_sig; // 内部genlock频率信号 14
|
|
wire internal_work_state_sig; // 内部工作状态信号 15
|
|
wire internal_100hz_output; // 内部工作状态信号 16
|
|
|
|
xsync_internal_generator xsync_internal_generator_ins (
|
|
.clk (sys_clk),
|
|
.rst_n(sys_rst_n)
|
|
);
|
|
|
|
wire [31:0] ttl_output_module_source_sig_af;
|
|
zutils_pwm_generator #(
|
|
.SYS_CLOCK_FREQ(SYS_CLOCK_FREQ),
|
|
.OUTPUT_FREQ(100)
|
|
) pwm100hz_gen (
|
|
.clk(sys_clk),
|
|
.rst_n(sys_rst_n),
|
|
.output_signal(internal_100hz_output)
|
|
);
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
* 输出组件 *
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
|
|
assign ttl_output_module_source_sig_af[0] = 0;
|
|
assign ttl_output_module_source_sig_af[1] = 1;
|
|
assign ttl_output_module_source_sig_af[2] = ttlin1_module_raw_sig;
|
|
assign ttl_output_module_source_sig_af[3] = ttlin1_module_sig_divide;
|
|
assign ttl_output_module_source_sig_af[4] = ttlin2_module_raw_sig;
|
|
assign ttl_output_module_source_sig_af[5] = ttlin2_module_sig_divide;
|
|
assign ttl_output_module_source_sig_af[6] = ttlin3_module_raw_sig;
|
|
assign ttl_output_module_source_sig_af[7] = ttlin3_module_sig_divide;
|
|
assign ttl_output_module_source_sig_af[8] = ttlin4_module_raw_sig;
|
|
assign ttl_output_module_source_sig_af[9] = ttlin4_module_sig_divide;
|
|
assign ttl_output_module_source_sig_af[10] = genlockin_module_freq_sig;
|
|
assign ttl_output_module_source_sig_af[11] = timecodein_module_trigger_sig;
|
|
assign ttl_output_module_source_sig_af[12] = internal_camera_sync_sig;
|
|
assign ttl_output_module_source_sig_af[13] = internal_timecode_trigger_sig;
|
|
assign ttl_output_module_source_sig_af[14] = internal_genlock_freq_sig;
|
|
assign ttl_output_module_source_sig_af[15] = internal_work_state_sig;
|
|
assign ttl_output_module_source_sig_af[16] = internal_100hz_output;
|
|
|
|
|
|
ttl_output #(
|
|
.REG_START_ADD(`REG_ADD_OFF_TTLOUT1),
|
|
.SYS_CLOCK_FREQ(SYS_CLOCK_FREQ),
|
|
.ID(1)
|
|
) ttl_output_1 (
|
|
.clk (sys_clk),
|
|
.rst_n(sys_rst_n),
|
|
|
|
.addr(reg_reader_bus_addr),
|
|
.wr_data(reg_reader_bus_wr_data),
|
|
.wr_en(reg_reader_bus_wr_en),
|
|
.rd_data(ttlout1_rd_data),
|
|
|
|
.signal_in(ttl_output_module_source_sig_af),
|
|
|
|
.ttloutput(sync_ttl_out1),
|
|
.ttloutput_state_led(sync_ttl_out1_state_led)
|
|
);
|
|
|
|
ttl_output #(
|
|
.REG_START_ADD(`REG_ADD_OFF_TTLOUT2),
|
|
.SYS_CLOCK_FREQ(SYS_CLOCK_FREQ),
|
|
.ID(2)
|
|
) ttl_output_2 (
|
|
.clk (sys_clk),
|
|
.rst_n(sys_rst_n),
|
|
|
|
.addr(reg_reader_bus_addr),
|
|
.wr_data(reg_reader_bus_wr_data),
|
|
.wr_en(reg_reader_bus_wr_en),
|
|
.rd_data(ttlout2_rd_data),
|
|
|
|
.signal_in(ttl_output_module_source_sig_af),
|
|
|
|
.ttloutput(sync_ttl_out2),
|
|
.ttloutput_state_led(sync_ttl_out2_state_led)
|
|
);
|
|
|
|
ttl_output #(
|
|
.REG_START_ADD(`REG_ADD_OFF_TTLOUT3),
|
|
.SYS_CLOCK_FREQ(SYS_CLOCK_FREQ),
|
|
.ID(3)
|
|
) ttl_output_3 (
|
|
.clk (sys_clk),
|
|
.rst_n(sys_rst_n),
|
|
|
|
.addr(reg_reader_bus_addr),
|
|
.wr_data(reg_reader_bus_wr_data),
|
|
.wr_en(reg_reader_bus_wr_en),
|
|
.rd_data(ttlout3_rd_data),
|
|
|
|
.signal_in(ttl_output_module_source_sig_af),
|
|
|
|
.ttloutput(sync_ttl_out3),
|
|
.ttloutput_state_led(sync_ttl_out3_state_led)
|
|
);
|
|
|
|
ttl_output #(
|
|
.REG_START_ADD(`REG_ADD_OFF_TTLOUT4),
|
|
.SYS_CLOCK_FREQ(SYS_CLOCK_FREQ),
|
|
.ID(4)
|
|
) ttl_output_4 (
|
|
.clk (sys_clk),
|
|
.rst_n(sys_rst_n),
|
|
|
|
.addr(reg_reader_bus_addr),
|
|
.wr_data(reg_reader_bus_wr_data),
|
|
.wr_en(reg_reader_bus_wr_en),
|
|
.rd_data(ttlout4_rd_data),
|
|
|
|
.signal_in(ttl_output_module_source_sig_af),
|
|
|
|
.ttloutput(sync_ttl_out4),
|
|
.ttloutput_state_led(sync_ttl_out4_state_led)
|
|
);
|
|
|
|
|
|
rd_data_router rd_data_router_inst (
|
|
.addr(reg_reader_bus_addr),
|
|
|
|
.stm32_rd_data(stm32_rd_data),
|
|
.fpga_test_rd_data(fpga_test_rd_data),
|
|
.control_sensor_rd_data(control_sensor_rd_data),
|
|
.ttlin1_rd_data(ttlin1_rd_data),
|
|
.ttlin2_rd_data(ttlin2_rd_data),
|
|
.ttlin3_rd_data(ttlin3_rd_data),
|
|
.ttlin4_rd_data(ttlin4_rd_data),
|
|
.timecode_in_rd_data(timecode_in_rd_data),
|
|
.genlock_in_rd_data(genlock_in_rd_data),
|
|
|
|
.ttlout1_rd_data(ttlout1_rd_data), // ok
|
|
.ttlout2_rd_data(ttlout2_rd_data), // ok
|
|
.ttlout3_rd_data(ttlout3_rd_data), // ok
|
|
.ttlout4_rd_data(ttlout4_rd_data), // ok
|
|
|
|
.timecode_out_rd_data(timecode_out_rd_data),
|
|
.genlock_out_rd_data(genlock_out_rd_data),
|
|
.stm32_if_rd_data(stm32_if_rd_data),
|
|
.debuger_rd_data(debuger_rd_data),
|
|
|
|
.rd_data_out(reg_reader_bus_rd_data)
|
|
);
|
|
// assign reg_reader_bus_rd_data[31:0] = fpga_test_rd_data[31:0];
|
|
|
|
assign debug_signal_output[0] = spi2_cs_pin;
|
|
assign debug_signal_output[1] = spi2_clk_pin;
|
|
assign debug_signal_output[2] = spi2_rx_pin;
|
|
assign debug_signal_output[3] = spi2_tx_pin;
|
|
assign debug_signal_output[4] = sync_ttl_out1;
|
|
assign debug_signal_output[5] = sync_ttl_out2;
|
|
assign debug_signal_output[6] = sync_ttl_out3;
|
|
assign debug_signal_output[7] = sync_ttl_out4;
|
|
assign core_board_debug_led = 1;
|
|
|
|
|
|
endmodule
|