module_content
stringlengths
18
1.05M
module NEOMOTE_5 ; wire Net_664; wire Net_672; wire Net_671; wire Net_670; wire Net_669; wire Net_668; wire Net_667; wire Net_666; wire Net_665; wire Net_636; wire Net_635; wire Net_634; wire Net_633; wire Net_632; wire Net_631; wire Net_630; wire Net_629; wire Net_628; wire Net_627; wire Net_626; wire Net_625; wire Net_542; wire Net_541; wire Net_540; wire Net_539; wire Net_538; wire Net_537; wire Net_536; wire Net_535; wire Net_534; wire Net_533; wire Net_532; wire Net_531; wire Net_648; wire Net_660; wire Net_651; wire Net_176; wire Net_212; UART_v2_30_2 UART_MOTE ( .cts_n(1'b0), .tx(Net_176), .rts_n(Net_532), .tx_en(Net_533), .clock(1'b0), .reset(Net_535), .rx(Net_212), .tx_interrupt(Net_536), .rx_interrupt(Net_537), .tx_data(Net_538), .tx_clk(Net_539), .rx_data(Net_540), .rx_clk(Net_541)); defparam UART_MOTE.Address1 = 0; defparam UART_MOTE.Address2 = 0; defparam UART_MOTE.EnIntRXInterrupt = 0; defparam UART_MOTE.EnIntTXInterrupt = 0; defparam UART_MOTE.FlowControl = 0; defparam UART_MOTE.HalfDuplexEn = 0; defparam UART_MOTE.HwTXEnSignal = 0; defparam UART_MOTE.NumDataBits = 8; defparam UART_MOTE.NumStopBits = 1; defparam UART_MOTE.ParityType = 0; defparam UART_MOTE.RXEnable = 1; defparam UART_MOTE.TXEnable = 1; wire [0:0] tmpOE__RX_Pin_net; wire [0:0] tmpIO_0__RX_Pin_net; wire [0:0] tmpINTERRUPT_0__RX_Pin_net; electrical [0:0] tmpSIOVREF__RX_Pin_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/483c8cff-b35d-4e9b-b782-7d15671bd8fc"), .drive_mode(3'b010), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("I"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) RX_Pin (.oe(tmpOE__RX_Pin_net), .y({1'b0}), .fb({Net_212}), .io({tmpIO_0__RX_Pin_net[0:0]}), .siovref(tmpSIOVREF__RX_Pin_net), .interrupt({tmpINTERRUPT_0__RX_Pin_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__RX_Pin_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; wire [0:0] tmpOE__TX_Pin_net; wire [0:0] tmpFB_0__TX_Pin_net; wire [0:0] tmpIO_0__TX_Pin_net; wire [0:0] tmpINTERRUPT_0__TX_Pin_net; electrical [0:0] tmpSIOVREF__TX_Pin_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/ed092b9b-d398-4703-be89-cebf998501f6"), .drive_mode(3'b110), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b1), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) TX_Pin (.oe(tmpOE__TX_Pin_net), .y({Net_176}), .fb({tmpFB_0__TX_Pin_net[0:0]}), .io({tmpIO_0__TX_Pin_net[0:0]}), .siovref(tmpSIOVREF__TX_Pin_net), .interrupt({tmpINTERRUPT_0__TX_Pin_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__TX_Pin_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; ZeroTerminal ZeroTerminal_2 ( .z(Net_535)); cy_isr_v1_0 #(.int_type(2'b10)) isr_RX (.int_signal(Net_537)); wire [0:0] tmpOE__RX_RTS_n_net; wire [0:0] tmpFB_0__RX_RTS_n_net; wire [0:0] tmpIO_0__RX_RTS_n_net; electrical [0:0] tmpSIOVREF__RX_RTS_n_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/f497a9ab-60b4-4f16-b3f4-5d5c511256c1"), .drive_mode(3'b010), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b11), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("I"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) RX_RTS_n (.oe(tmpOE__RX_RTS_n_net), .y({1'b0}), .fb({tmpFB_0__RX_RTS_n_net[0:0]}), .io({tmpIO_0__RX_RTS_n_net[0:0]}), .siovref(tmpSIOVREF__RX_RTS_n_net), .interrupt({Net_542}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__RX_RTS_n_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; wire [0:0] tmpOE__RX_CTS_n_net; wire [0:0] tmpFB_0__RX_CTS_n_net; wire [0:0] tmpIO_0__RX_CTS_n_net; wire [0:0] tmpINTERRUPT_0__RX_CTS_n_net; electrical [0:0] tmpSIOVREF__RX_CTS_n_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/aedfa372-ccbb-489a-9d67-d67b95d9adc7"), .drive_mode(3'b110), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) RX_CTS_n (.oe(tmpOE__RX_CTS_n_net), .y({1'b0}), .fb({tmpFB_0__RX_CTS_n_net[0:0]}), .io({tmpIO_0__RX_CTS_n_net[0:0]}), .siovref(tmpSIOVREF__RX_CTS_n_net), .interrupt({tmpINTERRUPT_0__RX_CTS_n_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__RX_CTS_n_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; wire [0:0] tmpOE__TX_RTS_n_net; wire [0:0] tmpFB_0__TX_RTS_n_net; wire [0:0] tmpIO_0__TX_RTS_n_net; wire [0:0] tmpINTERRUPT_0__TX_RTS_n_net; electrical [0:0] tmpSIOVREF__TX_RTS_n_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/52d1081a-4b5a-4078-8e67-f4f9a3e0209d"), .drive_mode(3'b110), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) TX_RTS_n (.oe(tmpOE__TX_RTS_n_net), .y({1'b0}), .fb({tmpFB_0__TX_RTS_n_net[0:0]}), .io({tmpIO_0__TX_RTS_n_net[0:0]}), .siovref(tmpSIOVREF__TX_RTS_n_net), .interrupt({tmpINTERRUPT_0__TX_RTS_n_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__TX_RTS_n_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; wire [0:0] tmpOE__TX_CTS_n_net; wire [0:0] tmpFB_0__TX_CTS_n_net; wire [0:0] tmpIO_0__TX_CTS_n_net; wire [0:0] tmpINTERRUPT_0__TX_CTS_n_net; electrical [0:0] tmpSIOVREF__TX_CTS_n_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/16e1e3e6-3865-4bb9-bb8c-3f92d51bf7af"), .drive_mode(3'b001), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("I"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) TX_CTS_n (.oe(tmpOE__TX_CTS_n_net), .y({1'b0}), .fb({tmpFB_0__TX_CTS_n_net[0:0]}), .io({tmpIO_0__TX_CTS_n_net[0:0]}), .siovref(tmpSIOVREF__TX_CTS_n_net), .interrupt({tmpINTERRUPT_0__TX_CTS_n_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__TX_CTS_n_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; wire [0:0] tmpOE__TimeN_net; wire [0:0] tmpFB_0__TimeN_net; wire [0:0] tmpIO_0__TimeN_net; wire [0:0] tmpINTERRUPT_0__TimeN_net; electrical [0:0] tmpSIOVREF__TimeN_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/0818fd13-68e2-43ac-afc2-87e7ba6f6425"), .drive_mode(3'b110), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) TimeN (.oe(tmpOE__TimeN_net), .y({1'b0}), .fb({tmpFB_0__TimeN_net[0:0]}), .io({tmpIO_0__TimeN_net[0:0]}), .siovref(tmpSIOVREF__TimeN_net), .interrupt({tmpINTERRUPT_0__TimeN_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__TimeN_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; cy_isr_v1_0 #(.int_type(2'b10)) isr_RX_RTSn (.int_signal(Net_542)); wire [0:0] tmpOE__External_VRef_net; wire [0:0] tmpFB_0__External_VRef_net; wire [0:0] tmpIO_0__External_VRef_net; wire [0:0] tmpINTERRUPT_0__External_VRef_net; electrical [0:0] tmpSIOVREF__External_VRef_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/52f31aa9-2f0a-497d-9a1f-1424095e13e6"), .drive_mode(3'b110), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) External_VRef (.oe(tmpOE__External_VRef_net), .y({1'b0}), .fb({tmpFB_0__External_VRef_net[0:0]}), .io({tmpIO_0__External_VRef_net[0:0]}), .siovref(tmpSIOVREF__External_VRef_net), .interrupt({tmpINTERRUPT_0__External_VRef_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__External_VRef_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; I2C_v3_30_3 I2C_0 ( .sda(Net_625), .scl(Net_626), .clock(1'b0), .reset(1'b0), .bclk(Net_629), .iclk(Net_630), .scl_i(1'b0), .sda_i(1'b0), .scl_o(Net_633), .sda_o(Net_634), .itclk(Net_635)); wire [0:0] tmpOE__I2C_0_SDA_net; wire [0:0] tmpFB_0__I2C_0_SDA_net; wire [0:0] tmpINTERRUPT_0__I2C_0_SDA_net; electrical [0:0] tmpSIOVREF__I2C_0_SDA_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/5c1decb5-69e3-4a8d-bb0c-281221d15217"), .drive_mode(3'b100), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("B"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) I2C_0_SDA (.oe(tmpOE__I2C_0_SDA_net), .y({1'b0}), .fb({tmpFB_0__I2C_0_SDA_net[0:0]}), .io({Net_625}), .siovref(tmpSIOVREF__I2C_0_SDA_net), .interrupt({tmpINTERRUPT_0__I2C_0_SDA_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__I2C_0_SDA_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; wire [0:0] tmpOE__I2C_0_SCL_net; wire [0:0] tmpFB_0__I2C_0_SCL_net; wire [0:0] tmpINTERRUPT_0__I2C_0_SCL_net; electrical [0:0] tmpSIOVREF__I2C_0_SCL_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/25518df9-7fe0-4da6-8dbf-d2a9e2ed11c1"), .drive_mode(3'b100), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("B"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) I2C_0_SCL (.oe(tmpOE__I2C_0_SCL_net), .y({1'b0}), .fb({tmpFB_0__I2C_0_SCL_net[0:0]}), .io({Net_626}), .siovref(tmpSIOVREF__I2C_0_SCL_net), .interrupt({tmpINTERRUPT_0__I2C_0_SCL_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__I2C_0_SCL_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; wire [0:0] tmpOE__NEO_RTC_INT1_net; wire [0:0] tmpFB_0__NEO_RTC_INT1_net; wire [0:0] tmpIO_0__NEO_RTC_INT1_net; electrical [0:0] tmpSIOVREF__NEO_RTC_INT1_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/94c29172-218c-472e-b77b-9668892b6f11"), .drive_mode(3'b010), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b10), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("I"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) NEO_RTC_INT1 (.oe(tmpOE__NEO_RTC_INT1_net), .y({1'b0}), .fb({tmpFB_0__NEO_RTC_INT1_net[0:0]}), .io({tmpIO_0__NEO_RTC_INT1_net[0:0]}), .siovref(tmpSIOVREF__NEO_RTC_INT1_net), .interrupt({Net_636}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__NEO_RTC_INT1_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; cy_isr_v1_0 #(.int_type(2'b00)) isr_rtc_int1 (.int_signal(Net_636)); wire [0:0] tmpOE__SD_Card_Power_net; wire [0:0] tmpFB_0__SD_Card_Power_net; wire [0:0] tmpIO_0__SD_Card_Power_net; wire [0:0] tmpINTERRUPT_0__SD_Card_Power_net; electrical [0:0] tmpSIOVREF__SD_Card_Power_net; cy_psoc3_pins_v1_10 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/37615ece-52ed-4b08-a3cb-e053c56b7928"), .drive_mode(3'b110), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) SD_Card_Power (.oe(tmpOE__SD_Card_Power_net), .y({1'b0}), .fb({tmpFB_0__SD_Card_Power_net[0:0]}), .io({tmpIO_0__SD_Card_Power_net[0:0]}), .siovref(tmpSIOVREF__SD_Card_Power_net), .interrupt({tmpINTERRUPT_0__SD_Card_Power_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__SD_Card_Power_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; Counter_v2_40_4 DELAY_COUNTER ( .reset(Net_648), .tc(Net_665), .comp(Net_666), .clock(Net_651), .interrupt(Net_660), .enable(1'b0), .capture(1'b0), .upCnt(1'b0), .downCnt(1'b0), .up_ndown(1'b1), .count(1'b0)); defparam DELAY_COUNTER.CaptureMode = 0; defparam DELAY_COUNTER.ClockMode = 3; defparam DELAY_COUNTER.CompareMode = 1; defparam DELAY_COUNTER.CompareStatusEdgeSense = 1; defparam DELAY_COUNTER.EnableMode = 0; defparam DELAY_COUNTER.ReloadOnCapture = 0; defparam DELAY_COUNTER.ReloadOnCompare = 0; defparam DELAY_COUNTER.ReloadOnOverUnder = 1; defparam DELAY_COUNTER.ReloadOnReset = 1; defparam DELAY_COUNTER.Resolution = 16; defparam DELAY_COUNTER.RunMode = 0; defparam DELAY_COUNTER.UseInterrupt = 1; assign Net_648 = 1'h0; cy_isr_v1_0 #(.int_type(2'b10)) isr_packet_delay (.int_signal(Net_660)); cy_clock_v1_0 #(.id("42a3c2ea-f0b8-4d0c-bf50-a43bc1e1db6a/96bd6326-bc84-40d3-a080-adae5cf2aa35"), .source_clock_id(""), .divisor(0), .period("83333333333.3333"), .is_direct(0), .is_digital(1)) Clock_1 (.clock_out(Net_651)); endmodule
module SPI_Master_v2_40_6 ( clock, reset, miso, sclk, mosi, ss, rx_interrupt, sdat, tx_interrupt); input clock; input reset; input miso; output sclk; output mosi; output ss; output rx_interrupt; inout sdat; output tx_interrupt; parameter BidirectMode = 0; parameter HighSpeedMode = 1; parameter NumberOfDataBits = 8; parameter ShiftDir = 0; wire Net_257; wire Net_273; wire Net_274; wire Net_244; wire Net_239; wire Net_253; wire Net_161; wire Net_276; // VirtualMux_1 (cy_virtualmux_v1_0) assign Net_276 = clock; B_SPI_Master_v2_40 BSPIM ( .sclk(sclk), .ss(ss), .miso(Net_244), .clock(Net_276), .reset(Net_273), .rx_interpt(rx_interrupt), .tx_enable(Net_253), .mosi(mosi), .tx_interpt(tx_interrupt)); defparam BSPIM.BidirectMode = 0; defparam BSPIM.HighSpeedMode = 1; defparam BSPIM.ModeCPHA = 0; defparam BSPIM.ModePOL = 0; defparam BSPIM.NumberOfDataBits = 8; defparam BSPIM.ShiftDir = 0; // VirtualMux_2 (cy_virtualmux_v1_0) assign Net_244 = miso; // VirtualMux_3 (cy_virtualmux_v1_0) assign Net_273 = Net_274; ZeroTerminal ZeroTerminal_1 ( .z(Net_274)); endmodule
module emFile_v1_20_7 ; wire Net_31; wire Net_30; wire Net_29; wire Net_28; wire Net_27; wire Net_26; wire Net_24; wire Net_23; wire Net_21; wire Net_20; wire Net_18; wire Net_17; wire Net_14; wire Net_13; wire Net_12; wire Net_11; wire Net_9; wire Net_8; wire Net_6; wire Net_5; wire Net_4; wire Net_3; wire Net_2; wire Net_1; wire Net_58; wire Net_57; wire Net_55; wire Net_54; wire Net_43; wire Net_42; wire Net_40; wire Net_39; wire Net_83; wire Net_81; wire Net_80; wire Net_66; wire Net_19; wire Net_16; wire Net_22; wire Net_10; SPI_Master_v2_40_6 SPI0 ( .mosi(Net_10), .sclk(Net_22), .ss(Net_1), .miso(Net_16), .clock(Net_19), .reset(Net_2), .rx_interrupt(Net_3), .sdat(Net_4), .tx_interrupt(Net_5)); defparam SPI0.BidirectMode = 0; defparam SPI0.HighSpeedMode = 1; defparam SPI0.NumberOfDataBits = 8; defparam SPI0.ShiftDir = 0; wire [0:0] tmpOE__mosi0_net; wire [0:0] tmpFB_0__mosi0_net; wire [0:0] tmpIO_0__mosi0_net; wire [0:0] tmpINTERRUPT_0__mosi0_net; electrical [0:0] tmpSIOVREF__mosi0_net; cy_psoc3_pins_v1_10 #(.id("62946763-63ac-47e7-8754-b206ba7765cc/ed092b9b-d398-4703-be89-cebf998501f6"), .drive_mode(3'b110), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b1), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) mosi0 (.oe(tmpOE__mosi0_net), .y({Net_10}), .fb({tmpFB_0__mosi0_net[0:0]}), .io({tmpIO_0__mosi0_net[0:0]}), .siovref(tmpSIOVREF__mosi0_net), .interrupt({tmpINTERRUPT_0__mosi0_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__mosi0_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; cy_clock_v1_0 #(.id("62946763-63ac-47e7-8754-b206ba7765cc/5ed615c6-e1f0-40ed-8816-f906ef67d531"), .source_clock_id("61737EF6-3B74-48f9-8B91-F7473A442AE7"), .divisor(1), .period("0"), .is_direct(0), .is_digital(1)) Clock_1 (.clock_out(Net_19)); wire [0:0] tmpOE__miso0_net; wire [0:0] tmpIO_0__miso0_net; wire [0:0] tmpINTERRUPT_0__miso0_net; electrical [0:0] tmpSIOVREF__miso0_net; cy_psoc3_pins_v1_10 #(.id("62946763-63ac-47e7-8754-b206ba7765cc/1425177d-0d0e-4468-8bcc-e638e5509a9b"), .drive_mode(3'b001), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b0), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("I"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) miso0 (.oe(tmpOE__miso0_net), .y({1'b0}), .fb({Net_16}), .io({tmpIO_0__miso0_net[0:0]}), .siovref(tmpSIOVREF__miso0_net), .interrupt({tmpINTERRUPT_0__miso0_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__miso0_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; ZeroTerminal ZeroTerminal_1 ( .z(Net_2)); wire [0:0] tmpOE__sclk0_net; wire [0:0] tmpFB_0__sclk0_net; wire [0:0] tmpIO_0__sclk0_net; wire [0:0] tmpINTERRUPT_0__sclk0_net; electrical [0:0] tmpSIOVREF__sclk0_net; cy_psoc3_pins_v1_10 #(.id("62946763-63ac-47e7-8754-b206ba7765cc/ae249072-87dc-41aa-9405-888517aefa28"), .drive_mode(3'b110), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b1), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) sclk0 (.oe(tmpOE__sclk0_net), .y({Net_22}), .fb({tmpFB_0__sclk0_net[0:0]}), .io({tmpIO_0__sclk0_net[0:0]}), .siovref(tmpSIOVREF__sclk0_net), .interrupt({tmpINTERRUPT_0__sclk0_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__sclk0_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; wire [0:0] tmpOE__SPI0_CS_net; wire [0:0] tmpFB_0__SPI0_CS_net; wire [0:0] tmpIO_0__SPI0_CS_net; wire [0:0] tmpINTERRUPT_0__SPI0_CS_net; electrical [0:0] tmpSIOVREF__SPI0_CS_net; cy_psoc3_pins_v1_10 #(.id("62946763-63ac-47e7-8754-b206ba7765cc/6df85302-e45f-45fb-97de-4bdf3128e07b"), .drive_mode(3'b110), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) SPI0_CS (.oe(tmpOE__SPI0_CS_net), .y({1'b0}), .fb({tmpFB_0__SPI0_CS_net[0:0]}), .io({tmpIO_0__SPI0_CS_net[0:0]}), .siovref(tmpSIOVREF__SPI0_CS_net), .interrupt({tmpINTERRUPT_0__SPI0_CS_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__SPI0_CS_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; endmodule
module I2C_v3_30_8 ( sda_o, scl_o, sda_i, scl_i, iclk, bclk, reset, clock, scl, sda, itclk); output sda_o; output scl_o; input sda_i; input scl_i; output iclk; output bclk; input reset; input clock; inout scl; inout sda; output itclk; wire sda_x_wire; wire sda_yfb; wire udb_clk; wire Net_975; wire Net_974; wire Net_973; wire bus_clk; wire Net_972; wire Net_968; wire scl_yfb; wire Net_969; wire Net_971; wire Net_970; wire timeout_clk; wire Net_697; wire Net_1045; wire [1:0] Net_1109; wire [5:0] Net_643; wire scl_x_wire; // Vmux_sda_out (cy_virtualmux_v1_0) assign sda_x_wire = Net_643[4]; cy_isr_v1_0 #(.int_type(2'b00)) I2C_IRQ (.int_signal(Net_697)); // Vmux_interrupt (cy_virtualmux_v1_0) assign Net_697 = Net_643[5]; cy_clock_v1_0 #(.id("6f2d57bd-b6d0-4115-93da-ded3485bf4ed/be0a0e37-ad17-42ca-b5a1-1a654d736358"), .source_clock_id(""), .divisor(0), .period("625000000"), .is_direct(0), .is_digital(1)) IntClock (.clock_out(Net_970)); bI2C_v3_30 bI2C_UDB ( .clock(udb_clk), .scl_in(Net_1109[0]), .sda_in(Net_1109[1]), .sda_out(Net_643[4]), .scl_out(Net_643[3]), .interrupt(Net_643[5]), .reset(reset)); defparam bI2C_UDB.Mode = 2; // Vmux_scl_out (cy_virtualmux_v1_0) assign scl_x_wire = Net_643[3]; OneTerminal OneTerminal_1 ( .o(Net_969)); OneTerminal OneTerminal_2 ( .o(Net_968)); // Vmux_clock (cy_virtualmux_v1_0) assign udb_clk = Net_970; assign bclk = bus_clk | Net_973; ZeroTerminal ZeroTerminal_1 ( .z(Net_973)); assign iclk = udb_clk | Net_974; ZeroTerminal ZeroTerminal_2 ( .z(Net_974)); // Vmux_scl_in (cy_virtualmux_v1_0) assign Net_1109[0] = scl_yfb; // Vmux_sda_in (cy_virtualmux_v1_0) assign Net_1109[1] = sda_yfb; wire [0:0] tmpOE__Bufoe_scl_net; cy_bufoe Bufoe_scl (.x(scl_x_wire), .y(scl), .oe(tmpOE__Bufoe_scl_net), .yfb(scl_yfb)); assign tmpOE__Bufoe_scl_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{Net_969} : {Net_969}; wire [0:0] tmpOE__Bufoe_sda_net; cy_bufoe Bufoe_sda (.x(sda_x_wire), .y(sda), .oe(tmpOE__Bufoe_sda_net), .yfb(sda_yfb)); assign tmpOE__Bufoe_sda_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{Net_968} : {Net_968}; // Vmux_timeout_clock (cy_virtualmux_v1_0) assign timeout_clk = udb_clk; assign itclk = timeout_clk | Net_975; ZeroTerminal ZeroTerminal_3 ( .z(Net_975)); assign scl_o = scl_x_wire; assign sda_o = sda_x_wire; endmodule
module top ; wire Net_147; wire Net_146; wire Net_145; wire Net_144; wire Net_143; wire Net_142; wire Net_141; wire Net_140; wire Net_139; wire Net_129; wire Net_128; wire Net_113; wire Net_112; wire Net_111; wire Net_110; wire Net_109; wire Net_44; wire Net_108; wire Net_107; wire Net_106; wire Net_105; wire Net_104; wire Net_103; wire Net_66; wire Net_65; wire Net_64; wire Net_63; wire Net_62; wire Net_61; wire Net_60; wire Net_59; wire Net_58; wire Net_57; wire Net_56; wire Net_97; wire Net_7; wire Net_35; UART_v2_30_0 UART_SoilMoisture_Decagon ( .cts_n(1'b0), .tx(Net_57), .rts_n(Net_58), .tx_en(Net_59), .clock(1'b0), .reset(1'b0), .rx(Net_7), .tx_interrupt(Net_62), .rx_interrupt(Net_35), .tx_data(Net_63), .tx_clk(Net_64), .rx_data(Net_65), .rx_clk(Net_66)); defparam UART_SoilMoisture_Decagon.Address1 = 0; defparam UART_SoilMoisture_Decagon.Address2 = 0; defparam UART_SoilMoisture_Decagon.EnIntRXInterrupt = 0; defparam UART_SoilMoisture_Decagon.EnIntTXInterrupt = 0; defparam UART_SoilMoisture_Decagon.FlowControl = 0; defparam UART_SoilMoisture_Decagon.HalfDuplexEn = 0; defparam UART_SoilMoisture_Decagon.HwTXEnSignal = 1; defparam UART_SoilMoisture_Decagon.NumDataBits = 8; defparam UART_SoilMoisture_Decagon.NumStopBits = 1; defparam UART_SoilMoisture_Decagon.ParityType = 0; defparam UART_SoilMoisture_Decagon.RXEnable = 1; defparam UART_SoilMoisture_Decagon.TXEnable = 0; wire [0:0] tmpOE__Rx_SoilMoisture_Decagon_net; wire [0:0] tmpIO_0__Rx_SoilMoisture_Decagon_net; wire [0:0] tmpINTERRUPT_0__Rx_SoilMoisture_Decagon_net; electrical [0:0] tmpSIOVREF__Rx_SoilMoisture_Decagon_net; cy_psoc3_pins_v1_10 #(.id("1425177d-0d0e-4468-8bcc-e638e5509a9b"), .drive_mode(3'b001), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("I"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) Rx_SoilMoisture_Decagon (.oe(tmpOE__Rx_SoilMoisture_Decagon_net), .y({1'b0}), .fb({Net_7}), .io({tmpIO_0__Rx_SoilMoisture_Decagon_net[0:0]}), .siovref(tmpSIOVREF__Rx_SoilMoisture_Decagon_net), .interrupt({tmpINTERRUPT_0__Rx_SoilMoisture_Decagon_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__Rx_SoilMoisture_Decagon_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; UART_v2_30_1 UART_Ultrasonic_Maxbotix ( .cts_n(1'b0), .tx(Net_104), .rts_n(Net_105), .tx_en(Net_106), .clock(1'b0), .reset(1'b0), .rx(Net_44), .tx_interrupt(Net_109), .rx_interrupt(Net_97), .tx_data(Net_110), .tx_clk(Net_111), .rx_data(Net_112), .rx_clk(Net_113)); defparam UART_Ultrasonic_Maxbotix.Address1 = 0; defparam UART_Ultrasonic_Maxbotix.Address2 = 0; defparam UART_Ultrasonic_Maxbotix.EnIntRXInterrupt = 0; defparam UART_Ultrasonic_Maxbotix.EnIntTXInterrupt = 0; defparam UART_Ultrasonic_Maxbotix.FlowControl = 0; defparam UART_Ultrasonic_Maxbotix.HalfDuplexEn = 0; defparam UART_Ultrasonic_Maxbotix.HwTXEnSignal = 1; defparam UART_Ultrasonic_Maxbotix.NumDataBits = 8; defparam UART_Ultrasonic_Maxbotix.NumStopBits = 1; defparam UART_Ultrasonic_Maxbotix.ParityType = 0; defparam UART_Ultrasonic_Maxbotix.RXEnable = 1; defparam UART_Ultrasonic_Maxbotix.TXEnable = 0; wire [0:0] tmpOE__Rx_Depth_Maxbotix_net; wire [0:0] tmpIO_0__Rx_Depth_Maxbotix_net; wire [0:0] tmpINTERRUPT_0__Rx_Depth_Maxbotix_net; electrical [0:0] tmpSIOVREF__Rx_Depth_Maxbotix_net; cy_psoc3_pins_v1_10 #(.id("3e017343-901d-4f28-862c-3c6b5cdd94b9"), .drive_mode(3'b001), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("I"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) Rx_Depth_Maxbotix (.oe(tmpOE__Rx_Depth_Maxbotix_net), .y({1'b0}), .fb({Net_44}), .io({tmpIO_0__Rx_Depth_Maxbotix_net[0:0]}), .siovref(tmpSIOVREF__Rx_Depth_Maxbotix_net), .interrupt({tmpINTERRUPT_0__Rx_Depth_Maxbotix_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__Rx_Depth_Maxbotix_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; cy_isr_v1_0 #(.int_type(2'b10)) isr_Ultrasonic_Maxbotix (.int_signal(Net_97)); wire [0:0] tmpOE__Decagon_Sensor_Power_net; wire [0:0] tmpFB_0__Decagon_Sensor_Power_net; wire [0:0] tmpIO_0__Decagon_Sensor_Power_net; wire [0:0] tmpINTERRUPT_0__Decagon_Sensor_Power_net; electrical [0:0] tmpSIOVREF__Decagon_Sensor_Power_net; cy_psoc3_pins_v1_10 #(.id("3dba336a-f6a5-43fb-aed3-de1e0b7bf362"), .drive_mode(3'b110), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) Decagon_Sensor_Power (.oe(tmpOE__Decagon_Sensor_Power_net), .y({1'b0}), .fb({tmpFB_0__Decagon_Sensor_Power_net[0:0]}), .io({tmpIO_0__Decagon_Sensor_Power_net[0:0]}), .siovref(tmpSIOVREF__Decagon_Sensor_Power_net), .interrupt({tmpINTERRUPT_0__Decagon_Sensor_Power_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__Decagon_Sensor_Power_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; cy_isr_v1_0 #(.int_type(2'b10)) isr_SoilMoisture_Decagon (.int_signal(Net_35)); NEOMOTE_5 NEOMOTE_1 (); emFile_v1_20_7 emFile_1 (); wire [0:0] tmpOE__SDA_1_net; wire [0:0] tmpFB_0__SDA_1_net; wire [0:0] tmpINTERRUPT_0__SDA_1_net; electrical [0:0] tmpSIOVREF__SDA_1_net; cy_psoc3_pins_v1_10 #(.id("22863ebe-a37b-476f-b252-6e49a8c00b12"), .drive_mode(3'b100), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("B"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) SDA_1 (.oe(tmpOE__SDA_1_net), .y({1'b0}), .fb({tmpFB_0__SDA_1_net[0:0]}), .io({Net_128}), .siovref(tmpSIOVREF__SDA_1_net), .interrupt({tmpINTERRUPT_0__SDA_1_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__SDA_1_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; wire [0:0] tmpOE__SCL_1_net; wire [0:0] tmpFB_0__SCL_1_net; wire [0:0] tmpINTERRUPT_0__SCL_1_net; electrical [0:0] tmpSIOVREF__SCL_1_net; cy_psoc3_pins_v1_10 #(.id("02f2cf2c-2c7a-49df-9246-7a3435c21be3"), .drive_mode(3'b100), .ibuf_enabled(1'b1), .init_dr_st(1'b1), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("B"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b00), .width(1)) SCL_1 (.oe(tmpOE__SCL_1_net), .y({1'b0}), .fb({tmpFB_0__SCL_1_net[0:0]}), .io({Net_129}), .siovref(tmpSIOVREF__SCL_1_net), .interrupt({tmpINTERRUPT_0__SCL_1_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__SCL_1_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; I2C_v3_30_8 I2C_1 ( .sda(Net_128), .scl(Net_129), .clock(1'b0), .reset(1'b0), .bclk(Net_141), .iclk(Net_142), .scl_i(1'b0), .sda_i(1'b0), .scl_o(Net_145), .sda_o(Net_146), .itclk(Net_147)); wire [0:0] tmpOE__Digital_Sensor_Power_net; wire [0:0] tmpFB_0__Digital_Sensor_Power_net; wire [0:0] tmpIO_0__Digital_Sensor_Power_net; wire [0:0] tmpINTERRUPT_0__Digital_Sensor_Power_net; electrical [0:0] tmpSIOVREF__Digital_Sensor_Power_net; cy_psoc3_pins_v1_10 #(.id("b4d82f45-d2ff-4880-ba26-f4781b7e5d27"), .drive_mode(3'b010), .ibuf_enabled(1'b1), .init_dr_st(1'b0), .input_clk_en(0), .input_sync(1'b1), .input_sync_mode(1'b0), .intr_mode(2'b00), .invert_in_clock(0), .invert_in_clock_en(0), .invert_in_reset(0), .invert_out_clock(0), .invert_out_clock_en(0), .invert_out_reset(0), .io_voltage(""), .layout_mode("CONTIGUOUS"), .oe_conn(1'b0), .oe_reset(0), .oe_sync(1'b0), .output_clk_en(0), .output_clock_mode(1'b0), .output_conn(1'b0), .output_mode(1'b0), .output_reset(0), .output_sync(1'b0), .pa_in_clock(-1), .pa_in_clock_en(-1), .pa_in_reset(-1), .pa_out_clock(-1), .pa_out_clock_en(-1), .pa_out_reset(-1), .pin_aliases(""), .pin_mode("O"), .por_state(4), .sio_group_cnt(0), .sio_hyst(1'b0), .sio_ibuf(""), .sio_info(2'b00), .sio_obuf(""), .sio_refsel(""), .sio_vtrip(""), .slew_rate(1'b0), .spanning(0), .use_annotation(1'b0), .vtrip(2'b10), .width(1)) Digital_Sensor_Power (.oe(tmpOE__Digital_Sensor_Power_net), .y({1'b0}), .fb({tmpFB_0__Digital_Sensor_Power_net[0:0]}), .io({tmpIO_0__Digital_Sensor_Power_net[0:0]}), .siovref(tmpSIOVREF__Digital_Sensor_Power_net), .interrupt({tmpINTERRUPT_0__Digital_Sensor_Power_net[0:0]}), .in_clock({1'b0}), .in_clock_en({1'b1}), .in_reset({1'b0}), .out_clock({1'b0}), .out_clock_en({1'b1}), .out_reset({1'b0})); assign tmpOE__Digital_Sensor_Power_net = (`CYDEV_CHIP_MEMBER_USED == `CYDEV_CHIP_MEMBER_3A && `CYDEV_CHIP_REVISION_USED < `CYDEV_CHIP_REVISION_3A_ES3) ? ~{1'b1} : {1'b1}; endmodule
module Test_Line ( address, clock, q); input [0:0] address; input clock; output [7:0] q; wire [7:0] sub_wire0; wire [7:0] q = sub_wire0[7:0]; altsyncram altsyncram_component ( .clock0 (clock), .address_a (address), .q_a (sub_wire0), .aclr0 (1'b0), .aclr1 (1'b0), .address_b (1'b1), .addressstall_a (1'b0), .addressstall_b (1'b0), .byteena_a (1'b1), .byteena_b (1'b1), .clock1 (1'b1), .clocken0 (1'b1), .clocken1 (1'b1), .clocken2 (1'b1), .clocken3 (1'b1), .data_a ({8{1'b1}}), .data_b (1'b1), .eccstatus (), .q_b (), .rden_a (1'b1), .rden_b (1'b1), .wren_a (1'b0), .wren_b (1'b0)); defparam altsyncram_component.address_aclr_a = "NONE", altsyncram_component.clock_enable_input_a = "BYPASS", altsyncram_component.clock_enable_output_a = "BYPASS", altsyncram_component.init_file = "Test_Line.mif", altsyncram_component.intended_device_family = "Cyclone III", altsyncram_component.lpm_hint = "ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=line", altsyncram_component.lpm_type = "altsyncram", altsyncram_component.numwords_a = 1, altsyncram_component.operation_mode = "ROM", altsyncram_component.outdata_aclr_a = "NONE", altsyncram_component.outdata_reg_a = "CLOCK0", altsyncram_component.widthad_a = 1, altsyncram_component.width_a = 8, altsyncram_component.width_byteena_a = 1; endmodule
module sha256_w_mem( input wire clk, input wire reset_n, input wire [511 : 0] block, input wire init, input wire next, output wire [31 : 0] w ); //---------------------------------------------------------------- // Internal constant and parameter definitions. //---------------------------------------------------------------- parameter CTRL_IDLE = 0; parameter CTRL_UPDATE = 1; //---------------------------------------------------------------- // Registers including update variables and write enable. //---------------------------------------------------------------- reg [31 : 0] w_mem [0 : 15]; reg [31 : 0] w_mem00_new; reg [31 : 0] w_mem01_new; reg [31 : 0] w_mem02_new; reg [31 : 0] w_mem03_new; reg [31 : 0] w_mem04_new; reg [31 : 0] w_mem05_new; reg [31 : 0] w_mem06_new; reg [31 : 0] w_mem07_new; reg [31 : 0] w_mem08_new; reg [31 : 0] w_mem09_new; reg [31 : 0] w_mem10_new; reg [31 : 0] w_mem11_new; reg [31 : 0] w_mem12_new; reg [31 : 0] w_mem13_new; reg [31 : 0] w_mem14_new; reg [31 : 0] w_mem15_new; reg w_mem_we; reg [5 : 0] w_ctr_reg; reg [5 : 0] w_ctr_new; reg w_ctr_we; reg w_ctr_inc; reg w_ctr_rst; reg [1 : 0] sha256_w_mem_ctrl_reg; reg [1 : 0] sha256_w_mem_ctrl_new; reg sha256_w_mem_ctrl_we; //---------------------------------------------------------------- // Wires. //---------------------------------------------------------------- reg [31 : 0] w_tmp; reg [31 : 0] w_new; //---------------------------------------------------------------- // Concurrent connectivity for ports etc. //---------------------------------------------------------------- assign w = w_tmp; //---------------------------------------------------------------- // reg_update // Update functionality for all registers in the core. // All registers are positive edge triggered with synchronous // active low reset. All registers have write enable. //---------------------------------------------------------------- always @ (posedge clk or negedge reset_n) begin : reg_update if (!reset_n) begin w_mem[00] <= 32'h0; w_mem[01] <= 32'h0; w_mem[02] <= 32'h0; w_mem[03] <= 32'h0; w_mem[04] <= 32'h0; w_mem[05] <= 32'h0; w_mem[06] <= 32'h0; w_mem[07] <= 32'h0; w_mem[08] <= 32'h0; w_mem[09] <= 32'h0; w_mem[10] <= 32'h0; w_mem[11] <= 32'h0; w_mem[12] <= 32'h0; w_mem[13] <= 32'h0; w_mem[14] <= 32'h0; w_mem[15] <= 32'h0; w_ctr_reg <= 6'h00; sha256_w_mem_ctrl_reg <= CTRL_IDLE; end else begin if (w_mem_we) begin w_mem[00] <= w_mem00_new; w_mem[01] <= w_mem01_new; w_mem[02] <= w_mem02_new; w_mem[03] <= w_mem03_new; w_mem[04] <= w_mem04_new; w_mem[05] <= w_mem05_new; w_mem[06] <= w_mem06_new; w_mem[07] <= w_mem07_new; w_mem[08] <= w_mem08_new; w_mem[09] <= w_mem09_new; w_mem[10] <= w_mem10_new; w_mem[11] <= w_mem11_new; w_mem[12] <= w_mem12_new; w_mem[13] <= w_mem13_new; w_mem[14] <= w_mem14_new; w_mem[15] <= w_mem15_new; end if (w_ctr_we) w_ctr_reg <= w_ctr_new; if (sha256_w_mem_ctrl_we) sha256_w_mem_ctrl_reg <= sha256_w_mem_ctrl_new; end end // reg_update //---------------------------------------------------------------- // select_w // // Mux for the external read operation. This is where we exract // the W variable. //---------------------------------------------------------------- always @* begin : select_w if (w_ctr_reg < 16) begin w_tmp = w_mem[w_ctr_reg[3 : 0]]; end else begin w_tmp = w_new; end end // select_w //---------------------------------------------------------------- // w_new_logic // // Logic that calculates the next value to be inserted into // the sliding window of the memory. //---------------------------------------------------------------- always @* begin : w_mem_update_logic reg [31 : 0] w_0; reg [31 : 0] w_1; reg [31 : 0] w_9; reg [31 : 0] w_14; reg [31 : 0] d0; reg [31 : 0] d1; w_mem00_new = 32'h0; w_mem01_new = 32'h0; w_mem02_new = 32'h0; w_mem03_new = 32'h0; w_mem04_new = 32'h0; w_mem05_new = 32'h0; w_mem06_new = 32'h0; w_mem07_new = 32'h0; w_mem08_new = 32'h0; w_mem09_new = 32'h0; w_mem10_new = 32'h0; w_mem11_new = 32'h0; w_mem12_new = 32'h0; w_mem13_new = 32'h0; w_mem14_new = 32'h0; w_mem15_new = 32'h0; w_mem_we = 0; w_0 = w_mem[0]; w_1 = w_mem[1]; w_9 = w_mem[9]; w_14 = w_mem[14]; d0 = {w_1[6 : 0], w_1[31 : 7]} ^ {w_1[17 : 0], w_1[31 : 18]} ^ {3'b000, w_1[31 : 3]}; d1 = {w_14[16 : 0], w_14[31 : 17]} ^ {w_14[18 : 0], w_14[31 : 19]} ^ {10'b0000000000, w_14[31 : 10]}; w_new = d1 + w_9 + d0 + w_0; if (init) begin w_mem00_new = block[511 : 480]; w_mem01_new = block[479 : 448]; w_mem02_new = block[447 : 416]; w_mem03_new = block[415 : 384]; w_mem04_new = block[383 : 352]; w_mem05_new = block[351 : 320]; w_mem06_new = block[319 : 288]; w_mem07_new = block[287 : 256]; w_mem08_new = block[255 : 224]; w_mem09_new = block[223 : 192]; w_mem10_new = block[191 : 160]; w_mem11_new = block[159 : 128]; w_mem12_new = block[127 : 96]; w_mem13_new = block[95 : 64]; w_mem14_new = block[63 : 32]; w_mem15_new = block[31 : 0]; w_mem_we = 1; end else if (w_ctr_reg > 15) begin w_mem00_new = w_mem[01]; w_mem01_new = w_mem[02]; w_mem02_new = w_mem[03]; w_mem03_new = w_mem[04]; w_mem04_new = w_mem[05]; w_mem05_new = w_mem[06]; w_mem06_new = w_mem[07]; w_mem07_new = w_mem[08]; w_mem08_new = w_mem[09]; w_mem09_new = w_mem[10]; w_mem10_new = w_mem[11]; w_mem11_new = w_mem[12]; w_mem12_new = w_mem[13]; w_mem13_new = w_mem[14]; w_mem14_new = w_mem[15]; w_mem15_new = w_new; w_mem_we = 1; end end // w_mem_update_logic //---------------------------------------------------------------- // w_ctr // W schedule adress counter. Counts from 0x10 to 0x3f and // is used to expand the block into words. //---------------------------------------------------------------- always @* begin : w_ctr w_ctr_new = 0; w_ctr_we = 0; if (w_ctr_rst) begin w_ctr_new = 6'h00; w_ctr_we = 1; end if (w_ctr_inc) begin w_ctr_new = w_ctr_reg + 6'h01; w_ctr_we = 1; end end // w_ctr //---------------------------------------------------------------- // sha256_w_mem_fsm // Logic for the w shedule FSM. //---------------------------------------------------------------- always @* begin : sha256_w_mem_fsm w_ctr_rst = 0; w_ctr_inc = 0; sha256_w_mem_ctrl_new = CTRL_IDLE; sha256_w_mem_ctrl_we = 0; case (sha256_w_mem_ctrl_reg) CTRL_IDLE: begin if (init) begin w_ctr_rst = 1; sha256_w_mem_ctrl_new = CTRL_UPDATE; sha256_w_mem_ctrl_we = 1; end end CTRL_UPDATE: begin if (next) begin w_ctr_inc = 1; end if (w_ctr_reg == 6'h3f) begin sha256_w_mem_ctrl_new = CTRL_IDLE; sha256_w_mem_ctrl_we = 1; end end endcase // case (sha256_ctrl_reg) end // sha256_ctrl_fsm endmodule
module FIFO_pixelq_op_img_rows_V_channel_shiftReg ( clk, data, ce, a, q); parameter DATA_WIDTH = 32'd12; parameter ADDR_WIDTH = 32'd2; parameter DEPTH = 32'd3; input clk; input [DATA_WIDTH-1:0] data; input ce; input [ADDR_WIDTH-1:0] a; output [DATA_WIDTH-1:0] q; reg[DATA_WIDTH-1:0] SRL_SIG [0:DEPTH-1]; integer i; always @ (posedge clk) begin if (ce) begin for (i=0;i<DEPTH-1;i=i+1) SRL_SIG[i+1] <= SRL_SIG[i]; SRL_SIG[0] <= data; end end assign q = SRL_SIG[a]; endmodule
module FIFO_pixelq_op_img_rows_V_channel ( clk, reset, if_empty_n, if_read_ce, if_read, if_dout, if_full_n, if_write_ce, if_write, if_din); parameter MEM_STYLE = "shiftreg"; parameter DATA_WIDTH = 32'd12; parameter ADDR_WIDTH = 32'd2; parameter DEPTH = 32'd3; input clk; input reset; output if_empty_n; input if_read_ce; input if_read; output[DATA_WIDTH - 1:0] if_dout; output if_full_n; input if_write_ce; input if_write; input[DATA_WIDTH - 1:0] if_din; wire[ADDR_WIDTH - 1:0] shiftReg_addr ; wire[DATA_WIDTH - 1:0] shiftReg_data, shiftReg_q; reg[ADDR_WIDTH:0] mOutPtr = {(ADDR_WIDTH+1){1'b1}}; reg internal_empty_n = 0, internal_full_n = 1; assign if_empty_n = internal_empty_n; assign if_full_n = internal_full_n; assign shiftReg_data = if_din; assign if_dout = shiftReg_q; always @ (posedge clk) begin if (reset == 1'b1) begin mOutPtr <= ~{ADDR_WIDTH+1{1'b0}}; internal_empty_n <= 1'b0; internal_full_n <= 1'b1; end else begin if (((if_read & if_read_ce) == 1 & internal_empty_n == 1) && ((if_write & if_write_ce) == 0 | internal_full_n == 0)) begin mOutPtr <= mOutPtr -1; if (mOutPtr == 0) internal_empty_n <= 1'b0; internal_full_n <= 1'b1; end else if (((if_read & if_read_ce) == 0 | internal_empty_n == 0) && ((if_write & if_write_ce) == 1 & internal_full_n == 1)) begin mOutPtr <= mOutPtr +1; internal_empty_n <= 1'b1; if (mOutPtr == DEPTH-2) internal_full_n <= 1'b0; end end end assign shiftReg_addr = mOutPtr[ADDR_WIDTH] == 1'b0 ? mOutPtr[ADDR_WIDTH-1:0]:{ADDR_WIDTH{1'b0}}; assign shiftReg_ce = (if_write & if_write_ce) & internal_full_n; FIFO_pixelq_op_img_rows_V_channel_shiftReg #( .DATA_WIDTH(DATA_WIDTH), .ADDR_WIDTH(ADDR_WIDTH), .DEPTH(DEPTH)) U_FIFO_pixelq_op_img_rows_V_channel_ram ( .clk(clk), .data(shiftReg_data), .ce(shiftReg_ce), .a(shiftReg_addr), .q(shiftReg_q)); endmodule
module processing_system7_bfm_v2_0_intr_wr_mem( sw_clk, rstn, full, WR_DATA_ACK_OCM, WR_DATA_ACK_DDR, WR_ADDR, WR_DATA, WR_BYTES, WR_QOS, WR_DATA_VALID_OCM, WR_DATA_VALID_DDR ); `include "processing_system7_bfm_v2_0_local_params.v" /* local parameters for interconnect wr fifo model */ input sw_clk, rstn; output full; input WR_DATA_ACK_DDR, WR_DATA_ACK_OCM; output reg WR_DATA_VALID_DDR, WR_DATA_VALID_OCM; output reg [max_burst_bits-1:0] WR_DATA; output reg [addr_width-1:0] WR_ADDR; output reg [max_burst_bytes_width:0] WR_BYTES; output reg [axi_qos_width-1:0] WR_QOS; reg [intr_cnt_width-1:0] wr_ptr = 0, rd_ptr = 0; reg [wr_fifo_data_bits-1:0] wr_fifo [0:intr_max_outstanding-1]; wire empty; assign empty = (wr_ptr === rd_ptr)?1'b1: 1'b0; assign full = ((wr_ptr[intr_cnt_width-1]!== rd_ptr[intr_cnt_width-1]) && (wr_ptr[intr_cnt_width-2:0] === rd_ptr[intr_cnt_width-2:0]))?1'b1 :1'b0; parameter SEND_DATA = 0, WAIT_ACK = 1; reg state; task automatic write_mem; input [wr_fifo_data_bits-1:0] data; begin wr_fifo[wr_ptr[intr_cnt_width-2:0]] = data; if(wr_ptr[intr_cnt_width-2:0] === intr_max_outstanding-1) wr_ptr[intr_cnt_width-2:0] = 0; else wr_ptr = wr_ptr + 1; end endtask always@(negedge rstn or posedge sw_clk) begin if(!rstn) begin wr_ptr = 0; rd_ptr = 0; WR_DATA_VALID_DDR = 1'b0; WR_DATA_VALID_OCM = 1'b0; WR_QOS = 0; state = SEND_DATA; end else begin case(state) SEND_DATA :begin state = SEND_DATA; WR_DATA_VALID_OCM = 1'b0; WR_DATA_VALID_DDR = 1'b0; if(!empty) begin WR_DATA = wr_fifo[rd_ptr[intr_cnt_width-2:0]][wr_data_msb : wr_data_lsb]; WR_ADDR = wr_fifo[rd_ptr[intr_cnt_width-2:0]][wr_addr_msb : wr_addr_lsb]; WR_BYTES = wr_fifo[rd_ptr[intr_cnt_width-2:0]][wr_bytes_msb : wr_bytes_lsb]; WR_QOS = wr_fifo[rd_ptr[intr_cnt_width-2:0]][wr_qos_msb : wr_qos_lsb]; state = WAIT_ACK; case(decode_address(wr_fifo[rd_ptr[intr_cnt_width-2:0]][wr_addr_msb : wr_addr_lsb])) OCM_MEM : WR_DATA_VALID_OCM = 1; DDR_MEM : WR_DATA_VALID_DDR = 1; default : state = SEND_DATA; endcase if(rd_ptr[intr_cnt_width-2:0] === intr_max_outstanding-1) begin rd_ptr[intr_cnt_width-2:0] = 0; end else begin rd_ptr = rd_ptr+1; end end end WAIT_ACK :begin state = WAIT_ACK; if(WR_DATA_ACK_OCM | WR_DATA_ACK_DDR) begin WR_DATA_VALID_OCM = 1'b0; WR_DATA_VALID_DDR = 1'b0; state = SEND_DATA; end end endcase end end endmodule
module jt10_adpcm_drvB( input rst_n, input clk, input cen, // 8MHz cen input cen55, // clk & cen55 = 55 kHz // Control input acmd_on_b, // Control - Process start, Key On input acmd_rep_b, // Control - Repeat input acmd_rst_b, // Control - Reset input acmd_up_b, // Control - New command received input [ 1:0] alr_b, // Left / Right input [15:0] astart_b, // Start address input [15:0] aend_b, // End address input [15:0] adeltan_b, // Delta-N input [ 7:0] aeg_b, // Envelope Generator Control output flag, input clr_flag, // memory output [23:0] addr, input [ 7:0] data, output reg roe_n, output reg signed [15:0] pcm55_l, output reg signed [15:0] pcm55_r ); wire nibble_sel; wire adv; // advance to next reading wire restart; wire chon; // `ifdef SIMULATION // real fsample; // always @(posedge acmd_on_b) begin // fsample = adeltan_b; // fsample = fsample/65536; // fsample = fsample * 55.5; // $display("\nINFO: ADPCM-B ON: %X delta N = %6d (%2.1f kHz)", astart_b, adeltan_b, fsample ); // end // `endif always @(posedge clk) roe_n <= ~(adv & cen55); jt10_adpcmb_cnt u_cnt( .rst_n ( rst_n ), .clk ( clk ), .cen ( cen55 ), .delta_n ( adeltan_b ), .acmd_up_b ( acmd_up_b ), .clr ( acmd_rst_b ), .on ( acmd_on_b ), .astart ( astart_b ), .aend ( aend_b ), .arepeat ( acmd_rep_b ), .addr ( addr ), .nibble_sel ( nibble_sel ), // Flag control .chon ( chon ), .clr_flag ( clr_flag ), .flag ( flag ), .restart ( restart ), .adv ( adv ) ); reg [3:0] din; always @(posedge clk) din <= !nibble_sel ? data[7:4] : data[3:0]; wire signed [15:0] pcmdec, pcminter, pcmgain; jt10_adpcmb u_decoder( .rst_n ( rst_n ), .clk ( clk ), .cen ( cen ), .adv ( adv & cen55 ), .data ( din ), .chon ( chon ), .clr ( flag | restart ), .pcm ( pcmdec ) ); `ifndef NOBINTERPOL jt10_adpcmb_interpol u_interpol( .rst_n ( rst_n ), .clk ( clk ), .cen ( cen ), .cen55 ( cen55 && chon ), .adv ( adv ), .pcmdec ( pcmdec ), .pcmout ( pcminter ) ); `else assign pcminter = pcmdec; `endif jt10_adpcmb_gain u_gain( .rst_n ( rst_n ), .clk ( clk ), .cen55 ( cen55 ), .tl ( aeg_b ), .pcm_in ( pcminter ), .pcm_out( pcmgain ) ); always @(posedge clk) if(cen55) begin pcm55_l <= alr_b[1] ? pcmgain : 16'd0; pcm55_r <= alr_b[0] ? pcmgain : 16'd0; end endmodule
module IntegerDivision( input [63:0] Dividend, input [31:0] Divisor, output[63:0] quotient, output[31:0] remainder, input start, input clk ); reg [8:0] count; reg [96:0] tmp; reg oldStart; wire [33:0] nDivisor; wire [33:0] pDivisor; wire [63:0] result; wire [33:0] addend; initial begin count <= 129; tmp <= 0; end assign pDivisor[33] = 0, pDivisor[32] = 0, pDivisor[31:0] = Divisor; assign nDivisor = -pDivisor; assign addend = {34{tmp[96]}} & pDivisor | {34{!tmp[96]}} & nDivisor; AdderAndSubber64 adder({30'b0,tmp[96:63]},{30'b0,addend},1'b0,result,SF,CF,OF,PF,ZF); always @(posedge clk) begin if (count <= 128) begin if (count < 127) begin if (count[0]) begin tmp[96:1] <= tmp[95:0]; tmp[0] <= ~tmp[96]; end else begin tmp[96:63] <= result[33:0]; end end else if ( count == 127 ) begin if ( tmp[96] ) begin tmp[95:63] <= result[32:0]; end end else if ( count == 128 ) begin tmp[96:1] <= tmp[95:0]; tmp[0] <= ~tmp[96]; end count <= count + 1; end else if ( count > 128 && (start != oldStart)) begin tmp[63:0] <= Dividend; tmp[96:64] <= 0; count <= 0; end else begin tmp <= tmp; count <= 129; end oldStart <= start; end assign quotient = tmp[63:0]; assign remainder = tmp[95:64]; endmodule
module ddr3_s4_uniphy_example_if0_p0_write_datapath( pll_afi_clk, reset_n, force_oct_off, phy_ddio_oct_ena, afi_dqs_en, afi_wdata, afi_wdata_valid, afi_dm, phy_ddio_dq, phy_ddio_dqs_en, phy_ddio_wrdata_en, phy_ddio_wrdata_mask ); parameter MEM_ADDRESS_WIDTH = ""; parameter MEM_DM_WIDTH = ""; parameter MEM_CONTROL_WIDTH = ""; parameter MEM_DQ_WIDTH = ""; parameter MEM_READ_DQS_WIDTH = ""; parameter MEM_WRITE_DQS_WIDTH = ""; parameter AFI_ADDRESS_WIDTH = ""; parameter AFI_DATA_MASK_WIDTH = ""; parameter AFI_CONTROL_WIDTH = ""; parameter AFI_DATA_WIDTH = ""; parameter AFI_DQS_WIDTH = ""; parameter NUM_WRITE_PATH_FLOP_STAGES = ""; input pll_afi_clk; input reset_n; input [AFI_DQS_WIDTH-1:0] force_oct_off; output [AFI_DQS_WIDTH-1:0] phy_ddio_oct_ena; input [AFI_DQS_WIDTH-1:0] afi_dqs_en; input [AFI_DATA_WIDTH-1:0] afi_wdata; input [AFI_DQS_WIDTH-1:0] afi_wdata_valid; input [AFI_DATA_MASK_WIDTH-1:0] afi_dm; output [AFI_DATA_WIDTH-1:0] phy_ddio_dq; output [AFI_DQS_WIDTH-1:0] phy_ddio_dqs_en; output [AFI_DQS_WIDTH-1:0] phy_ddio_wrdata_en; output [AFI_DATA_MASK_WIDTH-1:0] phy_ddio_wrdata_mask; wire [AFI_DQS_WIDTH-1:0] phy_ddio_dqs_en_pre_shift; wire [AFI_DATA_WIDTH-1:0] phy_ddio_dq_pre_shift; wire [AFI_DQS_WIDTH-1:0] phy_ddio_wrdata_en_pre_shift; wire [AFI_DATA_MASK_WIDTH-1:0] phy_ddio_wrdata_mask_pre_shift; generate genvar stage; if (NUM_WRITE_PATH_FLOP_STAGES == 0) begin assign phy_ddio_dq_pre_shift = afi_wdata; assign phy_ddio_dqs_en_pre_shift = afi_dqs_en; assign phy_ddio_wrdata_en_pre_shift = afi_wdata_valid; assign phy_ddio_wrdata_mask_pre_shift = afi_dm; end else begin reg [AFI_DATA_WIDTH-1:0] afi_wdata_r [NUM_WRITE_PATH_FLOP_STAGES-1:0]; reg [AFI_DQS_WIDTH-1:0] afi_wdata_valid_r [NUM_WRITE_PATH_FLOP_STAGES-1:0] /* synthesis dont_merge */; reg [AFI_DQS_WIDTH-1:0] afi_dqs_en_r [NUM_WRITE_PATH_FLOP_STAGES-1:0]; // phy_ddio_wrdata_mask is tied low during calibration // the purpose of the assignment is to avoid Quartus from connecting the signal to the sclr pin of the flop // sclr pin is very slow and causes timing failures (* altera_attribute = {"-name ALLOW_SYNCH_CTRL_USAGE OFF"}*) reg [AFI_DATA_MASK_WIDTH-1:0] afi_dm_r [NUM_WRITE_PATH_FLOP_STAGES-1:0]; always @(posedge pll_afi_clk) begin afi_wdata_r[0] <= afi_wdata; afi_dqs_en_r[0] <= afi_dqs_en; afi_wdata_valid_r[0] <= afi_wdata_valid; afi_dm_r[0] <= afi_dm; end for (stage = 1; stage < NUM_WRITE_PATH_FLOP_STAGES; stage = stage + 1) begin : stage_gen always @(posedge pll_afi_clk) begin afi_wdata_r[stage] <= afi_wdata_r[stage-1]; afi_dqs_en_r[stage] <= afi_dqs_en_r[stage-1]; afi_wdata_valid_r[stage] <= afi_wdata_valid_r[stage-1]; afi_dm_r[stage] <= afi_dm_r[stage-1]; end end assign phy_ddio_dq_pre_shift = afi_wdata_r[NUM_WRITE_PATH_FLOP_STAGES-1]; assign phy_ddio_dqs_en_pre_shift = afi_dqs_en_r[NUM_WRITE_PATH_FLOP_STAGES-1]; assign phy_ddio_wrdata_en_pre_shift = afi_wdata_valid_r[NUM_WRITE_PATH_FLOP_STAGES-1]; assign phy_ddio_wrdata_mask_pre_shift = afi_dm_r[NUM_WRITE_PATH_FLOP_STAGES-1]; end endgenerate wire [AFI_DQS_WIDTH-1:0] oct_ena; reg [MEM_WRITE_DQS_WIDTH-1:0] dqs_en_reg; always @(posedge pll_afi_clk) dqs_en_reg <= phy_ddio_dqs_en[AFI_DQS_WIDTH-1:MEM_WRITE_DQS_WIDTH]; assign oct_ena[AFI_DQS_WIDTH-1:MEM_WRITE_DQS_WIDTH] = ~phy_ddio_dqs_en[AFI_DQS_WIDTH-1:MEM_WRITE_DQS_WIDTH]; assign oct_ena[MEM_WRITE_DQS_WIDTH-1:0] = ~(phy_ddio_dqs_en[AFI_DQS_WIDTH-1:MEM_WRITE_DQS_WIDTH] | dqs_en_reg); assign phy_ddio_oct_ena_pre_shift = oct_ena & ~force_oct_off; assign phy_ddio_dq = phy_ddio_dq_pre_shift; assign phy_ddio_wrdata_mask = phy_ddio_wrdata_mask_pre_shift; assign phy_ddio_wrdata_en = phy_ddio_wrdata_en_pre_shift; assign phy_ddio_dqs_en = phy_ddio_dqs_en_pre_shift; assign phy_ddio_oct_ena = phy_ddio_oct_ena_pre_shift; endmodule
module sky130_fd_sc_hdll__sdfxtp_2 ( Q , CLK , D , SCD , SCE , VPWR, VGND, VPB , VNB ); output Q ; input CLK ; input D ; input SCD ; input SCE ; input VPWR; input VGND; input VPB ; input VNB ; sky130_fd_sc_hdll__sdfxtp base ( .Q(Q), .CLK(CLK), .D(D), .SCD(SCD), .SCE(SCE), .VPWR(VPWR), .VGND(VGND), .VPB(VPB), .VNB(VNB) ); endmodule
module sky130_fd_sc_hdll__sdfxtp_2 ( Q , CLK, D , SCD, SCE ); output Q ; input CLK; input D ; input SCD; input SCE; // Voltage supply signals supply1 VPWR; supply0 VGND; supply1 VPB ; supply0 VNB ; sky130_fd_sc_hdll__sdfxtp base ( .Q(Q), .CLK(CLK), .D(D), .SCD(SCD), .SCE(SCE) ); endmodule
module utim64( //System input wire iIF_CLOCK, //Global Clock input wire iTIMER_CLOCK, input wire inRESET, //Counter input wire iREQ_VALID, output wire oREQ_BUSY, input wire iREQ_RW, input wire [3:0] iREQ_ADDR, input wire [31:0] iREQ_DATA, output wire oREQ_VALID, output wire [31:0] oREQ_DATA, //Interrupt output wire [3:0] oIRQ_IRQ ); wire req_fifo_full; wire req_fifo_empty; wire req_fifo_rw; wire [31:0] req_fifo_data; wire [3:0] req_fifo_addr; wire req_fifo_read_condition; mist1032sa_async_fifo #(37, 4, 2) FIFO_REQ( //System .inRESET(inRESET), //Remove .iREMOVE(1'b0), //WR .iWR_CLOCK(iIF_CLOCK), .iWR_EN(iREQ_VALID), .iWR_DATA({iREQ_RW, iREQ_ADDR, iREQ_DATA}), .oWR_FULL(req_fifo_full), //RD .iRD_CLOCK(iTIMER_CLOCK), .iRD_EN(req_fifo_read_condition), .oRD_DATA({req_fifo_rw, req_fifo_addr, req_fifo_data}), .oRD_EMPTY(req_fifo_empty) ); wire write_condition = req_fifo_read_condition && req_fifo_rw; wire read_condition = req_fifo_read_condition && !req_fifo_rw; //Configlation Table integer i; reg [31:0] b_config_register_list[0:14]; always@(posedge iTIMER_CLOCK or negedge inRESET)begin if(!inRESET)begin for(i = 0; i < 15; i = i + 1)begin b_config_register_list [i] <= 32'h0; end end else begin if(write_condition)begin b_config_register_list [req_fifo_addr] <= req_fifo_data; end end end //Main Counter wire main_config_write_cc = (req_fifo_addr == `UTIM6XAMCFGR)? write_condition : 1'b0; wire main_counter_low_write_cc = (req_fifo_addr == `UTIM6XAMCR31_0)? write_condition : 1'b0; wire main_counter_high_write_cc = (req_fifo_addr == `UTIM6XAMCR63_32)? write_condition : 1'b0; wire [63:0] main_counter_write_data = (main_counter_high_write_cc)? {req_fifo_data, 32'h0} : {32'h0, req_fifo_data}; wire main_counter_working; wire [63:0] main_counter; main_counter MAIN_COUNTER( .iCLOCK(iTIMER_CLOCK), .inRESET(inRESET), .iCONF_WRITE(main_config_write_cc), .iCONF_ENA(req_fifo_data[0]), .iCOUNT_WRITE(main_counter_high_write_cc || main_counter_low_write_cc), .inCOUNT_DQM({!main_counter_high_write_cc, !main_counter_low_write_cc}), .iCOUNT_COUNTER(main_counter_write_data), .oWORKING(main_counter_working), .oCOUNTER(main_counter) ); //Comparator0 wire compare0_config_write_cc = (req_fifo_addr == `UTIM64XACC0CFRG)? write_condition : 1'b0; wire compare0_counter_low_write_cc = (req_fifo_addr == `UTIM64XACC0R31_0)? write_condition : 1'b0; wire compare0_counter_high_write_cc = (req_fifo_addr == `UTIM64XACC0R63_32)? write_condition : 1'b0; wire [63:0] compare0_counter_write_data = (compare0_counter_high_write_cc)? {req_fifo_data, 32'h0} : {32'h0, req_fifo_data};//64'h00000000_000071af; wire compare0_irq; comparator_counter COMPARATOR0( .iCLOCK(iTIMER_CLOCK), .inRESET(inRESET), .iMTIMER_WORKING(main_counter_working), .iMTIMER_COUNT(main_counter), .iCONF_WRITE(compare0_config_write_cc), .iCONF_ENA(req_fifo_data[0]), .iCONF_IRQENA(req_fifo_data[1]), .iCONF_64MODE(req_fifo_data[2]), .iCONF_PERIODIC(req_fifo_data[3]), .iCOUNT_WRITE(compare0_counter_high_write_cc || compare0_counter_low_write_cc), .inCOUNT_DQM({!compare0_counter_high_write_cc, !compare0_counter_low_write_cc}), .iCOUNT_COUNTER(compare0_counter_write_data), .oIRQ(compare0_irq) ); //Comparator1 wire compare1_config_write_cc = (req_fifo_addr == `UTIM64XACC1CFRG)? write_condition : 1'b0; wire compare1_counter_low_write_cc = (req_fifo_addr == `UTIM64XACC1R31_0)? write_condition : 1'b0; wire compare1_counter_high_write_cc = (req_fifo_addr == `UTIM64XACC1R63_32)? write_condition : 1'b0; wire [63:0] compare1_counter_write_data = (compare1_counter_high_write_cc)? {req_fifo_data, 32'h0} : {32'h0, req_fifo_data}; wire compare1_irq; comparator_counter COMPARATOR1( .iCLOCK(iTIMER_CLOCK), .inRESET(inRESET), .iMTIMER_WORKING(main_counter_working), .iMTIMER_COUNT(main_counter), .iCONF_WRITE(compare1_config_write_cc), .iCONF_ENA(req_fifo_data[0]), .iCONF_IRQENA(req_fifo_data[1]), .iCONF_64MODE(req_fifo_data[2]), .iCONF_PERIODIC(req_fifo_data[3]), .iCOUNT_WRITE(compare1_counter_high_write_cc || compare1_counter_low_write_cc), .inCOUNT_DQM({!compare1_counter_high_write_cc, !compare1_counter_low_write_cc}), .iCOUNT_COUNTER(compare1_counter_write_data), .oIRQ(compare1_irq) ); //Comparator2 wire compare2_config_write_cc = (req_fifo_addr == `UTIM64XACC2CFRG)? write_condition : 1'b0; wire compare2_counter_low_write_cc = (req_fifo_addr == `UTIM64XACC2R31_0)? write_condition : 1'b0; wire compare2_counter_high_write_cc = (req_fifo_addr == `UTIM64XACC2R63_32)? write_condition : 1'b0; wire [63:0] compare2_counter_write_data = (compare2_counter_high_write_cc)? {req_fifo_data, 32'h0} : {32'h0, req_fifo_data}; wire compare2_irq; comparator_counter COMPARATOR2( .iCLOCK(iTIMER_CLOCK), .inRESET(inRESET), .iMTIMER_WORKING(main_counter_working), .iMTIMER_COUNT(main_counter), .iCONF_WRITE(compare2_config_write_cc), .iCONF_ENA(req_fifo_data[0]), .iCONF_IRQENA(req_fifo_data[1]), .iCONF_64MODE(req_fifo_data[2]), .iCONF_PERIODIC(req_fifo_data[3]), .iCOUNT_WRITE(compare2_counter_high_write_cc || compare2_counter_low_write_cc), .inCOUNT_DQM({!compare2_counter_high_write_cc, !compare2_counter_low_write_cc}), .iCOUNT_COUNTER(compare2_counter_write_data), .oIRQ(compare2_irq) ); //Comparator3 wire compare3_config_write_cc = (req_fifo_addr == `UTIM64XACC3CFRG)? write_condition : 1'b0; wire compare3_counter_low_write_cc = (req_fifo_addr == `UTIM64XACC3R31_0)? write_condition : 1'b0; wire compare3_counter_high_write_cc = (req_fifo_addr == `UTIM64XACC3R63_32)? write_condition : 1'b0; wire [63:0] compare3_counter_write_data = (compare3_counter_high_write_cc)? {req_fifo_data, 32'h0} : {32'h0, req_fifo_data}; wire compare3_irq; comparator_counter COMPARATOR3( .iCLOCK(iTIMER_CLOCK), .inRESET(inRESET), .iMTIMER_WORKING(main_counter_working), .iMTIMER_COUNT(main_counter), .iCONF_WRITE(compare3_config_write_cc), .iCONF_ENA(req_fifo_data[0]), .iCONF_IRQENA(req_fifo_data[1]), .iCONF_64MODE(req_fifo_data[2]), .iCONF_PERIODIC(req_fifo_data[3]), .iCOUNT_WRITE(compare3_counter_high_write_cc || compare3_counter_low_write_cc), .inCOUNT_DQM({!compare3_counter_high_write_cc, !compare3_counter_low_write_cc}), .iCOUNT_COUNTER(compare3_counter_write_data), .oIRQ(compare3_irq) ); //Output Buffer wire out_fifo_full; wire out_fifo_empty; wire [31:0] out_fifo_data; wire out_fifo_read_condition; assign out_fifo_read_condition = !out_fifo_empty; mist1032sa_async_fifo #(32, 4, 2) FIFO_OUT( //System .inRESET(inRESET), //Remove .iREMOVE(1'b0), //WR .iWR_CLOCK(iTIMER_CLOCK), .iWR_EN(req_fifo_read_condition), .iWR_DATA(b_config_register_list[req_fifo_addr]), .oWR_FULL(out_fifo_full), //RD .iRD_CLOCK(iIF_CLOCK), .iRD_EN(out_fifo_read_condition), .oRD_DATA(out_fifo_data), .oRD_EMPTY(out_fifo_empty) ); assign req_fifo_read_condition = !req_fifo_empty && (req_fifo_rw || (!req_fifo_rw && !out_fifo_full)); assign oREQ_VALID = out_fifo_read_condition; assign oREQ_DATA = out_fifo_data; assign oREQ_BUSY = req_fifo_full; assign oIRQ_IRQ = {compare3_irq, compare2_irq, compare1_irq, compare0_irq}; endmodule
module cpu_tb; integer i = 0; reg clk; cpu #(.NMEM(12)) mips1(.clk(clk)); always begin clk <= ~clk; #5; end initial begin // $dumpfile(`DUMP_FILE); // $dumpvars(0, cpu_tb); clk <= 1'b0; /* cpu will $display output when `DEBUG_CPU_STAGES is on */ // Run all the lines, plus 5 extra to finish off the pipeline. for (i = 0; i < 12 + 5; i = i + 1) begin @(posedge clk); end $finish; end endmodule
module ALU ( input [ `ALU_DATA_WIDTH-1:0] wIn , // working register in input [ `ALU_DATA_WIDTH-1:0] fIn , // general purpose register in input [ `ALU_DATA_WIDTH-1:0] lIn , // literlal in input [ `ALU_FUNC_WIDTH-1:0] funcIn , // alu function in input [ 2:0] bitSel , // bit selection in input cFlag , // carry flag in(for RRF, RLF instruction) input [`ALU_STATUS_WIDTH-1:0] statusIn , // status in output [`ALU_STATUS_WIDTH-1:0] aluStatusOut, // alu status out {zero, digit carry, carry} output [ `ALU_DATA_WIDTH-1:0] aluResultOut // alu result out ); // Arithmetic reg C3; reg carry; reg [`ALU_DATA_WIDTH-1:0] result; assign aluResultOut = result; always @(*) begin C3 = 1'b0; carry = 1'b0; case (funcIn) `ALU_ADDWF: begin // ADD W and f {C3,result[3:0]} = fIn[3:0] + wIn[3:0]; {carry,result[7:4]} = fIn [7:4] + wIn[7:4] + C3; end `ALU_SUBWF: begin // SUB w form f {C3,result[3:0]} = fIn[3:0] - wIn[3:0]; {carry,result[7:4]} = fIn[7:4] - wIn[7:4] - C3; end `ALU_ANDWF: begin // AND w with f result = wIn & fIn; end `ALU_COMF: begin // Complement f result = ~ fIn; end `ALU_DECF: begin // Decrement f result = fIn - 1'b1; end `ALU_INCF: begin // Incresement f result = fIn + 1'b1; end `ALU_IORWF: begin // Inclusive OR W with f result = fIn | wIn; end `ALU_RLF: begin // Rotate left f throngh Carry {carry, result} = {fIn[`DATA_WIDTH-1:0], cFlag}; end `ALU_RRF: begin // Rotate right f through Carry {carry, result} = {fIn[0], cFlag, fIn[`DATA_WIDTH-1:1]}; end `ALU_SWAPF: begin // Swap f result = {fIn[3:0],fIn[7:4]}; end `ALU_XORWF: begin // Exclusive OR W wtih f result = fIn ^ wIn; end `ALU_BCF: begin // Bit Clear f result = fIn & ~ (8'h01 << bitSel); end `ALU_BSF: begin // Bit Set f result = fIn | (8'h1 << bitSel); end `ALU_ANDLW: begin // AND literal with W result = wIn & lIn; end `ALU_IORLW: begin // Inclusive Or Literal in W result = lIn | wIn; end `ALU_XORLW: begin result = lIn ^ wIn; end `ALU_MOVF : begin result = fIn; end `ALU_IDLE: begin result = 8'hEF; end default: begin result = 8'hEF; end endcase end // Status Affected reg [`ALU_STATUS_WIDTH - 1:0] status; assign aluStatusOut = status; always@(*) begin case (funcIn) `ALU_ADDWF:begin status = {(result == 8'b0), 1'b0, 1'b0} | {1'b0, C3, carry}; end `ALU_SUBWF: begin status = {(result == 8'b0), 1'b0, 1'b0} | {1'b0, ~C3, ~carry}; end `ALU_RLF, `ALU_RRF: begin status = statusIn | {1'b0, 1'b0, carry}; end default: begin status = {(result == 8'b0), statusIn[1:0]}; end endcase end endmodule
module uart_baud_gen #(parameter BAUD_RATE_BITS=16) (input wire clk, input wire rst, input wire ena, input wire[BAUD_RATE_BITS-1:0] baud_rate_div, output wire out); // // Простой счётчик от 0 до top (от 0 до baud_rate_div). simple_upcounter #(BAUD_RATE_BITS) cnt_baud(.clk(clk), .rst(rst), .ena(ena), .top(baud_rate_div), .out(), .ovf(out)); // endmodule
module uart_tx (input wire clk, input wire rst, input wire ena, input wire baud_rate_clk, input wire parity_ena, input wire parity_type, input wire stop_size, input wire[7:0] data, input wire start, output wire busy, output wire tx); // // Регистры. // // Состояние. // Бит 3 - передача байта данных. // Бит 2 - общий бит. // Бит 1 - биты индекса в массиве специальных бит (передача бит старта, чётности, стопа). // Бит 0 / // 0 - IDLE. reg[3:0] state; // // Общие провода. // // Флаг работы передатчика (state != 0). wire running = |state; // Флаг передачи байта данных (state[3] == 1). wire transmit_data = state[3]; // Флаг синхронизации с генератором частоты. wire baud_clk_sync = (~state[3] & state[2] & ~state[1] & ~state[0]); // Специальные биты (idle, старт, чётность, стоп) для передачи. wire[3:0] spec_bits = {1'b1, data_parity, 1'b0, 1'b1}; // Данные младшим битом вперёд для передачи. wire[7:0] reversed_data; // // Генерация частоты передатчика. // // Сброс генератора частоты. wire baud_gen_rst = rst & running & ~baud_clk_sync; // Разрешение генератора частоты. wire baud_gen_ena = ena & running & baud_rate_clk; // Тик генератора частоты. wire baud_tick; // // Сдвиговый регистр передаваемых данных. // // Флаг загрузки данных в регистр. wire shift_reg_load = start & ~running; // Флаг разрешения сдвига регистра. wire shift_reg_ena = ena & baud_tick & transmit_data; // Выход сдвигового регистра. wire shift_reg_out; // Выход данных сдвигового регистра. wire[7:0] shift_reg_data_out; // // Чётность. // // Значение чётности данных по принципу "чётный". wire data_parity_even = ^shift_reg_data_out; // Значение чётности данных в зависимости от выбранного режима. wire data_parity = (~parity_type & data_parity_even) | (parity_type & ~data_parity_even); // // // Инициализация. // Начальное состояние - 0 (IDLE). initial begin state <= 4'b0; end // // // Реверсирование данных. genvar i; generate for(i = 0; i <= 7; i = i + 1) begin: gen_reverse assign reversed_data[i] = data[7 - i]; end endgenerate // // Выходные линии. // // Флаг занятости. assign busy = running; // Линия передачи. assign tx = (transmit_data & shift_reg_out) | (~transmit_data & spec_bits[state[1:0]]); // // // Модули. // // Сдвиговый регистр данных для передачи. shift_reg #(8) sh_reg(.clk(clk), .rst(rst), .ena(shift_reg_ena), .load(shift_reg_load), .load_data(reversed_data), .in(shift_reg_out), .out_data(shift_reg_data_out), .out(shift_reg_out)); // // Делитель входной частоты на 16. // Синхронизируется по ближайшему тику генератора частоты после старта передачи. simple_binary_upcounter #(4) baud_gen(.clk(clk), .rst(baud_gen_rst), .ena(baud_gen_ena), .out(), .ovf(baud_tick)); // // always @(posedge clk or negedge rst) begin if(!rst) begin state <= 4'b0; end else begin case (state) 4'b0000: if(start) state <= 4'b0100; // idle 4'b0100: if(baud_rate_clk) state <= 4'b0001; // Ожидание синхронизации с генератором частоты. 4'b0001: if(baud_tick) state <= 4'b1000; // Стартовый бит. 4'b1000: if(baud_tick) state <= 4'b1001; // Бит 0 4'b1001: if(baud_tick) state <= 4'b1010; // Бит 1 4'b1010: if(baud_tick) state <= 4'b1011; // Бит 2 4'b1011: if(baud_tick) state <= 4'b1100; // Бит 3 4'b1100: if(baud_tick) state <= 4'b1101; // Бит 4 4'b1101: if(baud_tick) state <= 4'b1110; // Бит 5 4'b1110: if(baud_tick) state <= 4'b1111; // Бит 6 4'b1111: if(baud_tick) begin // Бит 7 // Если разрешена передача // бита чётности. if(parity_ena) begin state <= 4'b0010; // -> Чётность. end else begin state <= 4'b0011; // -> Стоповый бит 1. end end 4'b0010: if(baud_tick) state <= 4'b0011; // Бит чётности. 4'b0011: if(baud_tick) begin // Стоповый бит 1. // Если длина стопового бита // равна двум. if(stop_size) begin state <= 4'b0111; // -> Стоповый бит 2. end else begin state <= 4'b0000; // -> idle end end 4'b0111: if(baud_tick) state <= 4'b0000; // Стоповый бит 2. default: state <= 4'b0000; // -> idle. endcase end end // endmodule
module uart_rx (input wire clk, input wire rst, input wire ena, input wire baud_rate_clk, input wire parity_ena, input wire parity_type, input wire rx, output wire[7:0] data, output wire ready, output wire parity_err, output wire frame_err); // // Регистры. // // Состояние. // Бит 3 - передача байта данных. // Бит 2 \ // Бит 1 - Общие биты. // Бит 0 / // 0 - IDLE. reg[3:0] state; // // Флаг ошибки чётности. reg parity_err_flag; // Флаг ошибки кадра. reg frame_err_flag; // // Общие провода. // // Флаг работы передатчика (state != 0). wire running = |state; // Флаг приёма байта данных (state[3] == 1). wire receive_data = state[3]; // Данные младшим битом вперёд для передачи. wire[7:0] reversed_data; // Значения линии приёма данных каждый тик генератора частоты. wire[15:0] samples; // // Чётность. // // Значение чётности данных по принципу "чётный". wire data_parity_even = ^data; // Значение чётности данных в зависимости от выбранного режима. wire data_parity = (~parity_type & data_parity_even) | (parity_type & ~data_parity_even); // // Поиск ниспадающего фронта. // // Выход мажоритарного элемента нахождения ниспадающего фронта. wire falling_edge_detect_front; // Мажоритарный элемент нахождения ниспадающего фронта. majority3 falling_edge_detect_front_maj({samples[10], samples[8], samples[6]}, falling_edge_detect_front); // Выход мажоритарного элемента нахождения центра стопового бита. wire falling_edge_detect_center; // Мажоритарный элемент нахождения центра стопового бита. majority3 falling_edge_detect_center_maj(samples[5:3], falling_edge_detect_center); // В выборке (samples) ищется последовательность 1110X|0X0X0|000. wire falling_edge = &samples[15:13] & ~samples[12] & ~falling_edge_detect_front & ~falling_edge_detect_center; // Флаг нахождения стартового бита. wire start_bit = falling_edge & ~running; // // Полученный бит. // // Выход мажоритарного элемента цента выборки - полученный бит. wire sampled_bit; // Мажоритарный элемент цента выборки - полученный бит. majority3 sampled_bit_maj(samples[8:6], sampled_bit); // // Сдвиговый регистр выборки. // // Разрешение сдвига выборки. wire samples_sh_reg_ena = ena & baud_rate_clk; // // Генератор частоты следования бит (делитель частоты генератора на 16). // // Разрешения деления частоты. wire baud_gen_ena = ena & running & baud_rate_clk; // Выход генератора частоты следования бит. wire baud_tick; // // Сдвиговый регистр получаемых данных. // // Разрешение сдвига данных. wire data_sh_reg_ena = ena & receive_data & baud_tick; // // // Инициализация. // Начальное состояние - 0 (IDLE). initial begin state <= 4'b0; parity_err_flag <= 1'b0; frame_err_flag <= 1'b0; end // // // Реверсирование данных. genvar i; generate for(i = 0; i <= 7; i = i + 1) begin: gen_reverse assign data[i] = reversed_data[7 - i]; end endgenerate // // // Выходные линии. // // Флаг доступности данных. assign ready = ~running; // Флаг ошибки чётности. assign parity_err = parity_err_flag; // Флаг ошибки кадра. assign frame_err = frame_err_flag; // // // Модули. // // Сдвиговый регистр выборки. simple_shift_reg #(16) samples_sh_reg(.clk(clk), .rst(rst), .ena(samples_sh_reg_ena), .in(rx), .out_data(samples), .out()); // // Генератор частоты следования бит (делитель на 16). // Синхронизируется по текущей позиции при получении стартового бита. binary_upcounter #(4) baud_gen(.clk(clk), .rst(rst), .ena(baud_gen_ena), .value(4'hc), .load(start_bit), .out(), .ovf(baud_tick)); // // Сдвиговй регистр бит данных. simple_shift_reg #(8) data_sh_reg(.clk(clk), .rst(rst), .ena(data_sh_reg_ena), .in(sampled_bit), .out_data(reversed_data), .out()); // // always @(posedge clk or negedge rst) begin if(!rst) begin state <= 4'b0; parity_err_flag <= 1'b0; frame_err_flag <= 1'b0; end else begin case (state) 4'b0000: if(start_bit) begin // idle parity_err_flag <= 1'b0; frame_err_flag <= 1'b0; state <= 4'b0001; // -> Стартовый бит. end 4'b0001: if(baud_tick) state <= 4'b1000; // Стартовый бит. 4'b1000: if(baud_tick) state <= 4'b1001; // Бит 0 4'b1001: if(baud_tick) state <= 4'b1010; // Бит 1 4'b1010: if(baud_tick) state <= 4'b1011; // Бит 2 4'b1011: if(baud_tick) state <= 4'b1100; // Бит 3 4'b1100: if(baud_tick) state <= 4'b1101; // Бит 4 4'b1101: if(baud_tick) state <= 4'b1110; // Бит 5 4'b1110: if(baud_tick) state <= 4'b1111; // Бит 6 4'b1111: if(baud_tick) begin // Бит 7 // Если разрешена передача // бита чётности. if(parity_ena) begin state <= 4'b0010; // -> Чётность. end else begin state <= 4'b0011; // -> Стоповый бит. end end 4'b0010: if(baud_tick) begin // Бит чётности. parity_err_flag <= parity_ena & (sampled_bit ^ data_parity); state <= 4'b0011; // -> Стоповый бит. end 4'b0011: if(baud_tick) begin // Стоповый бит. // Если принятый стоповый бит // имеет низкий логический уровень. if(~sampled_bit) begin // Установим ошибку кадра. frame_err_flag <= 1'b1; end state <= 4'b0000; // -> idle. end default: state <= 4'b0000; // -> idle. endcase end end // endmodule
module uart #(parameter F_CLK=50_000_000, parameter BAUD=9600) (input wire clk, input wire rst, input wire ena, input wire parity_ena, input wire parity_type, input wire stop_size, input wire[7:0] tx_data, input wire tx_start, output wire tx_busy, output wire tx, input wire rx, output wire[7:0] rx_data, output wire rx_ready, output wire parity_err, output wire frame_err); // // Значение делителя частоты генератора. localparam BAUD_GEN_DIV = F_CLK / (16 * BAUD) - 1; localparam BAUD_GEN_DIV_BITS = $clog2(BAUD_GEN_DIV); localparam BAUD_GEN_DIV_VAL = BAUD_GEN_DIV[BAUD_GEN_DIV_BITS-1:0]; // // Провода. // // Выход генератора частоты. wire baud_rate_clk; // // Модули. // // Генератор частоты. uart_baud_gen #(BAUD_GEN_DIV_BITS) baud_gen(.clk(clk), .rst(rst), .ena(ena), .baud_rate_div(BAUD_GEN_DIV_VAL), .out(baud_rate_clk)); // Передатчик. uart_tx transmitter (.clk(clk), .rst(rst), .ena(rst), .baud_rate_clk(baud_rate_clk), .parity_ena(parity_ena), .parity_type(parity_type), .stop_size(stop_size), .data(tx_data), .start(tx_start), .busy(tx_busy), .tx(tx)); // Приёмник. uart_rx receiver (.clk(clk), .rst(rst), .ena(ena), .baud_rate_clk(baud_rate_clk), .parity_ena(parity_ena), .parity_type(parity_type), .rx(rx), .data(rx_data), .ready(rx_ready), .parity_err(parity_err), .frame_err(frame_err)); // endmodule
module bram_2048_0 (clka, ena, wea, addra, dina, douta); (* x_interface_info = "xilinx.com:interface:bram:1.0 BRAM_PORTA CLK" *) input clka; (* x_interface_info = "xilinx.com:interface:bram:1.0 BRAM_PORTA EN" *) input ena; (* x_interface_info = "xilinx.com:interface:bram:1.0 BRAM_PORTA WE" *) input [0:0]wea; (* x_interface_info = "xilinx.com:interface:bram:1.0 BRAM_PORTA ADDR" *) input [10:0]addra; (* x_interface_info = "xilinx.com:interface:bram:1.0 BRAM_PORTA DIN" *) input [19:0]dina; (* x_interface_info = "xilinx.com:interface:bram:1.0 BRAM_PORTA DOUT" *) output [19:0]douta; wire [10:0]addra; wire clka; wire [19:0]dina; wire [19:0]douta; wire ena; wire [0:0]wea; wire NLW_U0_dbiterr_UNCONNECTED; wire NLW_U0_rsta_busy_UNCONNECTED; wire NLW_U0_rstb_busy_UNCONNECTED; wire NLW_U0_s_axi_arready_UNCONNECTED; wire NLW_U0_s_axi_awready_UNCONNECTED; wire NLW_U0_s_axi_bvalid_UNCONNECTED; wire NLW_U0_s_axi_dbiterr_UNCONNECTED; wire NLW_U0_s_axi_rlast_UNCONNECTED; wire NLW_U0_s_axi_rvalid_UNCONNECTED; wire NLW_U0_s_axi_sbiterr_UNCONNECTED; wire NLW_U0_s_axi_wready_UNCONNECTED; wire NLW_U0_sbiterr_UNCONNECTED; wire [19:0]NLW_U0_doutb_UNCONNECTED; wire [10:0]NLW_U0_rdaddrecc_UNCONNECTED; wire [3:0]NLW_U0_s_axi_bid_UNCONNECTED; wire [1:0]NLW_U0_s_axi_bresp_UNCONNECTED; wire [10:0]NLW_U0_s_axi_rdaddrecc_UNCONNECTED; wire [19:0]NLW_U0_s_axi_rdata_UNCONNECTED; wire [3:0]NLW_U0_s_axi_rid_UNCONNECTED; wire [1:0]NLW_U0_s_axi_rresp_UNCONNECTED; (* C_ADDRA_WIDTH = "11" *) (* C_ADDRB_WIDTH = "11" *) (* C_ALGORITHM = "1" *) (* C_AXI_ID_WIDTH = "4" *) (* C_AXI_SLAVE_TYPE = "0" *) (* C_AXI_TYPE = "1" *) (* C_BYTE_SIZE = "9" *) (* C_COMMON_CLK = "0" *) (* C_COUNT_18K_BRAM = "1" *) (* C_COUNT_36K_BRAM = "1" *) (* C_CTRL_ECC_ALGO = "NONE" *) (* C_DEFAULT_DATA = "0" *) (* C_DISABLE_WARN_BHV_COLL = "0" *) (* C_DISABLE_WARN_BHV_RANGE = "0" *) (* C_ELABORATION_DIR = "./" *) (* C_ENABLE_32BIT_ADDRESS = "0" *) (* C_EN_DEEPSLEEP_PIN = "0" *) (* C_EN_ECC_PIPE = "0" *) (* C_EN_RDADDRA_CHG = "0" *) (* C_EN_RDADDRB_CHG = "0" *) (* C_EN_SAFETY_CKT = "0" *) (* C_EN_SHUTDOWN_PIN = "0" *) (* C_EN_SLEEP_PIN = "0" *) (* C_EST_POWER_SUMMARY = "Estimated Power for IP : 3.9373 mW" *) (* C_FAMILY = "zynq" *) (* C_HAS_AXI_ID = "0" *) (* C_HAS_ENA = "1" *) (* C_HAS_ENB = "0" *) (* C_HAS_INJECTERR = "0" *) (* C_HAS_MEM_OUTPUT_REGS_A = "1" *) (* C_HAS_MEM_OUTPUT_REGS_B = "0" *) (* C_HAS_MUX_OUTPUT_REGS_A = "0" *) (* C_HAS_MUX_OUTPUT_REGS_B = "0" *) (* C_HAS_REGCEA = "0" *) (* C_HAS_REGCEB = "0" *) (* C_HAS_RSTA = "0" *) (* C_HAS_RSTB = "0" *) (* C_HAS_SOFTECC_INPUT_REGS_A = "0" *) (* C_HAS_SOFTECC_OUTPUT_REGS_B = "0" *) (* C_INITA_VAL = "0" *) (* C_INITB_VAL = "0" *) (* C_INIT_FILE = "bram_2048_0.mem" *) (* C_INIT_FILE_NAME = "bram_2048_0.mif" *) (* C_INTERFACE_TYPE = "0" *) (* C_LOAD_INIT_FILE = "1" *) (* C_MEM_TYPE = "0" *) (* C_MUX_PIPELINE_STAGES = "0" *) (* C_PRIM_TYPE = "1" *) (* C_READ_DEPTH_A = "2048" *) (* C_READ_DEPTH_B = "2048" *) (* C_READ_WIDTH_A = "20" *) (* C_READ_WIDTH_B = "20" *) (* C_RSTRAM_A = "0" *) (* C_RSTRAM_B = "0" *) (* C_RST_PRIORITY_A = "CE" *) (* C_RST_PRIORITY_B = "CE" *) (* C_SIM_COLLISION_CHECK = "ALL" *) (* C_USE_BRAM_BLOCK = "0" *) (* C_USE_BYTE_WEA = "0" *) (* C_USE_BYTE_WEB = "0" *) (* C_USE_DEFAULT_DATA = "0" *) (* C_USE_ECC = "0" *) (* C_USE_SOFTECC = "0" *) (* C_USE_URAM = "0" *) (* C_WEA_WIDTH = "1" *) (* C_WEB_WIDTH = "1" *) (* C_WRITE_DEPTH_A = "2048" *) (* C_WRITE_DEPTH_B = "2048" *) (* C_WRITE_MODE_A = "WRITE_FIRST" *) (* C_WRITE_MODE_B = "WRITE_FIRST" *) (* C_WRITE_WIDTH_A = "20" *) (* C_WRITE_WIDTH_B = "20" *) (* C_XDEVICEFAMILY = "zynq" *) (* downgradeipidentifiedwarnings = "yes" *) bram_2048_0_blk_mem_gen_v8_3_5 U0 (.addra(addra), .addrb({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .clka(clka), .clkb(1'b0), .dbiterr(NLW_U0_dbiterr_UNCONNECTED), .deepsleep(1'b0), .dina(dina), .dinb({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .douta(douta), .doutb(NLW_U0_doutb_UNCONNECTED[19:0]), .eccpipece(1'b0), .ena(ena), .enb(1'b0), .injectdbiterr(1'b0), .injectsbiterr(1'b0), .rdaddrecc(NLW_U0_rdaddrecc_UNCONNECTED[10:0]), .regcea(1'b0), .regceb(1'b0), .rsta(1'b0), .rsta_busy(NLW_U0_rsta_busy_UNCONNECTED), .rstb(1'b0), .rstb_busy(NLW_U0_rstb_busy_UNCONNECTED), .s_aclk(1'b0), .s_aresetn(1'b0), .s_axi_araddr({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .s_axi_arburst({1'b0,1'b0}), .s_axi_arid({1'b0,1'b0,1'b0,1'b0}), .s_axi_arlen({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .s_axi_arready(NLW_U0_s_axi_arready_UNCONNECTED), .s_axi_arsize({1'b0,1'b0,1'b0}), .s_axi_arvalid(1'b0), .s_axi_awaddr({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .s_axi_awburst({1'b0,1'b0}), .s_axi_awid({1'b0,1'b0,1'b0,1'b0}), .s_axi_awlen({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .s_axi_awready(NLW_U0_s_axi_awready_UNCONNECTED), .s_axi_awsize({1'b0,1'b0,1'b0}), .s_axi_awvalid(1'b0), .s_axi_bid(NLW_U0_s_axi_bid_UNCONNECTED[3:0]), .s_axi_bready(1'b0), .s_axi_bresp(NLW_U0_s_axi_bresp_UNCONNECTED[1:0]), .s_axi_bvalid(NLW_U0_s_axi_bvalid_UNCONNECTED), .s_axi_dbiterr(NLW_U0_s_axi_dbiterr_UNCONNECTED), .s_axi_injectdbiterr(1'b0), .s_axi_injectsbiterr(1'b0), .s_axi_rdaddrecc(NLW_U0_s_axi_rdaddrecc_UNCONNECTED[10:0]), .s_axi_rdata(NLW_U0_s_axi_rdata_UNCONNECTED[19:0]), .s_axi_rid(NLW_U0_s_axi_rid_UNCONNECTED[3:0]), .s_axi_rlast(NLW_U0_s_axi_rlast_UNCONNECTED), .s_axi_rready(1'b0), .s_axi_rresp(NLW_U0_s_axi_rresp_UNCONNECTED[1:0]), .s_axi_rvalid(NLW_U0_s_axi_rvalid_UNCONNECTED), .s_axi_sbiterr(NLW_U0_s_axi_sbiterr_UNCONNECTED), .s_axi_wdata({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .s_axi_wlast(1'b0), .s_axi_wready(NLW_U0_s_axi_wready_UNCONNECTED), .s_axi_wstrb(1'b0), .s_axi_wvalid(1'b0), .sbiterr(NLW_U0_sbiterr_UNCONNECTED), .shutdown(1'b0), .sleep(1'b0), .wea(wea), .web(1'b0)); endmodule
module bram_2048_0_blk_mem_gen_generic_cstr (douta, clka, ena, addra, dina, wea); output [19:0]douta; input clka; input ena; input [10:0]addra; input [19:0]dina; input [0:0]wea; wire [10:0]addra; wire clka; wire [19:0]dina; wire [19:0]douta; wire ena; wire [0:0]wea; bram_2048_0_blk_mem_gen_prim_width \ramloop[0].ram.r (.addra(addra), .clka(clka), .dina(dina[8:0]), .douta(douta[8:0]), .ena(ena), .wea(wea)); bram_2048_0_blk_mem_gen_prim_width__parameterized0 \ramloop[1].ram.r (.addra(addra), .clka(clka), .dina(dina[19:9]), .douta(douta[19:9]), .ena(ena), .wea(wea)); endmodule
module bram_2048_0_blk_mem_gen_prim_width (douta, clka, ena, addra, dina, wea); output [8:0]douta; input clka; input ena; input [10:0]addra; input [8:0]dina; input [0:0]wea; wire [10:0]addra; wire clka; wire [8:0]dina; wire [8:0]douta; wire ena; wire [0:0]wea; bram_2048_0_blk_mem_gen_prim_wrapper_init \prim_init.ram (.addra(addra), .clka(clka), .dina(dina), .douta(douta), .ena(ena), .wea(wea)); endmodule
module bram_2048_0_blk_mem_gen_prim_width__parameterized0 (douta, clka, ena, addra, dina, wea); output [10:0]douta; input clka; input ena; input [10:0]addra; input [10:0]dina; input [0:0]wea; wire [10:0]addra; wire clka; wire [10:0]dina; wire [10:0]douta; wire ena; wire [0:0]wea; bram_2048_0_blk_mem_gen_prim_wrapper_init__parameterized0 \prim_init.ram (.addra(addra), .clka(clka), .dina(dina), .douta(douta), .ena(ena), .wea(wea)); endmodule
module bram_2048_0_blk_mem_gen_prim_wrapper_init (douta, clka, ena, addra, dina, wea); output [8:0]douta; input clka; input ena; input [10:0]addra; input [8:0]dina; input [0:0]wea; wire [10:0]addra; wire clka; wire [8:0]dina; wire [8:0]douta; wire ena; wire [0:0]wea; wire [15:8]\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM18.ram_DOADO_UNCONNECTED ; wire [15:0]\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM18.ram_DOBDO_UNCONNECTED ; wire [1:1]\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM18.ram_DOPADOP_UNCONNECTED ; wire [1:0]\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM18.ram_DOPBDOP_UNCONNECTED ; (* CLOCK_DOMAINS = "COMMON" *) (* box_type = "PRIMITIVE" *) RAMB18E1 #( .DOA_REG(1), .DOB_REG(0), .INITP_00(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_01(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_02(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_03(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_04(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_05(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_06(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_07(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_00(256'h3F3D3B39373533312F2D2B29272523211F1D1B19171513110F0D0B0907050301), .INIT_01(256'h7F7D7B79777573716F6D6B69676563615F5D5B59575553514F4D4B4947454341), .INIT_02(256'hBFBDBBB9B7B5B3B1AFADABA9A7A5A3A19F9D9B99979593918F8D8B8987858381), .INIT_03(256'hFFFDFBF9F7F5F3F1EFEDEBE9E7E5E3E1DFDDDBD9D7D5D3D1CFCDCBC9C7C5C3C1), .INIT_04(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_05(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_06(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_07(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_08(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_09(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_10(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_11(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_12(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_13(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_14(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_15(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_16(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_17(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_18(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_19(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_20(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_21(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_22(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_23(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_24(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_25(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_26(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_27(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_28(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_29(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_30(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_31(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_32(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_33(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_34(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_35(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_36(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_37(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_38(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_39(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_A(18'h00000), .INIT_B(18'h00000), .INIT_FILE("NONE"), .IS_CLKARDCLK_INVERTED(1'b0), .IS_CLKBWRCLK_INVERTED(1'b0), .IS_ENARDEN_INVERTED(1'b0), .IS_ENBWREN_INVERTED(1'b0), .IS_RSTRAMARSTRAM_INVERTED(1'b0), .IS_RSTRAMB_INVERTED(1'b0), .IS_RSTREGARSTREG_INVERTED(1'b0), .IS_RSTREGB_INVERTED(1'b0), .RAM_MODE("TDP"), .RDADDR_COLLISION_HWCONFIG("PERFORMANCE"), .READ_WIDTH_A(9), .READ_WIDTH_B(9), .RSTREG_PRIORITY_A("REGCE"), .RSTREG_PRIORITY_B("REGCE"), .SIM_COLLISION_CHECK("ALL"), .SIM_DEVICE("7SERIES"), .SRVAL_A(18'h00000), .SRVAL_B(18'h00000), .WRITE_MODE_A("WRITE_FIRST"), .WRITE_MODE_B("WRITE_FIRST"), .WRITE_WIDTH_A(9), .WRITE_WIDTH_B(9)) \DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM18.ram (.ADDRARDADDR({addra,1'b0,1'b0,1'b0}), .ADDRBWRADDR({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .CLKARDCLK(clka), .CLKBWRCLK(clka), .DIADI({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,dina[7:0]}), .DIBDI({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .DIPADIP({1'b0,dina[8]}), .DIPBDIP({1'b0,1'b0}), .DOADO({\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM18.ram_DOADO_UNCONNECTED [15:8],douta[7:0]}), .DOBDO(\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM18.ram_DOBDO_UNCONNECTED [15:0]), .DOPADOP({\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM18.ram_DOPADOP_UNCONNECTED [1],douta[8]}), .DOPBDOP(\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM18.ram_DOPBDOP_UNCONNECTED [1:0]), .ENARDEN(ena), .ENBWREN(1'b0), .REGCEAREGCE(ena), .REGCEB(1'b0), .RSTRAMARSTRAM(1'b0), .RSTRAMB(1'b0), .RSTREGARSTREG(1'b0), .RSTREGB(1'b0), .WEA({wea,wea}), .WEBWE({1'b0,1'b0,1'b0,1'b0})); endmodule
module bram_2048_0_blk_mem_gen_prim_wrapper_init__parameterized0 (douta, clka, ena, addra, dina, wea); output [10:0]douta; input clka; input ena; input [10:0]addra; input [10:0]dina; input [0:0]wea; wire \DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_37 ; wire \DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_38 ; wire \DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_39 ; wire \DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_45 ; wire \DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_46 ; wire \DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_87 ; wire \DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_88 ; wire [10:0]addra; wire clka; wire [10:0]dina; wire [10:0]douta; wire ena; wire [0:0]wea; wire \NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_CASCADEOUTA_UNCONNECTED ; wire \NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_CASCADEOUTB_UNCONNECTED ; wire \NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_DBITERR_UNCONNECTED ; wire \NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_SBITERR_UNCONNECTED ; wire [31:16]\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_DOADO_UNCONNECTED ; wire [31:0]\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_DOBDO_UNCONNECTED ; wire [3:2]\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_DOPADOP_UNCONNECTED ; wire [3:0]\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_DOPBDOP_UNCONNECTED ; wire [7:0]\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_ECCPARITY_UNCONNECTED ; wire [8:0]\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_RDADDRECC_UNCONNECTED ; (* CLOCK_DOMAINS = "COMMON" *) (* box_type = "PRIMITIVE" *) RAMB36E1 #( .DOA_REG(1), .DOB_REG(0), .EN_ECC_READ("FALSE"), .EN_ECC_WRITE("FALSE"), .INITP_00(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_01(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_02(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_03(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_04(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_05(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_06(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_07(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_08(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_09(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_0A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_0B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_0C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_0D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_0E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INITP_0F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_00(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_01(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_02(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_03(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_04(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_05(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_06(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_07(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_08(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_09(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_0F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_10(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_11(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_12(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_13(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_14(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_15(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_16(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_17(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_18(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_19(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_1F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_20(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_21(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_22(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_23(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_24(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_25(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_26(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_27(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_28(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_29(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_2F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_30(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_31(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_32(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_33(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_34(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_35(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_36(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_37(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_38(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_39(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_3F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_40(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_41(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_42(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_43(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_44(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_45(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_46(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_47(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_48(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_49(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_4A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_4B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_4C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_4D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_4E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_4F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_50(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_51(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_52(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_53(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_54(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_55(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_56(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_57(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_58(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_59(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_5A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_5B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_5C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_5D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_5E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_5F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_60(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_61(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_62(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_63(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_64(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_65(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_66(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_67(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_68(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_69(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_6A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_6B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_6C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_6D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_6E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_6F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_70(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_71(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_72(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_73(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_74(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_75(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_76(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_77(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_78(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_79(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_7A(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_7B(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_7C(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_7D(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_7E(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_7F(256'h0000000000000000000000000000000000000000000000000000000000000000), .INIT_A(36'h000000000), .INIT_B(36'h000000000), .INIT_FILE("NONE"), .IS_CLKARDCLK_INVERTED(1'b0), .IS_CLKBWRCLK_INVERTED(1'b0), .IS_ENARDEN_INVERTED(1'b0), .IS_ENBWREN_INVERTED(1'b0), .IS_RSTRAMARSTRAM_INVERTED(1'b0), .IS_RSTRAMB_INVERTED(1'b0), .IS_RSTREGARSTREG_INVERTED(1'b0), .IS_RSTREGB_INVERTED(1'b0), .RAM_EXTENSION_A("NONE"), .RAM_EXTENSION_B("NONE"), .RAM_MODE("TDP"), .RDADDR_COLLISION_HWCONFIG("PERFORMANCE"), .READ_WIDTH_A(18), .READ_WIDTH_B(18), .RSTREG_PRIORITY_A("REGCE"), .RSTREG_PRIORITY_B("REGCE"), .SIM_COLLISION_CHECK("ALL"), .SIM_DEVICE("7SERIES"), .SRVAL_A(36'h000000000), .SRVAL_B(36'h000000000), .WRITE_MODE_A("WRITE_FIRST"), .WRITE_MODE_B("WRITE_FIRST"), .WRITE_WIDTH_A(18), .WRITE_WIDTH_B(18)) \DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram (.ADDRARDADDR({1'b1,addra,1'b1,1'b1,1'b1,1'b1}), .ADDRBWRADDR({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .CASCADEINA(1'b0), .CASCADEINB(1'b0), .CASCADEOUTA(\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_CASCADEOUTA_UNCONNECTED ), .CASCADEOUTB(\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_CASCADEOUTB_UNCONNECTED ), .CLKARDCLK(clka), .CLKBWRCLK(clka), .DBITERR(\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_DBITERR_UNCONNECTED ), .DIADI({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,dina[10:6],1'b0,1'b0,dina[5:0]}), .DIBDI({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0}), .DIPADIP({1'b0,1'b0,1'b0,1'b0}), .DIPBDIP({1'b0,1'b0,1'b0,1'b0}), .DOADO({\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_DOADO_UNCONNECTED [31:16],\DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_37 ,\DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_38 ,\DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_39 ,douta[10:6],\DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_45 ,\DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_46 ,douta[5:0]}), .DOBDO(\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_DOBDO_UNCONNECTED [31:0]), .DOPADOP({\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_DOPADOP_UNCONNECTED [3:2],\DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_87 ,\DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_n_88 }), .DOPBDOP(\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_DOPBDOP_UNCONNECTED [3:0]), .ECCPARITY(\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_ECCPARITY_UNCONNECTED [7:0]), .ENARDEN(ena), .ENBWREN(1'b0), .INJECTDBITERR(1'b0), .INJECTSBITERR(1'b0), .RDADDRECC(\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_RDADDRECC_UNCONNECTED [8:0]), .REGCEAREGCE(ena), .REGCEB(1'b0), .RSTRAMARSTRAM(1'b0), .RSTRAMB(1'b0), .RSTREGARSTREG(1'b0), .RSTREGB(1'b0), .SBITERR(\NLW_DEVICE_7SERIES.NO_BMM_INFO.SP.SIMPLE_PRIM36.ram_SBITERR_UNCONNECTED ), .WEA({wea,wea,wea,wea}), .WEBWE({1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0,1'b0})); endmodule
module bram_2048_0_blk_mem_gen_top (douta, clka, ena, addra, dina, wea); output [19:0]douta; input clka; input ena; input [10:0]addra; input [19:0]dina; input [0:0]wea; wire [10:0]addra; wire clka; wire [19:0]dina; wire [19:0]douta; wire ena; wire [0:0]wea; bram_2048_0_blk_mem_gen_generic_cstr \valid.cstr (.addra(addra), .clka(clka), .dina(dina), .douta(douta), .ena(ena), .wea(wea)); endmodule
module bram_2048_0_blk_mem_gen_v8_3_5 (clka, rsta, ena, regcea, wea, addra, dina, douta, clkb, rstb, enb, regceb, web, addrb, dinb, doutb, injectsbiterr, injectdbiterr, eccpipece, sbiterr, dbiterr, rdaddrecc, sleep, deepsleep, shutdown, rsta_busy, rstb_busy, s_aclk, s_aresetn, s_axi_awid, s_axi_awaddr, s_axi_awlen, s_axi_awsize, s_axi_awburst, s_axi_awvalid, s_axi_awready, s_axi_wdata, s_axi_wstrb, s_axi_wlast, s_axi_wvalid, s_axi_wready, s_axi_bid, s_axi_bresp, s_axi_bvalid, s_axi_bready, s_axi_arid, s_axi_araddr, s_axi_arlen, s_axi_arsize, s_axi_arburst, s_axi_arvalid, s_axi_arready, s_axi_rid, s_axi_rdata, s_axi_rresp, s_axi_rlast, s_axi_rvalid, s_axi_rready, s_axi_injectsbiterr, s_axi_injectdbiterr, s_axi_sbiterr, s_axi_dbiterr, s_axi_rdaddrecc); input clka; input rsta; input ena; input regcea; input [0:0]wea; input [10:0]addra; input [19:0]dina; output [19:0]douta; input clkb; input rstb; input enb; input regceb; input [0:0]web; input [10:0]addrb; input [19:0]dinb; output [19:0]doutb; input injectsbiterr; input injectdbiterr; input eccpipece; output sbiterr; output dbiterr; output [10:0]rdaddrecc; input sleep; input deepsleep; input shutdown; output rsta_busy; output rstb_busy; input s_aclk; input s_aresetn; input [3:0]s_axi_awid; input [31:0]s_axi_awaddr; input [7:0]s_axi_awlen; input [2:0]s_axi_awsize; input [1:0]s_axi_awburst; input s_axi_awvalid; output s_axi_awready; input [19:0]s_axi_wdata; input [0:0]s_axi_wstrb; input s_axi_wlast; input s_axi_wvalid; output s_axi_wready; output [3:0]s_axi_bid; output [1:0]s_axi_bresp; output s_axi_bvalid; input s_axi_bready; input [3:0]s_axi_arid; input [31:0]s_axi_araddr; input [7:0]s_axi_arlen; input [2:0]s_axi_arsize; input [1:0]s_axi_arburst; input s_axi_arvalid; output s_axi_arready; output [3:0]s_axi_rid; output [19:0]s_axi_rdata; output [1:0]s_axi_rresp; output s_axi_rlast; output s_axi_rvalid; input s_axi_rready; input s_axi_injectsbiterr; input s_axi_injectdbiterr; output s_axi_sbiterr; output s_axi_dbiterr; output [10:0]s_axi_rdaddrecc; wire \<const0> ; wire [10:0]addra; wire clka; wire [19:0]dina; wire [19:0]douta; wire ena; wire [0:0]wea; assign dbiterr = \<const0> ; assign doutb[19] = \<const0> ; assign doutb[18] = \<const0> ; assign doutb[17] = \<const0> ; assign doutb[16] = \<const0> ; assign doutb[15] = \<const0> ; assign doutb[14] = \<const0> ; assign doutb[13] = \<const0> ; assign doutb[12] = \<const0> ; assign doutb[11] = \<const0> ; assign doutb[10] = \<const0> ; assign doutb[9] = \<const0> ; assign doutb[8] = \<const0> ; assign doutb[7] = \<const0> ; assign doutb[6] = \<const0> ; assign doutb[5] = \<const0> ; assign doutb[4] = \<const0> ; assign doutb[3] = \<const0> ; assign doutb[2] = \<const0> ; assign doutb[1] = \<const0> ; assign doutb[0] = \<const0> ; assign rdaddrecc[10] = \<const0> ; assign rdaddrecc[9] = \<const0> ; assign rdaddrecc[8] = \<const0> ; assign rdaddrecc[7] = \<const0> ; assign rdaddrecc[6] = \<const0> ; assign rdaddrecc[5] = \<const0> ; assign rdaddrecc[4] = \<const0> ; assign rdaddrecc[3] = \<const0> ; assign rdaddrecc[2] = \<const0> ; assign rdaddrecc[1] = \<const0> ; assign rdaddrecc[0] = \<const0> ; assign rsta_busy = \<const0> ; assign rstb_busy = \<const0> ; assign s_axi_arready = \<const0> ; assign s_axi_awready = \<const0> ; assign s_axi_bid[3] = \<const0> ; assign s_axi_bid[2] = \<const0> ; assign s_axi_bid[1] = \<const0> ; assign s_axi_bid[0] = \<const0> ; assign s_axi_bresp[1] = \<const0> ; assign s_axi_bresp[0] = \<const0> ; assign s_axi_bvalid = \<const0> ; assign s_axi_dbiterr = \<const0> ; assign s_axi_rdaddrecc[10] = \<const0> ; assign s_axi_rdaddrecc[9] = \<const0> ; assign s_axi_rdaddrecc[8] = \<const0> ; assign s_axi_rdaddrecc[7] = \<const0> ; assign s_axi_rdaddrecc[6] = \<const0> ; assign s_axi_rdaddrecc[5] = \<const0> ; assign s_axi_rdaddrecc[4] = \<const0> ; assign s_axi_rdaddrecc[3] = \<const0> ; assign s_axi_rdaddrecc[2] = \<const0> ; assign s_axi_rdaddrecc[1] = \<const0> ; assign s_axi_rdaddrecc[0] = \<const0> ; assign s_axi_rdata[19] = \<const0> ; assign s_axi_rdata[18] = \<const0> ; assign s_axi_rdata[17] = \<const0> ; assign s_axi_rdata[16] = \<const0> ; assign s_axi_rdata[15] = \<const0> ; assign s_axi_rdata[14] = \<const0> ; assign s_axi_rdata[13] = \<const0> ; assign s_axi_rdata[12] = \<const0> ; assign s_axi_rdata[11] = \<const0> ; assign s_axi_rdata[10] = \<const0> ; assign s_axi_rdata[9] = \<const0> ; assign s_axi_rdata[8] = \<const0> ; assign s_axi_rdata[7] = \<const0> ; assign s_axi_rdata[6] = \<const0> ; assign s_axi_rdata[5] = \<const0> ; assign s_axi_rdata[4] = \<const0> ; assign s_axi_rdata[3] = \<const0> ; assign s_axi_rdata[2] = \<const0> ; assign s_axi_rdata[1] = \<const0> ; assign s_axi_rdata[0] = \<const0> ; assign s_axi_rid[3] = \<const0> ; assign s_axi_rid[2] = \<const0> ; assign s_axi_rid[1] = \<const0> ; assign s_axi_rid[0] = \<const0> ; assign s_axi_rlast = \<const0> ; assign s_axi_rresp[1] = \<const0> ; assign s_axi_rresp[0] = \<const0> ; assign s_axi_rvalid = \<const0> ; assign s_axi_sbiterr = \<const0> ; assign s_axi_wready = \<const0> ; assign sbiterr = \<const0> ; GND GND (.G(\<const0> )); bram_2048_0_blk_mem_gen_v8_3_5_synth inst_blk_mem_gen (.addra(addra), .clka(clka), .dina(dina), .douta(douta), .ena(ena), .wea(wea)); endmodule
module bram_2048_0_blk_mem_gen_v8_3_5_synth (douta, clka, ena, addra, dina, wea); output [19:0]douta; input clka; input ena; input [10:0]addra; input [19:0]dina; input [0:0]wea; wire [10:0]addra; wire clka; wire [19:0]dina; wire [19:0]douta; wire ena; wire [0:0]wea; bram_2048_0_blk_mem_gen_top \gnbram.gnativebmg.native_blk_mem_gen (.addra(addra), .clka(clka), .dina(dina), .douta(douta), .ena(ena), .wea(wea)); endmodule
module glbl (); parameter ROC_WIDTH = 100000; parameter TOC_WIDTH = 0; //-------- STARTUP Globals -------------- wire GSR; wire GTS; wire GWE; wire PRLD; tri1 p_up_tmp; tri (weak1, strong0) PLL_LOCKG = p_up_tmp; wire PROGB_GLBL; wire CCLKO_GLBL; wire FCSBO_GLBL; wire [3:0] DO_GLBL; wire [3:0] DI_GLBL; reg GSR_int; reg GTS_int; reg PRLD_int; //-------- JTAG Globals -------------- wire JTAG_TDO_GLBL; wire JTAG_TCK_GLBL; wire JTAG_TDI_GLBL; wire JTAG_TMS_GLBL; wire JTAG_TRST_GLBL; reg JTAG_CAPTURE_GLBL; reg JTAG_RESET_GLBL; reg JTAG_SHIFT_GLBL; reg JTAG_UPDATE_GLBL; reg JTAG_RUNTEST_GLBL; reg JTAG_SEL1_GLBL = 0; reg JTAG_SEL2_GLBL = 0 ; reg JTAG_SEL3_GLBL = 0; reg JTAG_SEL4_GLBL = 0; reg JTAG_USER_TDO1_GLBL = 1'bz; reg JTAG_USER_TDO2_GLBL = 1'bz; reg JTAG_USER_TDO3_GLBL = 1'bz; reg JTAG_USER_TDO4_GLBL = 1'bz; assign (weak1, weak0) GSR = GSR_int; assign (weak1, weak0) GTS = GTS_int; assign (weak1, weak0) PRLD = PRLD_int; initial begin GSR_int = 1'b1; PRLD_int = 1'b1; #(ROC_WIDTH) GSR_int = 1'b0; PRLD_int = 1'b0; end initial begin GTS_int = 1'b1; #(TOC_WIDTH) GTS_int = 1'b0; end endmodule
module clk_wiz_1(clk_in1, clk_out1) /* synthesis syn_black_box black_box_pad_pin="clk_in1,clk_out1" */; input clk_in1; output clk_out1; endmodule
module sky130_fd_sc_hd__tap (); // Voltage supply signals supply1 VPWR; supply0 VGND; supply1 VPB ; supply0 VNB ; endmodule
module acl_mem2x #( parameter DEPTH_WORDS=1, parameter WIDTH=32, parameter RDW_MODE="DONT_CARE", parameter RAM_OPERATION_MODE = "BIDIR_DUAL_PORT", // altsyncram's OPERATION_MODE parameter parameter RAM_BLOCK_TYPE = "AUTO", // altsyncram's RAM_BLOCK_TYPE parameter parameter INTENDED_DEVICE_FAMILY = "Stratix IV", // altsyncram's INTENDED_DEVICE_FAMILY parameter parameter ENABLED = 0, //use enable inputs parameter PREFERRED_WIDTH = 160 ) ( input clk, input clk2x, input resetn, input avs_port1_enable, input avs_port2_enable, input avs_port3_enable, input avs_port4_enable, input [WIDTH-1:0] avs_port1_writedata, input [WIDTH-1:0] avs_port2_writedata, input [WIDTH-1:0] avs_port3_writedata, input [WIDTH-1:0] avs_port4_writedata, input [WIDTH/8-1:0] avs_port1_byteenable, input [WIDTH/8-1:0] avs_port2_byteenable, input [WIDTH/8-1:0] avs_port3_byteenable, input [WIDTH/8-1:0] avs_port4_byteenable, input [$clog2(DEPTH_WORDS)-1:0] avs_port1_address, input [$clog2(DEPTH_WORDS)-1:0] avs_port2_address, input [$clog2(DEPTH_WORDS)-1:0] avs_port3_address, input [$clog2(DEPTH_WORDS)-1:0] avs_port4_address, input avs_port1_read, input avs_port2_read, input avs_port3_read, input avs_port4_read, input avs_port1_write, input avs_port2_write, input avs_port3_write, input avs_port4_write, output reg [WIDTH-1:0] avs_port1_readdata, output reg [WIDTH-1:0] avs_port2_readdata, output reg [WIDTH-1:0] avs_port3_readdata, output reg [WIDTH-1:0] avs_port4_readdata, output avs_port1_readdatavalid, output avs_port2_readdatavalid, output avs_port3_readdatavalid, output avs_port4_readdatavalid, output avs_port1_waitrequest, output avs_port2_waitrequest, output avs_port3_waitrequest, output avs_port4_waitrequest ); localparam LOG2DEPTH = $clog2( DEPTH_WORDS ); assign avs_port1_waitrequest=1'b0; assign avs_port2_waitrequest=1'b0; assign avs_port3_waitrequest=1'b0; assign avs_port4_waitrequest=1'b0; wire port1_enable; wire port2_enable; wire port3_enable; wire port4_enable; generate if (ENABLED) begin assign port1_enable = avs_port1_enable; assign port2_enable = avs_port2_enable; assign port3_enable = avs_port3_enable; assign port4_enable = avs_port4_enable; end else begin assign port1_enable = 1'b1; assign port2_enable = 1'b1; assign port3_enable = 1'b1; assign port4_enable = 1'b1; end endgenerate wire [WIDTH-1:0] data_out_a_mem; wire [WIDTH-1:0] data_out_b_mem; wire [WIDTH-1:0] data_out_a_unreg; wire [WIDTH-1:0] data_out_b_unreg; reg [WIDTH-1:0] data_out_a_reg; reg [WIDTH-1:0] data_out_b_reg; reg [WIDTH-1:0] data_out_a_reg2; reg [WIDTH-1:0] data_out_b_reg2; _acl_mem2x_shiftreg readatavalid_1(.D(avs_port1_read), .clock(clk), .resetn(resetn), .enable(port1_enable), .Q(avs_port1_readdatavalid)); defparam readatavalid_1.WIDTH = 1; defparam readatavalid_1.DEPTH = 4; _acl_mem2x_shiftreg readatavalid_2(.D(avs_port2_read), .clock(clk), .resetn(resetn), .enable(port2_enable), .Q(avs_port2_readdatavalid)); defparam readatavalid_2.WIDTH = 1; defparam readatavalid_2.DEPTH = 4; _acl_mem2x_shiftreg readatavalid_3(.D(avs_port3_read), .clock(clk), .resetn(resetn), .enable(port3_enable), .Q(avs_port3_readdatavalid)); defparam readatavalid_3.WIDTH = 1; defparam readatavalid_3.DEPTH = 4; _acl_mem2x_shiftreg readatavalid_4(.D(avs_port4_read), .clock(clk), .resetn(resetn), .enable(port4_enable), .Q(avs_port4_readdatavalid)); defparam readatavalid_4.WIDTH = 1; defparam readatavalid_4.DEPTH = 4; localparam NUM_RAMS=((WIDTH+PREFERRED_WIDTH-1)/PREFERRED_WIDTH); genvar n; generate for(n=0; n<NUM_RAMS; n++) begin : block_n localparam MY_WIDTH=( (n==NUM_RAMS-1) ? (WIDTH-(NUM_RAMS-1)*PREFERRED_WIDTH) : PREFERRED_WIDTH ); localparam MY_WIDTH_BYTES = MY_WIDTH / 8; reg [LOG2DEPTH-1:0] addr_1_reg2x /* synthesis dont_merge */; reg [LOG2DEPTH-1:0] addr_2_reg2x /* synthesis dont_merge */; reg write_1_reg2x /* synthesis dont_merge */; reg write_2_reg2x /* synthesis dont_merge */; reg [LOG2DEPTH-1:0] addr_1_reg /* synthesis dont_merge */; reg [LOG2DEPTH-1:0] addr_2_reg /* synthesis dont_merge */; reg [LOG2DEPTH-1:0] addr_3_reg /* synthesis dont_merge */; reg [LOG2DEPTH-1:0] addr_4_reg /* synthesis dont_merge */; reg write_1_reg, write_2_reg /* synthesis dont_merge */; reg write_3_reg, write_4_reg /* synthesis dont_merge */; reg [MY_WIDTH-1:0] data_1_reg2x /* synthesis dont_merge */; reg [MY_WIDTH-1:0] data_2_reg2x /* synthesis dont_merge */; reg [MY_WIDTH/8-1:0] byteen_1_reg2x /* synthesis dont_merge */; reg [MY_WIDTH/8-1:0] byteen_2_reg2x /* synthesis dont_merge */; reg [MY_WIDTH-1:0] data_1_reg /* synthesis dont_merge */; reg [MY_WIDTH-1:0] data_2_reg /* synthesis dont_merge */; reg [MY_WIDTH-1:0] data_3_reg /* synthesis dont_merge */; reg [MY_WIDTH-1:0] data_4_reg /* synthesis dont_merge */; reg [MY_WIDTH/8-1:0] byteen_1_reg /* synthesis dont_merge */; reg [MY_WIDTH/8-1:0] byteen_2_reg /* synthesis dont_merge */; reg [MY_WIDTH/8-1:0] byteen_3_reg /* synthesis dont_merge */; reg [MY_WIDTH/8-1:0] byteen_4_reg /* synthesis dont_merge */; reg clk_90deg, sel2x /* synthesis dont_merge */; //Convert clock to data signal always@(negedge clk2x) clk_90deg<=clk; always@(posedge clk2x) sel2x<=clk_90deg; //This should give you exactly sel2x=~clk always@(posedge clk2x) begin if (!resetn & ENABLED) begin addr_1_reg2x <= {LOG2DEPTH{1'b0}}; addr_2_reg2x <= {LOG2DEPTH{1'b0}}; write_1_reg2x <= 1'b0; write_2_reg2x <= 1'b0; end else begin if(!ENABLED | (port1_enable | port2_enable)) begin addr_1_reg2x <= (!sel2x) ? addr_2_reg : addr_1_reg; write_1_reg2x <= (!sel2x) ? write_2_reg : write_1_reg; end if(!ENABLED | (port3_enable | port4_enable)) begin addr_2_reg2x <= (!sel2x) ? addr_4_reg : addr_3_reg; write_2_reg2x <= (!sel2x) ? write_4_reg : write_3_reg; end end end always@(posedge clk) begin if (!resetn & ENABLED) begin addr_1_reg <= {LOG2DEPTH{1'b0}}; addr_2_reg <= {LOG2DEPTH{1'b0}}; addr_3_reg <= {LOG2DEPTH{1'b0}}; addr_4_reg <= {LOG2DEPTH{1'b0}}; write_1_reg <= 1'b0; write_2_reg <= 1'b0; write_3_reg <= 1'b0; write_4_reg <= 1'b0; end else begin if(!ENABLED | port1_enable) begin addr_1_reg <= avs_port1_address; write_1_reg <= avs_port1_write; end if(!ENABLED | port2_enable) begin addr_2_reg <= avs_port2_address; write_2_reg <= avs_port2_write; end if(!ENABLED | port3_enable) begin addr_3_reg <= avs_port3_address; write_3_reg <= avs_port3_write; end if(!ENABLED | port4_enable) begin addr_4_reg <= avs_port4_address; write_4_reg <= avs_port4_write; end end end //Register before double pumping always@(posedge clk) begin if (!resetn & ENABLED) begin data_1_reg <= {MY_WIDTH{1'b0}}; data_2_reg <= {MY_WIDTH{1'b0}}; data_3_reg <= {MY_WIDTH{1'b0}}; data_4_reg <= {MY_WIDTH{1'b0}}; byteen_1_reg <= {(MY_WIDTH/8){1'b1}}; byteen_2_reg <= {(MY_WIDTH/8){1'b1}}; byteen_3_reg <= {(MY_WIDTH/8){1'b1}}; byteen_4_reg <= {(MY_WIDTH/8){1'b1}}; end else begin if(!ENABLED | port1_enable) begin data_1_reg <= avs_port1_writedata[n*PREFERRED_WIDTH +: MY_WIDTH]; byteen_1_reg <= avs_port1_byteenable[n*(PREFERRED_WIDTH/8) +: (MY_WIDTH/8)]; end if(!ENABLED | port2_enable) begin data_2_reg <= avs_port2_writedata[n*PREFERRED_WIDTH +: MY_WIDTH]; byteen_2_reg <= avs_port2_byteenable[n*(PREFERRED_WIDTH/8) +: (MY_WIDTH/8)]; end if(!ENABLED | port3_enable) begin data_3_reg <= avs_port3_writedata[n*PREFERRED_WIDTH +: MY_WIDTH]; byteen_3_reg <= avs_port3_byteenable[n*(PREFERRED_WIDTH/8) +: (MY_WIDTH/8)]; end if(!ENABLED | port4_enable) begin data_4_reg <= avs_port4_writedata[n*PREFERRED_WIDTH +: MY_WIDTH]; byteen_4_reg <= avs_port4_byteenable[n*(PREFERRED_WIDTH/8) +: (MY_WIDTH/8)]; end end end // Consider making only one port r/w and the rest read only always@(posedge clk2x) begin if (!resetn & ENABLED) begin data_1_reg2x <= {MY_WIDTH{1'b0}}; data_2_reg2x <= {MY_WIDTH{1'b0}}; byteen_1_reg2x <= {(MY_WIDTH/8){1'b1}}; byteen_2_reg2x <= {(MY_WIDTH/8){1'b1}}; end else begin if(!ENABLED | (port1_enable | port2_enable)) begin data_1_reg2x <= (!sel2x) ? data_2_reg : data_1_reg; byteen_1_reg2x <= (!sel2x) ? byteen_2_reg : byteen_1_reg; end if(!ENABLED | (port3_enable | port4_enable)) begin data_2_reg2x <= (!sel2x) ? data_4_reg : data_3_reg; byteen_2_reg2x <= (!sel2x) ? byteen_4_reg : byteen_3_reg; end end end altsyncram altsyncram_component ( .clock0 (clk2x), .wren_a (write_1_reg2x), .wren_b (write_2_reg2x), .address_a (addr_1_reg2x), .address_b (addr_2_reg2x), .data_a (data_1_reg2x), .data_b (data_2_reg2x), .q_a (data_out_a_mem[n*PREFERRED_WIDTH +: MY_WIDTH]), .q_b (data_out_b_mem[n*PREFERRED_WIDTH +: MY_WIDTH]), .aclr0 (1'b0), .aclr1 (1'b0), .addressstall_a (ENABLED & (~port1_enable & ~port2_enable) ), //ports 1 and 2 must share the same enable source .addressstall_b (ENABLED & (~port3_enable & ~port4_enable) ), //ports 3 and 4 must share the same enable source .byteena_a (byteen_1_reg2x), .byteena_b (byteen_2_reg2x), .clock1 (1'b1), .clocken0 (1'b1), .clocken1 (1'b1), .clocken2 (1'b1), .clocken3 (1'b1), .eccstatus (), .rden_a (1'b1), .rden_b (1'b1)); defparam altsyncram_component.address_reg_b = "CLOCK0", altsyncram_component.clock_enable_input_a = "BYPASS", altsyncram_component.clock_enable_input_b = "BYPASS", altsyncram_component.clock_enable_output_a = "BYPASS", altsyncram_component.clock_enable_output_b = "BYPASS", altsyncram_component.address_reg_b = "CLOCK0", altsyncram_component.rdcontrol_reg_b = "CLOCK0", altsyncram_component.byteena_reg_b = "CLOCK0", altsyncram_component.indata_reg_b = "CLOCK0", altsyncram_component.intended_device_family = INTENDED_DEVICE_FAMILY, altsyncram_component.lpm_type = "altsyncram", altsyncram_component.numwords_a = DEPTH_WORDS, altsyncram_component.numwords_b = DEPTH_WORDS, altsyncram_component.operation_mode = RAM_OPERATION_MODE, altsyncram_component.outdata_aclr_a = "NONE", altsyncram_component.outdata_aclr_b = "NONE", altsyncram_component.outdata_reg_a = "CLOCK0", altsyncram_component.outdata_reg_b = "CLOCK0", altsyncram_component.power_up_uninitialized = "FALSE", altsyncram_component.read_during_write_mode_mixed_ports = RDW_MODE, altsyncram_component.read_during_write_mode_port_a = "DONT_CARE", altsyncram_component.read_during_write_mode_port_b = "DONT_CARE", altsyncram_component.widthad_a = LOG2DEPTH, altsyncram_component.widthad_b = LOG2DEPTH, altsyncram_component.width_a = MY_WIDTH, altsyncram_component.width_b = MY_WIDTH, altsyncram_component.width_byteena_a = MY_WIDTH_BYTES, altsyncram_component.width_byteena_b = MY_WIDTH_BYTES, altsyncram_component.wrcontrol_wraddress_reg_b = "CLOCK0", altsyncram_component.ram_block_type = RAM_BLOCK_TYPE; if (ENABLED) begin // catch read output data if disabled // this should be synthesized away if enable is tied to 1 acl_mem_staging_reg #( .WIDTH(MY_WIDTH) ) data_a_acl_mem_staging_reg ( .clk (clk2x), .resetn (resetn), .enable (port1_enable | port2_enable), .rdata_in (data_out_a_mem[n*PREFERRED_WIDTH +: MY_WIDTH]), .rdata_out(data_out_a_unreg[n*PREFERRED_WIDTH +: MY_WIDTH]) ); acl_mem_staging_reg #( .WIDTH(MY_WIDTH) ) data_b_acl_mem_staging_reg ( .clk (clk2x), .resetn (resetn), .enable (port3_enable | port4_enable), .rdata_in (data_out_b_mem[n*PREFERRED_WIDTH +: MY_WIDTH]), .rdata_out(data_out_b_unreg[n*PREFERRED_WIDTH +: MY_WIDTH]) ); end else begin assign data_out_a_unreg[n*PREFERRED_WIDTH +: MY_WIDTH] = data_out_a_mem[n*PREFERRED_WIDTH +: MY_WIDTH]; assign data_out_b_unreg[n*PREFERRED_WIDTH +: MY_WIDTH] = data_out_b_mem[n*PREFERRED_WIDTH +: MY_WIDTH]; end end endgenerate always@(posedge clk2x) begin if (!ENABLED | (port1_enable | port2_enable)) begin data_out_a_reg<=data_out_a_unreg; data_out_a_reg2<=data_out_a_reg; end if (!ENABLED | (port3_enable | port4_enable)) begin data_out_b_reg<=data_out_b_unreg; data_out_b_reg2<=data_out_b_reg; end end always@(posedge clk) begin if (!ENABLED | port1_enable) begin avs_port1_readdata <= data_out_a_reg; end if (!ENABLED | port2_enable) begin avs_port2_readdata <= data_out_a_reg2; end if (!ENABLED | port3_enable) begin avs_port3_readdata <= data_out_b_reg; end if (!ENABLED | port4_enable) begin avs_port4_readdata <= data_out_b_reg2; end end endmodule
module _acl_mem2x_shiftreg(D, clock, resetn, enable, Q); parameter WIDTH = 32; parameter DEPTH = 1; input [WIDTH-1:0] D; input clock, resetn, enable; output [WIDTH-1:0] Q; reg [DEPTH-1:0][WIDTH-1:0] local_ffs /* synthesis preserve */; always @(posedge clock or negedge resetn) if (!resetn) local_ffs <= '0; else if (enable) local_ffs <= {local_ffs[DEPTH-2:0], D}; assign Q = local_ffs[DEPTH-1]; endmodule
module sky130_fd_sc_ls__o211a_1 ( X , A1 , A2 , B1 , C1 , VPWR, VGND, VPB , VNB ); output X ; input A1 ; input A2 ; input B1 ; input C1 ; input VPWR; input VGND; input VPB ; input VNB ; sky130_fd_sc_ls__o211a base ( .X(X), .A1(A1), .A2(A2), .B1(B1), .C1(C1), .VPWR(VPWR), .VGND(VGND), .VPB(VPB), .VNB(VNB) ); endmodule
module sky130_fd_sc_ls__o211a_1 ( X , A1, A2, B1, C1 ); output X ; input A1; input A2; input B1; input C1; // Voltage supply signals supply1 VPWR; supply0 VGND; supply1 VPB ; supply0 VNB ; sky130_fd_sc_ls__o211a base ( .X(X), .A1(A1), .A2(A2), .B1(B1), .C1(C1) ); endmodule
module FullAdder ( input wire a, input wire b, input wire ci, output reg co, output reg s ); always @(a, b, ci) begin: assig_process_co co = a & b | (a & ci) | (b & ci); end always @(a, b, ci) begin: assig_process_s s = a ^ b ^ ci; end endmodule
module RippleAdder1 #( parameter p_wordlength = 4 ) ( input wire[3:0] a, input wire[3:0] b, input wire ci, output reg co, output reg[3:0] s ); reg[4:0] c; reg sig_fa_0_a; reg sig_fa_0_b; reg sig_fa_0_ci; wire sig_fa_0_co; wire sig_fa_0_s; reg sig_fa_1_a; reg sig_fa_1_b; reg sig_fa_1_ci; wire sig_fa_1_co; wire sig_fa_1_s; reg sig_fa_2_a; reg sig_fa_2_b; reg sig_fa_2_ci; wire sig_fa_2_co; wire sig_fa_2_s; reg sig_fa_3_a; reg sig_fa_3_b; reg sig_fa_3_ci; wire sig_fa_3_co; wire sig_fa_3_s; FullAdder fa_0_inst ( .a(sig_fa_0_a), .b(sig_fa_0_b), .ci(sig_fa_0_ci), .co(sig_fa_0_co), .s(sig_fa_0_s) ); FullAdder fa_1_inst ( .a(sig_fa_1_a), .b(sig_fa_1_b), .ci(sig_fa_1_ci), .co(sig_fa_1_co), .s(sig_fa_1_s) ); FullAdder fa_2_inst ( .a(sig_fa_2_a), .b(sig_fa_2_b), .ci(sig_fa_2_ci), .co(sig_fa_2_co), .s(sig_fa_2_s) ); FullAdder fa_3_inst ( .a(sig_fa_3_a), .b(sig_fa_3_b), .ci(sig_fa_3_ci), .co(sig_fa_3_co), .s(sig_fa_3_s) ); always @(ci, sig_fa_0_co, sig_fa_1_co, sig_fa_2_co, sig_fa_3_co) begin: assig_process_c c = {{{{sig_fa_3_co, sig_fa_2_co}, sig_fa_1_co}, sig_fa_0_co}, ci}; end always @(c) begin: assig_process_co co = c[4]; end always @(sig_fa_0_s, sig_fa_1_s, sig_fa_2_s, sig_fa_3_s) begin: assig_process_s s = {{{sig_fa_3_s, sig_fa_2_s}, sig_fa_1_s}, sig_fa_0_s}; end always @(a) begin: assig_process_sig_fa_0_a sig_fa_0_a = a[0]; end always @(b) begin: assig_process_sig_fa_0_b sig_fa_0_b = b[0]; end always @(c) begin: assig_process_sig_fa_0_ci sig_fa_0_ci = c[0]; end always @(a) begin: assig_process_sig_fa_1_a sig_fa_1_a = a[1]; end always @(b) begin: assig_process_sig_fa_1_b sig_fa_1_b = b[1]; end always @(c) begin: assig_process_sig_fa_1_ci sig_fa_1_ci = c[1]; end always @(a) begin: assig_process_sig_fa_2_a sig_fa_2_a = a[2]; end always @(b) begin: assig_process_sig_fa_2_b sig_fa_2_b = b[2]; end always @(c) begin: assig_process_sig_fa_2_ci sig_fa_2_ci = c[2]; end always @(a) begin: assig_process_sig_fa_3_a sig_fa_3_a = a[3]; end always @(b) begin: assig_process_sig_fa_3_b sig_fa_3_b = b[3]; end always @(c) begin: assig_process_sig_fa_3_ci sig_fa_3_ci = c[3]; end generate if (p_wordlength != 4) $error("%m Generated only for this param value"); endgenerate endmodule
module sky130_fd_sc_hdll__mux2_12 ( X , A0 , A1 , S , VPWR, VGND, VPB , VNB ); output X ; input A0 ; input A1 ; input S ; input VPWR; input VGND; input VPB ; input VNB ; sky130_fd_sc_hdll__mux2 base ( .X(X), .A0(A0), .A1(A1), .S(S), .VPWR(VPWR), .VGND(VGND), .VPB(VPB), .VNB(VNB) ); endmodule
module sky130_fd_sc_hdll__mux2_12 ( X , A0, A1, S ); output X ; input A0; input A1; input S ; // Voltage supply signals supply1 VPWR; supply0 VGND; supply1 VPB ; supply0 VNB ; sky130_fd_sc_hdll__mux2 base ( .X(X), .A0(A0), .A1(A1), .S(S) ); endmodule
module counter_f (Clk, Rst, Load_In, Count_Enable, Count_Load, Count_Down, Count_Out, Carry_Out); parameter C_NUM_BITS = 9; parameter C_FAMILY = "nofamily"; input Clk; input Rst; input[C_NUM_BITS - 1:0] Load_In; input Count_Enable; input Count_Load; input Count_Down; output[C_NUM_BITS - 1:0] Count_Out; wire[C_NUM_BITS - 1:0] Count_Out; output Carry_Out; wire Carry_Out; reg[C_NUM_BITS:0] icount_out; wire[C_NUM_BITS:0] icount_out_x; wire[C_NUM_BITS:0] load_in_x; //------------------------------------------------------------------- // Begin architecture //------------------------------------------------------------------- //------------------------------------------------------------------- // Generate Inferred code //------------------------------------------------------------------- assign load_in_x = {1'b0, Load_In}; // Mask out carry position to retain legacy self-clear on next enable. // icount_out_x <= ('0' & icount_out(C_NUM_BITS-1 downto 0)); -- Echeck WA assign icount_out_x = {1'b0, icount_out[C_NUM_BITS - 1:0]}; //--------------------------------------------------------------- // Process to generate counter with - synchronous reset, load, // counter enable, count down / up features. //--------------------------------------------------------------- always @(posedge Clk) begin : CNTR_PROC if (Rst == 1'b1) begin icount_out <= {C_NUM_BITS-(0)+1{1'b0}} ; end else if (Count_Load == 1'b1) begin icount_out <= load_in_x ; end else if (Count_Down == 1'b1 & Count_Enable == 1'b1) begin icount_out <= icount_out_x - 1 ; end else if (Count_Enable == 1'b1) begin icount_out <= icount_out_x + 1 ; end end assign Carry_Out = icount_out[C_NUM_BITS] ; assign Count_Out = icount_out[C_NUM_BITS - 1:0]; endmodule
module sky130_fd_sc_hs__dlxbn ( Q , Q_N , D , GATE_N, VPWR , VGND ); // Module ports output Q ; output Q_N ; input D ; input GATE_N; input VPWR ; input VGND ; // Local signals wire GATE ; wire buf_Q ; wire GATE_N_delayed; wire D_delayed ; reg notifier ; wire awake ; wire 1 ; // Name Output Other arguments not not0 (GATE , GATE_N_delayed ); sky130_fd_sc_hs__u_dl_p_no_pg u_dl_p_no_pg0 (buf_Q , D_delayed, GATE, notifier, VPWR, VGND); assign awake = ( VPWR === 1 ); buf buf0 (Q , buf_Q ); not not1 (Q_N , buf_Q ); endmodule
module sky130_fd_sc_ls__bufbuf ( //# {{data|Data Signals}} input A , output X , //# {{power|Power}} input VPB , input VPWR, input VGND, input VNB ); endmodule
module top(); // Inputs are registered reg D; reg SCD; reg SCE; reg ASYNC; reg VPWR; reg VGND; reg VPB; reg VNB; // Outputs are wires wire Q; wire Q_N; initial begin // Initial state is x for all inputs. ASYNC = 1'bX; D = 1'bX; SCD = 1'bX; SCE = 1'bX; VGND = 1'bX; VNB = 1'bX; VPB = 1'bX; VPWR = 1'bX; #20 ASYNC = 1'b0; #40 D = 1'b0; #60 SCD = 1'b0; #80 SCE = 1'b0; #100 VGND = 1'b0; #120 VNB = 1'b0; #140 VPB = 1'b0; #160 VPWR = 1'b0; #180 ASYNC = 1'b1; #200 D = 1'b1; #220 SCD = 1'b1; #240 SCE = 1'b1; #260 VGND = 1'b1; #280 VNB = 1'b1; #300 VPB = 1'b1; #320 VPWR = 1'b1; #340 ASYNC = 1'b0; #360 D = 1'b0; #380 SCD = 1'b0; #400 SCE = 1'b0; #420 VGND = 1'b0; #440 VNB = 1'b0; #460 VPB = 1'b0; #480 VPWR = 1'b0; #500 VPWR = 1'b1; #520 VPB = 1'b1; #540 VNB = 1'b1; #560 VGND = 1'b1; #580 SCE = 1'b1; #600 SCD = 1'b1; #620 D = 1'b1; #640 ASYNC = 1'b1; #660 VPWR = 1'bx; #680 VPB = 1'bx; #700 VNB = 1'bx; #720 VGND = 1'bx; #740 SCE = 1'bx; #760 SCD = 1'bx; #780 D = 1'bx; #800 ASYNC = 1'bx; end // Create a clock reg CLK; initial begin CLK = 1'b0; end always begin #5 CLK = ~CLK; end sky130_fd_sc_lp__sregsbp dut (.D(D), .SCD(SCD), .SCE(SCE), .ASYNC(ASYNC), .VPWR(VPWR), .VGND(VGND), .VPB(VPB), .VNB(VNB), .Q(Q), .Q_N(Q_N), .CLK(CLK)); endmodule
module sky130_fd_sc_hs__dlxtp ( VPWR, VGND, Q , D , GATE ); // Module ports input VPWR; input VGND; output Q ; input D ; input GATE; // Local signals wire buf_Q GATE_delayed; wire buf_Q D_delayed ; wire buf_Q ; // Name Output Other arguments sky130_fd_sc_hs__u_dl_p_pg u_dl_p_pg0 (buf_Q , D, GATE, VPWR, VGND); buf buf0 (Q , buf_Q ); endmodule
module daq_dma32 ( input clk, input reset, // avalon mm data master input avm_data_waitrq, output avm_data_write, output [31:0]avm_data_writedata, output [31:0]avm_data_address, output [3:0]avm_data_byteenable, // avalon mm ctrl slave input avs_ctrl_write, input [31:0]avs_ctrl_writedata, input avs_ctrl_read, output reg [31:0]avs_ctrl_readdata, input [2:0]avs_ctrl_address, // conduit interface input clk_daq, input write, input [15:0]din, output reg running ); wire fifo_read; wire fifo_empty; wire fifo_full; wire dreg_clear; wire dreg_write; wire [15:0]data; wire [1:0]be; wire next; // register reg [15:0]dreg; reg dreg_empty; reg [30:1]mem_base; reg [26:1]mem_size; reg [26:1]mem_read; reg [26:1]mem_write; reg next2; reg start; reg fifo_ovfl; reg ram_ovfl; reg running_int; // --- register write ----------------------------------------------------- wire write_ctrl = avs_ctrl_write && (avs_ctrl_address == 3'd4); wire set_start = write_ctrl && avs_ctrl_writedata[0]; wire set_stop = write_ctrl && !avs_ctrl_writedata[0]; wire [26:1]inc_addr = mem_write + 26'd1; wire carry = inc_addr == mem_size; wire [26:1]next_addr = carry ? 26'd0 : inc_addr; wire overflow = next_addr == mem_read; always @(posedge clk or posedge reset) begin if (reset) begin dreg <= 0; dreg_empty <= 1; next2 <= 0; mem_base <= 0; mem_size <= 0; mem_write <= 0; mem_read <= 0; start <= 0; running_int <= 0; fifo_ovfl <= 0; ram_ovfl <= 0; end else begin start <= set_start; if (running_int) begin if (dreg_write) {dreg, dreg_empty} = {data, 1'b0}; else if (dreg_clear) dreg_empty = 1'b1; if (overflow) ram_ovfl <= 1; if (fifo_full) fifo_ovfl <= 1; if (overflow || fifo_full || set_stop) running_int <= 0; if (next || next2) mem_write <= next_addr; if ((be == 3) && avm_data_write && !avm_data_waitrq) next2 <= 1; else if (!next) next2 <= 0; if (avs_ctrl_write && (avs_ctrl_address == 2)) mem_read <= avs_ctrl_writedata[25:0]; end else if (start) begin dreg_empty <= 1; next2 <= 0; mem_write <= 0; mem_read <= 0; fifo_ovfl <= 0; ram_ovfl <= 0; running_int <= 1; end else begin if (avs_ctrl_write) case (avs_ctrl_address) 0: mem_base <= avs_ctrl_writedata[30:1]; 1: mem_size <= avs_ctrl_writedata[25:0]; 2: mem_read <= avs_ctrl_writedata[25:0]; endcase end end end // --- register read ------------------------------------------------------ always @(*) begin case (avs_ctrl_address) 0: avs_ctrl_readdata <= {1'b0, mem_base, 1'b0}; 1: avs_ctrl_readdata <= {6'b000000, mem_size }; 2: avs_ctrl_readdata <= {6'b000000, mem_read }; 3: avs_ctrl_readdata <= {6'b000000, mem_write }; default: avs_ctrl_readdata <= {29'b0, fifo_ovfl, ram_ovfl, running_int}; endcase end // --- DMA write controller ----------------------------------------------- wire [30:1]address = mem_base + {4'b0000, mem_write}; reg [6:0]sm_out; always @(*) begin if (running_int) case ({fifo_empty, dreg_empty, address[1], avm_data_waitrq}) 4'b0000: sm_out <= 7'b1011111; 4'b0001: sm_out <= 7'b0001110; 4'b0010: sm_out <= 7'b1101101; 4'b0011: sm_out <= 7'b0001100; 4'b0100: sm_out <= 7'b1100110; 4'b0101: sm_out <= 7'b1100110; 4'b0110: sm_out <= 7'b1100100; 4'b0111: sm_out <= 7'b1100100; 4'b1000: sm_out <= 7'b0011011; 4'b1001: sm_out <= 7'b0001010; 4'b1010: sm_out <= 7'b0011101; 4'b1011: sm_out <= 7'b0001100; 4'b1100: sm_out <= 7'b0000010; 4'b1101: sm_out <= 7'b0000010; 4'b1110: sm_out <= 7'b0000100; 4'b1111: sm_out <= 7'b0000100; endcase else sm_out <= 7'b0000000; end assign {fifo_read, dreg_write, dreg_clear, avm_data_write, be, next} = sm_out; assign avm_data_byteenable = { be[1], be[1], be[0], be[0] }; assign avm_data_address = {1'b0, address[30:2], 2'b00}; assign avm_data_writedata = be[0] ? {data, dreg} : {dreg, dreg}; daq_dma_fifo buffer ( .aclr(reset || start), .data(din), .rdclk(clk), .rdreq(fifo_read), .wrclk(clk_daq), .wrreq(write), .q(data), .rdempty(fifo_empty), .rdfull(fifo_full) ); // clock crossing: runnning_int -> running reg running1; always @(posedge clk_daq or posedge reset) begin if (reset) begin running1 <= 0; running <= 0; end else begin running1 <= running_int; running <= running1; end end endmodule
module registerfile( Q1,Q2.DI,clk,reset written,AD,A1,A2 ); output [31:0] Q1,Q2; input [31:0] DI; input clk,reset,written; input [4:0] AD,A1,A2; wire [31:0] decoderout,regen; wire [31:0] q[31:0]; decoder dec_0(decoderout,AD); assign regen[0] = decoderout[0]& written; assign regen[1] = decoderout[1]& written; //省略 assign regen[31] = decoderout[31]& written; regesiter reg_0(q[0],DI,clk,reset,regen[0]); regesiter reg_1(q[1],DI,clk,reset,regen[1]); //省略 regesiter reg_31(q[31],DI,clk,reset,regen[31]); mux_32 mux_1(Q1,q,A1); mux_32 mux_2(Q2,q,A2); endmodule
module dff(q,data,clk,reset,en) output q; input data,clk,reset,en; reg q; always@(posedge clk) begin if(reset) q<=0; else if(en) q<=data; else q<=q; end endmodule
module register( q,data,clk,reset,en ); output [31:0] q; input [31:0]data; input clk,reset,en; dff u_0(q[0],data[0],clk,reset,en); dff u_1(q[1],data[1],clk,reset,en); // 省略 dff u_31(q[31],data[31],clk,reset,en); endmodule
module mux_32( output reg [31:0]q; input [31:0]q[31:0]; input [4:0]raddr; ); always@(raddr or q[31:0]) case(raddr) 5’d0: q<=q[0]; 5’d1: q<=q[1]; // 省略 5’d31: q<=q[31]; default: q<= X; endcase endmodule
module decoder( decoderout,waddr ); output[31:0]decoderout; input[4:0] waddr; reg [31:0]decoderout; always@(wadder) case(wadder) 5’d0: decoderout<=32’b0000_00000_0000_0000_0000_0000_0000_0001; 5’d1: decoderout<=32’b0000_00000_0000_0000_0000_0000_0000_0010; // 省略 5’d31: decoderout<=32’b1000_00000_0000_0000_0000_0000_0000_0000; default: decoderout<= 32’bxxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx; endcase endmodule
module cycloneive_dffe ( Q, CLK, ENA, D, CLRN, PRN ); input D; input CLK; input CLRN; input PRN; input ENA; output Q; wire D_ipd; wire ENA_ipd; wire CLK_ipd; wire PRN_ipd; wire CLRN_ipd; buf (D_ipd, D); buf (ENA_ipd, ENA); buf (CLK_ipd, CLK); buf (PRN_ipd, PRN); buf (CLRN_ipd, CLRN); wire legal; reg viol_notifier; CYCLONEIVE_PRIM_DFFE ( Q, ENA_ipd, D_ipd, CLK_ipd, CLRN_ipd, PRN_ipd, viol_notifier ); and(legal, ENA_ipd, CLRN_ipd, PRN_ipd); specify specparam TREG = 0; specparam TREN = 0; specparam TRSU = 0; specparam TRH = 0; specparam TRPR = 0; specparam TRCL = 0; $setup ( D, posedge CLK &&& legal, TRSU, viol_notifier ) ; $hold ( posedge CLK &&& legal, D, TRH, viol_notifier ) ; $setup ( ENA, posedge CLK &&& legal, TREN, viol_notifier ) ; $hold ( posedge CLK &&& legal, ENA, 0, viol_notifier ) ; ( negedge CLRN => (Q +: 1'b0)) = ( TRCL, TRCL) ; ( negedge PRN => (Q +: 1'b1)) = ( TRPR, TRPR) ; ( posedge CLK => (Q +: D)) = ( TREG, TREG) ; endspecify endmodule
module cycloneive_mux21 (MO, A, B, S); input A, B, S; output MO; wire A_in; wire B_in; wire S_in; buf(A_in, A); buf(B_in, B); buf(S_in, S); wire tmp_MO; specify (A => MO) = (0, 0); (B => MO) = (0, 0); (S => MO) = (0, 0); endspecify assign tmp_MO = (S_in == 1) ? B_in : A_in; buf (MO, tmp_MO); endmodule
module cycloneive_mux41 (MO, IN0, IN1, IN2, IN3, S); input IN0; input IN1; input IN2; input IN3; input [1:0] S; output MO; wire IN0_in; wire IN1_in; wire IN2_in; wire IN3_in; wire S1_in; wire S0_in; buf(IN0_in, IN0); buf(IN1_in, IN1); buf(IN2_in, IN2); buf(IN3_in, IN3); buf(S1_in, S[1]); buf(S0_in, S[0]); wire tmp_MO; specify (IN0 => MO) = (0, 0); (IN1 => MO) = (0, 0); (IN2 => MO) = (0, 0); (IN3 => MO) = (0, 0); (S[1] => MO) = (0, 0); (S[0] => MO) = (0, 0); endspecify assign tmp_MO = S1_in ? (S0_in ? IN3_in : IN2_in) : (S0_in ? IN1_in : IN0_in); buf (MO, tmp_MO); endmodule
module cycloneive_and1 (Y, IN1); input IN1; output Y; specify (IN1 => Y) = (0, 0); endspecify buf (Y, IN1); endmodule
module cycloneive_and16 (Y, IN1); input [15:0] IN1; output [15:0] Y; specify (IN1 => Y) = (0, 0); endspecify buf (Y[0], IN1[0]); buf (Y[1], IN1[1]); buf (Y[2], IN1[2]); buf (Y[3], IN1[3]); buf (Y[4], IN1[4]); buf (Y[5], IN1[5]); buf (Y[6], IN1[6]); buf (Y[7], IN1[7]); buf (Y[8], IN1[8]); buf (Y[9], IN1[9]); buf (Y[10], IN1[10]); buf (Y[11], IN1[11]); buf (Y[12], IN1[12]); buf (Y[13], IN1[13]); buf (Y[14], IN1[14]); buf (Y[15], IN1[15]); endmodule
module cycloneive_bmux21 (MO, A, B, S); input [15:0] A, B; input S; output [15:0] MO; assign MO = (S == 1) ? B : A; endmodule
module cycloneive_b17mux21 (MO, A, B, S); input [16:0] A, B; input S; output [16:0] MO; assign MO = (S == 1) ? B : A; endmodule
module cycloneive_nmux21 (MO, A, B, S); input A, B, S; output MO; assign MO = (S == 1) ? ~B : ~A; endmodule
module cycloneive_b5mux21 (MO, A, B, S); input [4:0] A, B; input S; output [4:0] MO; assign MO = (S == 1) ? B : A; endmodule
module cycloneive_latch(D, ENA, PRE, CLR, Q); input D; input ENA, PRE, CLR; output Q; reg q_out; specify $setup (D, negedge ENA, 0) ; $hold (negedge ENA, D, 0) ; (D => Q) = (0, 0); (negedge ENA => (Q +: q_out)) = (0, 0); (negedge PRE => (Q +: q_out)) = (0, 0); (negedge CLR => (Q +: q_out)) = (0, 0); endspecify wire D_in; wire ENA_in; wire PRE_in; wire CLR_in; buf (D_in, D); buf (ENA_in, ENA); buf (PRE_in, PRE); buf (CLR_in, CLR); initial begin q_out <= 1'b0; end always @(D_in or ENA_in or PRE_in or CLR_in) begin if (PRE_in == 1'b0) begin // latch being preset, preset is active low q_out <= 1'b1; end else if (CLR_in == 1'b0) begin // latch being cleared, clear is active low q_out <= 1'b0; end else if (ENA_in == 1'b1) begin // latch is transparent q_out <= D_in; end end and (Q, q_out, 1'b1); endmodule
module cycloneive_routing_wire ( datain, dataout ); // INPUT PORTS input datain; // OUTPUT PORTS output dataout; // INTERNAL VARIABLES wire dataout_tmp; specify (datain => dataout) = (0, 0) ; endspecify assign dataout_tmp = datain; and (dataout, dataout_tmp, 1'b1); endmodule
module cycloneive_m_cntr ( clk, reset, cout, initial_value, modulus, time_delay); // INPUT PORTS input clk; input reset; input [31:0] initial_value; input [31:0] modulus; input [31:0] time_delay; // OUTPUT PORTS output cout; // INTERNAL VARIABLES AND NETS integer count; reg tmp_cout; reg first_rising_edge; reg clk_last_value; reg cout_tmp; initial begin count = 1; first_rising_edge = 1; clk_last_value = 0; end always @(reset or clk) begin if (reset) begin count = 1; tmp_cout = 0; first_rising_edge = 1; cout_tmp <= tmp_cout; end else begin if (clk_last_value !== clk) begin if (clk === 1'b1 && first_rising_edge) begin first_rising_edge = 0; tmp_cout = clk; cout_tmp <= #(time_delay) tmp_cout; end else if (first_rising_edge == 0) begin if (count < modulus) count = count + 1; else begin count = 1; tmp_cout = ~tmp_cout; cout_tmp <= #(time_delay) tmp_cout; end end end end clk_last_value = clk; // cout_tmp <= #(time_delay) tmp_cout; end and (cout, cout_tmp, 1'b1); endmodule
module cycloneive_n_cntr ( clk, reset, cout, modulus); // INPUT PORTS input clk; input reset; input [31:0] modulus; // OUTPUT PORTS output cout; // INTERNAL VARIABLES AND NETS integer count; reg tmp_cout; reg first_rising_edge; reg clk_last_value; reg cout_tmp; initial begin count = 1; first_rising_edge = 1; clk_last_value = 0; end always @(reset or clk) begin if (reset) begin count = 1; tmp_cout = 0; first_rising_edge = 1; end else begin if (clk == 1 && clk_last_value !== clk && first_rising_edge) begin first_rising_edge = 0; tmp_cout = clk; end else if (first_rising_edge == 0) begin if (count < modulus) count = count + 1; else begin count = 1; tmp_cout = ~tmp_cout; end end end clk_last_value = clk; end assign cout = tmp_cout; endmodule
module cycloneive_scale_cntr ( clk, reset, cout, high, low, initial_value, mode, ph_tap); // INPUT PORTS input clk; input reset; input [31:0] high; input [31:0] low; input [31:0] initial_value; input [8*6:1] mode; input [31:0] ph_tap; // OUTPUT PORTS output cout; // INTERNAL VARIABLES AND NETS reg tmp_cout; reg first_rising_edge; reg clk_last_value; reg init; integer count; integer output_shift_count; reg cout_tmp; initial begin count = 1; first_rising_edge = 0; tmp_cout = 0; output_shift_count = 1; end always @(clk or reset) begin if (init !== 1'b1) begin clk_last_value = 0; init = 1'b1; end if (reset) begin count = 1; output_shift_count = 1; tmp_cout = 0; first_rising_edge = 0; end else if (clk_last_value !== clk) begin if (mode == " off") tmp_cout = 0; else if (mode == "bypass") begin tmp_cout = clk; first_rising_edge = 1; end else if (first_rising_edge == 0) begin if (clk == 1) begin if (output_shift_count == initial_value) begin tmp_cout = clk; first_rising_edge = 1; end else output_shift_count = output_shift_count + 1; end end else if (output_shift_count < initial_value) begin if (clk == 1) output_shift_count = output_shift_count + 1; end else begin count = count + 1; if (mode == " even" && (count == (high*2) + 1)) tmp_cout = 0; else if (mode == " odd" && (count == (high*2))) tmp_cout = 0; else if (count == (high + low)*2 + 1) begin tmp_cout = 1; count = 1; // reset count end end end clk_last_value = clk; cout_tmp <= tmp_cout; end and (cout, cout_tmp, 1'b1); endmodule
module cycloneive_pll_reg ( q, clk, ena, d, clrn, prn); // INPUT PORTS input d; input clk; input clrn; input prn; input ena; // OUTPUT PORTS output q; // INTERNAL VARIABLES reg q; reg clk_last_value; // DEFAULT VALUES THRO' PULLUPs tri1 prn, clrn, ena; initial q = 0; always @ (clk or negedge clrn or negedge prn ) begin if (prn == 1'b0) q <= 1; else if (clrn == 1'b0) q <= 0; else if ((clk === 1'b1) && (clk_last_value === 1'b0) && (ena === 1'b1)) q <= d; clk_last_value = clk; end endmodule
module cycloneive_pll (inclk, fbin, fbout, clkswitch, areset, pfdena, scanclk, scandata, scanclkena, configupdate, clk, phasecounterselect, phaseupdown, phasestep, clkbad, activeclock, locked, scandataout, scandone, phasedone, vcooverrange, vcounderrange ); parameter operation_mode = "normal"; parameter pll_type = "auto"; // auto,fast(left_right),enhanced(top_bottom) parameter compensate_clock = "clock0"; parameter inclk0_input_frequency = 0; parameter inclk1_input_frequency = 0; parameter self_reset_on_loss_lock = "off"; parameter switch_over_type = "auto"; parameter switch_over_counter = 1; parameter enable_switch_over_counter = "off"; parameter bandwidth = 0; parameter bandwidth_type = "auto"; parameter use_dc_coupling = "false"; parameter lock_high = 0; // 0 .. 4095 parameter lock_low = 0; // 0 .. 7 parameter lock_window_ui = "0.05"; // "0.05", "0.1", "0.15", "0.2" parameter test_bypass_lock_detect = "off"; parameter clk0_output_frequency = 0; parameter clk0_multiply_by = 0; parameter clk0_divide_by = 0; parameter clk0_phase_shift = "0"; parameter clk0_duty_cycle = 50; parameter clk1_output_frequency = 0; parameter clk1_multiply_by = 0; parameter clk1_divide_by = 0; parameter clk1_phase_shift = "0"; parameter clk1_duty_cycle = 50; parameter clk2_output_frequency = 0; parameter clk2_multiply_by = 0; parameter clk2_divide_by = 0; parameter clk2_phase_shift = "0"; parameter clk2_duty_cycle = 50; parameter clk3_output_frequency = 0; parameter clk3_multiply_by = 0; parameter clk3_divide_by = 0; parameter clk3_phase_shift = "0"; parameter clk3_duty_cycle = 50; parameter clk4_output_frequency = 0; parameter clk4_multiply_by = 0; parameter clk4_divide_by = 0; parameter clk4_phase_shift = "0"; parameter clk4_duty_cycle = 50; parameter pfd_min = 0; parameter pfd_max = 0; parameter vco_min = 0; parameter vco_max = 0; parameter vco_center = 0; // ADVANCED USE PARAMETERS parameter m_initial = 1; parameter m = 0; parameter n = 1; parameter c0_high = 1; parameter c0_low = 1; parameter c0_initial = 1; parameter c0_mode = "bypass"; parameter c0_ph = 0; parameter c1_high = 1; parameter c1_low = 1; parameter c1_initial = 1; parameter c1_mode = "bypass"; parameter c1_ph = 0; parameter c2_high = 1; parameter c2_low = 1; parameter c2_initial = 1; parameter c2_mode = "bypass"; parameter c2_ph = 0; parameter c3_high = 1; parameter c3_low = 1; parameter c3_initial = 1; parameter c3_mode = "bypass"; parameter c3_ph = 0; parameter c4_high = 1; parameter c4_low = 1; parameter c4_initial = 1; parameter c4_mode = "bypass"; parameter c4_ph = 0; parameter m_ph = 0; parameter clk0_counter = "unused"; parameter clk1_counter = "unused"; parameter clk2_counter = "unused"; parameter clk3_counter = "unused"; parameter clk4_counter = "unused"; parameter c1_use_casc_in = "off"; parameter c2_use_casc_in = "off"; parameter c3_use_casc_in = "off"; parameter c4_use_casc_in = "off"; parameter m_test_source = -1; parameter c0_test_source = -1; parameter c1_test_source = -1; parameter c2_test_source = -1; parameter c3_test_source = -1; parameter c4_test_source = -1; parameter vco_multiply_by = 0; parameter vco_divide_by = 0; parameter vco_post_scale = 1; // 1 .. 2 parameter vco_frequency_control = "auto"; parameter vco_phase_shift_step = 0; parameter charge_pump_current = 10; parameter loop_filter_r = "1.0"; // "1.0", "2.0", "4.0", "6.0", "8.0", "12.0", "16.0", "20.0" parameter loop_filter_c = 0; // 0 , 2 , 4 parameter pll_compensation_delay = 0; parameter simulation_type = "functional"; parameter lpm_type = "cycloneive_pll"; // SIMULATION_ONLY_PARAMETERS_BEGIN parameter down_spread = "0.0"; parameter lock_c = 4; parameter sim_gate_lock_device_behavior = "off"; parameter clk0_phase_shift_num = 0; parameter clk1_phase_shift_num = 0; parameter clk2_phase_shift_num = 0; parameter clk3_phase_shift_num = 0; parameter clk4_phase_shift_num = 0; parameter family_name = "Cycloneive"; parameter clk0_use_even_counter_mode = "off"; parameter clk1_use_even_counter_mode = "off"; parameter clk2_use_even_counter_mode = "off"; parameter clk3_use_even_counter_mode = "off"; parameter clk4_use_even_counter_mode = "off"; parameter clk0_use_even_counter_value = "off"; parameter clk1_use_even_counter_value = "off"; parameter clk2_use_even_counter_value = "off"; parameter clk3_use_even_counter_value = "off"; parameter clk4_use_even_counter_value = "off"; // TEST ONLY parameter init_block_reset_a_count = 1; parameter init_block_reset_b_count = 1; // SIMULATION_ONLY_PARAMETERS_END // LOCAL_PARAMETERS_BEGIN parameter phase_counter_select_width = 3; parameter lock_window = 5; parameter inclk0_freq = inclk0_input_frequency; parameter inclk1_freq = inclk1_input_frequency; parameter charge_pump_current_bits = 0; parameter lock_window_ui_bits = 0; parameter loop_filter_c_bits = 0; parameter loop_filter_r_bits = 0; parameter test_counter_c0_delay_chain_bits = 0; parameter test_counter_c1_delay_chain_bits = 0; parameter test_counter_c2_delay_chain_bits = 0; parameter test_counter_c3_delay_chain_bits = 0; parameter test_counter_c4_delay_chain_bits = 0; parameter test_counter_c5_delay_chain_bits = 0; parameter test_counter_m_delay_chain_bits = 0; parameter test_counter_n_delay_chain_bits = 0; parameter test_feedback_comp_delay_chain_bits = 0; parameter test_input_comp_delay_chain_bits = 0; parameter test_volt_reg_output_mode_bits = 0; parameter test_volt_reg_output_voltage_bits = 0; parameter test_volt_reg_test_mode = "false"; parameter vco_range_detector_high_bits = -1; parameter vco_range_detector_low_bits = -1; parameter scan_chain_mif_file = ""; parameter auto_settings = "true"; // LOCAL_PARAMETERS_END // INPUT PORTS input [1:0] inclk; input fbin; input clkswitch; input areset; input pfdena; input [phase_counter_select_width - 1:0] phasecounterselect; input phaseupdown; input phasestep; input scanclk; input scanclkena; input scandata; input configupdate; // OUTPUT PORTS output [4:0] clk; output [1:0] clkbad; output activeclock; output locked; output scandataout; output scandone; output fbout; output phasedone; output vcooverrange; output vcounderrange; // TIMING CHECKS specify $setuphold(negedge scanclk, scandata, 0, 0); $setuphold(negedge scanclk, scanclkena, 0, 0); endspecify // INTERNAL VARIABLES AND NETS reg [8*6:1] clk_num[0:4]; integer scan_chain_length; integer i; integer j; integer k; integer x; integer y; integer l_index; integer gate_count; integer egpp_offset; integer sched_time; integer delay_chain; integer low; integer high; integer initial_delay; integer fbk_phase; integer fbk_delay; integer phase_shift[0:7]; integer last_phase_shift[0:7]; integer m_times_vco_period; integer new_m_times_vco_period; integer refclk_period; integer fbclk_period; integer high_time; integer low_time; integer my_rem; integer tmp_rem; integer rem; integer tmp_vco_per; integer vco_per; integer offset; integer temp_offset; integer cycles_to_lock; integer cycles_to_unlock; integer loop_xplier; integer loop_initial; integer loop_ph; integer cycle_to_adjust; integer total_pull_back; integer pull_back_M; time fbclk_time; time first_fbclk_time; time refclk_time; reg switch_clock; reg [31:0] real_lock_high; reg got_first_refclk; reg got_second_refclk; reg got_first_fbclk; reg refclk_last_value; reg fbclk_last_value; reg inclk_last_value; reg pll_is_locked; reg locked_tmp; reg areset_last_value; reg pfdena_last_value; reg inclk_out_of_range; reg schedule_vco_last_value; // Test bypass lock detect reg pfd_locked; integer cycles_pfd_low, cycles_pfd_high; reg gate_out; reg vco_val; reg [31:0] m_initial_val; reg [31:0] m_val[0:1]; reg [31:0] n_val[0:1]; reg [31:0] m_delay; reg [8*6:1] m_mode_val[0:1]; reg [8*6:1] n_mode_val[0:1]; reg [31:0] c_high_val[0:9]; reg [31:0] c_low_val[0:9]; reg [8*6:1] c_mode_val[0:9]; reg [31:0] c_initial_val[0:9]; integer c_ph_val[0:9]; reg [31:0] c_val; // placeholder for c_high,c_low values // VCO Frequency Range control reg vco_over, vco_under; // temporary registers for reprogramming integer c_ph_val_tmp[0:9]; reg [31:0] c_high_val_tmp[0:9]; reg [31:0] c_hval[0:9]; reg [31:0] c_low_val_tmp[0:9]; reg [31:0] c_lval[0:9]; reg [8*6:1] c_mode_val_tmp[0:9]; // hold registers for reprogramming integer c_ph_val_hold[0:9]; reg [31:0] c_high_val_hold[0:9]; reg [31:0] c_low_val_hold[0:9]; reg [8*6:1] c_mode_val_hold[0:9]; // old values reg [31:0] m_val_old[0:1]; reg [31:0] m_val_tmp[0:1]; reg [31:0] n_val_old[0:1]; reg [8*6:1] m_mode_val_old[0:1]; reg [8*6:1] n_mode_val_old[0:1]; reg [31:0] c_high_val_old[0:9]; reg [31:0] c_low_val_old[0:9]; reg [8*6:1] c_mode_val_old[0:9]; integer c_ph_val_old[0:9]; integer m_ph_val_old; integer m_ph_val_tmp; integer cp_curr_old; integer cp_curr_val; integer lfc_old; integer lfc_val; integer vco_cur; integer vco_old; reg [9*8:1] lfr_val; reg [9*8:1] lfr_old; reg [1:2] lfc_val_bit_setting, lfc_val_old_bit_setting; reg vco_val_bit_setting, vco_val_old_bit_setting; reg [3:7] lfr_val_bit_setting, lfr_val_old_bit_setting; reg [14:16] cp_curr_bit_setting, cp_curr_old_bit_setting; // Setting on - display real values // Setting off - display only bits reg pll_reconfig_display_full_setting; reg [7:0] m_hi; reg [7:0] m_lo; reg [7:0] n_hi; reg [7:0] n_lo; // ph tap orig values (POF) integer c_ph_val_orig[0:9]; integer m_ph_val_orig; reg schedule_vco; reg stop_vco; reg inclk_n; reg inclk_man; reg inclk_es; reg [7:0] vco_out; reg [7:0] vco_tap; reg [7:0] vco_out_last_value; reg [7:0] vco_tap_last_value; wire inclk_c0; wire inclk_c1; wire inclk_c2; wire inclk_c3; wire inclk_c4; wire inclk_c0_from_vco; wire inclk_c1_from_vco; wire inclk_c2_from_vco; wire inclk_c3_from_vco; wire inclk_c4_from_vco; wire inclk_m_from_vco; wire inclk_m; wire pfdena_wire; wire [4:0] clk_tmp, clk_out_pfd; wire [4:0] clk_out; wire c0_clk; wire c1_clk; wire c2_clk; wire c3_clk; wire c4_clk; reg first_schedule; reg vco_period_was_phase_adjusted; reg phase_adjust_was_scheduled; wire refclk; wire fbclk; wire pllena_reg; wire test_mode_inclk; // Self Reset wire reset_self; // Clock Switchover reg clk0_is_bad; reg clk1_is_bad; reg inclk0_last_value; reg inclk1_last_value; reg other_clock_value; reg other_clock_last_value; reg primary_clk_is_bad; reg current_clk_is_bad; reg external_switch; reg active_clock; reg got_curr_clk_falling_edge_after_clkswitch; integer clk0_count; integer clk1_count; integer switch_over_count; wire scandataout_tmp; reg scandata_in, scandata_out; // hold scan data in negative-edge triggered ff (on either side on chain) reg scandone_tmp; reg initiate_reconfig; integer quiet_time; integer slowest_clk_old; integer slowest_clk_new; reg reconfig_err; reg error; time scanclk_last_rising_edge; time scanread_active_edge; reg got_first_scanclk; reg got_first_gated_scanclk; reg gated_scanclk; integer scanclk_period; reg scanclk_last_value; wire update_conf_latches; reg update_conf_latches_reg; reg [-1:142] scan_data; reg scanclkena_reg; // register scanclkena on negative edge of scanclk reg c0_rising_edge_transfer_done; reg c1_rising_edge_transfer_done; reg c2_rising_edge_transfer_done; reg c3_rising_edge_transfer_done; reg c4_rising_edge_transfer_done; reg scanread_setup_violation; integer index; integer scanclk_cycles; reg d_msg; integer num_output_cntrs; reg no_warn; // Phase reconfig reg [2:0] phasecounterselect_reg; reg phaseupdown_reg; reg phasestep_reg; integer select_counter; integer phasestep_high_count; reg update_phase; // LOCAL_PARAMETERS_BEGIN parameter SCAN_CHAIN = 144; parameter GPP_SCAN_CHAIN = 234; parameter FAST_SCAN_CHAIN = 180; // primary clk is always inclk0 parameter num_phase_taps = 8; // LOCAL_PARAMETERS_END // internal variables for scaling of multiply_by and divide_by values integer i_clk0_mult_by; integer i_clk0_div_by; integer i_clk1_mult_by; integer i_clk1_div_by; integer i_clk2_mult_by; integer i_clk2_div_by; integer i_clk3_mult_by; integer i_clk3_div_by; integer i_clk4_mult_by; integer i_clk4_div_by; integer i_clk5_mult_by; integer i_clk5_div_by; integer i_clk6_mult_by; integer i_clk6_div_by; integer i_clk7_mult_by; integer i_clk7_div_by; integer i_clk8_mult_by; integer i_clk8_div_by; integer i_clk9_mult_by; integer i_clk9_div_by; integer max_d_value; integer new_multiplier; // internal variables for storing the phase shift number.(used in lvds mode only) integer i_clk0_phase_shift; integer i_clk1_phase_shift; integer i_clk2_phase_shift; integer i_clk3_phase_shift; integer i_clk4_phase_shift; // user to advanced internal signals integer i_m_initial; integer i_m; integer i_n; integer i_c_high[0:9]; integer i_c_low[0:9]; integer i_c_initial[0:9]; integer i_c_ph[0:9]; reg [8*6:1] i_c_mode[0:9]; integer i_vco_min; integer i_vco_max; integer i_vco_min_no_division; integer i_vco_max_no_division; integer i_vco_center; integer i_pfd_min; integer i_pfd_max; integer i_m_ph; integer m_ph_val; reg [8*2:1] i_clk4_counter; reg [8*2:1] i_clk3_counter; reg [8*2:1] i_clk2_counter; reg [8*2:1] i_clk1_counter; reg [8*2:1] i_clk0_counter; integer i_charge_pump_current; integer i_loop_filter_r; integer max_neg_abs; integer output_count; integer new_divisor; integer loop_filter_c_arr[0:3]; integer fpll_loop_filter_c_arr[0:3]; integer charge_pump_curr_arr[0:15]; reg pll_in_test_mode; reg pll_is_in_reset; reg pll_has_just_been_reconfigured; // uppercase to lowercase parameter values reg [8*`WORD_LENGTH:1] l_operation_mode; reg [8*`WORD_LENGTH:1] l_pll_type; reg [8*`WORD_LENGTH:1] l_compensate_clock; reg [8*`WORD_LENGTH:1] l_scan_chain; reg [8*`WORD_LENGTH:1] l_switch_over_type; reg [8*`WORD_LENGTH:1] l_bandwidth_type; reg [8*`WORD_LENGTH:1] l_simulation_type; reg [8*`WORD_LENGTH:1] l_sim_gate_lock_device_behavior; reg [8*`WORD_LENGTH:1] l_vco_frequency_control; reg [8*`WORD_LENGTH:1] l_enable_switch_over_counter; reg [8*`WORD_LENGTH:1] l_self_reset_on_loss_lock; integer current_clock; integer current_clock_man; reg is_fast_pll; reg ic1_use_casc_in; reg ic2_use_casc_in; reg ic3_use_casc_in; reg ic4_use_casc_in; reg init; reg tap0_is_active; real inclk0_period, last_inclk0_period,inclk1_period, last_inclk1_period; real last_inclk0_edge,last_inclk1_edge,diff_percent_period; reg first_inclk0_edge_detect,first_inclk1_edge_detect; specify endspecify // finds the closest integer fraction of a given pair of numerator and denominator. task find_simple_integer_fraction; input numerator; input denominator; input max_denom; output fraction_num; output fraction_div; parameter max_iter = 20; integer numerator; integer denominator; integer max_denom; integer fraction_num; integer fraction_div; integer quotient_array[max_iter-1:0]; integer int_loop_iter; integer int_quot; integer m_value; integer d_value; integer old_m_value; integer swap; integer loop_iter; integer num; integer den; integer i_max_iter; begin loop_iter = 0; num = (numerator == 0) ? 1 : numerator; den = (denominator == 0) ? 1 : denominator; i_max_iter = max_iter; while (loop_iter < i_max_iter) begin int_quot = num / den; quotient_array[loop_iter] = int_quot; num = num - (den*int_quot); loop_iter=loop_iter+1; if ((num == 0) || (max_denom != -1) || (loop_iter == i_max_iter)) begin // calculate the numerator and denominator if there is a restriction on the // max denom value or if the loop is ending m_value = 0; d_value = 1; // get the rounded value at this stage for the remaining fraction if (den != 0) begin m_value = (2*num/den); end // calculate the fraction numerator and denominator at this stage for (int_loop_iter = loop_iter-1; int_loop_iter >= 0; int_loop_iter=int_loop_iter-1) begin if (m_value == 0) begin m_value = quotient_array[int_loop_iter]; d_value = 1; end else begin old_m_value = m_value; m_value = quotient_array[int_loop_iter]*m_value + d_value; d_value = old_m_value; end end // if the denominator is less than the maximum denom_value or if there is no restriction save it if ((d_value <= max_denom) || (max_denom == -1)) begin fraction_num = m_value; fraction_div = d_value; end // end the loop if the denomitor has overflown or the numerator is zero (no remainder during this round) if (((d_value > max_denom) && (max_denom != -1)) || (num == 0)) begin i_max_iter = loop_iter; end end // swap the numerator and denominator for the next round swap = den; den = num; num = swap; end end endtask // find_simple_integer_fraction // get the absolute value function integer abs; input value; integer value; begin if (value < 0) abs = value * -1; else abs = value; end endfunction // find twice the period of the slowest clock function integer slowest_clk; input C0, C0_mode, C1, C1_mode, C2, C2_mode, C3, C3_mode, C4, C4_mode, C5, C5_mode, C6, C6_mode, C7, C7_mode, C8, C8_mode, C9, C9_mode, refclk, m_mod; integer C0, C1, C2, C3, C4, C5, C6, C7, C8, C9; reg [8*6:1] C0_mode, C1_mode, C2_mode, C3_mode, C4_mode, C5_mode, C6_mode, C7_mode, C8_mode, C9_mode; integer refclk; reg [31:0] m_mod; integer max_modulus; begin max_modulus = 1; if (C0_mode != "bypass" && C0_mode != " off") max_modulus = C0; if (C1 > max_modulus && C1_mode != "bypass" && C1_mode != " off") max_modulus = C1; if (C2 > max_modulus && C2_mode != "bypass" && C2_mode != " off") max_modulus = C2; if (C3 > max_modulus && C3_mode != "bypass" && C3_mode != " off") max_modulus = C3; if (C4 > max_modulus && C4_mode != "bypass" && C4_mode != " off") max_modulus = C4; if (C5 > max_modulus && C5_mode != "bypass" && C5_mode != " off") max_modulus = C5; if (C6 > max_modulus && C6_mode != "bypass" && C6_mode != " off") max_modulus = C6; if (C7 > max_modulus && C7_mode != "bypass" && C7_mode != " off") max_modulus = C7; if (C8 > max_modulus && C8_mode != "bypass" && C8_mode != " off") max_modulus = C8; if (C9 > max_modulus && C9_mode != "bypass" && C9_mode != " off") max_modulus = C9; slowest_clk = (refclk * max_modulus *2 / m_mod); end endfunction // count the number of digits in the given integer function integer count_digit; input X; integer X; integer count, result; begin count = 0; result = X; while (result != 0) begin result = (result / 10); count = count + 1; end count_digit = count; end endfunction // reduce the given huge number(X) to Y significant digits function integer scale_num; input X, Y; integer X, Y; integer count; integer fac_ten, lc; begin fac_ten = 1; count = count_digit(X); for (lc = 0; lc < (count-Y); lc = lc + 1) fac_ten = fac_ten * 10; scale_num = (X / fac_ten); end endfunction // find the greatest common denominator of X and Y function integer gcd; input X,Y; integer X,Y; integer L, S, R, G; begin if (X < Y) // find which is smaller. begin S = X; L = Y; end else begin S = Y; L = X; end R = S; while ( R > 1) begin S = L; L = R; R = S % L; // divide bigger number by smaller. // remainder becomes smaller number. end if (R == 0) // if evenly divisible then L is gcd else it is 1. G = L; else G = R; gcd = G; end endfunction // find the least common multiple of A1 to A10 function integer lcm; input A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, P; integer A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, P; integer M1, M2, M3, M4, M5 , M6, M7, M8, M9, R; begin M1 = (A1 * A2)/gcd(A1, A2); M2 = (M1 * A3)/gcd(M1, A3); M3 = (M2 * A4)/gcd(M2, A4); M4 = (M3 * A5)/gcd(M3, A5); M5 = (M4 * A6)/gcd(M4, A6); M6 = (M5 * A7)/gcd(M5, A7); M7 = (M6 * A8)/gcd(M6, A8); M8 = (M7 * A9)/gcd(M7, A9); M9 = (M8 * A10)/gcd(M8, A10); if (M9 < 3) R = 10; else if ((M9 <= 10) && (M9 >= 3)) R = 4 * M9; else if (M9 > 1000) R = scale_num(M9, 3); else R = M9; lcm = R; end endfunction // find the M and N values for Manual phase based on the following 5 criterias: // 1. The PFD frequency (i.e. Fin / N) must be in the range 5 MHz to 720 MHz // 2. The VCO frequency (i.e. Fin * M / N) must be in the range 300 MHz to 1300 MHz // 3. M is less than 512 // 4. N is less than 512 // 5. It's the smallest M/N which satisfies all the above constraints, and is within 2ps // of the desired vco-phase-shift-step task find_m_and_n_4_manual_phase; input inclock_period; input vco_phase_shift_step; input clk0_mult, clk1_mult, clk2_mult, clk3_mult, clk4_mult; input clk5_mult, clk6_mult, clk7_mult, clk8_mult, clk9_mult; input clk0_div, clk1_div, clk2_div, clk3_div, clk4_div; input clk5_div, clk6_div, clk7_div, clk8_div, clk9_div; input clk0_used, clk1_used, clk2_used, clk3_used, clk4_used; input clk5_used, clk6_used, clk7_used, clk8_used, clk9_used; output m; output n; parameter max_m = 511; parameter max_n = 511; parameter max_pfd = 720; parameter min_pfd = 5; parameter max_vco = 1600; // max vco frequency. (in mHz) parameter min_vco = 300; // min vco frequency. (in mHz) parameter max_offset = 0.004; reg[160:1] clk0_used, clk1_used, clk2_used, clk3_used, clk4_used; reg[160:1] clk5_used, clk6_used, clk7_used, clk8_used, clk9_used; integer inclock_period; integer vco_phase_shift_step; integer clk0_mult, clk1_mult, clk2_mult, clk3_mult, clk4_mult; integer clk5_mult, clk6_mult, clk7_mult, clk8_mult, clk9_mult; integer clk0_div, clk1_div, clk2_div, clk3_div, clk4_div; integer clk5_div, clk6_div, clk7_div, clk8_div, clk9_div; integer m; integer n; integer pre_m; integer pre_n; integer m_out; integer n_out; integer closest_vco_step_value; integer vco_period; integer pfd_freq; integer vco_freq; integer vco_ps_step_value; real clk0_div_factor_real; real clk1_div_factor_real; real clk2_div_factor_real; real clk3_div_factor_real; real clk4_div_factor_real; real clk5_div_factor_real; real clk6_div_factor_real; real clk7_div_factor_real; real clk8_div_factor_real; real clk9_div_factor_real; real clk0_div_factor_diff; real clk1_div_factor_diff; real clk2_div_factor_diff; real clk3_div_factor_diff; real clk4_div_factor_diff; real clk5_div_factor_diff; real clk6_div_factor_diff; real clk7_div_factor_diff; real clk8_div_factor_diff; real clk9_div_factor_diff; integer clk0_div_factor_int; integer clk1_div_factor_int; integer clk2_div_factor_int; integer clk3_div_factor_int; integer clk4_div_factor_int; integer clk5_div_factor_int; integer clk6_div_factor_int; integer clk7_div_factor_int; integer clk8_div_factor_int; integer clk9_div_factor_int; begin vco_period = vco_phase_shift_step * 8; pre_m = 0; pre_n = 0; closest_vco_step_value = 0; begin : LOOP_1 for (n_out = 1; n_out < max_n; n_out = n_out +1) begin for (m_out = 1; m_out < max_m; m_out = m_out +1) begin clk0_div_factor_real = (clk0_div * m_out * 1.0 ) / (clk0_mult * n_out); clk1_div_factor_real = (clk1_div * m_out * 1.0) / (clk1_mult * n_out); clk2_div_factor_real = (clk2_div * m_out * 1.0) / (clk2_mult * n_out); clk3_div_factor_real = (clk3_div * m_out * 1.0) / (clk3_mult * n_out); clk4_div_factor_real = (clk4_div * m_out * 1.0) / (clk4_mult * n_out); clk5_div_factor_real = (clk5_div * m_out * 1.0) / (clk5_mult * n_out); clk6_div_factor_real = (clk6_div * m_out * 1.0) / (clk6_mult * n_out); clk7_div_factor_real = (clk7_div * m_out * 1.0) / (clk7_mult * n_out); clk8_div_factor_real = (clk8_div * m_out * 1.0) / (clk8_mult * n_out); clk9_div_factor_real = (clk9_div * m_out * 1.0) / (clk9_mult * n_out); clk0_div_factor_int = clk0_div_factor_real; clk1_div_factor_int = clk1_div_factor_real; clk2_div_factor_int = clk2_div_factor_real; clk3_div_factor_int = clk3_div_factor_real; clk4_div_factor_int = clk4_div_factor_real; clk5_div_factor_int = clk5_div_factor_real; clk6_div_factor_int = clk6_div_factor_real; clk7_div_factor_int = clk7_div_factor_real; clk8_div_factor_int = clk8_div_factor_real; clk9_div_factor_int = clk9_div_factor_real; clk0_div_factor_diff = (clk0_div_factor_real - clk0_div_factor_int < 0) ? (clk0_div_factor_real - clk0_div_factor_int) * -1.0 : clk0_div_factor_real - clk0_div_factor_int; clk1_div_factor_diff = (clk1_div_factor_real - clk1_div_factor_int < 0) ? (clk1_div_factor_real - clk1_div_factor_int) * -1.0 : clk1_div_factor_real - clk1_div_factor_int; clk2_div_factor_diff = (clk2_div_factor_real - clk2_div_factor_int < 0) ? (clk2_div_factor_real - clk2_div_factor_int) * -1.0 : clk2_div_factor_real - clk2_div_factor_int; clk3_div_factor_diff = (clk3_div_factor_real - clk3_div_factor_int < 0) ? (clk3_div_factor_real - clk3_div_factor_int) * -1.0 : clk3_div_factor_real - clk3_div_factor_int; clk4_div_factor_diff = (clk4_div_factor_real - clk4_div_factor_int < 0) ? (clk4_div_factor_real - clk4_div_factor_int) * -1.0 : clk4_div_factor_real - clk4_div_factor_int; clk5_div_factor_diff = (clk5_div_factor_real - clk5_div_factor_int < 0) ? (clk5_div_factor_real - clk5_div_factor_int) * -1.0 : clk5_div_factor_real - clk5_div_factor_int; clk6_div_factor_diff = (clk6_div_factor_real - clk6_div_factor_int < 0) ? (clk6_div_factor_real - clk6_div_factor_int) * -1.0 : clk6_div_factor_real - clk6_div_factor_int; clk7_div_factor_diff = (clk7_div_factor_real - clk7_div_factor_int < 0) ? (clk7_div_factor_real - clk7_div_factor_int) * -1.0 : clk7_div_factor_real - clk7_div_factor_int; clk8_div_factor_diff = (clk8_div_factor_real - clk8_div_factor_int < 0) ? (clk8_div_factor_real - clk8_div_factor_int) * -1.0 : clk8_div_factor_real - clk8_div_factor_int; clk9_div_factor_diff = (clk9_div_factor_real - clk9_div_factor_int < 0) ? (clk9_div_factor_real - clk9_div_factor_int) * -1.0 : clk9_div_factor_real - clk9_div_factor_int; if (((clk0_div_factor_diff < max_offset) || (clk0_used == "unused")) && ((clk1_div_factor_diff < max_offset) || (clk1_used == "unused")) && ((clk2_div_factor_diff < max_offset) || (clk2_used == "unused")) && ((clk3_div_factor_diff < max_offset) || (clk3_used == "unused")) && ((clk4_div_factor_diff < max_offset) || (clk4_used == "unused")) && ((clk5_div_factor_diff < max_offset) || (clk5_used == "unused")) && ((clk6_div_factor_diff < max_offset) || (clk6_used == "unused")) && ((clk7_div_factor_diff < max_offset) || (clk7_used == "unused")) && ((clk8_div_factor_diff < max_offset) || (clk8_used == "unused")) && ((clk9_div_factor_diff < max_offset) || (clk9_used == "unused")) ) begin if ((m_out != 0) && (n_out != 0)) begin pfd_freq = 1000000 / (inclock_period * n_out); vco_freq = (1000000 * m_out) / (inclock_period * n_out); vco_ps_step_value = (inclock_period * n_out) / (8 * m_out); if ( (m_out < max_m) && (n_out < max_n) && (pfd_freq >= min_pfd) && (pfd_freq <= max_pfd) && (vco_freq >= min_vco) && (vco_freq <= max_vco) ) begin if (abs(vco_ps_step_value - vco_phase_shift_step) <= 2) begin pre_m = m_out; pre_n = n_out; disable LOOP_1; end else begin if ((closest_vco_step_value == 0) || (abs(vco_ps_step_value - vco_phase_shift_step) < abs(closest_vco_step_value - vco_phase_shift_step))) begin pre_m = m_out; pre_n = n_out; closest_vco_step_value = vco_ps_step_value; end end end end end end end end if ((pre_m != 0) && (pre_n != 0)) begin find_simple_integer_fraction(pre_m, pre_n, max_n, m, n); end else begin n = 1; m = lcm (clk0_mult, clk1_mult, clk2_mult, clk3_mult, clk4_mult, clk5_mult, clk6_mult, clk7_mult, clk8_mult, clk9_mult, inclock_period); end end endtask // find_m_and_n_4_manual_phase // find the factor of division of the output clock frequency // compared to the VCO function integer output_counter_value; input clk_divide, clk_mult, M, N; integer clk_divide, clk_mult, M, N; real r; integer r_int; begin r = (clk_divide * M * 1.0)/(clk_mult * N); r_int = r; output_counter_value = r_int; end endfunction // find the mode of each of the PLL counters - bypass, even or odd function [8*6:1] counter_mode; input duty_cycle; input output_counter_value; integer duty_cycle; integer output_counter_value; integer half_cycle_high; reg [8*6:1] R; begin half_cycle_high = (2*duty_cycle*output_counter_value)/100.0; if (output_counter_value == 1) R = "bypass"; else if ((half_cycle_high % 2) == 0) R = " even"; else R = " odd"; counter_mode = R; end endfunction // find the number of VCO clock cycles to hold the output clock high function integer counter_high; input output_counter_value, duty_cycle; integer output_counter_value, duty_cycle; integer half_cycle_high; integer tmp_counter_high; integer mode; begin half_cycle_high = (2*duty_cycle*output_counter_value)/100.0; mode = ((half_cycle_high % 2) == 0); tmp_counter_high = half_cycle_high/2; counter_high = tmp_counter_high + !mode; end endfunction // find the number of VCO clock cycles to hold the output clock low function integer counter_low; input output_counter_value, duty_cycle; integer output_counter_value, duty_cycle, counter_h; integer half_cycle_high; integer mode; integer tmp_counter_high; begin half_cycle_high = (2*duty_cycle*output_counter_value)/100.0; mode = ((half_cycle_high % 2) == 0); tmp_counter_high = half_cycle_high/2; counter_h = tmp_counter_high + !mode; counter_low = output_counter_value - counter_h; end endfunction // find the smallest time delay amongst t1 to t10 function integer mintimedelay; input t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; integer t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; integer m1,m2,m3,m4,m5,m6,m7,m8,m9; begin if (t1 < t2) m1 = t1; else m1 = t2; if (m1 < t3) m2 = m1; else m2 = t3; if (m2 < t4) m3 = m2; else m3 = t4; if (m3 < t5) m4 = m3; else m4 = t5; if (m4 < t6) m5 = m4; else m5 = t6; if (m5 < t7) m6 = m5; else m6 = t7; if (m6 < t8) m7 = m6; else m7 = t8; if (m7 < t9) m8 = m7; else m8 = t9; if (m8 < t10) m9 = m8; else m9 = t10; if (m9 > 0) mintimedelay = m9; else mintimedelay = 0; end endfunction // find the numerically largest negative number, and return its absolute value function integer maxnegabs; input t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; integer t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; integer m1,m2,m3,m4,m5,m6,m7,m8,m9; begin if (t1 < t2) m1 = t1; else m1 = t2; if (m1 < t3) m2 = m1; else m2 = t3; if (m2 < t4) m3 = m2; else m3 = t4; if (m3 < t5) m4 = m3; else m4 = t5; if (m4 < t6) m5 = m4; else m5 = t6; if (m5 < t7) m6 = m5; else m6 = t7; if (m6 < t8) m7 = m6; else m7 = t8; if (m7 < t9) m8 = m7; else m8 = t9; if (m8 < t10) m9 = m8; else m9 = t10; maxnegabs = (m9 < 0) ? 0 - m9 : 0; end endfunction // adjust the given tap_phase by adding the largest negative number (ph_base) function integer ph_adjust; input tap_phase, ph_base; integer tap_phase, ph_base; begin ph_adjust = tap_phase + ph_base; end endfunction // find the number of VCO clock cycles to wait initially before the first // rising edge of the output clock function integer counter_initial; input tap_phase, m, n; integer tap_phase, m, n, phase; begin if (tap_phase < 0) tap_phase = 0 - tap_phase; // adding 0.5 for rounding correction (required in order to round // to the nearest integer instead of truncating) phase = ((tap_phase * m) / (360.0 * n)) + 0.6; counter_initial = phase; end endfunction // find which VCO phase tap to align the rising edge of the output clock to function integer counter_ph; input tap_phase; input m,n; integer m,n, phase; integer tap_phase; begin // adding 0.5 for rounding correction phase = (tap_phase * m / n) + 0.5; counter_ph = (phase % 360) / 45.0; if (counter_ph == 8) counter_ph = 0; end endfunction // convert the given string to length 6 by padding with spaces function [8*6:1] translate_string; input [8*6:1] mode; reg [8*6:1] new_mode; begin if (mode == "bypass") new_mode = "bypass"; else if (mode == "even") new_mode = " even"; else if (mode == "odd") new_mode = " odd"; translate_string = new_mode; end endfunction // convert string to integer with sign function integer str2int; input [8*16:1] s; reg [8*16:1] reg_s; reg [8:1] digit; reg [8:1] tmp; integer m, magnitude; integer sign; begin sign = 1; magnitude = 0; reg_s = s; for (m=1; m<=16; m=m+1) begin tmp = reg_s[128:121]; digit = tmp & 8'b00001111; reg_s = reg_s << 8; // Accumulate ascii digits 0-9 only. if ((tmp>=48) && (tmp<=57)) magnitude = (magnitude * 10) + digit; if (tmp == 45) sign = -1; // Found a '-' character, i.e. number is negative. end str2int = sign*magnitude; end endfunction // this is for cycloneive lvds only // convert phase delay to integer function integer get_int_phase_shift; input [8*16:1] s; input i_phase_shift; integer i_phase_shift; begin if (i_phase_shift != 0) begin get_int_phase_shift = i_phase_shift; end else begin get_int_phase_shift = str2int(s); end end endfunction // calculate the given phase shift (in ps) in terms of degrees function integer get_phase_degree; input phase_shift; integer phase_shift, result; begin result = (phase_shift * 360) / inclk0_freq; // this is to round up the calculation result if ( result > 0 ) result = result + 1; else if ( result < 0 ) result = result - 1; else result = 0; // assign the rounded up result get_phase_degree = result; end endfunction // convert uppercase parameter values to lowercase // assumes that the maximum character length of a parameter is 18 function [8*`WORD_LENGTH:1] alpha_tolower; input [8*`WORD_LENGTH:1] given_string; reg [8*`WORD_LENGTH:1] return_string; reg [8*`WORD_LENGTH:1] reg_string; reg [8:1] tmp; reg [8:1] conv_char; integer byte_count; begin return_string = " "; // initialise strings to spaces conv_char = " "; reg_string = given_string; for (byte_count = `WORD_LENGTH; byte_count >= 1; byte_count = byte_count - 1) begin tmp = reg_string[8*`WORD_LENGTH:(8*(`WORD_LENGTH-1)+1)]; reg_string = reg_string << 8; if ((tmp >= 65) && (tmp <= 90)) // ASCII number of 'A' is 65, 'Z' is 90 begin conv_char = tmp + 32; // 32 is the difference in the position of 'A' and 'a' in the ASCII char set return_string = {return_string, conv_char}; end else return_string = {return_string, tmp}; end alpha_tolower = return_string; end endfunction function integer display_msg; input [8*2:1] cntr_name; input msg_code; integer msg_code; begin if (msg_code == 1) $display ("Warning : %s counter switched from BYPASS mode to enabled. PLL may lose lock.", cntr_name); else if (msg_code == 2) $display ("Warning : Illegal 1 value for %s counter. Instead, the %s counter should be BYPASSED. Reconfiguration may not work.", cntr_name, cntr_name); else if (msg_code == 3) $display ("Warning : Illegal value for counter %s in BYPASS mode. The LSB of the counter should be set to 0 in order to operate the counter in BYPASS mode. Reconfiguration may not work.", cntr_name); else if (msg_code == 4) $display ("Warning : %s counter switched from enabled to BYPASS mode. PLL may lose lock.", cntr_name); $display ("Time: %0t Instance: %m", $time); display_msg = 1; end endfunction initial begin scandata_out = 1'b0; first_inclk0_edge_detect = 1'b0; first_inclk1_edge_detect = 1'b0; pll_reconfig_display_full_setting = 1'b0; initiate_reconfig = 1'b0; switch_over_count = 0; // convert string parameter values from uppercase to lowercase, // as expected in this model l_operation_mode = alpha_tolower(operation_mode); l_pll_type = alpha_tolower(pll_type); l_compensate_clock = alpha_tolower(compensate_clock); l_switch_over_type = alpha_tolower(switch_over_type); l_bandwidth_type = alpha_tolower(bandwidth_type); l_simulation_type = alpha_tolower(simulation_type); l_sim_gate_lock_device_behavior = alpha_tolower(sim_gate_lock_device_behavior); l_vco_frequency_control = alpha_tolower(vco_frequency_control); l_enable_switch_over_counter = alpha_tolower(enable_switch_over_counter); l_self_reset_on_loss_lock = alpha_tolower(self_reset_on_loss_lock); real_lock_high = (l_sim_gate_lock_device_behavior == "on") ? lock_high : 0; // initialize charge_pump_current, and loop_filter tables loop_filter_c_arr[0] = 0; loop_filter_c_arr[1] = 0; loop_filter_c_arr[2] = 0; loop_filter_c_arr[3] = 0; fpll_loop_filter_c_arr[0] = 0; fpll_loop_filter_c_arr[1] = 0; fpll_loop_filter_c_arr[2] = 0; fpll_loop_filter_c_arr[3] = 0; charge_pump_curr_arr[0] = 0; charge_pump_curr_arr[1] = 0; charge_pump_curr_arr[2] = 0; charge_pump_curr_arr[3] = 0; charge_pump_curr_arr[4] = 0; charge_pump_curr_arr[5] = 0; charge_pump_curr_arr[6] = 0; charge_pump_curr_arr[7] = 0; charge_pump_curr_arr[8] = 0; charge_pump_curr_arr[9] = 0; charge_pump_curr_arr[10] = 0; charge_pump_curr_arr[11] = 0; charge_pump_curr_arr[12] = 0; charge_pump_curr_arr[13] = 0; charge_pump_curr_arr[14] = 0; charge_pump_curr_arr[15] = 0; i_vco_max = vco_max; i_vco_min = vco_min; if(vco_post_scale == 1) begin i_vco_max_no_division = vco_max * 2; i_vco_min_no_division = vco_min * 2; end else begin i_vco_max_no_division = vco_max; i_vco_min_no_division = vco_min; end if (m == 0) begin i_clk4_counter = "c4" ; i_clk3_counter = "c3" ; i_clk2_counter = "c2" ; i_clk1_counter = "c1" ; i_clk0_counter = "c0" ; end else begin i_clk4_counter = alpha_tolower(clk4_counter); i_clk3_counter = alpha_tolower(clk3_counter); i_clk2_counter = alpha_tolower(clk2_counter); i_clk1_counter = alpha_tolower(clk1_counter); i_clk0_counter = alpha_tolower(clk0_counter); end if (m == 0) begin // set the limit of the divide_by value that can be returned by // the following function. max_d_value = 500; // scale down the multiply_by and divide_by values provided by the design // before attempting to use them in the calculations below find_simple_integer_fraction(clk0_multiply_by, clk0_divide_by, max_d_value, i_clk0_mult_by, i_clk0_div_by); find_simple_integer_fraction(clk1_multiply_by, clk1_divide_by, max_d_value, i_clk1_mult_by, i_clk1_div_by); find_simple_integer_fraction(clk2_multiply_by, clk2_divide_by, max_d_value, i_clk2_mult_by, i_clk2_div_by); find_simple_integer_fraction(clk3_multiply_by, clk3_divide_by, max_d_value, i_clk3_mult_by, i_clk3_div_by); find_simple_integer_fraction(clk4_multiply_by, clk4_divide_by, max_d_value, i_clk4_mult_by, i_clk4_div_by); // convert user parameters to advanced if (l_vco_frequency_control == "manual_phase") begin find_m_and_n_4_manual_phase(inclk0_freq, vco_phase_shift_step, i_clk0_mult_by, i_clk1_mult_by, i_clk2_mult_by, i_clk3_mult_by,i_clk4_mult_by, 1, 1, 1, 1, 1, i_clk0_div_by, i_clk1_div_by, i_clk2_div_by, i_clk3_div_by,i_clk4_div_by, 1, 1, 1, 1, 1, clk0_counter, clk1_counter, clk2_counter, clk3_counter,clk4_counter, "unused", "unused", "unused", "unused", "unused", i_m, i_n); end else if (((l_pll_type == "fast") || (l_pll_type == "lvds") || (l_pll_type == "left_right")) && (vco_multiply_by != 0) && (vco_divide_by != 0)) begin i_n = vco_divide_by; i_m = vco_multiply_by; end else begin i_n = 1; if (((l_pll_type == "fast") || (l_pll_type == "left_right")) && (l_compensate_clock == "lvdsclk")) i_m = i_clk0_mult_by; else i_m = lcm (i_clk0_mult_by, i_clk1_mult_by, i_clk2_mult_by, i_clk3_mult_by,i_clk4_mult_by, 1, 1, 1, 1, 1, inclk0_freq); end i_c_high[0] = counter_high (output_counter_value(i_clk0_div_by, i_clk0_mult_by, i_m, i_n), clk0_duty_cycle); i_c_high[1] = counter_high (output_counter_value(i_clk1_div_by, i_clk1_mult_by, i_m, i_n), clk1_duty_cycle); i_c_high[2] = counter_high (output_counter_value(i_clk2_div_by, i_clk2_mult_by, i_m, i_n), clk2_duty_cycle); i_c_high[3] = counter_high (output_counter_value(i_clk3_div_by, i_clk3_mult_by, i_m, i_n), clk3_duty_cycle); i_c_high[4] = counter_high (output_counter_value(i_clk4_div_by, i_clk4_mult_by, i_m, i_n), clk4_duty_cycle); i_c_low[0] = counter_low (output_counter_value(i_clk0_div_by, i_clk0_mult_by, i_m, i_n), clk0_duty_cycle); i_c_low[1] = counter_low (output_counter_value(i_clk1_div_by, i_clk1_mult_by, i_m, i_n), clk1_duty_cycle); i_c_low[2] = counter_low (output_counter_value(i_clk2_div_by, i_clk2_mult_by, i_m, i_n), clk2_duty_cycle); i_c_low[3] = counter_low (output_counter_value(i_clk3_div_by, i_clk3_mult_by, i_m, i_n), clk3_duty_cycle); i_c_low[4] = counter_low (output_counter_value(i_clk4_div_by, i_clk4_mult_by, i_m, i_n), clk4_duty_cycle); if (l_pll_type == "flvds") begin // Need to readjust phase shift values when the clock multiply value has been readjusted. new_multiplier = clk0_multiply_by / i_clk0_mult_by; i_clk0_phase_shift = (clk0_phase_shift_num * new_multiplier); i_clk1_phase_shift = (clk1_phase_shift_num * new_multiplier); i_clk2_phase_shift = (clk2_phase_shift_num * new_multiplier); i_clk3_phase_shift = 0; i_clk4_phase_shift = 0; end else begin i_clk0_phase_shift = get_int_phase_shift(clk0_phase_shift, clk0_phase_shift_num); i_clk1_phase_shift = get_int_phase_shift(clk1_phase_shift, clk1_phase_shift_num); i_clk2_phase_shift = get_int_phase_shift(clk2_phase_shift, clk2_phase_shift_num); i_clk3_phase_shift = get_int_phase_shift(clk3_phase_shift, clk3_phase_shift_num); i_clk4_phase_shift = get_int_phase_shift(clk4_phase_shift, clk4_phase_shift_num); end max_neg_abs = maxnegabs ( i_clk0_phase_shift, i_clk1_phase_shift, i_clk2_phase_shift, i_clk3_phase_shift, i_clk4_phase_shift, 0, 0, 0, 0, 0 ); i_c_initial[0] = counter_initial(get_phase_degree(ph_adjust(i_clk0_phase_shift, max_neg_abs)), i_m, i_n); i_c_initial[1] = counter_initial(get_phase_degree(ph_adjust(i_clk1_phase_shift, max_neg_abs)), i_m, i_n); i_c_initial[2] = counter_initial(get_phase_degree(ph_adjust(i_clk2_phase_shift, max_neg_abs)), i_m, i_n); i_c_initial[3] = counter_initial(get_phase_degree(ph_adjust(i_clk3_phase_shift, max_neg_abs)), i_m, i_n); i_c_initial[4] = counter_initial(get_phase_degree(ph_adjust(i_clk4_phase_shift, max_neg_abs)), i_m, i_n); i_c_mode[0] = counter_mode(clk0_duty_cycle,output_counter_value(i_clk0_div_by, i_clk0_mult_by, i_m, i_n)); i_c_mode[1] = counter_mode(clk1_duty_cycle,output_counter_value(i_clk1_div_by, i_clk1_mult_by, i_m, i_n)); i_c_mode[2] = counter_mode(clk2_duty_cycle,output_counter_value(i_clk2_div_by, i_clk2_mult_by, i_m, i_n)); i_c_mode[3] = counter_mode(clk3_duty_cycle,output_counter_value(i_clk3_div_by, i_clk3_mult_by, i_m, i_n)); i_c_mode[4] = counter_mode(clk4_duty_cycle,output_counter_value(i_clk4_div_by, i_clk4_mult_by, i_m, i_n)); i_m_ph = counter_ph(get_phase_degree(max_neg_abs), i_m, i_n); i_m_initial = counter_initial(get_phase_degree(max_neg_abs), i_m, i_n); i_c_ph[0] = counter_ph(get_phase_degree(ph_adjust(i_clk0_phase_shift, max_neg_abs)), i_m, i_n); i_c_ph[1] = counter_ph(get_phase_degree(ph_adjust(i_clk1_phase_shift, max_neg_abs)), i_m, i_n); i_c_ph[2] = counter_ph(get_phase_degree(ph_adjust(i_clk2_phase_shift, max_neg_abs)), i_m, i_n); i_c_ph[3] = counter_ph(get_phase_degree(ph_adjust(i_clk3_phase_shift,max_neg_abs)), i_m, i_n); i_c_ph[4] = counter_ph(get_phase_degree(ph_adjust(i_clk4_phase_shift,max_neg_abs)), i_m, i_n); end else begin // m != 0 i_n = n; i_m = m; i_c_high[0] = c0_high; i_c_high[1] = c1_high; i_c_high[2] = c2_high; i_c_high[3] = c3_high; i_c_high[4] = c4_high; i_c_low[0] = c0_low; i_c_low[1] = c1_low; i_c_low[2] = c2_low; i_c_low[3] = c3_low; i_c_low[4] = c4_low; i_c_initial[0] = c0_initial; i_c_initial[1] = c1_initial; i_c_initial[2] = c2_initial; i_c_initial[3] = c3_initial; i_c_initial[4] = c4_initial; i_c_mode[0] = translate_string(alpha_tolower(c0_mode)); i_c_mode[1] = translate_string(alpha_tolower(c1_mode)); i_c_mode[2] = translate_string(alpha_tolower(c2_mode)); i_c_mode[3] = translate_string(alpha_tolower(c3_mode)); i_c_mode[4] = translate_string(alpha_tolower(c4_mode)); i_c_ph[0] = c0_ph; i_c_ph[1] = c1_ph; i_c_ph[2] = c2_ph; i_c_ph[3] = c3_ph; i_c_ph[4] = c4_ph; i_m_ph = m_ph; // default i_m_initial = m_initial; end // user to advanced conversion switch_clock = 1'b0; refclk_period = inclk0_freq * i_n; m_times_vco_period = refclk_period; new_m_times_vco_period = refclk_period; fbclk_period = 0; high_time = 0; low_time = 0; schedule_vco = 0; vco_out[7:0] = 8'b0; vco_tap[7:0] = 8'b0; fbclk_last_value = 0; offset = 0; temp_offset = 0; got_first_refclk = 0; got_first_fbclk = 0; fbclk_time = 0; first_fbclk_time = 0; refclk_time = 0; first_schedule = 1; sched_time = 0; vco_val = 0; gate_count = 0; gate_out = 0; initial_delay = 0; fbk_phase = 0; for (i = 0; i <= 7; i = i + 1) begin phase_shift[i] = 0; last_phase_shift[i] = 0; end fbk_delay = 0; inclk_n = 0; inclk_es = 0; inclk_man = 0; cycle_to_adjust = 0; m_delay = 0; total_pull_back = 0; pull_back_M = 0; vco_period_was_phase_adjusted = 0; phase_adjust_was_scheduled = 0; inclk_out_of_range = 0; scandone_tmp = 1'b0; schedule_vco_last_value = 0; scan_chain_length = SCAN_CHAIN; num_output_cntrs = 5; phasestep_high_count = 0; update_phase = 0; // set initial values for counter parameters m_initial_val = i_m_initial; m_val[0] = i_m; n_val[0] = i_n; m_ph_val = i_m_ph; m_ph_val_orig = i_m_ph; m_ph_val_tmp = i_m_ph; m_val_tmp[0] = i_m; if (m_val[0] == 1) m_mode_val[0] = "bypass"; else m_mode_val[0] = ""; if (m_val[1] == 1) m_mode_val[1] = "bypass"; if (n_val[0] == 1) n_mode_val[0] = "bypass"; if (n_val[1] == 1) n_mode_val[1] = "bypass"; for (i = 0; i < 10; i=i+1) begin c_high_val[i] = i_c_high[i]; c_low_val[i] = i_c_low[i]; c_initial_val[i] = i_c_initial[i]; c_mode_val[i] = i_c_mode[i]; c_ph_val[i] = i_c_ph[i]; c_high_val_tmp[i] = i_c_high[i]; c_hval[i] = i_c_high[i]; c_low_val_tmp[i] = i_c_low[i]; c_lval[i] = i_c_low[i]; if (c_mode_val[i] == "bypass") begin if (l_pll_type == "fast" || l_pll_type == "lvds" || l_pll_type == "left_right") begin c_high_val[i] = 5'b10000; c_low_val[i] = 5'b10000; c_high_val_tmp[i] = 5'b10000; c_low_val_tmp[i] = 5'b10000; end else begin c_high_val[i] = 9'b100000000; c_low_val[i] = 9'b100000000; c_high_val_tmp[i] = 9'b100000000; c_low_val_tmp[i] = 9'b100000000; end end c_mode_val_tmp[i] = i_c_mode[i]; c_ph_val_tmp[i] = i_c_ph[i]; c_ph_val_orig[i] = i_c_ph[i]; c_high_val_hold[i] = i_c_high[i]; c_low_val_hold[i] = i_c_low[i]; c_mode_val_hold[i] = i_c_mode[i]; end lfc_val = loop_filter_c; lfr_val = loop_filter_r; cp_curr_val = charge_pump_current; vco_cur = vco_post_scale; i = 0; j = 0; inclk_last_value = 0; // initialize clkswitch variables clk0_is_bad = 0; clk1_is_bad = 0; inclk0_last_value = 0; inclk1_last_value = 0; other_clock_value = 0; other_clock_last_value = 0; primary_clk_is_bad = 0; current_clk_is_bad = 0; external_switch = 0; current_clock = 0; current_clock_man = 0; active_clock = 0; // primary_clk is always inclk0 if (l_pll_type == "fast" || (l_pll_type == "left_right")) l_switch_over_type = "manual"; if (l_switch_over_type == "manual" && clkswitch === 1'b1) begin current_clock_man = 1; active_clock = 1; end got_curr_clk_falling_edge_after_clkswitch = 0; clk0_count = 0; clk1_count = 0; // initialize reconfiguration variables // quiet_time quiet_time = slowest_clk ( c_high_val[0]+c_low_val[0], c_mode_val[0], c_high_val[1]+c_low_val[1], c_mode_val[1], c_high_val[2]+c_low_val[2], c_mode_val[2], c_high_val[3]+c_low_val[3], c_mode_val[3], c_high_val[4]+c_low_val[4], c_mode_val[4], c_high_val[5]+c_low_val[5], c_mode_val[5], c_high_val[6]+c_low_val[6], c_mode_val[6], c_high_val[7]+c_low_val[7], c_mode_val[7], c_high_val[8]+c_low_val[8], c_mode_val[8], c_high_val[9]+c_low_val[9], c_mode_val[9], refclk_period, m_val[0]); reconfig_err = 0; error = 0; c0_rising_edge_transfer_done = 0; c1_rising_edge_transfer_done = 0; c2_rising_edge_transfer_done = 0; c3_rising_edge_transfer_done = 0; c4_rising_edge_transfer_done = 0; got_first_scanclk = 0; got_first_gated_scanclk = 0; gated_scanclk = 1; scanread_setup_violation = 0; index = 0; vco_over = 1'b0; vco_under = 1'b0; // Initialize the scan chain // LF unused : bit 1 scan_data[-1:0] = 2'b00; // LF Capacitance : bits 1,2 : all values are legal scan_data[1:2] = loop_filter_c_bits; // LF Resistance : bits 3-7 scan_data[3:7] = loop_filter_r_bits; // VCO post scale if(vco_post_scale == 1) begin scan_data[8] = 1'b1; vco_val_old_bit_setting = 1'b1; end else begin scan_data[8] = 1'b0; vco_val_old_bit_setting = 1'b0; end scan_data[9:13] = 5'b00000; // CP // Bit 8 : CRBYPASS // Bit 9-13 : unused // Bits 14-16 : all values are legal scan_data[14:16] = charge_pump_current_bits; // store as old values cp_curr_old_bit_setting = charge_pump_current_bits; lfc_val_old_bit_setting = loop_filter_c_bits; lfr_val_old_bit_setting = loop_filter_r_bits; // C counters (start bit 53) bit 1:mode(bypass),bit 2-9:high,bit 10:mode(odd/even),bit 11-18:low for (i = 0; i < num_output_cntrs; i = i + 1) begin // 1. Mode - bypass if (c_mode_val[i] == "bypass") begin scan_data[53 + i*18 + 0] = 1'b1; if (c_mode_val[i] == " odd") scan_data[53 + i*18 + 9] = 1'b1; else scan_data[53 + i*18 + 9] = 1'b0; end else begin scan_data[53 + i*18 + 0] = 1'b0; // 3. Mode - odd/even if (c_mode_val[i] == " odd") scan_data[53 + i*18 + 9] = 1'b1; else scan_data[53 + i*18 + 9] = 1'b0; end // 2. Hi c_val = c_high_val[i]; for (j = 1; j <= 8; j = j + 1) scan_data[53 + i*18 + j] = c_val[8 - j]; // 4. Low c_val = c_low_val[i]; for (j = 10; j <= 17; j = j + 1) scan_data[53 + i*18 + j] = c_val[17 - j]; end // M counter // 1. Mode - bypass (bit 17) if (m_mode_val[0] == "bypass") scan_data[35] = 1'b1; else scan_data[35] = 1'b0; // 2. High (bit 18-25) // 3. Mode - odd/even (bit 26) if (m_val[0] % 2 == 0) begin // M is an even no. : set M high = low, // set odd/even bit to 0 scan_data[36:43]= m_val[0]/2; scan_data[44] = 1'b0; end else begin // M is odd : M high = low + 1 scan_data[36:43] = m_val[0]/2 + 1; scan_data[44] = 1'b1; end // 4. Low (bit 27-34) scan_data[45:52] = m_val[0]/2; // N counter // 1. Mode - bypass (bit 35) if (n_mode_val[0] == "bypass") scan_data[17] = 1'b1; else scan_data[17] = 1'b0; // 2. High (bit 36-43) // 3. Mode - odd/even (bit 44) if (n_val[0] % 2 == 0) begin // N is an even no. : set N high = low, // set odd/even bit to 0 scan_data[18:25] = n_val[0]/2; scan_data[26] = 1'b0; end else begin // N is odd : N high = N low + 1 scan_data[18:25] = n_val[0]/2+ 1; scan_data[26] = 1'b1; end // 4. Low (bit 45-52) scan_data[27:34] = n_val[0]/2; l_index = 1; stop_vco = 0; cycles_to_lock = 0; cycles_to_unlock = 0; locked_tmp = 0; pll_is_locked = 0; no_warn = 1'b0; pfd_locked = 1'b0; cycles_pfd_high = 0; cycles_pfd_low = 0; // check if pll is in test mode if (m_test_source != -1 || c0_test_source != -1 || c1_test_source != -1 || c2_test_source != -1 || c3_test_source != -1 || c4_test_source != -1) pll_in_test_mode = 1'b1; else pll_in_test_mode = 1'b0; pll_is_in_reset = 0; pll_has_just_been_reconfigured = 0; if (l_pll_type == "fast" || l_pll_type == "lvds" || l_pll_type == "left_right") is_fast_pll = 1; else is_fast_pll = 0; if (c1_use_casc_in == "on") ic1_use_casc_in = 1; else ic1_use_casc_in = 0; if (c2_use_casc_in == "on") ic2_use_casc_in = 1; else ic2_use_casc_in = 0; if (c3_use_casc_in == "on") ic3_use_casc_in = 1; else ic3_use_casc_in = 0; if (c4_use_casc_in == "on") ic4_use_casc_in = 1; else ic4_use_casc_in = 0; tap0_is_active = 1; // To display clock mapping case( i_clk0_counter) "c0" : clk_num[0] = " clk0"; "c1" : clk_num[0] = " clk1"; "c2" : clk_num[0] = " clk2"; "c3" : clk_num[0] = " clk3"; "c4" : clk_num[0] = " clk4"; default:clk_num[0] = "unused"; endcase case( i_clk1_counter) "c0" : clk_num[1] = " clk0"; "c1" : clk_num[1] = " clk1"; "c2" : clk_num[1] = " clk2"; "c3" : clk_num[1] = " clk3"; "c4" : clk_num[1] = " clk4"; default:clk_num[1] = "unused"; endcase case( i_clk2_counter) "c0" : clk_num[2] = " clk0"; "c1" : clk_num[2] = " clk1"; "c2" : clk_num[2] = " clk2"; "c3" : clk_num[2] = " clk3"; "c4" : clk_num[2] = " clk4"; default:clk_num[2] = "unused"; endcase case( i_clk3_counter) "c0" : clk_num[3] = " clk0"; "c1" : clk_num[3] = " clk1"; "c2" : clk_num[3] = " clk2"; "c3" : clk_num[3] = " clk3"; "c4" : clk_num[3] = " clk4"; default:clk_num[3] = "unused"; endcase case( i_clk4_counter) "c0" : clk_num[4] = " clk0"; "c1" : clk_num[4] = " clk1"; "c2" : clk_num[4] = " clk2"; "c3" : clk_num[4] = " clk3"; "c4" : clk_num[4] = " clk4"; default:clk_num[4] = "unused"; endcase end // Clock Switchover always @(clkswitch) begin if (clkswitch === 1'b1 && l_switch_over_type == "auto") external_switch = 1; else if (l_switch_over_type == "manual") begin if(clkswitch === 1'b1) switch_clock = 1'b1; else switch_clock = 1'b0; end end always @(posedge inclk[0]) begin // Determine the inclk0 frequency if (first_inclk0_edge_detect == 1'b0) begin first_inclk0_edge_detect = 1'b1; end else begin last_inclk0_period = inclk0_period; inclk0_period = $realtime - last_inclk0_edge; end last_inclk0_edge = $realtime; end always @(posedge inclk[1]) begin // Determine the inclk1 frequency if (first_inclk1_edge_detect == 1'b0) begin first_inclk1_edge_detect = 1'b1; end else begin last_inclk1_period = inclk1_period; inclk1_period = $realtime - last_inclk1_edge; end last_inclk1_edge = $realtime; end always @(inclk[0] or inclk[1]) begin if(switch_clock == 1'b1) begin if(current_clock_man == 0) begin current_clock_man = 1; active_clock = 1; end else begin current_clock_man = 0; active_clock = 0; end switch_clock = 1'b0; end if (current_clock_man == 0) inclk_man = inclk[0]; else inclk_man = inclk[1]; // save the inclk event value if (inclk[0] !== inclk0_last_value) begin if (current_clock != 0) other_clock_value = inclk[0]; end if (inclk[1] !== inclk1_last_value) begin if (current_clock != 1) other_clock_value = inclk[1]; end // check if either input clk is bad if (inclk[0] === 1'b1 && inclk[0] !== inclk0_last_value) begin clk0_count = clk0_count + 1; clk0_is_bad = 0; clk1_count = 0; if (clk0_count > 2) begin // no event on other clk for 2 cycles clk1_is_bad = 1; if (current_clock == 1) current_clk_is_bad = 1; end end if (inclk[1] === 1'b1 && inclk[1] !== inclk1_last_value) begin clk1_count = clk1_count + 1; clk1_is_bad = 0; clk0_count = 0; if (clk1_count > 2) begin // no event on other clk for 2 cycles clk0_is_bad = 1; if (current_clock == 0) current_clk_is_bad = 1; end end // check if the bad clk is the primary clock, which is always clk0 if (clk0_is_bad == 1'b1) primary_clk_is_bad = 1; else primary_clk_is_bad = 0; // actual switching -- manual switch if ((inclk[0] !== inclk0_last_value) && current_clock == 0) begin if (external_switch == 1'b1) begin if (!got_curr_clk_falling_edge_after_clkswitch) begin if (inclk[0] === 1'b0) got_curr_clk_falling_edge_after_clkswitch = 1; inclk_es = inclk[0]; end end else inclk_es = inclk[0]; end if ((inclk[1] !== inclk1_last_value) && current_clock == 1) begin if (external_switch == 1'b1) begin if (!got_curr_clk_falling_edge_after_clkswitch) begin if (inclk[1] === 1'b0) got_curr_clk_falling_edge_after_clkswitch = 1; inclk_es = inclk[1]; end end else inclk_es = inclk[1]; end // actual switching -- automatic switch if ((other_clock_value == 1'b1) && (other_clock_value != other_clock_last_value) && l_enable_switch_over_counter == "on" && primary_clk_is_bad) switch_over_count = switch_over_count + 1; if ((other_clock_value == 1'b0) && (other_clock_value != other_clock_last_value)) begin if ((external_switch && (got_curr_clk_falling_edge_after_clkswitch || current_clk_is_bad)) || (primary_clk_is_bad && (clkswitch !== 1'b1) && ((l_enable_switch_over_counter == "off" || switch_over_count == switch_over_counter)))) begin if (areset === 1'b0) begin if ((inclk0_period > inclk1_period) && (inclk1_period != 0)) diff_percent_period = (( inclk0_period - inclk1_period ) * 100) / inclk1_period; else if (inclk0_period != 0) diff_percent_period = (( inclk1_period - inclk0_period ) * 100) / inclk0_period; if((diff_percent_period > 20)&& (l_switch_over_type == "auto")) begin $display ("Warning : The input clock frequencies specified for the specified PLL are too far apart for auto-switch-over feature to work properly. Please make sure that the clock frequencies are 20 percent apart for correct functionality."); $display ("Time: %0t Instance: %m", $time); end end got_curr_clk_falling_edge_after_clkswitch = 0; if (current_clock == 0) current_clock = 1; else current_clock = 0; active_clock = ~active_clock; switch_over_count = 0; external_switch = 0; current_clk_is_bad = 0; end else if(l_switch_over_type == "auto") begin if(current_clock == 0 && clk0_is_bad == 1'b1 && clk1_is_bad == 1'b0 ) begin current_clock = 1; active_clock = ~active_clock; end if(current_clock == 1 && clk1_is_bad == 1'b1 && clk0_is_bad == 1'b0 ) begin current_clock = 0; active_clock = ~active_clock; end end end if(l_switch_over_type == "manual") inclk_n = inclk_man; else inclk_n = inclk_es; inclk0_last_value = inclk[0]; inclk1_last_value = inclk[1]; other_clock_last_value = other_clock_value; end and (clkbad[0], clk0_is_bad, 1'b1); and (clkbad[1], clk1_is_bad, 1'b1); and (activeclock, active_clock, 1'b1); assign inclk_m = (m_test_source == 0) ? fbclk : (m_test_source == 1) ? refclk : inclk_m_from_vco; cycloneive_m_cntr m1 (.clk(inclk_m), .reset(areset || stop_vco), .cout(fbclk), .initial_value(m_initial_val), .modulus(m_val[0]), .time_delay(m_delay)); cycloneive_n_cntr n1 (.clk(inclk_n), .reset(areset), .cout(refclk), .modulus(n_val[0])); // Update clock on /o counters from corresponding VCO tap assign inclk_m_from_vco = vco_tap[m_ph_val]; assign inclk_c0_from_vco = vco_tap[c_ph_val[0]]; assign inclk_c1_from_vco = vco_tap[c_ph_val[1]]; assign inclk_c2_from_vco = vco_tap[c_ph_val[2]]; assign inclk_c3_from_vco = vco_tap[c_ph_val[3]]; assign inclk_c4_from_vco = vco_tap[c_ph_val[4]]; always @(vco_out) begin // check which VCO TAP has event for (x = 0; x <= 7; x = x + 1) begin if (vco_out[x] !== vco_out_last_value[x]) begin // TAP 'X' has event if ((x == 0) && (!pll_is_in_reset) && (stop_vco !== 1'b1)) begin if (vco_out[0] == 1'b1) tap0_is_active = 1; if (tap0_is_active == 1'b1) vco_tap[0] <= vco_out[0]; end else if (tap0_is_active == 1'b1) vco_tap[x] <= vco_out[x]; if (stop_vco === 1'b1) vco_out[x] <= 1'b0; end end vco_out_last_value = vco_out; end always @(vco_tap) begin // Update phase taps for C/M counters on negative edge of VCO clock output if (update_phase == 1'b1) begin for (x = 0; x <= 7; x = x + 1) begin if ((vco_tap[x] === 1'b0) && (vco_tap[x] !== vco_tap_last_value[x])) begin for (y = 0; y < 10; y = y + 1) begin if (c_ph_val_tmp[y] == x) c_ph_val[y] = c_ph_val_tmp[y]; end if (m_ph_val_tmp == x) m_ph_val = m_ph_val_tmp; end end update_phase <= #(0.5*scanclk_period) 1'b0; end // On reset, set all C/M counter phase taps to POF programmed values if (areset === 1'b1) begin m_ph_val = m_ph_val_orig; m_ph_val_tmp = m_ph_val_orig; for (i=0; i<= 9; i=i+1) begin c_ph_val[i] = c_ph_val_orig[i]; c_ph_val_tmp[i] = c_ph_val_orig[i]; end end vco_tap_last_value = vco_tap; end assign inclk_c0 = (c0_test_source == 0) ? fbclk : (c0_test_source == 1) ? refclk : inclk_c0_from_vco; cycloneive_scale_cntr c0 (.clk(inclk_c0), .reset(areset || stop_vco), .cout(c0_clk), .high(c_high_val[0]), .low(c_low_val[0]), .initial_value(c_initial_val[0]), .mode(c_mode_val[0]), .ph_tap(c_ph_val[0])); // Update /o counters mode and duty cycle immediately after configupdate is asserted always @(posedge scanclk) begin if (update_conf_latches_reg == 1'b1) begin c_high_val[0] <= c_high_val_tmp[0]; c_mode_val[0] <= c_mode_val_tmp[0]; c0_rising_edge_transfer_done = 1; end end always @(negedge scanclk) begin if (c0_rising_edge_transfer_done) begin c_low_val[0] <= c_low_val_tmp[0]; end end assign inclk_c1 = (c1_test_source == 0) ? fbclk : (c1_test_source == 1) ? refclk : (ic1_use_casc_in == 1) ? c0_clk : inclk_c1_from_vco; cycloneive_scale_cntr c1 (.clk(inclk_c1), .reset(areset || stop_vco), .cout(c1_clk), .high(c_high_val[1]), .low(c_low_val[1]), .initial_value(c_initial_val[1]), .mode(c_mode_val[1]), .ph_tap(c_ph_val[1])); always @(posedge scanclk) begin if (update_conf_latches_reg == 1'b1) begin c_high_val[1] <= c_high_val_tmp[1]; c_mode_val[1] <= c_mode_val_tmp[1]; c1_rising_edge_transfer_done = 1; end end always @(negedge scanclk) begin if (c1_rising_edge_transfer_done) begin c_low_val[1] <= c_low_val_tmp[1]; end end assign inclk_c2 = (c2_test_source == 0) ? fbclk : (c2_test_source == 1) ? refclk :(ic2_use_casc_in == 1) ? c1_clk : inclk_c2_from_vco; cycloneive_scale_cntr c2 (.clk(inclk_c2), .reset(areset || stop_vco), .cout(c2_clk), .high(c_high_val[2]), .low(c_low_val[2]), .initial_value(c_initial_val[2]), .mode(c_mode_val[2]), .ph_tap(c_ph_val[2])); always @(posedge scanclk) begin if (update_conf_latches_reg == 1'b1) begin c_high_val[2] <= c_high_val_tmp[2]; c_mode_val[2] <= c_mode_val_tmp[2]; c2_rising_edge_transfer_done = 1; end end always @(negedge scanclk) begin if (c2_rising_edge_transfer_done) begin c_low_val[2] <= c_low_val_tmp[2]; end end assign inclk_c3 = (c3_test_source == 0) ? fbclk : (c3_test_source == 1) ? refclk : (ic3_use_casc_in == 1) ? c2_clk : inclk_c3_from_vco; cycloneive_scale_cntr c3 (.clk(inclk_c3), .reset(areset || stop_vco), .cout(c3_clk), .high(c_high_val[3]), .low(c_low_val[3]), .initial_value(c_initial_val[3]), .mode(c_mode_val[3]), .ph_tap(c_ph_val[3])); always @(posedge scanclk) begin if (update_conf_latches_reg == 1'b1) begin c_high_val[3] <= c_high_val_tmp[3]; c_mode_val[3] <= c_mode_val_tmp[3]; c3_rising_edge_transfer_done = 1; end end always @(negedge scanclk) begin if (c3_rising_edge_transfer_done) begin c_low_val[3] <= c_low_val_tmp[3]; end end assign inclk_c4 = ((c4_test_source == 0) ? fbclk : (c4_test_source == 1) ? refclk : (ic4_use_casc_in == 1) ? c3_clk : inclk_c4_from_vco); cycloneive_scale_cntr c4 (.clk(inclk_c4), .reset(areset || stop_vco), .cout(c4_clk), .high(c_high_val[4]), .low(c_low_val[4]), .initial_value(c_initial_val[4]), .mode(c_mode_val[4]), .ph_tap(c_ph_val[4])); always @(posedge scanclk) begin if (update_conf_latches_reg == 1'b1) begin c_high_val[4] <= c_high_val_tmp[4]; c_mode_val[4] <= c_mode_val_tmp[4]; c4_rising_edge_transfer_done = 1; end end always @(negedge scanclk) begin if (c4_rising_edge_transfer_done) begin c_low_val[4] <= c_low_val_tmp[4]; end end assign locked = (test_bypass_lock_detect == "on") ? pfd_locked : locked_tmp; // Register scanclk enable always @(negedge scanclk) scanclkena_reg <= scanclkena; // Negative edge flip-flop in front of scan-chain always @(negedge scanclk) begin if (scanclkena_reg) begin scandata_in <= scandata; end end // Scan chain always @(posedge scanclk) begin if (got_first_scanclk === 1'b0) got_first_scanclk = 1'b1; else scanclk_period = $time - scanclk_last_rising_edge; if (scanclkena_reg) begin for (j = scan_chain_length-2; j >= 0; j = j - 1) scan_data[j] = scan_data[j - 1]; scan_data[-1] <= scandata_in; end scanclk_last_rising_edge = $realtime; end // Scan output assign scandataout_tmp = scan_data[SCAN_CHAIN - 2]; // Negative edge flip-flop in rear of scan-chain always @(negedge scanclk) begin if (scanclkena_reg) begin scandata_out <= scandataout_tmp; end end // Scan complete always @(negedge scandone_tmp) begin if (got_first_scanclk === 1'b1) begin if (reconfig_err == 1'b0) begin $display("NOTE : PLL Reprogramming completed with the following values (Values in parantheses are original values) : "); $display ("Time: %0t Instance: %m", $time); $display(" N modulus = %0d (%0d) ", n_val[0], n_val_old[0]); $display(" M modulus = %0d (%0d) ", m_val[0], m_val_old[0]); for (i = 0; i < num_output_cntrs; i=i+1) begin $display(" %s : C%0d high = %0d (%0d), C%0d low = %0d (%0d), C%0d mode = %s (%s)", clk_num[i],i, c_high_val[i], c_high_val_old[i], i, c_low_val_tmp[i], c_low_val_old[i], i, c_mode_val[i], c_mode_val_old[i]); end // display Charge pump and loop filter values if (pll_reconfig_display_full_setting == 1'b1) begin $display (" Charge Pump Current (uA) = %0d (%0d) ", cp_curr_val, cp_curr_old); $display (" Loop Filter Capacitor (pF) = %0d (%0d) ", lfc_val, lfc_old); $display (" Loop Filter Resistor (Kohm) = %s (%s) ", lfr_val, lfr_old); $display (" VCO_Post_Scale = %0d (%0d) ", vco_cur, vco_old); end else begin $display (" Charge Pump Current = %0d (%0d) ", cp_curr_bit_setting, cp_curr_old_bit_setting); $display (" Loop Filter Capacitor = %0d (%0d) ", lfc_val_bit_setting, lfc_val_old_bit_setting); $display (" Loop Filter Resistor = %0d (%0d) ", lfr_val_bit_setting, lfr_val_old_bit_setting); $display (" VCO_Post_Scale = %b (%b) ", vco_val_bit_setting, vco_val_old_bit_setting); end cp_curr_old_bit_setting = cp_curr_bit_setting; lfc_val_old_bit_setting = lfc_val_bit_setting; lfr_val_old_bit_setting = lfr_val_bit_setting; vco_val_old_bit_setting = vco_val_bit_setting; end else begin $display("Warning : Errors were encountered during PLL reprogramming. Please refer to error/warning messages above."); $display ("Time: %0t Instance: %m", $time); end end end // ************ PLL Phase Reconfiguration ************* // // Latch updown,counter values at pos edge of scan clock always @(posedge scanclk) begin if (phasestep_reg == 1'b1) begin if (phasestep_high_count == 1) begin phasecounterselect_reg <= phasecounterselect; phaseupdown_reg <= phaseupdown; // start reconfiguration if (phasecounterselect < 3'b111) // no counters selected begin if (phasecounterselect == 0) // all output counters selected begin for (i = 0; i < num_output_cntrs; i = i + 1) c_ph_val_tmp[i] = (phaseupdown == 1'b1) ? (c_ph_val_tmp[i] + 1) % num_phase_taps : (c_ph_val_tmp[i] == 0) ? num_phase_taps - 1 : (c_ph_val_tmp[i] - 1) % num_phase_taps ; end else if (phasecounterselect == 1) // select M counter begin m_ph_val_tmp = (phaseupdown == 1'b1) ? (m_ph_val + 1) % num_phase_taps : (m_ph_val == 0) ? num_phase_taps - 1 : (m_ph_val - 1) % num_phase_taps ; end else // select C counters begin select_counter = phasecounterselect - 2; c_ph_val_tmp[select_counter] = (phaseupdown == 1'b1) ? (c_ph_val_tmp[select_counter] + 1) % num_phase_taps : (c_ph_val_tmp[select_counter] == 0) ? num_phase_taps - 1 : (c_ph_val_tmp[select_counter] - 1) % num_phase_taps ; end update_phase <= 1'b1; end end phasestep_high_count = phasestep_high_count + 1; end end // Latch phase enable (same as phasestep) on neg edge of scan clock always @(negedge scanclk) begin phasestep_reg <= phasestep; end always @(posedge phasestep) begin if (update_phase == 1'b0) phasestep_high_count = 0; // phase adjustments must be 1 cycle apart // if not, next phasestep cycle is skipped end // ************ PLL Full Reconfiguration ************* // assign update_conf_latches = configupdate; // reset counter transfer flags always @(negedge scandone_tmp) begin c0_rising_edge_transfer_done = 0; c1_rising_edge_transfer_done = 0; c2_rising_edge_transfer_done = 0; c3_rising_edge_transfer_done = 0; c4_rising_edge_transfer_done = 0; update_conf_latches_reg <= 1'b0; end always @(posedge update_conf_latches) begin initiate_reconfig <= 1'b1; end always @(posedge areset) begin if (scandone_tmp == 1'b1) scandone_tmp = 1'b0; end always @(posedge scanclk) begin if (initiate_reconfig == 1'b1) begin initiate_reconfig <= 1'b0; $display ("NOTE : PLL Reprogramming initiated ...."); $display ("Time: %0t Instance: %m", $time); scandone_tmp <= #(scanclk_period) 1'b1; update_conf_latches_reg <= update_conf_latches; error = 0; reconfig_err = 0; scanread_setup_violation = 0; // save old values cp_curr_old = cp_curr_val; lfc_old = lfc_val; lfr_old = lfr_val; vco_old = vco_cur; // save old values of bit settings cp_curr_bit_setting = scan_data[14:16]; lfc_val_bit_setting = scan_data[1:2]; lfr_val_bit_setting = scan_data[3:7]; vco_val_bit_setting = scan_data[8]; // LF unused : bit 1 // LF Capacitance : bits 1,2 : all values are legal if ((l_pll_type == "fast") || (l_pll_type == "lvds") || (l_pll_type == "left_right")) lfc_val = fpll_loop_filter_c_arr[scan_data[1:2]]; else lfc_val = loop_filter_c_arr[scan_data[1:2]]; // LF Resistance : bits 3-7 // valid values - 00000,00100,10000,10100,11000,11011,11100,11110 if (((scan_data[3:7] == 5'b00000) || (scan_data[3:7] == 5'b00100)) || ((scan_data[3:7] == 5'b10000) || (scan_data[3:7] == 5'b10100)) || ((scan_data[3:7] == 5'b11000) || (scan_data[3:7] == 5'b11011)) || ((scan_data[3:7] == 5'b11100) || (scan_data[3:7] == 5'b11110)) ) begin lfr_val = (scan_data[3:7] == 5'b00000) ? "20" : (scan_data[3:7] == 5'b00100) ? "16" : (scan_data[3:7] == 5'b10000) ? "12" : (scan_data[3:7] == 5'b10100) ? "8" : (scan_data[3:7] == 5'b11000) ? "6" : (scan_data[3:7] == 5'b11011) ? "4" : (scan_data[3:7] == 5'b11100) ? "2" : "1"; end //VCO post scale value if (scan_data[8] === 1'b1) // vco_post_scale = 1 begin i_vco_max = i_vco_max_no_division/2; i_vco_min = i_vco_min_no_division/2; vco_cur = 1; end else begin i_vco_max = vco_max; i_vco_min = vco_min; vco_cur = 2; end // CP // Bit 8 : CRBYPASS // Bit 9-13 : unused // Bits 14-16 : all values are legal cp_curr_val = scan_data[14:16]; // save old values for display info. for (i=0; i<=1; i=i+1) begin m_val_old[i] = m_val[i]; n_val_old[i] = n_val[i]; m_mode_val_old[i] = m_mode_val[i]; n_mode_val_old[i] = n_mode_val[i]; end for (i=0; i< num_output_cntrs; i=i+1) begin c_high_val_old[i] = c_high_val[i]; c_low_val_old[i] = c_low_val[i]; c_mode_val_old[i] = c_mode_val[i]; end // M counter // 1. Mode - bypass (bit 17) if (scan_data[17] == 1'b1) n_mode_val[0] = "bypass"; // 3. Mode - odd/even (bit 26) else if (scan_data[26] == 1'b1) n_mode_val[0] = " odd"; else n_mode_val[0] = " even"; // 2. High (bit 18-25) n_hi = scan_data[18:25]; // 4. Low (bit 27-34) n_lo = scan_data[27:34]; // N counter // 1. Mode - bypass (bit 35) if (scan_data[35] == 1'b1) m_mode_val[0] = "bypass"; // 3. Mode - odd/even (bit 44) else if (scan_data[44] == 1'b1) m_mode_val[0] = " odd"; else m_mode_val[0] = " even"; // 2. High (bit 36-43) m_hi = scan_data[36:43]; // 4. Low (bit 45-52) m_lo = scan_data[45:52]; //Update the current M and N counter values if the counters are NOT bypassed if (m_mode_val[0] != "bypass") m_val[0] = m_hi + m_lo; if (n_mode_val[0] != "bypass") n_val[0] = n_hi + n_lo; // C counters (start bit 53) bit 1:mode(bypass),bit 2-9:high,bit 10:mode(odd/even),bit 11-18:low for (i = 0; i < num_output_cntrs; i = i + 1) begin // 1. Mode - bypass if (scan_data[53 + i*18 + 0] == 1'b1) c_mode_val_tmp[i] = "bypass"; // 3. Mode - odd/even else if (scan_data[53 + i*18 + 9] == 1'b1) c_mode_val_tmp[i] = " odd"; else c_mode_val_tmp[i] = " even"; // 2. Hi for (j = 1; j <= 8; j = j + 1) c_val[8-j] = scan_data[53 + i*18 + j]; c_hval[i] = c_val[7:0]; if (c_hval[i] !== 32'h00000000) c_high_val_tmp[i] = c_hval[i]; else c_high_val_tmp[i] = 9'b100000000; // 4. Low for (j = 10; j <= 17; j = j + 1) c_val[17 - j] = scan_data[53 + i*18 + j]; c_lval[i] = c_val[7:0]; if (c_lval[i] !== 32'h00000000) c_low_val_tmp[i] = c_lval[i]; else c_low_val_tmp[i] = 9'b100000000; end // Legality Checks if (m_mode_val[0] != "bypass") begin if ((m_hi !== m_lo) && (m_mode_val[0] != " odd")) begin reconfig_err = 1; $display ("Warning : The M counter of the %s Fast PLL should be configured for 50%% duty cycle only. In this case the HIGH and LOW moduli programmed will result in a duty cycle other than 50%%, which is illegal. Reconfiguration may not work", family_name); $display ("Time: %0t Instance: %m", $time); end else if (m_hi !== 8'b00000000) begin // counter value m_val_tmp[0] = m_hi + m_lo; end else m_val_tmp[0] = 9'b100000000; end else m_val_tmp[0] = 8'b00000001; if (n_mode_val[0] != "bypass") begin if ((n_hi !== n_lo) && (n_mode_val[0] != " odd")) begin reconfig_err = 1; $display ("Warning : The N counter of the %s Fast PLL should be configured for 50%% duty cycle only. In this case the HIGH and LOW moduli programmed will result in a duty cycle other than 50%%, which is illegal. Reconfiguration may not work", family_name); $display ("Time: %0t Instance: %m", $time); end else if (n_hi !== 8'b00000000) begin // counter value n_val[0] = n_hi + n_lo; end else n_val[0] = 9'b100000000; end else n_val[0] = 8'b00000001; // TODO : Give warnings/errors in the following cases? // 1. Illegal counter values (error) // 2. Change of mode (warning) // 3. Only 50% duty cycle allowed for M counter (odd mode - hi-lo=1,even - hi-lo=0) end end // Self reset on loss of lock assign reset_self = (l_self_reset_on_loss_lock == "on") ? ~pll_is_locked : 1'b0; always @(posedge reset_self) begin $display (" Note : %s PLL self reset due to loss of lock", family_name); $display ("Time: %0t Instance: %m", $time); end // Phase shift on /o counters always @(schedule_vco or areset) begin sched_time = 0; for (i = 0; i <= 7; i=i+1) last_phase_shift[i] = phase_shift[i]; cycle_to_adjust = 0; l_index = 1; m_times_vco_period = new_m_times_vco_period; // give appropriate messages // if areset was asserted if (areset === 1'b1 && areset_last_value !== areset) begin $display (" Note : %s PLL was reset", family_name); $display ("Time: %0t Instance: %m", $time); // reset lock parameters pll_is_locked = 0; cycles_to_lock = 0; cycles_to_unlock = 0; tap0_is_active = 0; phase_adjust_was_scheduled = 0; for (x = 0; x <= 7; x=x+1) vco_tap[x] <= 1'b0; end // illegal value on areset if (areset === 1'bx && (areset_last_value === 1'b0 || areset_last_value === 1'b1)) begin $display("Warning : Illegal value 'X' detected on ARESET input"); $display ("Time: %0t Instance: %m", $time); end if ((areset == 1'b1)) begin pll_is_in_reset = 1; got_first_refclk = 0; got_second_refclk = 0; end if ((schedule_vco !== schedule_vco_last_value) && (areset == 1'b1 || stop_vco == 1'b1)) begin // drop VCO taps to 0 for (i = 0; i <= 7; i=i+1) begin for (j = 0; j <= last_phase_shift[i] + 1; j=j+1) vco_out[i] <= #(j) 1'b0; phase_shift[i] = 0; last_phase_shift[i] = 0; end // reset lock parameters pll_is_locked = 0; cycles_to_lock = 0; cycles_to_unlock = 0; got_first_refclk = 0; got_second_refclk = 0; refclk_time = 0; got_first_fbclk = 0; fbclk_time = 0; first_fbclk_time = 0; fbclk_period = 0; first_schedule = 1; vco_val = 0; vco_period_was_phase_adjusted = 0; phase_adjust_was_scheduled = 0; // reset all counter phase tap values to POF programmed values m_ph_val = m_ph_val_orig; for (i=0; i<= 5; i=i+1) c_ph_val[i] = c_ph_val_orig[i]; end else if (areset === 1'b0 && stop_vco === 1'b0) begin // else note areset deassert time // note it as refclk_time to prevent false triggering // of stop_vco after areset if (areset === 1'b0 && areset_last_value === 1'b1 && pll_is_in_reset === 1'b1) begin refclk_time = $time; locked_tmp = 1'b0; end pll_is_in_reset = 0; // calculate loop_xplier : this will be different from m_val in ext. fbk mode loop_xplier = m_val[0]; loop_initial = i_m_initial - 1; loop_ph = m_ph_val; // convert initial value to delay initial_delay = (loop_initial * m_times_vco_period)/loop_xplier; // convert loop ph_tap to delay rem = m_times_vco_period % loop_xplier; vco_per = m_times_vco_period/loop_xplier; if (rem != 0) vco_per = vco_per + 1; fbk_phase = (loop_ph * vco_per)/8; pull_back_M = initial_delay + fbk_phase; total_pull_back = pull_back_M; if (l_simulation_type == "timing") total_pull_back = total_pull_back + pll_compensation_delay; while (total_pull_back > refclk_period) total_pull_back = total_pull_back - refclk_period; if (total_pull_back > 0) offset = refclk_period - total_pull_back; else offset = 0; fbk_delay = total_pull_back - fbk_phase; if (fbk_delay < 0) begin offset = offset - fbk_phase; fbk_delay = total_pull_back; end // assign m_delay m_delay = fbk_delay; for (i = 1; i <= loop_xplier; i=i+1) begin // adjust cycles tmp_vco_per = m_times_vco_period/loop_xplier; if (rem != 0 && l_index <= rem) begin tmp_rem = (loop_xplier * l_index) % rem; cycle_to_adjust = (loop_xplier * l_index) / rem; if (tmp_rem != 0) cycle_to_adjust = cycle_to_adjust + 1; end if (cycle_to_adjust == i) begin tmp_vco_per = tmp_vco_per + 1; l_index = l_index + 1; end // calculate high and low periods high_time = tmp_vco_per/2; if (tmp_vco_per % 2 != 0) high_time = high_time + 1; low_time = tmp_vco_per - high_time; // schedule the rising and falling egdes for (j=0; j<=1; j=j+1) begin vco_val = ~vco_val; if (vco_val == 1'b0) sched_time = sched_time + high_time; else sched_time = sched_time + low_time; // schedule taps with appropriate phase shifts for (k = 0; k <= 7; k=k+1) begin phase_shift[k] = (k*tmp_vco_per)/8; if (first_schedule) vco_out[k] <= #(sched_time + phase_shift[k]) vco_val; else vco_out[k] <= #(sched_time + last_phase_shift[k]) vco_val; end end end if (first_schedule) begin vco_val = ~vco_val; if (vco_val == 1'b0) sched_time = sched_time + high_time; else sched_time = sched_time + low_time; for (k = 0; k <= 7; k=k+1) begin phase_shift[k] = (k*tmp_vco_per)/8; vco_out[k] <= #(sched_time+phase_shift[k]) vco_val; end first_schedule = 0; end schedule_vco <= #(sched_time) ~schedule_vco; if (vco_period_was_phase_adjusted) begin m_times_vco_period = refclk_period; new_m_times_vco_period = refclk_period; vco_period_was_phase_adjusted = 0; phase_adjust_was_scheduled = 1; tmp_vco_per = m_times_vco_period/loop_xplier; for (k = 0; k <= 7; k=k+1) phase_shift[k] = (k*tmp_vco_per)/8; end end areset_last_value = areset; schedule_vco_last_value = schedule_vco; end assign pfdena_wire = (pfdena === 1'b0) ? 1'b0 : 1'b1; // PFD enable always @(pfdena_wire) begin if (pfdena_wire === 1'b0) begin if (pll_is_locked) locked_tmp = 1'bx; pll_is_locked = 0; cycles_to_lock = 0; $display (" Note : PFDENA was deasserted"); $display ("Time: %0t Instance: %m", $time); end else if (pfdena_wire === 1'b1 && pfdena_last_value === 1'b0) begin // PFD was disabled, now enabled again got_first_refclk = 0; got_second_refclk = 0; refclk_time = $time; end pfdena_last_value = pfdena_wire; end always @(negedge refclk or negedge fbclk) begin refclk_last_value = refclk; fbclk_last_value = fbclk; end // Bypass lock detect always @(posedge refclk) begin if (test_bypass_lock_detect == "on") begin if (pfdena_wire === 1'b1) begin cycles_pfd_low = 0; if (pfd_locked == 1'b0) begin if (cycles_pfd_high == lock_high) begin $display ("Note : %s PLL locked in test mode on PFD enable assert", family_name); $display ("Time: %0t Instance: %m", $time); pfd_locked <= 1'b1; end cycles_pfd_high = cycles_pfd_high + 1; end end if (pfdena_wire === 1'b0) begin cycles_pfd_high = 0; if (pfd_locked == 1'b1) begin if (cycles_pfd_low == lock_low) begin $display ("Note : %s PLL lost lock in test mode on PFD enable deassert", family_name); $display ("Time: %0t Instance: %m", $time); pfd_locked <= 1'b0; end cycles_pfd_low = cycles_pfd_low + 1; end end end end always @(posedge scandone_tmp or posedge locked_tmp) begin if(scandone_tmp == 1) pll_has_just_been_reconfigured <= 1; else pll_has_just_been_reconfigured <= 0; end // VCO Frequency Range check always @(posedge refclk or posedge fbclk) begin if (refclk == 1'b1 && refclk_last_value !== refclk && areset === 1'b0) begin if (! got_first_refclk) begin got_first_refclk = 1; end else begin got_second_refclk = 1; refclk_period = $time - refclk_time; // check if incoming freq. will cause VCO range to be // exceeded if ((i_vco_max != 0 && i_vco_min != 0) && (pfdena_wire === 1'b1) && ((refclk_period/loop_xplier > i_vco_max) || (refclk_period/loop_xplier < i_vco_min)) ) begin if (pll_is_locked == 1'b1) begin if (refclk_period/loop_xplier > i_vco_max) begin $display ("Warning : Input clock freq. is over VCO range. %s PLL may lose lock", family_name); vco_over = 1'b1; end if (refclk_period/loop_xplier < i_vco_min) begin $display ("Warning : Input clock freq. is under VCO range. %s PLL may lose lock", family_name); vco_under = 1'b1; end $display ("Time: %0t Instance: %m", $time); if (inclk_out_of_range === 1'b1) begin // unlock pll_is_locked = 0; locked_tmp = 0; cycles_to_lock = 0; $display ("Note : %s PLL lost lock", family_name); $display ("Time: %0t Instance: %m", $time); vco_period_was_phase_adjusted = 0; phase_adjust_was_scheduled = 0; end end else begin if (no_warn == 1'b0) begin if (refclk_period/loop_xplier > i_vco_max) begin $display ("Warning : Input clock freq. is over VCO range. %s PLL may lose lock", family_name); vco_over = 1'b1; end if (refclk_period/loop_xplier < i_vco_min) begin $display ("Warning : Input clock freq. is under VCO range. %s PLL may lose lock", family_name); vco_under = 1'b1; end $display ("Time: %0t Instance: %m", $time); no_warn = 1'b1; end end inclk_out_of_range = 1; end else begin vco_over = 1'b0; vco_under = 1'b0; inclk_out_of_range = 0; no_warn = 1'b0; end end if (stop_vco == 1'b1) begin stop_vco = 0; schedule_vco = ~schedule_vco; end refclk_time = $time; end // Update M counter value on feedback clock edge if (fbclk == 1'b1 && fbclk_last_value !== fbclk) begin if (update_conf_latches === 1'b1) begin m_val[0] <= m_val_tmp[0]; m_val[1] <= m_val_tmp[1]; end if (!got_first_fbclk) begin got_first_fbclk = 1; first_fbclk_time = $time; end else fbclk_period = $time - fbclk_time; // need refclk_period here, so initialized to proper value above if ( ( ($time - refclk_time > 1.5 * refclk_period) && pfdena_wire === 1'b1 && pll_is_locked === 1'b1) || ( ($time - refclk_time > 5 * refclk_period) && (pfdena_wire === 1'b1) && (pll_has_just_been_reconfigured == 0) ) || ( ($time - refclk_time > 50 * refclk_period) && (pfdena_wire === 1'b1) && (pll_has_just_been_reconfigured == 1) ) ) begin stop_vco = 1; // reset got_first_refclk = 0; got_first_fbclk = 0; got_second_refclk = 0; if (pll_is_locked == 1'b1) begin pll_is_locked = 0; locked_tmp = 0; $display ("Note : %s PLL lost lock due to loss of input clock or the input clock is not detected within the allowed time frame.", family_name); if ((i_vco_max == 0) && (i_vco_min == 0)) $display ("Note : Please run timing simulation to check whether the input clock is operating within the supported VCO range or not."); $display ("Time: %0t Instance: %m", $time); end cycles_to_lock = 0; cycles_to_unlock = 0; first_schedule = 1; vco_period_was_phase_adjusted = 0; phase_adjust_was_scheduled = 0; tap0_is_active = 0; for (x = 0; x <= 7; x=x+1) vco_tap[x] <= 1'b0; end fbclk_time = $time; end // Core lock functionality if (got_second_refclk && pfdena_wire === 1'b1 && (!inclk_out_of_range)) begin // now we know actual incoming period if (abs(fbclk_time - refclk_time) <= lock_window || (got_first_fbclk && abs(refclk_period - abs(fbclk_time - refclk_time)) <= lock_window)) begin // considered in phase if (cycles_to_lock == real_lock_high) begin if (pll_is_locked === 1'b0) begin $display (" Note : %s PLL locked to incoming clock", family_name); $display ("Time: %0t Instance: %m", $time); end pll_is_locked = 1; locked_tmp = 1; cycles_to_unlock = 0; end // increment lock counter only if the second part of the above // time check is not true if (!(abs(refclk_period - abs(fbclk_time - refclk_time)) <= lock_window)) begin cycles_to_lock = cycles_to_lock + 1; end // adjust m_times_vco_period new_m_times_vco_period = refclk_period; end else begin // if locked, begin unlock if (pll_is_locked) begin cycles_to_unlock = cycles_to_unlock + 1; if (cycles_to_unlock == lock_low) begin pll_is_locked = 0; locked_tmp = 0; cycles_to_lock = 0; $display ("Note : %s PLL lost lock", family_name); $display ("Time: %0t Instance: %m", $time); vco_period_was_phase_adjusted = 0; phase_adjust_was_scheduled = 0; got_first_refclk = 0; got_first_fbclk = 0; got_second_refclk = 0; end end if (abs(refclk_period - fbclk_period) <= 2) begin // frequency is still good if ($time == fbclk_time && (!phase_adjust_was_scheduled)) begin if (abs(fbclk_time - refclk_time) > refclk_period/2) begin new_m_times_vco_period = abs(m_times_vco_period + (refclk_period - abs(fbclk_time - refclk_time))); vco_period_was_phase_adjusted = 1; end else begin new_m_times_vco_period = abs(m_times_vco_period - abs(fbclk_time - refclk_time)); vco_period_was_phase_adjusted = 1; end end end else begin new_m_times_vco_period = refclk_period; phase_adjust_was_scheduled = 0; end end end if (reconfig_err == 1'b1) begin locked_tmp = 0; end refclk_last_value = refclk; fbclk_last_value = fbclk; end assign clk_tmp[0] = i_clk0_counter == "c0" ? c0_clk : i_clk0_counter == "c1" ? c1_clk : i_clk0_counter == "c2" ? c2_clk : i_clk0_counter == "c3" ? c3_clk : i_clk0_counter == "c4" ? c4_clk : 1'b0; assign clk_tmp[1] = i_clk1_counter == "c0" ? c0_clk : i_clk1_counter == "c1" ? c1_clk : i_clk1_counter == "c2" ? c2_clk : i_clk1_counter == "c3" ? c3_clk : i_clk1_counter == "c4" ? c4_clk : 1'b0; assign clk_tmp[2] = i_clk2_counter == "c0" ? c0_clk : i_clk2_counter == "c1" ? c1_clk : i_clk2_counter == "c2" ? c2_clk : i_clk2_counter == "c3" ? c3_clk : i_clk2_counter == "c4" ? c4_clk : 1'b0; assign clk_tmp[3] = i_clk3_counter == "c0" ? c0_clk : i_clk3_counter == "c1" ? c1_clk : i_clk3_counter == "c2" ? c2_clk : i_clk3_counter == "c3" ? c3_clk : i_clk3_counter == "c4" ? c4_clk : 1'b0; assign clk_tmp[4] = i_clk4_counter == "c0" ? c0_clk : i_clk4_counter == "c1" ? c1_clk : i_clk4_counter == "c2" ? c2_clk : i_clk4_counter == "c3" ? c3_clk : i_clk4_counter == "c4" ? c4_clk : 1'b0; assign clk_out_pfd[0] = (pfd_locked == 1'b1) ? clk_tmp[0] : 1'bx; assign clk_out_pfd[1] = (pfd_locked == 1'b1) ? clk_tmp[1] : 1'bx; assign clk_out_pfd[2] = (pfd_locked == 1'b1) ? clk_tmp[2] : 1'bx; assign clk_out_pfd[3] = (pfd_locked == 1'b1) ? clk_tmp[3] : 1'bx; assign clk_out_pfd[4] = (pfd_locked == 1'b1) ? clk_tmp[4] : 1'bx; assign clk_out[0] = (test_bypass_lock_detect == "on") ? clk_out_pfd[0] : ((areset === 1'b1 || pll_in_test_mode === 1'b1) || (locked == 1'b1 && !reconfig_err) ? clk_tmp[0] : 1'bx); assign clk_out[1] = (test_bypass_lock_detect == "on") ? clk_out_pfd[1] : ((areset === 1'b1 || pll_in_test_mode === 1'b1) || (locked == 1'b1 && !reconfig_err) ? clk_tmp[1] : 1'bx); assign clk_out[2] = (test_bypass_lock_detect == "on") ? clk_out_pfd[2] : ((areset === 1'b1 || pll_in_test_mode === 1'b1) || (locked == 1'b1 && !reconfig_err) ? clk_tmp[2] : 1'bx); assign clk_out[3] = (test_bypass_lock_detect == "on") ? clk_out_pfd[3] : ((areset === 1'b1 || pll_in_test_mode === 1'b1) || (locked == 1'b1 && !reconfig_err) ? clk_tmp[3] : 1'bx); assign clk_out[4] = (test_bypass_lock_detect == "on") ? clk_out_pfd[4] : ((areset === 1'b1 || pll_in_test_mode === 1'b1) || (locked == 1'b1 && !reconfig_err) ? clk_tmp[4] : 1'bx); // ACCELERATE OUTPUTS and (clk[0], 1'b1, clk_out[0]); and (clk[1], 1'b1, clk_out[1]); and (clk[2], 1'b1, clk_out[2]); and (clk[3], 1'b1, clk_out[3]); and (clk[4], 1'b1, clk_out[4]); and (scandataout, 1'b1, scandata_out); and (scandone, 1'b1, scandone_tmp); assign fbout = fbclk; assign vcooverrange = (vco_range_detector_high_bits == -1) ? 1'bz : vco_over; assign vcounderrange = (vco_range_detector_low_bits == -1) ? 1'bz :vco_under; assign phasedone = ~update_phase; endmodule
module cycloneive_lcell_comb ( dataa, datab, datac, datad, cin, combout, cout ); input dataa; input datab; input datac; input datad; input cin; output combout; output cout; parameter lut_mask = 16'hFFFF; parameter sum_lutc_input = "datac"; parameter dont_touch = "off"; parameter lpm_type = "cycloneive_lcell_comb"; reg cout_tmp; reg combout_tmp; reg [1:0] isum_lutc_input; wire dataa_in; wire datab_in; wire datac_in; wire datad_in; wire cin_in; buf (dataa_in, dataa); buf (datab_in, datab); buf (datac_in, datac); buf (datad_in, datad); buf (cin_in, cin); specify (dataa => combout) = (0, 0) ; (datab => combout) = (0, 0) ; (datac => combout) = (0, 0) ; (datad => combout) = (0, 0) ; (cin => combout) = (0, 0) ; (dataa => cout) = (0, 0); (datab => cout) = (0, 0); (cin => cout) = (0, 0) ; endspecify // 4-input LUT function function lut4; input [15:0] mask; input dataa; input datab; input datac; input datad; begin lut4 = datad ? ( datac ? ( datab ? ( dataa ? mask[15] : mask[14]) : ( dataa ? mask[13] : mask[12])) : ( datab ? ( dataa ? mask[11] : mask[10]) : ( dataa ? mask[ 9] : mask[ 8]))) : ( datac ? ( datab ? ( dataa ? mask[ 7] : mask[ 6]) : ( dataa ? mask[ 5] : mask[ 4])) : ( datab ? ( dataa ? mask[ 3] : mask[ 2]) : ( dataa ? mask[ 1] : mask[ 0]))); end endfunction initial begin if (sum_lutc_input == "datac") isum_lutc_input = 0; else if (sum_lutc_input == "cin") isum_lutc_input = 1; else begin $display ("Error: Invalid sum_lutc_input specified\n"); $display ("Time: %0t Instance: %m", $time); isum_lutc_input = 2; end end always @(datad_in or datac_in or datab_in or dataa_in or cin_in) begin if (isum_lutc_input == 0) // datac begin combout_tmp = lut4(lut_mask, dataa_in, datab_in, datac_in, datad_in); end else if (isum_lutc_input == 1) // cin begin combout_tmp = lut4(lut_mask, dataa_in, datab_in, cin_in, datad_in); end cout_tmp = lut4(lut_mask, dataa_in, datab_in, cin_in, 'b0); end and (combout, combout_tmp, 1'b1) ; and (cout, cout_tmp, 1'b1) ; endmodule
module cycloneive_ff ( d, clk, clrn, aload, sclr, sload, asdata, ena, devclrn, devpor, q ); parameter power_up = "low"; parameter x_on_violation = "on"; parameter lpm_type = "cycloneive_ff"; input d; input clk; input clrn; input aload; input sclr; input sload; input asdata; input ena; input devclrn; input devpor; output q; tri1 devclrn; tri1 devpor; reg q_tmp; wire reset; reg d_viol; reg sclr_viol; reg sload_viol; reg asdata_viol; reg ena_viol; reg violation; reg clk_last_value; reg ix_on_violation; wire d_in; wire clk_in; wire clrn_in; wire aload_in; wire sclr_in; wire sload_in; wire asdata_in; wire ena_in; wire nosloadsclr; wire sloaddata; buf (d_in, d); buf (clk_in, clk); buf (clrn_in, clrn); buf (aload_in, aload); buf (sclr_in, sclr); buf (sload_in, sload); buf (asdata_in, asdata); buf (ena_in, ena); assign reset = devpor && devclrn && clrn_in && ena_in; assign nosloadsclr = reset && (!sload_in && !sclr_in); assign sloaddata = reset && sload_in; specify $setuphold (posedge clk &&& nosloadsclr, d, 0, 0, d_viol) ; $setuphold (posedge clk &&& reset, sclr, 0, 0, sclr_viol) ; $setuphold (posedge clk &&& reset, sload, 0, 0, sload_viol) ; $setuphold (posedge clk &&& sloaddata, asdata, 0, 0, asdata_viol) ; $setuphold (posedge clk &&& reset, ena, 0, 0, ena_viol) ; (posedge clk => (q +: q_tmp)) = 0 ; (posedge clrn => (q +: 1'b0)) = (0, 0) ; (posedge aload => (q +: q_tmp)) = (0, 0) ; (asdata => q) = (0, 0) ; endspecify initial begin violation = 'b0; clk_last_value = 'b0; if (power_up == "low") q_tmp = 'b0; else if (power_up == "high") q_tmp = 'b1; if (x_on_violation == "on") ix_on_violation = 1; else ix_on_violation = 0; end always @ (d_viol or sclr_viol or sload_viol or ena_viol or asdata_viol) begin if (ix_on_violation == 1) violation = 'b1; end always @ (asdata_in or clrn_in or posedge aload_in or devclrn or devpor) begin if (devpor == 'b0) q_tmp <= 'b0; else if (devclrn == 'b0) q_tmp <= 'b0; else if (clrn_in == 'b0) q_tmp <= 'b0; else if (aload_in == 'b1) q_tmp <= asdata_in; end always @ (clk_in or posedge clrn_in or posedge aload_in or devclrn or devpor or posedge violation) begin if (violation == 1'b1) begin violation = 'b0; q_tmp <= 'bX; end else begin if (devpor == 'b0 || devclrn == 'b0 || clrn_in === 'b0) q_tmp <= 'b0; else if (aload_in === 'b1) q_tmp <= asdata_in; else if (ena_in === 'b1 && clk_in === 'b1 && clk_last_value === 'b0) begin if (sclr_in === 'b1) q_tmp <= 'b0 ; else if (sload_in === 'b1) q_tmp <= asdata_in; else q_tmp <= d_in; end end clk_last_value = clk_in; end and (q, q_tmp, 1'b1); endmodule
module cycloneive_ram_pulse_generator ( clk, ena, pulse, cycle ); input clk; // clock input ena; // pulse enable output pulse; // pulse output cycle; // delayed clock parameter delay_pulse = 1'b0; parameter start_delay = (delay_pulse == 1'b0) ? 1 : 2; // delay write reg state; reg clk_prev; wire clk_ipd; specify specparam t_decode = 0,t_access = 0; (posedge clk => (pulse +: state)) = (t_decode,t_access); endspecify buf #(start_delay) (clk_ipd,clk); wire pulse_opd; buf buf_pulse (pulse,pulse_opd); initial clk_prev = 1'bx; always @(clk_ipd or posedge pulse) begin if (pulse) state <= 1'b0; else if (ena && clk_ipd === 1'b1 && clk_prev === 1'b0) state <= 1'b1; clk_prev = clk_ipd; end assign cycle = clk_ipd; assign pulse_opd = state; endmodule
module cycloneive_ram_register ( d, clk, aclr, devclrn, devpor, stall, ena, q, aclrout ); parameter width = 1; // data width parameter preset = 1'b0; // clear acts as preset input [width - 1:0] d; // data input clk; // clock input aclr; // asynch clear input devclrn,devpor; // device wide clear/reset input stall; // address stall input ena; // clock enable output [width - 1:0] q; // register output output aclrout; // delayed asynch clear wire ena_ipd; wire clk_ipd; wire aclr_ipd; wire [width - 1:0] d_ipd; buf buf_ena (ena_ipd,ena); buf buf_clk (clk_ipd,clk); buf buf_aclr (aclr_ipd,aclr); buf buf_d [width - 1:0] (d_ipd,d); wire stall_ipd; buf buf_stall (stall_ipd,stall); wire [width - 1:0] q_opd; buf buf_q [width - 1:0] (q,q_opd); reg [width - 1:0] q_reg; reg viol_notifier; wire reset; assign reset = devpor && devclrn && (!aclr_ipd) && (ena_ipd); specify $setup (d, posedge clk &&& reset, 0, viol_notifier); $setup (aclr, posedge clk, 0, viol_notifier); $setup (ena, posedge clk &&& reset, 0, viol_notifier ); $setup (stall, posedge clk &&& reset, 0, viol_notifier ); $hold (posedge clk &&& reset, d , 0, viol_notifier); $hold (posedge clk, aclr, 0, viol_notifier); $hold (posedge clk &&& reset, ena , 0, viol_notifier ); $hold (posedge clk &&& reset, stall, 0, viol_notifier ); (posedge clk => (q +: q_reg)) = (0,0); (posedge aclr => (q +: q_reg)) = (0,0); endspecify initial q_reg <= (preset) ? {width{1'b1}} : 'b0; always @(posedge clk_ipd or posedge aclr_ipd or negedge devclrn or negedge devpor) begin if (aclr_ipd || ~devclrn || ~devpor) q_reg <= (preset) ? {width{1'b1}} : 'b0; else if (ena_ipd & !stall_ipd) q_reg <= d_ipd; end assign aclrout = aclr_ipd; assign q_opd = q_reg; endmodule
module cycloneive_ram_block ( portadatain, portaaddr, portawe, portare, portbdatain, portbaddr, portbwe, portbre, clk0, clk1, ena0, ena1, ena2, ena3, clr0, clr1, portabyteenamasks, portbbyteenamasks, portaaddrstall, portbaddrstall, devclrn, devpor, portadataout, portbdataout ); // -------- GLOBAL PARAMETERS --------- parameter operation_mode = "single_port"; parameter mixed_port_feed_through_mode = "dont_care"; parameter ram_block_type = "auto"; parameter logical_ram_name = "ram_name"; parameter init_file = "init_file.hex"; parameter init_file_layout = "none"; parameter data_interleave_width_in_bits = 1; parameter data_interleave_offset_in_bits = 1; parameter port_a_logical_ram_depth = 0; parameter port_a_logical_ram_width = 0; parameter port_a_first_address = 0; parameter port_a_last_address = 0; parameter port_a_first_bit_number = 0; parameter port_a_data_out_clear = "none"; parameter port_a_data_out_clock = "none"; parameter port_a_data_width = 1; parameter port_a_address_width = 1; parameter port_a_byte_enable_mask_width = 1; parameter port_b_logical_ram_depth = 0; parameter port_b_logical_ram_width = 0; parameter port_b_first_address = 0; parameter port_b_last_address = 0; parameter port_b_first_bit_number = 0; parameter port_b_address_clear = "none"; parameter port_b_data_out_clear = "none"; parameter port_b_data_in_clock = "clock1"; parameter port_b_address_clock = "clock1"; parameter port_b_write_enable_clock = "clock1"; parameter port_b_read_enable_clock = "clock1"; parameter port_b_byte_enable_clock = "clock1"; parameter port_b_data_out_clock = "none"; parameter port_b_data_width = 1; parameter port_b_address_width = 1; parameter port_b_byte_enable_mask_width = 1; parameter port_a_read_during_write_mode = "new_data_no_nbe_read"; parameter port_b_read_during_write_mode = "new_data_no_nbe_read"; parameter power_up_uninitialized = "false"; parameter lpm_type = "cycloneive_ram_block"; parameter lpm_hint = "true"; parameter connectivity_checking = "off"; parameter mem_init0 = 2048'b0; parameter mem_init1 = 2048'b0; parameter mem_init2 = 2048'b0; parameter mem_init3 = 2048'b0; parameter mem_init4 = 2048'b0; parameter port_a_byte_size = 0; parameter port_b_byte_size = 0; parameter safe_write = "err_on_2clk"; parameter init_file_restructured = "unused"; parameter clk0_input_clock_enable = "none"; // ena0,ena2,none parameter clk0_core_clock_enable = "none"; // ena0,ena2,none parameter clk0_output_clock_enable = "none"; // ena0,none parameter clk1_input_clock_enable = "none"; // ena1,ena3,none parameter clk1_core_clock_enable = "none"; // ena1,ena3,none parameter clk1_output_clock_enable = "none"; // ena1,none // SIMULATION_ONLY_PARAMETERS_BEGIN parameter port_a_address_clear = "none"; parameter port_a_data_in_clock = "clock0"; parameter port_a_address_clock = "clock0"; parameter port_a_write_enable_clock = "clock0"; parameter port_a_byte_enable_clock = "clock0"; parameter port_a_read_enable_clock = "clock0"; // SIMULATION_ONLY_PARAMETERS_END // LOCAL_PARAMETERS_BEGIN parameter primary_port_is_a = (port_b_data_width <= port_a_data_width) ? 1'b1 : 1'b0; parameter primary_port_is_b = ~primary_port_is_a; parameter mode_is_rom_or_sp = ((operation_mode == "rom") || (operation_mode == "single_port")) ? 1'b1 : 1'b0; parameter data_width = (primary_port_is_a) ? port_a_data_width : port_b_data_width; parameter data_unit_width = (mode_is_rom_or_sp | primary_port_is_b) ? port_a_data_width : port_b_data_width; parameter address_width = (mode_is_rom_or_sp | primary_port_is_b) ? port_a_address_width : port_b_address_width; parameter address_unit_width = (mode_is_rom_or_sp | primary_port_is_a) ? port_a_address_width : port_b_address_width; parameter wired_mode = ((port_a_address_width == 1) && (port_a_address_width == port_b_address_width) && (port_a_data_width != port_b_data_width)); parameter num_rows = 1 << address_unit_width; parameter num_cols = (mode_is_rom_or_sp) ? 1 : ( wired_mode ? 2 : ( (primary_port_is_a) ? 1 << (port_b_address_width - port_a_address_width) : 1 << (port_a_address_width - port_b_address_width) ) ) ; parameter mask_width_prime = (primary_port_is_a) ? port_a_byte_enable_mask_width : port_b_byte_enable_mask_width; parameter mask_width_sec = (primary_port_is_a) ? port_b_byte_enable_mask_width : port_a_byte_enable_mask_width; parameter byte_size_a = port_a_data_width/port_a_byte_enable_mask_width; parameter byte_size_b = port_b_data_width/port_b_byte_enable_mask_width; parameter mode_is_dp = (operation_mode == "dual_port") ? 1'b1 : 1'b0; // Hardware write modes parameter dual_clock = ((operation_mode == "dual_port") || (operation_mode == "bidir_dual_port")) && (port_b_address_clock == "clock1"); parameter both_new_data_same_port = ( ((port_a_read_during_write_mode == "new_data_no_nbe_read") || (port_a_read_during_write_mode == "dont_care")) && ((port_b_read_during_write_mode == "new_data_no_nbe_read") || (port_b_read_during_write_mode == "dont_care")) ) ? 1'b1 : 1'b0; parameter hw_write_mode_a = ( ((port_a_read_during_write_mode == "old_data") || (port_a_read_during_write_mode == "new_data_with_nbe_read")) ) ? "R+W" : ( dual_clock || ( mixed_port_feed_through_mode == "dont_care" && both_new_data_same_port ) ? "FW" : "DW" ); parameter hw_write_mode_b = ( ((port_b_read_during_write_mode == "old_data") || (port_b_read_during_write_mode == "new_data_with_nbe_read")) ) ? "R+W" : ( dual_clock || ( mixed_port_feed_through_mode == "dont_care" && both_new_data_same_port ) ? "FW" : "DW" ); parameter delay_write_pulse_a = (hw_write_mode_a != "FW") ? 1'b1 : 1'b0; parameter delay_write_pulse_b = (hw_write_mode_b != "FW") ? 1'b1 : 1'b0; parameter be_mask_write_a = (port_a_read_during_write_mode == "new_data_with_nbe_read") ? 1'b1 : 1'b0; parameter be_mask_write_b = (port_b_read_during_write_mode == "new_data_with_nbe_read") ? 1'b1 : 1'b0; parameter old_data_write_a = (port_a_read_during_write_mode == "old_data") ? 1'b1 : 1'b0; parameter old_data_write_b = (port_b_read_during_write_mode == "old_data") ? 1'b1 : 1'b0; parameter read_before_write_a = (hw_write_mode_a == "R+W") ? 1'b1 : 1'b0; parameter read_before_write_b = (hw_write_mode_b == "R+W") ? 1'b1 : 1'b0; // LOCAL_PARAMETERS_END // -------- PORT DECLARATIONS --------- input portawe; input portare; input [port_a_data_width - 1:0] portadatain; input [port_a_address_width - 1:0] portaaddr; input [port_a_byte_enable_mask_width - 1:0] portabyteenamasks; input portbwe, portbre; input [port_b_data_width - 1:0] portbdatain; input [port_b_address_width - 1:0] portbaddr; input [port_b_byte_enable_mask_width - 1:0] portbbyteenamasks; input clr0,clr1; input clk0,clk1; input ena0,ena1; input ena2,ena3; input devclrn,devpor; input portaaddrstall; input portbaddrstall; output [port_a_data_width - 1:0] portadataout; output [port_b_data_width - 1:0] portbdataout; tri0 portawe_int; assign portawe_int = portawe; tri1 portare_int; assign portare_int = portare; tri0 [port_a_data_width - 1:0] portadatain_int; assign portadatain_int = portadatain; tri0 [port_a_address_width - 1:0] portaaddr_int; assign portaaddr_int = portaaddr; tri1 [port_a_byte_enable_mask_width - 1:0] portabyteenamasks_int; assign portabyteenamasks_int = portabyteenamasks; tri0 portbwe_int; assign portbwe_int = portbwe; tri1 portbre_int; assign portbre_int = portbre; tri0 [port_b_data_width - 1:0] portbdatain_int; assign portbdatain_int = portbdatain; tri0 [port_b_address_width - 1:0] portbaddr_int; assign portbaddr_int = portbaddr; tri1 [port_b_byte_enable_mask_width - 1:0] portbbyteenamasks_int; assign portbbyteenamasks_int = portbbyteenamasks; tri0 clr0_int,clr1_int; assign clr0_int = clr0; assign clr1_int = clr1; tri0 clk0_int,clk1_int; assign clk0_int = clk0; assign clk1_int = clk1; tri1 ena0_int,ena1_int; assign ena0_int = ena0; assign ena1_int = ena1; tri1 ena2_int,ena3_int; assign ena2_int = ena2; assign ena3_int = ena3; tri0 portaaddrstall_int; assign portaaddrstall_int = portaaddrstall; tri0 portbaddrstall_int; assign portbaddrstall_int = portbaddrstall; tri1 devclrn; tri1 devpor; // -------- INTERNAL signals --------- // clock / clock enable wire clk_a_in,clk_a_byteena,clk_a_out,clkena_a_out; wire clk_a_rena, clk_a_wena; wire clk_a_core; wire clk_b_in,clk_b_byteena,clk_b_out,clkena_b_out; wire clk_b_rena, clk_b_wena; wire clk_b_core; wire write_cycle_a,write_cycle_b; // asynch clear wire datain_a_clr,dataout_a_clr,datain_b_clr,dataout_b_clr; wire dataout_a_clr_reg, dataout_b_clr_reg; wire dataout_a_clr_reg_latch, dataout_b_clr_reg_latch; wire addr_a_clr,addr_b_clr; wire byteena_a_clr,byteena_b_clr; wire we_a_clr, re_a_clr, we_b_clr, re_b_clr; wire datain_a_clr_in,datain_b_clr_in; wire addr_a_clr_in,addr_b_clr_in; wire byteena_a_clr_in,byteena_b_clr_in; wire we_a_clr_in, re_a_clr_in, we_b_clr_in, re_b_clr_in; reg mem_invalidate; wire [`PRIME:`SEC] clear_asserted_during_write; reg clear_asserted_during_write_a,clear_asserted_during_write_b; // port A registers wire we_a_reg; wire re_a_reg; wire [port_a_address_width - 1:0] addr_a_reg; wire [port_a_data_width - 1:0] datain_a_reg, dataout_a_reg; reg [port_a_data_width - 1:0] dataout_a; wire [port_a_byte_enable_mask_width - 1:0] byteena_a_reg; reg out_a_is_reg; // port B registers wire we_b_reg, re_b_reg; wire [port_b_address_width - 1:0] addr_b_reg; wire [port_b_data_width - 1:0] datain_b_reg, dataout_b_reg; reg [port_b_data_width - 1:0] dataout_b; wire [port_b_byte_enable_mask_width - 1:0] byteena_b_reg; reg out_b_is_reg; // placeholders for read/written data reg [data_width - 1:0] read_data_latch; reg [data_width - 1:0] mem_data; reg [data_width - 1:0] old_mem_data; reg [data_unit_width - 1:0] read_unit_data_latch; reg [data_width - 1:0] mem_unit_data; // pulses for A/B ports wire write_pulse_a,write_pulse_b; wire read_pulse_a,read_pulse_b; wire read_pulse_a_feedthru,read_pulse_b_feedthru; wire rw_pulse_a, rw_pulse_b; wire [address_unit_width - 1:0] addr_prime_reg; // registered address wire [address_width - 1:0] addr_sec_reg; wire [data_width - 1:0] datain_prime_reg; // registered data wire [data_unit_width - 1:0] datain_sec_reg; // pulses for primary/secondary ports wire write_pulse_prime,write_pulse_sec; wire read_pulse_prime,read_pulse_sec; wire read_pulse_prime_feedthru,read_pulse_sec_feedthru; wire rw_pulse_prime, rw_pulse_sec; reg read_pulse_prime_last_value, read_pulse_sec_last_value; reg rw_pulse_prime_last_value, rw_pulse_sec_last_value; reg [`PRIME:`SEC] dual_write; // simultaneous write to same location // (row,column) coordinates reg [address_unit_width - 1:0] row_sec; reg [address_width + data_unit_width - address_unit_width - 1:0] col_sec; // memory core reg [data_width - 1:0] mem [num_rows - 1:0]; // byte enable wire [data_width - 1:0] mask_vector_prime, mask_vector_prime_int; wire [data_unit_width - 1:0] mask_vector_sec, mask_vector_sec_int; reg [data_unit_width - 1:0] mask_vector_common_int; reg [port_a_data_width - 1:0] mask_vector_a, mask_vector_a_int; reg [port_b_data_width - 1:0] mask_vector_b, mask_vector_b_int; // memory initialization integer i,j,k,l; integer addr_range_init; reg [data_width - 1:0] init_mem_word; reg [(port_a_last_address - port_a_first_address + 1)*port_a_data_width - 1:0] mem_init; // port active for read/write wire active_a_in, active_b_in; wire active_a_core,active_a_core_in,active_b_core,active_b_core_in; wire active_write_a,active_write_b,active_write_clear_a,active_write_clear_b; reg mode_is_rom,mode_is_sp,mode_is_bdp; // ram mode reg ram_type; // ram type eg. MRAM initial begin `ifdef QUARTUS_MEMORY_PLI $memory_connect(mem); `endif ram_type = 0; mode_is_rom = (operation_mode == "rom"); mode_is_sp = (operation_mode == "single_port"); mode_is_bdp = (operation_mode == "bidir_dual_port"); out_a_is_reg = (port_a_data_out_clock == "none") ? 1'b0 : 1'b1; out_b_is_reg = (port_b_data_out_clock == "none") ? 1'b0 : 1'b1; // powerup output latches to 0 dataout_a = 'b0; if (mode_is_dp || mode_is_bdp) dataout_b = 'b0; if ((power_up_uninitialized == "false") && ~ram_type) for (i = 0; i < num_rows; i = i + 1) mem[i] = 'b0; if ((init_file_layout == "port_a") || (init_file_layout == "port_b")) begin mem_init = { mem_init4 , mem_init3 , mem_init2 , mem_init1 , mem_init0 }; addr_range_init = (primary_port_is_a) ? port_a_last_address - port_a_first_address + 1 : port_b_last_address - port_b_first_address + 1 ; for (j = 0; j < addr_range_init; j = j + 1) begin for (k = 0; k < data_width; k = k + 1) init_mem_word[k] = mem_init[j*data_width + k]; mem[j] = init_mem_word; end end dual_write = 'b0; end assign clk_a_in = clk0_int; assign clk_a_wena = (port_a_write_enable_clock == "none") ? 1'b0 : clk_a_in; assign clk_a_rena = (port_a_read_enable_clock == "none") ? 1'b0 : clk_a_in; assign clk_a_byteena = (port_a_byte_enable_clock == "none") ? 1'b0 : clk_a_in; assign clk_a_out = (port_a_data_out_clock == "none") ? 1'b0 : ( (port_a_data_out_clock == "clock0") ? clk0_int : clk1_int); assign clk_b_in = (port_b_address_clock == "clock0") ? clk0_int : clk1_int; assign clk_b_byteena = (port_b_byte_enable_clock == "none") ? 1'b0 : ( (port_b_byte_enable_clock == "clock0") ? clk0_int : clk1_int); assign clk_b_wena = (port_b_write_enable_clock == "none") ? 1'b0 : ( (port_b_write_enable_clock == "clock0") ? clk0_int : clk1_int); assign clk_b_rena = (port_b_read_enable_clock == "none") ? 1'b0 : ( (port_b_read_enable_clock == "clock0") ? clk0_int : clk1_int); assign clk_b_out = (port_b_data_out_clock == "none") ? 1'b0 : ( (port_b_data_out_clock == "clock0") ? clk0_int : clk1_int); assign addr_a_clr_in = (port_a_address_clear == "none") ? 1'b0 : clr0_int; assign addr_b_clr_in = (port_b_address_clear == "none") ? 1'b0 : ( (port_b_address_clear == "clear0") ? clr0_int : clr1_int); assign datain_a_clr_in = 1'b0; assign dataout_a_clr = (port_a_data_out_clock == "none") ? ( (port_a_data_out_clear == "none") ? 1'b0 : ( (port_a_data_out_clear == "clear0") ? clr0_int : clr1_int)) : 1'b0; assign dataout_a_clr_reg = (port_a_data_out_clear == "none") ? 1'b0 : ( (port_a_data_out_clear == "clear0") ? clr0_int : clr1_int); assign datain_b_clr_in = 1'b0; assign dataout_b_clr = (port_b_data_out_clock == "none") ? ( (port_b_data_out_clear == "none") ? 1'b0 : ( (port_b_data_out_clear == "clear0") ? clr0_int : clr1_int)) : 1'b0; assign dataout_b_clr_reg = (port_b_data_out_clear == "none") ? 1'b0 : ( (port_b_data_out_clear == "clear0") ? clr0_int : clr1_int); assign byteena_a_clr_in = 1'b0; assign byteena_b_clr_in = 1'b0; assign we_a_clr_in = 1'b0; assign re_a_clr_in = 1'b0; assign we_b_clr_in = 1'b0; assign re_b_clr_in = 1'b0; assign active_a_in = (clk0_input_clock_enable == "none") ? 1'b1 : ( (clk0_input_clock_enable == "ena0") ? ena0_int : ena2_int ); assign active_a_core_in = (clk0_core_clock_enable == "none") ? 1'b1 : ( (clk0_core_clock_enable == "ena0") ? ena0_int : ena2_int ); assign active_b_in = (port_b_address_clock == "clock0") ? ( (clk0_input_clock_enable == "none") ? 1'b1 : ((clk0_input_clock_enable == "ena0") ? ena0_int : ena2_int) ) : ( (clk1_input_clock_enable == "none") ? 1'b1 : ((clk1_input_clock_enable == "ena1") ? ena1_int : ena3_int) ); assign active_b_core_in = (port_b_address_clock == "clock0") ? ( (clk0_core_clock_enable == "none") ? 1'b1 : ((clk0_core_clock_enable == "ena0") ? ena0_int : ena2_int) ) : ( (clk1_core_clock_enable == "none") ? 1'b1 : ((clk1_core_clock_enable == "ena1") ? ena1_int : ena3_int) ); assign active_write_a = (byteena_a_reg !== 'b0); assign active_write_b = (byteena_b_reg !== 'b0); // Store core clock enable value for delayed write // port A core active cycloneive_ram_register active_core_port_a ( .d(active_a_core_in), .clk(clk_a_in), .aclr(1'b0), .devclrn(1'b1), .devpor(1'b1), .stall(1'b0), .ena(1'b1), .q(active_a_core),.aclrout() ); defparam active_core_port_a.width = 1; // port B core active cycloneive_ram_register active_core_port_b ( .d(active_b_core_in), .clk(clk_b_in), .aclr(1'b0), .devclrn(1'b1), .devpor(1'b1), .stall(1'b0), .ena(1'b1), .q(active_b_core),.aclrout() ); defparam active_core_port_b.width = 1; // ------- A input registers ------- // write enable cycloneive_ram_register we_a_register ( .d(mode_is_rom ? 1'b0 : portawe_int), .clk(clk_a_wena), .aclr(we_a_clr_in), .devclrn(devclrn), .devpor(devpor), .stall(1'b0), .ena(active_a_in), .q(we_a_reg), .aclrout(we_a_clr) ); defparam we_a_register.width = 1; // read enable cycloneive_ram_register re_a_register ( .d(portare_int), .clk(clk_a_rena), .aclr(re_a_clr_in), .devclrn(devclrn), .devpor(devpor), .stall(1'b0), .ena(active_a_in), .q(re_a_reg), .aclrout(re_a_clr) ); // address cycloneive_ram_register addr_a_register ( .d(portaaddr_int), .clk(clk_a_in), .aclr(addr_a_clr_in), .devclrn(devclrn),.devpor(devpor), .stall(portaaddrstall_int), .ena(active_a_in), .q(addr_a_reg), .aclrout(addr_a_clr) ); defparam addr_a_register.width = port_a_address_width; // data cycloneive_ram_register datain_a_register ( .d(portadatain_int), .clk(clk_a_in), .aclr(datain_a_clr_in), .devclrn(devclrn), .devpor(devpor), .stall(1'b0), .ena(active_a_in), .q(datain_a_reg), .aclrout(datain_a_clr) ); defparam datain_a_register.width = port_a_data_width; // byte enable cycloneive_ram_register byteena_a_register ( .d(portabyteenamasks_int), .clk(clk_a_byteena), .aclr(byteena_a_clr_in), .stall(1'b0), .devclrn(devclrn), .devpor(devpor), .ena(active_a_in), .q(byteena_a_reg), .aclrout(byteena_a_clr) ); defparam byteena_a_register.width = port_a_byte_enable_mask_width; defparam byteena_a_register.preset = 1'b1; // ------- B input registers ------- // write enable cycloneive_ram_register we_b_register ( .d(portbwe_int), .clk(clk_b_wena), .aclr(we_b_clr_in), .stall(1'b0), .devclrn(devclrn), .devpor(devpor), .ena(active_b_in), .q(we_b_reg), .aclrout(we_b_clr) ); defparam we_b_register.width = 1; defparam we_b_register.preset = 1'b0; // read enable cycloneive_ram_register re_b_register ( .d(portbre_int), .clk(clk_b_rena), .aclr(re_b_clr_in), .stall(1'b0), .devclrn(devclrn), .devpor(devpor), .ena(active_b_in), .q(re_b_reg), .aclrout(re_b_clr) ); defparam re_b_register.width = 1; defparam re_b_register.preset = 1'b0; // address cycloneive_ram_register addr_b_register ( .d(portbaddr_int), .clk(clk_b_in), .aclr(addr_b_clr_in), .devclrn(devclrn), .devpor(devpor), .stall(portbaddrstall_int), .ena(active_b_in), .q(addr_b_reg), .aclrout(addr_b_clr) ); defparam addr_b_register.width = port_b_address_width; // data cycloneive_ram_register datain_b_register ( .d(portbdatain_int), .clk(clk_b_in), .aclr(datain_b_clr_in), .devclrn(devclrn), .devpor(devpor), .stall(1'b0), .ena(active_b_in), .q(datain_b_reg), .aclrout(datain_b_clr) ); defparam datain_b_register.width = port_b_data_width; // byte enable cycloneive_ram_register byteena_b_register ( .d(portbbyteenamasks_int), .clk(clk_b_byteena), .aclr(byteena_b_clr_in), .stall(1'b0), .devclrn(devclrn), .devpor(devpor), .ena(active_b_in), .q(byteena_b_reg), .aclrout(byteena_b_clr) ); defparam byteena_b_register.width = port_b_byte_enable_mask_width; defparam byteena_b_register.preset = 1'b1; assign datain_prime_reg = (primary_port_is_a) ? datain_a_reg : datain_b_reg; assign addr_prime_reg = (primary_port_is_a) ? addr_a_reg : addr_b_reg; assign datain_sec_reg = (primary_port_is_a) ? datain_b_reg : datain_a_reg; assign addr_sec_reg = (primary_port_is_a) ? addr_b_reg : addr_a_reg; assign mask_vector_prime = (primary_port_is_a) ? mask_vector_a : mask_vector_b; assign mask_vector_prime_int = (primary_port_is_a) ? mask_vector_a_int : mask_vector_b_int; assign mask_vector_sec = (primary_port_is_a) ? mask_vector_b : mask_vector_a; assign mask_vector_sec_int = (primary_port_is_a) ? mask_vector_b_int : mask_vector_a_int; // Hardware Write Modes // CYCLONEIVE // Write pulse generation cycloneive_ram_pulse_generator wpgen_a ( .clk(clk_a_in), .ena(active_a_core & active_write_a & we_a_reg), .pulse(write_pulse_a), .cycle(write_cycle_a) ); defparam wpgen_a.delay_pulse = delay_write_pulse_a; cycloneive_ram_pulse_generator wpgen_b ( .clk(clk_b_in), .ena(active_b_core & active_write_b & mode_is_bdp & we_b_reg), .pulse(write_pulse_b), .cycle(write_cycle_b) ); defparam wpgen_b.delay_pulse = delay_write_pulse_b; // Read pulse generation cycloneive_ram_pulse_generator rpgen_a ( .clk(clk_a_in), .ena(active_a_core & re_a_reg & ~we_a_reg & ~dataout_a_clr), .pulse(read_pulse_a), .cycle(clk_a_core) ); cycloneive_ram_pulse_generator rpgen_b ( .clk(clk_b_in), .ena((mode_is_dp | mode_is_bdp) & active_b_core & re_b_reg & ~we_b_reg & ~dataout_b_clr), .pulse(read_pulse_b), .cycle(clk_b_core) ); // Read during write pulse generation cycloneive_ram_pulse_generator rwpgen_a ( .clk(clk_a_in), .ena(active_a_core & re_a_reg & we_a_reg & read_before_write_a & ~dataout_a_clr), .pulse(rw_pulse_a),.cycle() ); cycloneive_ram_pulse_generator rwpgen_b ( .clk(clk_b_in), .ena(active_b_core & mode_is_bdp & re_b_reg & we_b_reg & read_before_write_b & ~dataout_b_clr), .pulse(rw_pulse_b),.cycle() ); assign write_pulse_prime = (primary_port_is_a) ? write_pulse_a : write_pulse_b; assign read_pulse_prime = (primary_port_is_a) ? read_pulse_a : read_pulse_b; assign read_pulse_prime_feedthru = (primary_port_is_a) ? read_pulse_a_feedthru : read_pulse_b_feedthru; assign rw_pulse_prime = (primary_port_is_a) ? rw_pulse_a : rw_pulse_b; assign write_pulse_sec = (primary_port_is_a) ? write_pulse_b : write_pulse_a; assign read_pulse_sec = (primary_port_is_a) ? read_pulse_b : read_pulse_a; assign read_pulse_sec_feedthru = (primary_port_is_a) ? read_pulse_b_feedthru : read_pulse_a_feedthru; assign rw_pulse_sec = (primary_port_is_a) ? rw_pulse_b : rw_pulse_a; // Create internal masks for byte enable processing always @(byteena_a_reg) begin for (i = 0; i < port_a_data_width; i = i + 1) begin mask_vector_a[i] = (byteena_a_reg[i/byte_size_a] === 1'b1) ? 1'b0 : 1'bx; mask_vector_a_int[i] = (byteena_a_reg[i/byte_size_a] === 1'b0) ? 1'b0 : 1'bx; end end always @(byteena_b_reg) begin for (l = 0; l < port_b_data_width; l = l + 1) begin mask_vector_b[l] = (byteena_b_reg[l/byte_size_b] === 1'b1) ? 1'b0 : 1'bx; mask_vector_b_int[l] = (byteena_b_reg[l/byte_size_b] === 1'b0) ? 1'b0 : 1'bx; end end // Latch Clear port A always @(posedge dataout_a_clr) begin if (primary_port_is_a) begin read_data_latch = 'b0; dataout_a = 'b0; end else begin read_unit_data_latch = 'b0; dataout_a = 'b0; end end // Latch Clear port B always @(posedge dataout_b_clr) begin if (primary_port_is_b) begin read_data_latch = 'b0; dataout_b = 'b0; end else begin read_unit_data_latch = 'b0; dataout_b = 'b0; end end always @(posedge write_pulse_prime or posedge write_pulse_sec or posedge read_pulse_prime or posedge read_pulse_sec or posedge rw_pulse_prime or posedge rw_pulse_sec ) begin // Read before Write stage 1 : read data from memory if (rw_pulse_prime && (rw_pulse_prime !== rw_pulse_prime_last_value)) begin read_data_latch = mem[addr_prime_reg]; rw_pulse_prime_last_value = rw_pulse_prime; end if (rw_pulse_sec && (rw_pulse_sec !== rw_pulse_sec_last_value)) begin row_sec = addr_sec_reg / num_cols; col_sec = (addr_sec_reg % num_cols) * data_unit_width; mem_unit_data = mem[row_sec]; for (j = col_sec; j <= col_sec + data_unit_width - 1; j = j + 1) read_unit_data_latch[j - col_sec] = mem_unit_data[j]; rw_pulse_sec_last_value = rw_pulse_sec; end // Write stage 1 : write X to memory if (write_pulse_prime) begin old_mem_data = mem[addr_prime_reg]; mem_data = mem[addr_prime_reg] ^ mask_vector_prime_int; mem[addr_prime_reg] = mem_data; if ((row_sec == addr_prime_reg) && (read_pulse_sec)) begin mem_unit_data = (mixed_port_feed_through_mode == "dont_care") ? {data_width{1'bx}} : old_mem_data; for (j = col_sec; j <= col_sec + data_unit_width - 1; j = j + 1) read_unit_data_latch[j - col_sec] = mem_unit_data[j]; end end if (write_pulse_sec) begin row_sec = addr_sec_reg / num_cols; col_sec = (addr_sec_reg % num_cols) * data_unit_width; mem_unit_data = mem[row_sec]; for (j = col_sec; j <= col_sec + data_unit_width - 1; j = j + 1) mem_unit_data[j] = mem_unit_data[j] ^ mask_vector_sec_int[j - col_sec]; mem[row_sec] = mem_unit_data; end if ((addr_prime_reg == row_sec) && write_pulse_prime && write_pulse_sec) dual_write = 2'b11; // Read stage 1 : read data from memory if (read_pulse_prime && read_pulse_prime !== read_pulse_prime_last_value) begin read_data_latch = mem[addr_prime_reg]; read_pulse_prime_last_value = read_pulse_prime; end if (read_pulse_sec && read_pulse_sec !== read_pulse_sec_last_value) begin row_sec = addr_sec_reg / num_cols; col_sec = (addr_sec_reg % num_cols) * data_unit_width; if ((row_sec == addr_prime_reg) && (write_pulse_prime)) mem_unit_data = (mixed_port_feed_through_mode == "dont_care") ? {data_width{1'bx}} : old_mem_data; else mem_unit_data = mem[row_sec]; for (j = col_sec; j <= col_sec + data_unit_width - 1; j = j + 1) read_unit_data_latch[j - col_sec] = mem_unit_data[j]; read_pulse_sec_last_value = read_pulse_sec; end end // Simultaneous write to same/overlapping location by both ports always @(dual_write) begin if (dual_write == 2'b11) begin for (i = 0; i < data_unit_width; i = i + 1) mask_vector_common_int[i] = mask_vector_prime_int[col_sec + i] & mask_vector_sec_int[i]; end else if (dual_write == 2'b01) mem_unit_data = mem[row_sec]; else if (dual_write == 'b0) begin mem_data = mem[addr_prime_reg]; for (i = 0; i < data_unit_width; i = i + 1) mem_data[col_sec + i] = mem_data[col_sec + i] ^ mask_vector_common_int[i]; mem[addr_prime_reg] = mem_data; end end // Write stage 2 : Write actual data to memory always @(negedge write_pulse_prime) begin if (clear_asserted_during_write[`PRIME] !== 1'b1) begin for (i = 0; i < data_width; i = i + 1) if (mask_vector_prime[i] == 1'b0) mem_data[i] = datain_prime_reg[i]; mem[addr_prime_reg] = mem_data; end dual_write[`PRIME] = 1'b0; end always @(negedge write_pulse_sec) begin if (clear_asserted_during_write[`SEC] !== 1'b1) begin for (i = 0; i < data_unit_width; i = i + 1) if (mask_vector_sec[i] == 1'b0) mem_unit_data[col_sec + i] = datain_sec_reg[i]; mem[row_sec] = mem_unit_data; end dual_write[`SEC] = 1'b0; end always @(negedge read_pulse_prime) read_pulse_prime_last_value = 1'b0; always @(negedge read_pulse_sec) read_pulse_sec_last_value = 1'b0; always @(negedge rw_pulse_prime) rw_pulse_prime_last_value = 1'b0; always @(negedge rw_pulse_sec) rw_pulse_sec_last_value = 1'b0; // Read stage 2 : Send data to output always @(negedge read_pulse_prime) begin if (primary_port_is_a) dataout_a = read_data_latch; else dataout_b = read_data_latch; end always @(negedge read_pulse_sec) begin if (primary_port_is_b) dataout_a = read_unit_data_latch; else dataout_b = read_unit_data_latch; end // Read during Write stage 2 : Send data to output always @(negedge rw_pulse_prime) begin if (primary_port_is_a) begin // BE mask write if (be_mask_write_a) begin for (i = 0; i < data_width; i = i + 1) if (mask_vector_prime[i] === 1'bx) // disabled byte dataout_a[i] = read_data_latch[i]; end else dataout_a = read_data_latch; end else begin // BE mask write if (be_mask_write_b) begin for (i = 0; i < data_width; i = i + 1) if (mask_vector_prime[i] === 1'bx) // disabled byte dataout_b[i] = read_data_latch[i]; end else dataout_b = read_data_latch; end end always @(negedge rw_pulse_sec) begin if (primary_port_is_b) begin // BE mask write if (be_mask_write_a) begin for (i = 0; i < data_unit_width; i = i + 1) if (mask_vector_sec[i] === 1'bx) // disabled byte dataout_a[i] = read_unit_data_latch[i]; end else dataout_a = read_unit_data_latch; end else begin // BE mask write if (be_mask_write_b) begin for (i = 0; i < data_unit_width; i = i + 1) if (mask_vector_sec[i] === 1'bx) // disabled byte dataout_b[i] = read_unit_data_latch[i]; end else dataout_b = read_unit_data_latch; end end // Same port feed through cycloneive_ram_pulse_generator ftpgen_a ( .clk(clk_a_in), .ena(active_a_core & ~mode_is_dp & ~old_data_write_a & we_a_reg & re_a_reg & ~dataout_a_clr), .pulse(read_pulse_a_feedthru),.cycle() ); cycloneive_ram_pulse_generator ftpgen_b ( .clk(clk_b_in), .ena(active_b_core & mode_is_bdp & ~old_data_write_b & we_b_reg & re_b_reg & ~dataout_b_clr), .pulse(read_pulse_b_feedthru),.cycle() ); always @(negedge read_pulse_prime_feedthru) begin if (primary_port_is_a) begin if (be_mask_write_a) begin for (i = 0; i < data_width; i = i + 1) if (mask_vector_prime[i] == 1'b0) // enabled byte dataout_a[i] = datain_prime_reg[i]; end else dataout_a = datain_prime_reg ^ mask_vector_prime; end else begin if (be_mask_write_b) begin for (i = 0; i < data_width; i = i + 1) if (mask_vector_prime[i] == 1'b0) // enabled byte dataout_b[i] = datain_prime_reg[i]; end else dataout_b = datain_prime_reg ^ mask_vector_prime; end end always @(negedge read_pulse_sec_feedthru) begin if (primary_port_is_b) begin if (be_mask_write_a) begin for (i = 0; i < data_unit_width; i = i + 1) if (mask_vector_sec[i] == 1'b0) // enabled byte dataout_a[i] = datain_sec_reg[i]; end else dataout_a = datain_sec_reg ^ mask_vector_sec; end else begin if (be_mask_write_b) begin for (i = 0; i < data_unit_width; i = i + 1) if (mask_vector_sec[i] == 1'b0) // enabled byte dataout_b[i] = datain_sec_reg[i]; end else dataout_b = datain_sec_reg ^ mask_vector_sec; end end // Input register clears always @(posedge addr_a_clr or posedge datain_a_clr or posedge we_a_clr) clear_asserted_during_write_a = write_pulse_a; assign active_write_clear_a = active_write_a & write_cycle_a; always @(posedge addr_a_clr) begin if (active_write_clear_a & we_a_reg) mem_invalidate = 1'b1; else if (active_a_core & re_a_reg & ~dataout_a_clr & ~dataout_a_clr_reg_latch) begin if (primary_port_is_a) begin read_data_latch = 'bx; end else begin read_unit_data_latch = 'bx; end dataout_a = 'bx; end end always @(posedge datain_a_clr or posedge we_a_clr) begin if (active_write_clear_a & we_a_reg) begin if (primary_port_is_a) mem[addr_prime_reg] = 'bx; else begin mem_unit_data = mem[row_sec]; for (j = col_sec; j <= col_sec + data_unit_width - 1; j = j + 1) mem_unit_data[j] = 1'bx; mem[row_sec] = mem_unit_data; end if (primary_port_is_a) begin read_data_latch = 'bx; end else begin read_unit_data_latch = 'bx; end end end assign active_write_clear_b = active_write_b & write_cycle_b; always @(posedge addr_b_clr or posedge datain_b_clr or posedge we_b_clr) clear_asserted_during_write_b = write_pulse_b; always @(posedge addr_b_clr) begin if (mode_is_bdp & active_write_clear_b & we_b_reg) mem_invalidate = 1'b1; else if ((mode_is_dp | mode_is_bdp) & active_b_core & re_b_reg & ~dataout_b_clr & ~dataout_b_clr_reg_latch) begin if (primary_port_is_b) begin read_data_latch = 'bx; end else begin read_unit_data_latch = 'bx; end dataout_b = 'bx; end end always @(posedge datain_b_clr or posedge we_b_clr) begin if (mode_is_bdp & active_write_clear_b & we_b_reg) begin if (primary_port_is_b) mem[addr_prime_reg] = 'bx; else begin mem_unit_data = mem[row_sec]; for (j = col_sec; j <= col_sec + data_unit_width - 1; j = j + 1) mem_unit_data[j] = 'bx; mem[row_sec] = mem_unit_data; end if (primary_port_is_b) begin read_data_latch = 'bx; end else begin read_unit_data_latch = 'bx; end end end assign clear_asserted_during_write[primary_port_is_a] = clear_asserted_during_write_a; assign clear_asserted_during_write[primary_port_is_b] = clear_asserted_during_write_b; always @(posedge mem_invalidate) begin for (i = 0; i < num_rows; i = i + 1) mem[i] = 'bx; mem_invalidate = 1'b0; end // ------- Aclr mux registers (Latch Clear) -------- // port A cycloneive_ram_register aclr__a__mux_register ( .d(dataout_a_clr), .clk(clk_a_core), .aclr(1'b0), .devclrn(devclrn), .devpor(devpor), .stall(1'b0), .ena(1'b1), .q(dataout_a_clr_reg_latch),.aclrout() ); // port B cycloneive_ram_register aclr__b__mux_register ( .d(dataout_b_clr), .clk(clk_b_core), .aclr(1'b0), .devclrn(devclrn), .devpor(devpor), .stall(1'b0), .ena(1'b1), .q(dataout_b_clr_reg_latch),.aclrout() ); // ------- Output registers -------- assign clkena_a_out = (port_a_data_out_clock == "clock0") ? ((clk0_output_clock_enable == "none") ? 1'b1 : ena0_int) : ((clk1_output_clock_enable == "none") ? 1'b1 : ena1_int) ; cycloneive_ram_register dataout_a_register ( .d(dataout_a), .clk(clk_a_out), .aclr(dataout_a_clr_reg), .devclrn(devclrn), .devpor(devpor), .stall(1'b0), .ena(clkena_a_out), .q(dataout_a_reg),.aclrout() ); defparam dataout_a_register.width = port_a_data_width; assign portadataout = (out_a_is_reg) ? dataout_a_reg : dataout_a; assign clkena_b_out = (port_b_data_out_clock == "clock0") ? ((clk0_output_clock_enable == "none") ? 1'b1 : ena0_int) : ((clk1_output_clock_enable == "none") ? 1'b1 : ena1_int) ; cycloneive_ram_register dataout_b_register ( .d( dataout_b ), .clk(clk_b_out), .aclr(dataout_b_clr_reg), .devclrn(devclrn),.devpor(devpor), .stall(1'b0), .ena(clkena_b_out), .q(dataout_b_reg),.aclrout() ); defparam dataout_b_register.width = port_b_data_width; assign portbdataout = (out_b_is_reg) ? dataout_b_reg : dataout_b; endmodule
module cycloneive_mac_data_reg (clk, data, ena, aclr, dataout ); parameter data_width = 18; // INPUT PORTS input clk; input [17 : 0] data; input ena; input aclr; // OUTPUT PORTS output [17:0] dataout; // INTERNAL VARIABLES AND NETS reg clk_last_value; reg [17:0] dataout_tmp; wire [17:0] dataout_wire; // INTERNAL VARIABLES wire [17:0] data_ipd; wire enable; wire no_clr; reg d_viol; reg ena_viol; wire clk_ipd; wire ena_ipd; wire aclr_ipd; // BUFFER INPUTS buf (clk_ipd, clk); buf (ena_ipd, ena); buf (aclr_ipd, aclr); buf (data_ipd[0], data[0]); buf (data_ipd[1], data[1]); buf (data_ipd[2], data[2]); buf (data_ipd[3], data[3]); buf (data_ipd[4], data[4]); buf (data_ipd[5], data[5]); buf (data_ipd[6], data[6]); buf (data_ipd[7], data[7]); buf (data_ipd[8], data[8]); buf (data_ipd[9], data[9]); buf (data_ipd[10], data[10]); buf (data_ipd[11], data[11]); buf (data_ipd[12], data[12]); buf (data_ipd[13], data[13]); buf (data_ipd[14], data[14]); buf (data_ipd[15], data[15]); buf (data_ipd[16], data[16]); buf (data_ipd[17], data[17]); assign enable = (!aclr_ipd) && (ena_ipd); assign no_clr = (!aclr_ipd); // TIMING PATHS specify $setuphold (posedge clk &&& enable, data, 0, 0, d_viol); $setuphold (posedge clk &&& no_clr, ena, 0, 0, ena_viol); (posedge clk => (dataout +: dataout_tmp)) = (0, 0); (posedge aclr => (dataout +: 1'b0)) = (0, 0); endspecify initial begin clk_last_value <= 'b0; dataout_tmp <= 18'b0; end always @(clk_ipd or aclr_ipd) begin if (d_viol == 1'b1 || ena_viol == 1'b1) begin dataout_tmp <= 'bX; end else if (aclr_ipd == 1'b1) begin dataout_tmp <= 'b0; end else begin if ((clk_ipd === 1'b1) && (clk_last_value == 1'b0)) if (ena_ipd === 1'b1) dataout_tmp <= data_ipd; end clk_last_value <= clk_ipd; end // always assign dataout_wire = dataout_tmp; and (dataout[0], dataout_wire[0], 1'b1); and (dataout[1], dataout_wire[1], 1'b1); and (dataout[2], dataout_wire[2], 1'b1); and (dataout[3], dataout_wire[3], 1'b1); and (dataout[4], dataout_wire[4], 1'b1); and (dataout[5], dataout_wire[5], 1'b1); and (dataout[6], dataout_wire[6], 1'b1); and (dataout[7], dataout_wire[7], 1'b1); and (dataout[8], dataout_wire[8], 1'b1); and (dataout[9], dataout_wire[9], 1'b1); and (dataout[10], dataout_wire[10], 1'b1); and (dataout[11], dataout_wire[11], 1'b1); and (dataout[12], dataout_wire[12], 1'b1); and (dataout[13], dataout_wire[13], 1'b1); and (dataout[14], dataout_wire[14], 1'b1); and (dataout[15], dataout_wire[15], 1'b1); and (dataout[16], dataout_wire[16], 1'b1); and (dataout[17], dataout_wire[17], 1'b1); endmodule
module cycloneive_mac_sign_reg ( clk, d, ena, aclr, q ); // INPUT PORTS input clk; input d; input ena; input aclr; // OUTPUT PORTS output q; // INTERNAL VARIABLES reg clk_last_value; reg q_tmp; reg ena_viol; reg d_viol; wire enable; // DEFAULT VALUES THRO' PULLUPs tri1 aclr, ena; wire d_ipd; wire clk_ipd; wire ena_ipd; wire aclr_ipd; buf (d_ipd, d); buf (clk_ipd, clk); buf (ena_ipd, ena); buf (aclr_ipd, aclr); assign enable = (!aclr_ipd) && (ena_ipd); specify $setuphold (posedge clk &&& enable, d, 0, 0, d_viol) ; $setuphold (posedge clk &&& enable, ena, 0, 0, ena_viol) ; (posedge clk => (q +: q_tmp)) = 0 ; (posedge aclr => (q +: 1'b0)) = 0 ; endspecify initial begin clk_last_value <= 'b0; q_tmp <= 'b0; end always @ (clk_ipd or aclr_ipd) begin if (d_viol == 1'b1 || ena_viol == 1'b1) begin q_tmp <= 'bX; end else begin if (aclr_ipd == 1'b1) q_tmp <= 0; else if ((clk_ipd == 1'b1) && (clk_last_value == 1'b0)) if (ena_ipd == 1'b1) q_tmp <= d_ipd; end clk_last_value <= clk_ipd; end and (q, q_tmp, 'b1); endmodule
module cycloneive_mac_mult_internal ( dataa, datab, signa, signb, dataout ); parameter dataa_width = 18; parameter datab_width = 18; parameter dataout_width = dataa_width + datab_width; // INPUT input [dataa_width-1:0] dataa; input [datab_width-1:0] datab; input signa; input signb; // OUTPUT output [dataout_width-1:0] dataout; // Internal variables wire [17:0] dataa_ipd; wire [17:0] datab_ipd; wire signa_ipd; wire signb_ipd; wire [dataout_width-1:0] dataout_tmp; wire ia_is_positive; wire ib_is_positive; wire [17:0] iabsa; // absolute value (i.e. positive) form of dataa input wire [17:0] iabsb; // absolute value (i.e. positive) form of datab input wire [35:0] iabsresult; // absolute value (i.e. positive) form of product (a * b) reg [17:0] i_ones; // padding with 1's for input negation // Input buffers buf (signa_ipd, signa); buf (signb_ipd, signb); buf dataa_buf [dataa_width-1:0] (dataa_ipd[dataa_width-1:0], dataa); buf datab_buf [datab_width-1:0] (datab_ipd[datab_width-1:0], datab); specify (dataa *> dataout) = (0, 0); (datab *> dataout) = (0, 0); (signa *> dataout) = (0, 0); (signb *> dataout) = (0, 0); endspecify initial begin // 1's padding for 18-bit wide inputs i_ones = ~0; end // get signs of a and b, and get absolute values since Verilog '*' operator // is an unsigned multiplication assign ia_is_positive = ~signa_ipd | ~dataa_ipd[dataa_width-1]; assign ib_is_positive = ~signb_ipd | ~datab_ipd[datab_width-1]; assign iabsa = ia_is_positive == 1 ? dataa_ipd[dataa_width-1:0] : -(dataa_ipd | (i_ones << dataa_width)); assign iabsb = ib_is_positive == 1 ? datab_ipd[datab_width-1:0] : -(datab_ipd | (i_ones << datab_width)); // multiply a * b assign iabsresult = iabsa * iabsb; assign dataout_tmp = (ia_is_positive ^ ib_is_positive) == 1 ? -iabsresult : iabsresult; buf dataout_buf [dataout_width-1:0] (dataout, dataout_tmp); endmodule
module cycloneive_mac_mult ( dataa, datab, signa, signb, clk, aclr, ena, dataout, devclrn, devpor ); parameter dataa_width = 18; parameter datab_width = 18; parameter dataa_clock = "none"; parameter datab_clock = "none"; parameter signa_clock = "none"; parameter signb_clock = "none"; parameter lpm_hint = "true"; parameter lpm_type = "cycloneive_mac_mult"; // SIMULATION_ONLY_PARAMETERS_BEGIN parameter dataout_width = dataa_width + datab_width; // SIMULATION_ONLY_PARAMETERS_END input [dataa_width-1:0] dataa; input [datab_width-1:0] datab; input signa; input signb; input clk; input aclr; input ena; input devclrn; input devpor; output [dataout_width-1:0] dataout; tri1 devclrn; tri1 devpor; wire [dataout_width-1:0] dataout_tmp; wire [17:0] idataa_reg; // optional register for dataa input wire [17:0] idatab_reg; // optional register for datab input wire [17:0] dataa_pad; // padded dataa input wire [17:0] datab_pad; // padded datab input wire isigna_reg; // optional register for signa input wire isignb_reg; // optional register for signb input wire [17:0] idataa_int; // dataa as seen by the multiplier input wire [17:0] idatab_int; // datab as seen by the multiplier input wire isigna_int; // signa as seen by the multiplier input wire isignb_int; // signb as seen by the multiplier input wire ia_is_positive; wire ib_is_positive; wire [17:0] iabsa; // absolute value (i.e. positive) form of dataa input wire [17:0] iabsb; // absolute value (i.e. positive) form of datab input wire [35:0] iabsresult; // absolute value (i.e. positive) form of product (a * b) wire dataa_use_reg; // equivalent to dataa_clock parameter wire datab_use_reg; // equivalent to datab_clock parameter wire signa_use_reg; // equivalent to signa_clock parameter wire signb_use_reg; // equivalent to signb_clock parameter reg [17:0] i_ones; // padding with 1's for input negation wire reg_aclr; assign reg_aclr = (!devpor) || (!devclrn) || (aclr); // optional registering parameters assign dataa_use_reg = (dataa_clock != "none") ? 1'b1 : 1'b0; assign datab_use_reg = (datab_clock != "none") ? 1'b1 : 1'b0; assign signa_use_reg = (signa_clock != "none") ? 1'b1 : 1'b0; assign signb_use_reg = (signb_clock != "none") ? 1'b1 : 1'b0; assign dataa_pad = ((18-dataa_width) == 0) ? dataa : {{(18-dataa_width){1'b0}},dataa}; assign datab_pad = ((18-datab_width) == 0) ? datab : {{(18-datab_width){1'b0}},datab}; initial begin // 1's padding for 18-bit wide inputs i_ones = ~0; end // Optional input registers for dataa,b and signa,b cycloneive_mac_data_reg dataa_reg ( .clk(clk), .data(dataa_pad), .ena(ena), .aclr(reg_aclr), .dataout(idataa_reg) ); defparam dataa_reg.data_width = dataa_width; cycloneive_mac_data_reg datab_reg ( .clk(clk), .data(datab_pad), .ena(ena), .aclr(reg_aclr), .dataout(idatab_reg) ); defparam datab_reg.data_width = datab_width; cycloneive_mac_sign_reg signa_reg ( .clk(clk), .d(signa), .ena(ena), .aclr(reg_aclr), .q(isigna_reg) ); cycloneive_mac_sign_reg signb_reg ( .clk(clk), .d(signb), .ena(ena), .aclr(reg_aclr), .q(isignb_reg) ); // mux input sources from direct inputs or optional registers assign idataa_int = dataa_use_reg == 1'b1 ? idataa_reg : dataa; assign idatab_int = datab_use_reg == 1'b1 ? idatab_reg : datab; assign isigna_int = signa_use_reg == 1'b1 ? isigna_reg : signa; assign isignb_int = signb_use_reg == 1'b1 ? isignb_reg : signb; cycloneive_mac_mult_internal mac_multiply ( .dataa(idataa_int[dataa_width-1:0]), .datab(idatab_int[datab_width-1:0]), .signa(isigna_int), .signb(isignb_int), .dataout(dataout) ); defparam mac_multiply.dataa_width = dataa_width; defparam mac_multiply.datab_width = datab_width; defparam mac_multiply.dataout_width = dataout_width; endmodule
module cycloneive_mac_out ( dataa, clk, aclr, ena, dataout, devclrn, devpor ); parameter dataa_width = 1; parameter output_clock = "none"; parameter lpm_hint = "true"; parameter lpm_type = "cycloneive_mac_out"; // SIMULATION_ONLY_PARAMETERS_BEGIN parameter dataout_width = dataa_width; // SIMULATION_ONLY_PARAMETERS_END input [dataa_width-1:0] dataa; input clk; input aclr; input ena; input devclrn; input devpor; output [dataout_width-1:0] dataout; tri1 devclrn; tri1 devpor; wire [dataa_width-1:0] dataa_ipd; // internal dataa wire clk_ipd; // internal clk wire aclr_ipd; // internal aclr wire ena_ipd; // internal ena // internal variable wire [dataout_width-1:0] dataout_tmp; reg [dataa_width-1:0] idataout_reg; // optional register for dataout output wire use_reg; // equivalent to dataout_clock parameter wire enable; wire no_aclr; // Input buffers buf (clk_ipd, clk); buf (aclr_ipd, aclr); buf (ena_ipd, ena); buf dataa_buf [dataa_width-1:0] (dataa_ipd, dataa); // optional registering parameter assign use_reg = (output_clock != "none") ? 1 : 0; assign enable = (!aclr) && (ena) && use_reg; assign no_aclr = (!aclr) && use_reg; specify if (use_reg) (posedge clk => (dataout +: dataout_tmp)) = 0; (posedge aclr => (dataout +: 1'b0)) = 0; ifnone (dataa *> dataout) = (0, 0); $setuphold (posedge clk &&& enable, dataa, 0, 0); $setuphold (posedge clk &&& no_aclr, ena, 0, 0); endspecify initial begin // initial values for optional register idataout_reg = 0; end // Optional input registers for dataa,b and signa,b always @ (posedge clk_ipd or posedge aclr_ipd or negedge devclrn or negedge devpor) begin if (devclrn == 0 || devpor == 0 || aclr_ipd == 1) begin idataout_reg <= 0; end else if (ena_ipd == 1) begin idataout_reg <= dataa_ipd; end end // mux input sources from direct inputs or optional registers assign dataout_tmp = use_reg == 1 ? idataout_reg : dataa_ipd; // accelerate outputs buf dataout_buf [dataout_width-1:0] (dataout, dataout_tmp); endmodule
module cycloneive_io_ibuf ( i, ibar, o ); // SIMULATION_ONLY_PARAMETERS_BEGIN parameter differential_mode = "false"; parameter bus_hold = "false"; parameter simulate_z_as = "Z"; parameter lpm_type = "cycloneive_io_ibuf"; // SIMULATION_ONLY_PARAMETERS_END //Input Ports Declaration input i; input ibar; //Output Ports Declaration output o; // Internal signals reg out_tmp; reg o_tmp; wire out_val ; reg prev_value; specify (i => o) = (0, 0); (ibar => o) = (0, 0); endspecify initial begin prev_value = 1'b0; end always@(i or ibar) begin if(differential_mode == "false") begin if(i == 1'b1) begin o_tmp = 1'b1; prev_value = 1'b1; end else if(i == 1'b0) begin o_tmp = 1'b0; prev_value = 1'b0; end else if( i === 1'bz) o_tmp = out_val; else o_tmp = i; if( bus_hold == "true") out_tmp = prev_value; else out_tmp = o_tmp; end else begin case({i,ibar}) 2'b00: out_tmp = 1'bX; 2'b01: out_tmp = 1'b0; 2'b10: out_tmp = 1'b1; 2'b11: out_tmp = 1'bX; default: out_tmp = 1'bX; endcase end end assign out_val = (simulate_z_as == "Z") ? 1'bz : (simulate_z_as == "X") ? 1'bx : (simulate_z_as == "vcc")? 1'b1 : (simulate_z_as == "gnd") ? 1'b0 : 1'bz; pmos (o, out_tmp, 1'b0); endmodule
module cycloneive_io_obuf ( i, oe, seriesterminationcontrol, devoe, o, obar ); //Parameter Declaration parameter open_drain_output = "false"; parameter bus_hold = "false"; parameter lpm_type = "cycloneive_io_obuf"; //Input Ports Declaration input i; input oe; input devoe; input [15:0] seriesterminationcontrol; //Outout Ports Declaration output o; output obar; //INTERNAL Signals reg out_tmp; reg out_tmp_bar; reg prev_value; wire tmp; wire tmp_bar; wire tmp1; wire tmp1_bar; tri1 devoe; specify (i => o) = (0, 0); (i => obar) = (0, 0); (oe => o) = (0, 0); (oe => obar) = (0, 0); endspecify initial begin prev_value = 'b0; out_tmp = 'bz; end always@(i or oe) begin if(oe == 1'b1) begin if(open_drain_output == "true") begin if(i == 'b0) begin out_tmp = 'b0; out_tmp_bar = 'b1; prev_value = 'b0; end else begin out_tmp = 'bz; out_tmp_bar = 'bz; end end else begin if( i == 'b0) begin out_tmp = 'b0; out_tmp_bar = 'b1; prev_value = 'b0; end else if( i == 'b1) begin out_tmp = 'b1; out_tmp_bar = 'b0; prev_value = 'b1; end else begin out_tmp = i; out_tmp_bar = i; end end end else if(oe == 1'b0) begin out_tmp = 'bz; out_tmp_bar = 'bz; end else begin out_tmp = 'bx; out_tmp_bar = 'bx; end end assign tmp = (bus_hold == "true") ? prev_value : out_tmp; assign tmp_bar = (bus_hold == "true") ? !prev_value : out_tmp_bar; assign tmp1 = (devoe == 1'b1) ? tmp : 1'bz; assign tmp1_bar = (devoe == 1'b1) ? tmp_bar : 1'bz; pmos (o, tmp1, 1'b0); pmos (obar, tmp1_bar, 1'b0); endmodule
module cycloneive_ddio_out ( datainlo, datainhi, clk, clkhi, clklo, muxsel, ena, areset, sreset, dataout, dfflo, dffhi, devpor, devclrn ); //Parameters Declaration parameter power_up = "low"; parameter async_mode = "none"; parameter sync_mode = "none"; parameter use_new_clocking_model = "false"; parameter lpm_type = "cycloneive_ddio_out"; //Input Ports Declaration input datainlo; input datainhi; input clk; input clkhi; input clklo; input muxsel; input ena; input areset; input sreset; input devpor; input devclrn; //Output Ports Declaration output dataout; //Buried Ports Declaration output dfflo; output dffhi ; tri1 devclrn; tri1 devpor; //Internal Signals reg ddioreg_aclr; reg ddioreg_adatasdata; reg ddioreg_sclr; reg ddioreg_sload; reg ddioreg_prn; reg viol_notifier; wire dfflo_tmp; wire dffhi_tmp; wire mux_sel; wire sel_mux_hi_in; wire clk_hi; wire clk_lo; wire datainlo_tmp; wire datainhi_tmp; reg dinhi_tmp; reg dinlo_tmp; reg clk1; reg clk2; reg muxsel1; reg muxsel2; reg muxsel_tmp; reg sel_mux_lo_in_tmp; reg sel_mux_hi_in_tmp; reg dffhi_tmp1; wire muxsel3; wire clk3; wire sel_mux_lo_in; initial begin ddioreg_aclr = 1'b1; ddioreg_prn = 1'b1; ddioreg_adatasdata = (sync_mode == "preset") ? 1'b1: 1'b0; ddioreg_sclr = 1'b0; ddioreg_sload = 1'b0; end assign dfflo = dfflo_tmp; assign dffhi = dffhi_tmp; always@(clk) begin clk1 = clk; clk2 <= clk1; end always@(muxsel) begin muxsel1 = muxsel; muxsel2 <= muxsel1; end always@(dfflo_tmp) begin sel_mux_lo_in_tmp <= dfflo_tmp; end always@(datainlo) begin dinlo_tmp <= datainlo; end always@(datainhi) begin dinhi_tmp <= datainhi; end always @(mux_sel) begin muxsel_tmp <= mux_sel; //REM_SV end always@(dffhi_tmp) begin dffhi_tmp1 <= dffhi_tmp; end always@(dffhi_tmp1) begin sel_mux_hi_in_tmp <= dffhi_tmp1; end always@(areset) begin if(async_mode == "clear") begin ddioreg_aclr = !areset; end else if(async_mode == "preset") begin ddioreg_prn = !areset; end end always@(sreset ) begin if(sync_mode == "clear") begin ddioreg_sclr = sreset; end else if(sync_mode == "preset") begin ddioreg_sload = sreset; end end //DDIO HIGH Register cycloneive_latch ddioreg_hi( .D(datainhi_tmp), .ENA(!clk_hi & ena), .PRE(ddioreg_prn), .CLR(ddioreg_aclr), .Q(dffhi_tmp) ); assign clk_hi = (use_new_clocking_model == "true") ? clkhi : clk; assign datainhi_tmp = (ddioreg_sclr == 1'b0 && ddioreg_sload == 1'b1)? 1'b1 : (ddioreg_sclr == 1'b1 && ddioreg_sload == 1'b0)? 1'b0: dinhi_tmp; //DDIO Low Register dffeas ddioreg_lo( .d(datainlo_tmp), .clk(clk_lo), .clrn(ddioreg_aclr), .aload(1'b0), .sclr(ddioreg_sclr), .sload(ddioreg_sload), .asdata(ddioreg_adatasdata), .ena(ena), .prn(ddioreg_prn), .q(dfflo_tmp), .devpor(devpor), .devclrn(devclrn) ); defparam ddioreg_lo.power_up = power_up; assign clk_lo = (use_new_clocking_model == "true") ? clklo : clk; assign datainlo_tmp = dinlo_tmp; //DDIO High Register //registered output selection cycloneive_mux21 sel_mux( .MO(dataout), .A(sel_mux_hi_in), .B(sel_mux_lo_in), .S(!muxsel_tmp) ); assign muxsel3 = muxsel2; assign clk3 = clk2; assign mux_sel = (use_new_clocking_model == "true")? muxsel3 : clk3; assign sel_mux_lo_in = sel_mux_lo_in_tmp; assign sel_mux_hi_in = sel_mux_hi_in_tmp; endmodule
module cycloneive_ddio_oe ( oe, clk, ena, areset, sreset, dataout, dfflo, dffhi, devpor, devclrn ); //Parameters Declaration parameter power_up = "low"; parameter async_mode = "none"; parameter sync_mode = "none"; parameter lpm_type = "cycloneive_ddio_oe"; //Input Ports Declaration input oe; input clk; input ena; input areset; input sreset; input devpor; input devclrn; //Output Ports Declaration output dataout; //Buried Ports Declaration output dfflo; output dffhi; tri1 devclrn; tri1 devpor; //Internal Signals reg ddioreg_aclr; reg ddioreg_prn; reg ddioreg_adatasdata; reg ddioreg_sclr; reg ddioreg_sload; reg viol_notifier; initial begin ddioreg_aclr = 1'b1; ddioreg_prn = 1'b1; ddioreg_adatasdata = 1'b0; ddioreg_sclr = 1'b0; ddioreg_sload = 1'b0; end wire dfflo_tmp; wire dffhi_tmp; always@(areset or sreset ) begin if(async_mode == "clear") begin ddioreg_aclr = !areset; ddioreg_prn = 1'b1; end else if(async_mode == "preset") begin ddioreg_aclr = 'b1; ddioreg_prn = !areset; end else begin ddioreg_aclr = 'b1; ddioreg_prn = 'b1; end if(sync_mode == "clear") begin ddioreg_adatasdata = 'b0; ddioreg_sclr = sreset; ddioreg_sload = 'b0; end else if(sync_mode == "preset") begin ddioreg_adatasdata = 'b1; ddioreg_sclr = 'b0; ddioreg_sload = sreset; end else begin ddioreg_adatasdata = 'b0; ddioreg_sclr = 'b0; ddioreg_sload = 'b0; end end //DDIO OE Register dffeas ddioreg_hi( .d(oe), .clk(clk), .clrn(ddioreg_aclr), .aload(1'b0), .sclr(ddioreg_sclr), .sload(ddioreg_sload), .asdata(ddioreg_adatasdata), .ena(ena), .prn(ddioreg_prn), .q(dffhi_tmp), .devpor(devpor), .devclrn(devclrn) ); defparam ddioreg_hi.power_up = power_up; //DDIO Low Register dffeas ddioreg_lo( .d(dffhi_tmp), .clk(!clk), .clrn(ddioreg_aclr), .aload(1'b0), .sclr(ddioreg_sclr), .sload(ddioreg_sload), .asdata(ddioreg_adatasdata), .ena(ena), .prn(ddioreg_prn), .q(dfflo_tmp), .devpor(devpor), .devclrn(devclrn) ); defparam ddioreg_lo.power_up = power_up; //registered output cycloneive_mux21 or_gate( .MO(dataout), .A(dffhi_tmp), .B(dfflo_tmp), .S(dfflo_tmp) ); assign dfflo = dfflo_tmp; assign dffhi = dffhi_tmp; endmodule
module cycloneive_pseudo_diff_out( i, o, obar ); parameter lpm_type = "cycloneive_pseudo_diff_out"; input i; output o; output obar; reg o_tmp; reg obar_tmp; assign o = o_tmp; assign obar = obar_tmp; always@(i) begin if( i == 1'b1) begin o_tmp = 1'b1; obar_tmp = 1'b0; end else if( i == 1'b0) begin o_tmp = 1'b0; obar_tmp = 1'b1; end else begin o_tmp = i; obar_tmp = i; end end endmodule
module cycloneive_io_pad ( padin, padout ); parameter lpm_type = "cycloneive_io_pad"; //INPUT PORTS input padin; //Input Pad //OUTPUT PORTS output padout;//Output Pad //INTERNAL SIGNALS wire padin_ipd; wire padout_opd; //INPUT BUFFER INSERTION FOR VERILOG-XL buf padin_buf (padin_ipd,padin); assign padout_opd = padin_ipd; //OUTPUT BUFFER INSERTION FOR VERILOG-XL buf padout_buf (padout, padout_opd); endmodule
module cycloneive_ena_reg ( clk, ena, d, clrn, prn, q ); // INPUT PORTS input d; input clk; input clrn; input prn; input ena; // OUTPUT PORTS output q; // INTERNAL VARIABLES reg q_tmp; reg violation; reg d_viol; reg clk_last_value; wire reset; // DEFAULT VALUES THRO' PULLUPs tri1 prn, clrn, ena; wire d_in; wire clk_in; buf (d_in, d); buf (clk_in, clk); assign reset = (!clrn) && (ena); specify $setuphold (posedge clk &&& reset, d, 0, 0, d_viol) ; (posedge clk => (q +: q_tmp)) = 0 ; endspecify initial begin q_tmp = 'b1; violation = 'b0; clk_last_value = clk_in; end always @ (clk_in or negedge clrn or negedge prn ) begin if (d_viol == 1'b1) begin violation = 1'b0; q_tmp <= 'bX; end else if (prn == 1'b0) q_tmp <= 1; else if (clrn == 1'b0) q_tmp <= 0; else if ((clk_last_value === 'b0) & (clk_in === 1'b1) & (ena == 1'b1)) q_tmp <= d_in; clk_last_value = clk_in; end and (q, q_tmp, 'b1); endmodule
module cycloneive_clkctrl ( inclk, clkselect, ena, devpor, devclrn, outclk ); input [3:0] inclk; input [1:0] clkselect; input ena; input devpor; input devclrn; output outclk; tri1 devclrn; tri1 devpor; parameter clock_type = "auto"; parameter ena_register_mode = "falling edge"; parameter lpm_type = "cycloneive_clkctrl"; wire clkmux_out; // output of CLK mux wire cereg1_out; // output of ENA register1 wire cereg2_out; // output of ENA register2 wire ena_out; // choice of registered ENA or none. wire inclk3_ipd; wire inclk2_ipd; wire inclk1_ipd; wire inclk0_ipd; wire clkselect1_ipd; wire clkselect0_ipd; wire ena_ipd; buf (inclk3_ipd, inclk[3]); buf (inclk2_ipd, inclk[2]); buf (inclk1_ipd, inclk[1]); buf (inclk0_ipd, inclk[0]); buf (clkselect1_ipd, clkselect[1]); buf (clkselect0_ipd, clkselect[0]); buf (ena_ipd, ena); specify (inclk *> outclk) = (0, 0) ; endspecify cycloneive_mux41 clk_mux (.MO(clkmux_out), .IN0(inclk0_ipd), .IN1(inclk1_ipd), .IN2(inclk2_ipd), .IN3(inclk3_ipd), .S({clkselect1_ipd, clkselect0_ipd})); cycloneive_ena_reg extena0_reg( .clk(!clkmux_out), .ena(1'b1), .d(ena_ipd), .clrn(1'b1), .prn(devpor), .q(cereg1_out) ); cycloneive_ena_reg extena1_reg( .clk(!clkmux_out), .ena(1'b1), .d(cereg1_out), .clrn(1'b1), .prn(devpor), .q(cereg2_out) ); assign ena_out = (ena_register_mode == "falling edge") ? cereg1_out : ((ena_register_mode == "none") ? ena_ipd : cereg2_out); and (outclk, ena_out, clkmux_out); endmodule
module cycloneive_rublock ( clk, shiftnld, captnupdt, regin, rsttimer, rconfig, regout ); parameter sim_init_config = "factory"; parameter sim_init_watchdog_value = 0; parameter sim_init_status = 0; parameter lpm_type = "cycloneive_rublock"; input clk; input shiftnld; input captnupdt; input regin; input rsttimer; input rconfig; output regout; endmodule
module cycloneive_apfcontroller ( usermode, nceout ); parameter lpm_type = "cycloneive_apfcontroller"; output usermode; output nceout; endmodule
module cycloneive_termination_ctrl ( clkusr, intosc, nclrusr, nfrzdrv, rclkdiv, rclrusrinv, rdivsel, roctusr, rsellvrefdn, rsellvrefup, rtest, vccnx, vssn, clken, clkin, maskbit, nclr, noctdoneuser, octdone, oregclk, oregnclr, vref, vrefh, vrefl); input clkusr; input intosc; // clk source in powerup mode input nclrusr; input nfrzdrv; // devclrn input rclkdiv; // - 14 input rclrusrinv; // invert nclrusr signal - 13 input rdivsel; // 0 = /32; 1 = /4; - 16 input roctusr; // run_time_control - 15 input rsellvrefdn; // shift_vref_rdn - 26 input rsellvrefup; // shift_vref_rup - 25 input rtest; // test_mode - 2 input vccnx; // VCC voltage src input vssn; // GND voltage src output clken; output clkin; output [8:0] maskbit; output nclr; output noctdoneuser; output octdone; output oregclk; output oregnclr; output vref; output vrefh; output vrefl; parameter REG_TCO_DLY = 0; // 1; reg divby2; reg divby4; reg divby8; reg divby16; reg divby32; reg oregclk; reg oregclkclk; reg intosc_div4; reg intosc_div32; reg clken; reg octdoneuser; reg startbit; reg [8:0] maskbit; reg octdone; wire [8:0] maskbit_d; wire intoscin; wire clk_sel; wire intosc_clk; wire clkin; wire oregnclr; wire clr_invert; wire nclr; wire adcclk; // data flow in user mode: // oregnclr = 1 forever so clkin is clkusr // // deasserting nclrusr starts off USER calibration // upon rising edge of nclrusr // (1). at 1st neg edge of clkin, clken = 1 // (2). enable adcclk // (3). Mask bits [8:0] shifts from MSB=1 into LSB=1 // (4). oregclkclk = bit[0] (=1); 7th cycle // (5). oregclk = 1 (after falling edge of oregclkclk) 8th cycle // (6). clken = 0 (!oregclk) // (7). octdoneuser = 1 (falling edge of clken) initial begin octdone = 1'b1; // from powerup stage octdoneuser = 1'b0; startbit = 1'b0; maskbit = 9'b000000000; oregclk = 1'b0; oregclkclk = 1'b0; clken = 1'b0; divby2 = 1'b0; divby4 = 1'b0; divby8 = 1'b0; divby16 = 1'b0; divby32 = 1'b0; intosc_div4 = 1'b0; intosc_div32 = 1'b0; end assign noctdoneuser = ~octdoneuser; // c7216 clkdiv always @(posedge intosc or negedge nfrzdrv) begin if (!nfrzdrv) divby2 <= #(REG_TCO_DLY) 1'b0; else divby2 <= #(REG_TCO_DLY) ~divby2; end always @(posedge divby2 or negedge nfrzdrv) begin if (!nfrzdrv) divby4 <= #(REG_TCO_DLY) 1'b0; else divby4 <= #(REG_TCO_DLY) ~divby4; end always @(posedge divby4 or negedge nfrzdrv) begin if (!nfrzdrv) divby8 <= #(REG_TCO_DLY) 1'b0; else divby8 <= #(REG_TCO_DLY) ~divby8; end always @(posedge divby8 or negedge nfrzdrv) begin if (!nfrzdrv) divby16 <= #(REG_TCO_DLY) 1'b0; else divby16 <= #(REG_TCO_DLY) ~divby16; end always @(posedge divby16 or negedge nfrzdrv) begin if (!nfrzdrv) divby32 <= #(REG_TCO_DLY) 1'b0; else divby32 <= #(REG_TCO_DLY) ~divby32; end assign intoscin = rdivsel ? divby4 : divby32; assign clk_sel = octdone & roctusr; // always 1 assign intosc_clk = rclkdiv ? intoscin : intosc; assign clkin = clk_sel ? clkusr : intosc_clk; assign oregnclr = rtest | nfrzdrv; // always 1 assign clr_invert = rclrusrinv ? ~nclrusr : nclrusr; assign nclr = clk_sel ? clr_invert : nfrzdrv; // c7206 always @(negedge clkin or negedge nclr) begin if (!nclr) clken <= #(REG_TCO_DLY) 1'b0; else clken <= #(REG_TCO_DLY) ~oregclk; end always @(negedge clken or negedge oregnclr) begin if (!oregnclr) octdone <= #(REG_TCO_DLY) 1'b0; else octdone <= #(REG_TCO_DLY) 1'b1; end assign adcclk = clkin & clken; always @(posedge adcclk or negedge nclr) begin if (!nclr) startbit <= #(REG_TCO_DLY) 1'b0; else startbit <= #(REG_TCO_DLY) 1'b1; end assign maskbit_d = {~startbit, maskbit[8:1]}; always @(posedge adcclk or negedge nclr) begin if (!nclr) begin maskbit <= #(REG_TCO_DLY) 9'b0; oregclkclk <= #(REG_TCO_DLY) 1'b0; end else begin maskbit <= #(REG_TCO_DLY) maskbit_d; oregclkclk <= #(REG_TCO_DLY) maskbit[0]; end end always @(negedge oregclkclk or negedge nclr) begin if (~nclr) oregclk <= #(REG_TCO_DLY) 1'b0; else oregclk <= #(REG_TCO_DLY) 1'b1; end always @(negedge clken or negedge nclr) begin if (~nclr) octdoneuser <= #(REG_TCO_DLY) 1'b0; else octdoneuser <= #(REG_TCO_DLY) 1'b1; end // OCT VREF c7207 xvref ( // Functional code assign vrefh = 1'b1; assign vref = 1'b1; assign vrefl = 1'b0; endmodule
module cycloneive_termination_rupdn ( clken, clkin, compout, maskbit, nclr, octcal, octpin, octrpcd, oregclk, oregnclr, radd, rcompoutinv, roctdone, rpwrdn, rshift, rshiftvref, rtest, shiftedvref, vccnx, vref ); input clken; input clkin; input [8:0] maskbit; input nclr; input octpin; input oregclk; input oregnclr; input [7:0] radd; input rcompoutinv; input roctdone; input rpwrdn; input rshift; input rshiftvref; input rtest; input shiftedvref; input vccnx; input vref; output compout; output [7:0] octcal; // to IO bank output [7:0] octrpcd; // to the reference RUP/RDN parameter is_rdn = "false";// initial value of octcal differ parameter OCTCAL_DLY = 0; // 1; parameter REG_TCO_DLY = 0; // 1; //supply0 vss; reg [7:0] comp_octrpcd; reg [7:0] octcal_reg; wire octref; wire shftref_out; wire compout_tmp; wire nout; wire nbias; wire pbias; wire [7:0] octrpcd; wire [7:0] octcal_reg_in; wire [7:0] reg_clk; wire [7:0] srpcd; wire [7:0] rpcdi; wire [8:0] rpcdi_temp; wire shift; wire shftvrefhv; wire compout; wire clr; wire reg_clkin; wire reg_nclr; wire shiftvref; wire compadcen; assign shift = rtest & ~clken; assign compadcen = ~roctdone & clken; assign shiftvref = ~(rshiftvref | maskbit[1]); //c6419 xinverted_ls ( //vss, shiftvref, shftvrefhv, vccnx ); //c7223 xbias_ckt ( assign nbias = (compadcen === 1'b1) ? 1'b1 : 1'b0; assign pbias = (compadcen === 1'b1) ? 1'b0 : 1'bz; //c7202 xoct_comp ( assign compout_tmp = (compadcen === 1'b1) ? octpin : 1'b0; assign shftvrefhv = shftref_out; assign octref = shftvrefhv ? shiftedvref : vref; assign compout = rcompoutinv ? compout_tmp : ~compout_tmp; // c7208 assign reg_clk[7:0] = maskbit[7:0]; assign reg_nclr = (compadcen | ~rpwrdn) & nclr; always @(posedge reg_clk[7] or negedge reg_nclr) begin if (!reg_nclr) comp_octrpcd[7] <= #(REG_TCO_DLY) 1'b0; else comp_octrpcd[7] <= #(REG_TCO_DLY) compout; end always @(posedge reg_clk[6] or negedge reg_nclr) begin if (!reg_nclr) comp_octrpcd[6] <= #(REG_TCO_DLY) 1'b0; else comp_octrpcd[6] <= #(REG_TCO_DLY) compout; end always @(posedge reg_clk[5] or negedge reg_nclr) begin if (!reg_nclr) comp_octrpcd[5] <= #(REG_TCO_DLY) 1'b0; else comp_octrpcd[5] <= #(REG_TCO_DLY) compout; end always @(posedge reg_clk[4] or negedge reg_nclr) begin if (!reg_nclr) comp_octrpcd[4] <= #(REG_TCO_DLY) 1'b0; else comp_octrpcd[4] <= #(REG_TCO_DLY) compout; end always @(posedge reg_clk[3] or negedge reg_nclr) begin if (!reg_nclr) comp_octrpcd[3] <= #(REG_TCO_DLY) 1'b0; else comp_octrpcd[3] <= #(REG_TCO_DLY) compout; end always @(posedge reg_clk[2] or negedge reg_nclr) begin if (!reg_nclr) comp_octrpcd[2] <= #(REG_TCO_DLY) 1'b0; else comp_octrpcd[2] <= #(REG_TCO_DLY) compout; end always @(posedge reg_clk[1] or negedge reg_nclr) begin if (!reg_nclr) comp_octrpcd[1] <= #(REG_TCO_DLY) 1'b0; else comp_octrpcd[1] <= #(REG_TCO_DLY) compout; end always @(posedge reg_clk[0] or negedge reg_nclr) begin if (!reg_nclr) comp_octrpcd[0] <= #(REG_TCO_DLY) 1'b0; else comp_octrpcd[0] <= #(REG_TCO_DLY) compout; end // output sends to RUP/DN reference pins assign octrpcd[7] = maskbit[8] ? 1'b1 : comp_octrpcd[7]; assign octrpcd[6] = maskbit[7] ? 1'b1 : comp_octrpcd[6]; // below: set octrpcd[5] and clear prior bit octrpcd[6] based on compout assign octrpcd[5] = maskbit[6] ? 1'b1 : comp_octrpcd[5]; assign octrpcd[4] = maskbit[5] ? 1'b1 : comp_octrpcd[4]; assign octrpcd[3] = maskbit[4] ? 1'b1 : comp_octrpcd[3]; assign octrpcd[2] = maskbit[3] ? 1'b1 : comp_octrpcd[2]; assign octrpcd[1] = maskbit[2] ? 1'b1 : comp_octrpcd[1]; assign octrpcd[0] = maskbit[1] ? 1'b1 : comp_octrpcd[0]; // c7210 - leftshift assign srpcd = rshift ? {octrpcd[6:0], 1'b0} : octrpcd; // c7214 - Adder: // overflow => max value 8'b1 // underflow => 0; assign rpcdi_temp[8:0] = srpcd[7:0] + radd[7:0]; assign rpcdi[7:0] = {8{(~radd[7] & rpcdi_temp[8])}} | rpcdi_temp[7:0]; // left shift rotation in test mode - only when calibration is done (clken=0) // calibration code (octcal) is 0 until calibration completed // oregclk indicates 10th cycle since masket[8]=1 --> masket[0]=1 + one cycle // clken is ~oregclk assign reg_clkin = ~shift ? oregclk : clkin; assign octcal_reg_in[7:0] = ~shift ? rpcdi[7:0] : ({octcal[6:0], octcal[7]}); initial begin if (is_rdn == "true") octcal_reg[7:0] = 8'hFF; else octcal_reg[7:0] = 8'h00; end // calibrated code cannot be cleared by user_clr // it is only changed by code from calibration block which is always @(posedge reg_clkin or negedge oregnclr) begin if (!oregnclr) octcal_reg[7:0] <= #(REG_TCO_DLY) 8'h00; else octcal_reg[7:0] <= #(REG_TCO_DLY) octcal_reg_in[7:0]; end assign #(OCTCAL_DLY) octcal = octcal_reg; endmodule
module cycloneive_termination ( rup, rdn, terminationclock, terminationclear, devpor, devclrn, comparatorprobe, terminationcontrolprobe, calibrationdone, terminationcontrol); input rup; input rdn; input terminationclock; input terminationclear; input devpor; input devclrn; output comparatorprobe; output terminationcontrolprobe; output calibrationdone; output [15:0] terminationcontrol; parameter pullup_control_to_core = "false"; parameter power_down = "true"; parameter test_mode = "false"; parameter left_shift_termination_code = "false"; parameter pullup_adder = 0; // -128, 127 parameter pulldown_adder = 0; // -128, 127 parameter clock_divide_by = 32; // 1, 4, 32 parameter runtime_control = "false"; parameter shift_vref_rup = "true"; parameter shift_vref_rdn = "true"; parameter shifted_vref_control = "true"; parameter lpm_type = "cycloneive_termination"; tri1 devclrn; tri1 devpor; wire m_gnd; wire m_vcc; // interconnecting wires // ctrl ----------------------------------------- wire xcbout_clken; wire xcbout_clkin; wire [8:0] xcbout_maskbit; wire xcbout_nclr; wire xcbout_noctdoneuser; wire xcbout_octdone; wire xcbout_oregclk; wire xcbout_oregnclr; wire xcbout_vref; // to run/dn comparator wire xcbout_vrefh; // to rdn - shfitedvref wire xcbout_vrefl; // to rup - shiftedvref wire xcbin_clkusr; wire xcbin_intosc; // clk source in powerup mode wire xcbin_nclrusr; wire xcbin_nfrzdrv; // devclrn wire xcbin_rclkdiv; // - 14 wire xcbin_rclrusrinv; // invert nclrusr signal - 13 wire xcbin_rdivsel; // 0 = /32; 1 = /4; - 16 wire xcbin_roctusr; // run_time_control - 15 wire xcbin_rsellvrefdn; // shift_vref_rdn - 26 wire xcbin_rsellvrefup; // shift_vref_rup - 25 wire xcbin_rtest; // test_mode - 2 wire xcbin_vccnx; // VCC voltage src wire xcbin_vssn; // GND voltage src // rup and rdn ------------------------------------ // common wire rshift_in; wire rpwrdn_in; wire rup_compout; wire [7:0] rup_octrupn; // out from XRUP to rupref pin wire [7:0] rup_octcalnout; // to the I/O bank wire rupin; reg [7:0] rup_radd; wire rdn_compout; wire [7:0] rdn_octrdnp; // out from XRDN to rdnref pin wire [7:0] rdn_octcalpout; // to the I/O bank wire rdnin; reg [7:0] rdn_radd; wire calout; // MSB of the calibration code // primary input and outputs assign rupin = rup; assign rdnin = rdn; // terminationclk and clear feeding into CTRL sub directly assign calibrationdone = xcbout_octdone; assign terminationcontrol = {rup_octcalnout, rdn_octcalpout}; assign comparatorprobe = (pullup_control_to_core == "true") ? rup_compout : rdn_compout; assign calout = (pullup_control_to_core == "true") ? rup_octcalnout[7] : rdn_octcalpout[7]; assign terminationcontrolprobe = (test_mode == "true") ? calout : xcbout_noctdoneuser; initial begin rup_radd = pullup_adder; rdn_radd = pulldown_adder; end // CTRL sub-block assign xcbin_clkusr = terminationclock; assign xcbin_intosc = 1'b0; // clk source in powerup mode assign xcbin_nclrusr = (terminationclear === 1'b1) ? 1'b0 : 1'b1; assign xcbin_nfrzdrv = (devclrn === 1'b0) ? 1'b0 : 1'b1; assign xcbin_vccnx = 1'b1; // VCC voltage src assign xcbin_vssn = 1'b0; // GND voltage src assign xcbin_rclkdiv = (clock_divide_by != 1) ? 1'b1 : 1'b0; //- 14 assign xcbin_rclrusrinv = 1'b0; // invert nclrusr signal - 13 assign xcbin_rdivsel = (clock_divide_by == 32) ? 1'b0 : 1'b1; //- 16 assign xcbin_roctusr = (runtime_control == "true") ? 1'b1 : 1'b0; //- 15 assign xcbin_rsellvrefdn = (shift_vref_rdn == "true") ? 1'b1 : 1'b0; //- 26 assign xcbin_rsellvrefup = (shift_vref_rup == "true") ? 1'b1 : 1'b0; //- 25 assign xcbin_rtest = (test_mode == "true") ? 1'b1 : 1'b0; // - 2 cycloneive_termination_ctrl m_ctrl ( .clken (xcbout_clken ), .clkin (xcbout_clkin ), .maskbit (xcbout_maskbit ), .nclr (xcbout_nclr ), .noctdoneuser (xcbout_noctdoneuser ), .octdone (xcbout_octdone ), .oregclk (xcbout_oregclk ), .oregnclr (xcbout_oregnclr ), .vref (xcbout_vref ), .vrefh (xcbout_vrefh ), .vrefl (xcbout_vrefl ), .clkusr (xcbin_clkusr ), .intosc (xcbin_intosc ), .nclrusr (xcbin_nclrusr ), .nfrzdrv (xcbin_nfrzdrv ), .vccnx (xcbin_vccnx ), .vssn (xcbin_vssn ), .rclkdiv (xcbin_rclkdiv ), .rclrusrinv (xcbin_rclrusrinv ), .rdivsel (xcbin_rdivsel ), .roctusr (xcbin_roctusr ), .rsellvrefdn (xcbin_rsellvrefdn ), .rsellvrefup (xcbin_rsellvrefup ), .rtest (xcbin_rtest ) ); assign m_vcc = 1'b1; assign m_gnd = 1'b0; assign rshift_in = (left_shift_termination_code == "true") ? 1'b1 : 1'b0; assign rpwrdn_in = (power_down == "true") ? 1'b1 : 1'b0; cycloneive_termination_rupdn m_rup ( .compout (rup_compout ), .octrpcd (rup_octrupn ), .octcal (rup_octcalnout ), .octpin (rupin ), .rcompoutinv (m_vcc ), // no inversion .radd (rup_radd ), .clken (xcbout_clken ), .clkin (xcbout_clkin ), .maskbit (xcbout_maskbit ), .nclr (xcbout_nclr ), .oregclk (xcbout_oregclk ), .oregnclr (xcbout_oregnclr), .shiftedvref (xcbout_vrefl ), .vccnx (xcbin_vccnx ), .vref (xcbout_vref ), .roctdone (m_gnd ), // [12] .rpwrdn (rpwrdn_in ), // [1] .rshift (rshift_in ), // [3] .rshiftvref (m_vcc ), // [27] .rtest (xcbin_rtest ) ); defparam m_rup.is_rdn = "false"; cycloneive_termination_rupdn m_rdn ( .compout (rdn_compout ), .octrpcd (rdn_octrdnp ), .octcal (rdn_octcalpout ), .octpin (rdnin ), .rcompoutinv (m_gnd ), // invert compout .radd (rdn_radd ), .clken (xcbout_clken ), .clkin (xcbout_clkin ), .maskbit (xcbout_maskbit ), .nclr (xcbout_nclr ), .oregclk (xcbout_oregclk ), .oregnclr (xcbout_oregnclr), .shiftedvref (xcbout_vrefh ), .vccnx (xcbin_vccnx ), .vref (xcbout_vref ), .roctdone (m_gnd ), // [12] .rpwrdn (rpwrdn_in ), // [1] .rshift (rshift_in ), // [3] .rshiftvref (m_vcc ), // [27] .rtest (xcbin_rtest ) ); defparam m_rdn.is_rdn = "true"; endmodule
module cycloneive_jtag ( tms, tck, tdi, tdoutap, tdouser, tdo, tmsutap, tckutap, tdiutap, shiftuser, clkdruser, updateuser, runidleuser, usr1user); input tms; input tck; input tdi; input tdoutap; input tdouser; output tdo; output tmsutap; output tckutap; output tdiutap; output shiftuser; output clkdruser; output updateuser; output runidleuser; output usr1user; parameter lpm_type = "cycloneive_jtag"; endmodule
module cycloneive_crcblock ( clk, shiftnld, ldsrc, crcerror, regout); input clk; input shiftnld; input ldsrc; output crcerror; output regout; assign crcerror = 1'b0; assign regout = 1'b0; parameter oscillator_divider = 1; parameter lpm_type = "cycloneive_crcblock"; endmodule
module cycloneive_oscillator ( oscena, clkout ); parameter lpm_type = "cycloneive_oscillator"; input oscena; output clkout; // LOCAL_PARAMETERS_BEGIN parameter OSC_PW = 6250; // fixed 80HZ running clock // LOCAL_PARAMETERS_END // INTERNAL wire reg int_osc; // internal oscillator specify (posedge oscena => (clkout +: 1'b1)) = (0, 0); endspecify initial int_osc = 1'b0; always @(int_osc or oscena) begin if (oscena == 1'b1) int_osc <= #OSC_PW ~int_osc; end and (clkout, int_osc, 1'b1); endmodule
module sky130_fd_sc_hd__clkinvlp ( //# {{data|Data Signals}} input A, output Y ); // Voltage supply signals supply1 VPWR; supply0 VGND; supply1 VPB ; supply0 VNB ; endmodule
module system_top ( ddr_addr, ddr_ba, ddr_cas_n, ddr_ck_n, ddr_ck_p, ddr_cke, ddr_cs_n, ddr_dm, ddr_dq, ddr_dqs_n, ddr_dqs_p, ddr_odt, ddr_ras_n, ddr_reset_n, ddr_we_n, fixed_io_ddr_vrn, fixed_io_ddr_vrp, fixed_io_mio, fixed_io_ps_clk, fixed_io_ps_porb, fixed_io_ps_srstb, gpio_bd, hdmi_out_clk, hdmi_vsync, hdmi_hsync, hdmi_data_e, hdmi_data, spdif, iic_scl, iic_sda, adc_clk_in_p, adc_clk_in_n, adc_or_in_p, adc_or_in_n, adc_data_in_p, adc_data_in_n, spi_adf4351_csn, spi_ad9652_csn, spi_ad9517_csn, spi_clk, spi_sdio, adf4351_ld); inout [14:0] ddr_addr; inout [ 2:0] ddr_ba; inout ddr_cas_n; inout ddr_ck_n; inout ddr_ck_p; inout ddr_cke; inout ddr_cs_n; inout [ 3:0] ddr_dm; inout [31:0] ddr_dq; inout [ 3:0] ddr_dqs_n; inout [ 3:0] ddr_dqs_p; inout ddr_odt; inout ddr_ras_n; inout ddr_reset_n; inout ddr_we_n; inout fixed_io_ddr_vrn; inout fixed_io_ddr_vrp; inout [53:0] fixed_io_mio; inout fixed_io_ps_clk; inout fixed_io_ps_porb; inout fixed_io_ps_srstb; inout [14:0] gpio_bd; output hdmi_out_clk; output hdmi_vsync; output hdmi_hsync; output hdmi_data_e; output [23:0] hdmi_data; output spdif; inout iic_scl; inout iic_sda; input adc_clk_in_p; input adc_clk_in_n; input adc_or_in_p; input adc_or_in_n; input [15:0] adc_data_in_p; input [15:0] adc_data_in_n; output spi_adf4351_csn; output spi_ad9652_csn; output spi_ad9517_csn; output spi_clk; inout spi_sdio; inout adf4351_ld; // internal registers reg adc_dwr = 'd0; reg [31:0] adc_ddata = 'd0; // internal signals wire [63:0] gpio_i; wire [63:0] gpio_o; wire [63:0] gpio_t; wire [ 2:0] spi0_csn; wire spi0_clk; wire spi0_mosi; wire spi0_miso; wire [ 2:0] spi1_csn; wire spi1_clk; wire spi1_mosi; wire spi1_miso; wire adc_clk; wire adc_valid_0; wire adc_enable_0; wire [15:0] adc_data_0; wire adc_valid_1; wire adc_enable_1; wire [15:0] adc_data_1; // pack-unpack place holder always @(posedge adc_clk) begin case ({adc_enable_1, adc_enable_0}) 2'b10: begin adc_dwr <= ~adc_dwr; adc_ddata <= {adc_data_1, adc_ddata[31:16]}; end 2'b01: begin adc_dwr <= ~adc_dwr; adc_ddata <= {adc_data_0, adc_ddata[31:16]}; end default: begin adc_dwr <= 1'b1; adc_ddata <= {adc_data_1, adc_data_0}; end endcase end // spi assign spi_clk = spi0_clk; assign spi_ad9517_csn = spi0_csn[0]; assign spi_ad9652_csn = spi0_csn[1]; assign spi_adf4351_csn = spi0_csn[2]; // instantiations fmcomms6_spi i_spi ( .spi_csn (spi0_csn), .spi_clk (spi0_clk), .spi_mosi (spi0_mosi), .spi_miso (spi0_miso), .spi_sdio (spi_sdio)); ad_iobuf #(.DATA_WIDTH(1)) i_iobuf ( .dio_t (gpio_t[32]), .dio_i (gpio_o[32]), .dio_o (gpio_i[32]), .dio_p (adf4351_ld)); ad_iobuf #(.DATA_WIDTH(15)) i_iobuf_bd ( .dio_t (gpio_t[14:0]), .dio_i (gpio_o[14:0]), .dio_o (gpio_i[14:0]), .dio_p (gpio_bd)); system_wrapper i_system_wrapper ( .adc_clk (adc_clk), .adc_clk_in_n (adc_clk_in_n), .adc_clk_in_p (adc_clk_in_p), .adc_data_0 (adc_data_0), .adc_data_1 (adc_data_1), .adc_data_in_n (adc_data_in_n), .adc_data_in_p (adc_data_in_p), .adc_ddata (adc_ddata), .adc_dwr (adc_dwr), .adc_enable_0 (adc_enable_0), .adc_enable_1 (adc_enable_1), .adc_or_in_n (adc_or_in_n), .adc_or_in_p (adc_or_in_p), .adc_valid_0 (adc_valid_0), .adc_valid_1 (adc_valid_1), .ddr_addr (ddr_addr), .ddr_ba (ddr_ba), .ddr_cas_n (ddr_cas_n), .ddr_ck_n (ddr_ck_n), .ddr_ck_p (ddr_ck_p), .ddr_cke (ddr_cke), .ddr_cs_n (ddr_cs_n), .ddr_dm (ddr_dm), .ddr_dq (ddr_dq), .ddr_dqs_n (ddr_dqs_n), .ddr_dqs_p (ddr_dqs_p), .ddr_odt (ddr_odt), .ddr_ras_n (ddr_ras_n), .ddr_reset_n (ddr_reset_n), .ddr_we_n (ddr_we_n), .fixed_io_ddr_vrn (fixed_io_ddr_vrn), .fixed_io_ddr_vrp (fixed_io_ddr_vrp), .fixed_io_mio (fixed_io_mio), .fixed_io_ps_clk (fixed_io_ps_clk), .fixed_io_ps_porb (fixed_io_ps_porb), .fixed_io_ps_srstb (fixed_io_ps_srstb), .gpio_i (gpio_i), .gpio_o (gpio_o), .gpio_t (gpio_t), .hdmi_data (hdmi_data), .hdmi_data_e (hdmi_data_e), .hdmi_hsync (hdmi_hsync), .hdmi_out_clk (hdmi_out_clk), .hdmi_vsync (hdmi_vsync), .iic_main_scl_io (iic_scl), .iic_main_sda_io (iic_sda), .ps_intr_00 (1'b0), .ps_intr_01 (1'b0), .ps_intr_02 (1'b0), .ps_intr_03 (1'b0), .ps_intr_04 (1'b0), .ps_intr_05 (1'b0), .ps_intr_06 (1'b0), .ps_intr_07 (1'b0), .ps_intr_08 (1'b0), .ps_intr_09 (1'b0), .ps_intr_10 (1'b0), .ps_intr_11 (1'b0), .ps_intr_12 (1'b0), .spdif (spdif), .spi0_clk_i (spi0_clk), .spi0_clk_o (spi0_clk), .spi0_csn_0_o (spi0_csn[0]), .spi0_csn_1_o (spi0_csn[1]), .spi0_csn_2_o (spi0_csn[2]), .spi0_csn_i (1'b1), .spi0_sdi_i (spi0_miso), .spi0_sdo_i (spi0_mosi), .spi0_sdo_o (spi0_mosi), .spi1_clk_i (spi1_clk), .spi1_clk_o (spi1_clk), .spi1_csn_0_o (spi1_csn[0]), .spi1_csn_1_o (spi1_csn[1]), .spi1_csn_2_o (spi1_csn[2]), .spi1_csn_i (1'b1), .spi1_sdi_i (1'b1), .spi1_sdo_i (spi1_mosi), .spi1_sdo_o (spi1_mosi)); endmodule
module lab5_top(CLK, SW, KEY, RESET_N, LEDR, HEX5, HEX4, HEX3, HEX2, HEX1, HEX0); input CLK; input [9:0] SW; input [3:0] KEY; input RESET_N; output [9:0] LEDR; output [6:0] HEX5; output [6:0] HEX4; output [6:0] HEX3; output [6:0] HEX2; output [6:0] HEX1; output [6:0] HEX0; wire RESET; wire EN_L; wire [7:0] IOA; wire [7:0] IOB; wire [7:0] IOC; wire [7:0] IOD; wire [7:0] IOE; wire [7:0] IOF; wire [7:0] IOG; assign RESET = ~RESET_N; assign EN_L = KEY[2]; lab5 daCore( .CLK(CLK), .RESET(RESET), .IOA(IOA), .IOB(IOB), .IOC(IOC), .EN_L(EN_L), .IOD(IOD), .IOE(IOE), .IOF(IOF), .IOG(IOG) ); dual_reg_in inputs( .CLK(CLK), .IN(SW[7:0]), .SEL(SW[8]), .WEN_L(KEY[3]), .OUTA(IOA), .OUTB(IOB) ); // PUSHBUTTON INPUT LOGIC assign IOC[7:2] = 6'b0; assign IOC[1] = ~KEY[1]; assign IOC[0] = ~KEY[0]; // LED ARRAY LOGIC assign LEDR[9] = CLK; assign LEDR[8] = 1'b0; assign LEDR[7:0] = IOD; // SEVEN-SEGMENT DISPLAY DRIVERS hex_to_seven_seg upperIOG( .B(IOG[7:4]), .SSEG_L(HEX5) ); hex_to_seven_seg lowerIOG( .B(IOG[3:0]), .SSEG_L(HEX4) ); hex_to_seven_seg upperIOF( .B(IOF[7:4]), .SSEG_L(HEX3) ); hex_to_seven_seg lowerIOF( .B(IOF[3:0]), .SSEG_L(HEX2) ); hex_to_seven_seg upperIOE( .B(IOE[7:4]), .SSEG_L(HEX1) ); hex_to_seven_seg lowerIOE( .B(IOE[3:0]), .SSEG_L(HEX0) ); endmodule
module nova_ram(pclk, prst, mm_adr, mm_we, mm_din, mm_dout); parameter addr_width = 16; parameter mem_size = 1 << addr_width; parameter mem_mask = mem_size-1; input pclk; input prst; input [0:15] mm_adr; input mm_we; input [0:15] mm_din; output [0:15] mm_dout; reg [0:15] m_mem[0:mem_size]; wire [0:addr_width-1] w_adr_masked; integer i; assign w_adr_masked = mm_adr[0:addr_width-1]; assign mm_dout = (~mm_we) ? m_mem[w_adr_masked] : 16'h0000; always @(posedge pclk) begin if(prst) begin for(i = 0; i < mem_size; i = i + 1) m_mem[i] = 16'h0000; // #9 $readmemh("rdos.hex", m_mem); // Interrupt test m_mem[1] = 16'b0000_0000_0000_0100; // @4 // IORST m_mem[2][0:2] = 3'b011; m_mem[2][`NOVA_IO_TRANSFER] = `NOVA_IO_TRANSFER_DIC; m_mem[2][`NOVA_IO_CONTROL] = `NOVA_IO_CONTROL_CLR; m_mem[2][`NOVA_IO_DEVICE] = 6'o77; // JMP 2 m_mem[3][`NOVA_LS_DISPLACE] = 8'h2; // HALT m_mem[4][0:2] = 3'b011; m_mem[4][`NOVA_IO_TRANSFER] = `NOVA_IO_TRANSFER_DOC; m_mem[4][`NOVA_IO_CONTROL] = `NOVA_IO_CONTROL_CLR; m_mem[4][`NOVA_IO_DEVICE] = 6'o77; end else begin if(mm_we) begin // $display("M[%h] = %h", mm_adr, mm_din); m_mem[w_adr_masked] <= mm_din; end end end endmodule
module fpga ( /* * Clock: 125MHz LVDS * Reset: Push button, active low */ input wire clk_125mhz_p, input wire clk_125mhz_n, input wire reset, /* * GPIO */ input wire btnu, input wire btnl, input wire btnd, input wire btnr, input wire btnc, input wire [3:0] sw, output wire [7:0] led, /* * I2C for board management */ inout wire i2c_scl, inout wire i2c_sda, /* * Ethernet: QSFP28 */ input wire qsfp_rx1_p, input wire qsfp_rx1_n, input wire qsfp_rx2_p, input wire qsfp_rx2_n, input wire qsfp_rx3_p, input wire qsfp_rx3_n, input wire qsfp_rx4_p, input wire qsfp_rx4_n, output wire qsfp_tx1_p, output wire qsfp_tx1_n, output wire qsfp_tx2_p, output wire qsfp_tx2_n, output wire qsfp_tx3_p, output wire qsfp_tx3_n, output wire qsfp_tx4_p, output wire qsfp_tx4_n, input wire qsfp_mgt_refclk_0_p, input wire qsfp_mgt_refclk_0_n, // input wire qsfp_mgt_refclk_1_p, // input wire qsfp_mgt_refclk_1_n, // output wire qsfp_recclk_p, // output wire qsfp_recclk_n, output wire qsfp_modsell, output wire qsfp_resetl, input wire qsfp_modprsl, input wire qsfp_intl, output wire qsfp_lpmode, /* * Ethernet: 1000BASE-T SGMII */ input wire phy_sgmii_rx_p, input wire phy_sgmii_rx_n, output wire phy_sgmii_tx_p, output wire phy_sgmii_tx_n, input wire phy_sgmii_clk_p, input wire phy_sgmii_clk_n, output wire phy_reset_n, input wire phy_int_n, /* * UART: 500000 bps, 8N1 */ input wire uart_rxd, output wire uart_txd, output wire uart_rts, input wire uart_cts ); // Clock and reset wire clk_125mhz_ibufg; // Internal 125 MHz clock wire clk_125mhz_mmcm_out; wire clk_125mhz_int; wire rst_125mhz_int; // Internal 156.25 MHz clock wire clk_156mhz_int; wire rst_156mhz_int; wire mmcm_rst = reset; wire mmcm_locked; wire mmcm_clkfb; IBUFGDS #( .DIFF_TERM("FALSE"), .IBUF_LOW_PWR("FALSE") ) clk_125mhz_ibufg_inst ( .O (clk_125mhz_ibufg), .I (clk_125mhz_p), .IB (clk_125mhz_n) ); // MMCM instance // 125 MHz in, 125 MHz out // PFD range: 10 MHz to 500 MHz // VCO range: 600 MHz to 1440 MHz // M = 5, D = 1 sets Fvco = 625 MHz (in range) // Divide by 5 to get output frequency of 125 MHz MMCME3_BASE #( .BANDWIDTH("OPTIMIZED"), .CLKOUT0_DIVIDE_F(5), .CLKOUT0_DUTY_CYCLE(0.5), .CLKOUT0_PHASE(0), .CLKOUT1_DIVIDE(1), .CLKOUT1_DUTY_CYCLE(0.5), .CLKOUT1_PHASE(0), .CLKOUT2_DIVIDE(1), .CLKOUT2_DUTY_CYCLE(0.5), .CLKOUT2_PHASE(0), .CLKOUT3_DIVIDE(1), .CLKOUT3_DUTY_CYCLE(0.5), .CLKOUT3_PHASE(0), .CLKOUT4_DIVIDE(1), .CLKOUT4_DUTY_CYCLE(0.5), .CLKOUT4_PHASE(0), .CLKOUT5_DIVIDE(1), .CLKOUT5_DUTY_CYCLE(0.5), .CLKOUT5_PHASE(0), .CLKOUT6_DIVIDE(1), .CLKOUT6_DUTY_CYCLE(0.5), .CLKOUT6_PHASE(0), .CLKFBOUT_MULT_F(5), .CLKFBOUT_PHASE(0), .DIVCLK_DIVIDE(1), .REF_JITTER1(0.010), .CLKIN1_PERIOD(8.0), .STARTUP_WAIT("FALSE"), .CLKOUT4_CASCADE("FALSE") ) clk_mmcm_inst ( .CLKIN1(clk_125mhz_ibufg), .CLKFBIN(mmcm_clkfb), .RST(mmcm_rst), .PWRDWN(1'b0), .CLKOUT0(clk_125mhz_mmcm_out), .CLKOUT0B(), .CLKOUT1(), .CLKOUT1B(), .CLKOUT2(), .CLKOUT2B(), .CLKOUT3(), .CLKOUT3B(), .CLKOUT4(), .CLKOUT5(), .CLKOUT6(), .CLKFBOUT(mmcm_clkfb), .CLKFBOUTB(), .LOCKED(mmcm_locked) ); BUFG clk_125mhz_bufg_inst ( .I(clk_125mhz_mmcm_out), .O(clk_125mhz_int) ); sync_reset #( .N(4) ) sync_reset_125mhz_inst ( .clk(clk_125mhz_int), .rst(~mmcm_locked), .out(rst_125mhz_int) ); // GPIO wire btnu_int; wire btnl_int; wire btnd_int; wire btnr_int; wire btnc_int; wire [3:0] sw_int; debounce_switch #( .WIDTH(9), .N(4), .RATE(156000) ) debounce_switch_inst ( .clk(clk_156mhz_int), .rst(rst_156mhz_int), .in({btnu, btnl, btnd, btnr, btnc, sw}), .out({btnu_int, btnl_int, btnd_int, btnr_int, btnc_int, sw_int}) ); wire uart_rxd_int; wire uart_cts_int; sync_signal #( .WIDTH(2), .N(2) ) sync_signal_inst ( .clk(clk_156mhz_int), .in({uart_rxd, uart_cts}), .out({uart_rxd_int, uart_cts_int}) ); // SI570 I2C wire i2c_scl_i; wire i2c_scl_o = 1'b1; wire i2c_scl_t = 1'b1; wire i2c_sda_i; wire i2c_sda_o = 1'b1; wire i2c_sda_t = 1'b1; assign i2c_scl_i = i2c_scl; assign i2c_scl = i2c_scl_t ? 1'bz : i2c_scl_o; assign i2c_sda_i = i2c_sda; assign i2c_sda = i2c_sda_t ? 1'bz : i2c_sda_o; // XGMII 10G PHY assign qsfp_modsell = 1'b0; assign qsfp_resetl = 1'b1; assign qsfp_lpmode = 1'b0; wire qsfp_tx_clk_1_int; wire qsfp_tx_rst_1_int; wire [63:0] qsfp_txd_1_int; wire [7:0] qsfp_txc_1_int; wire qsfp_rx_clk_1_int; wire qsfp_rx_rst_1_int; wire [63:0] qsfp_rxd_1_int; wire [7:0] qsfp_rxc_1_int; wire qsfp_tx_clk_2_int; wire qsfp_tx_rst_2_int; wire [63:0] qsfp_txd_2_int; wire [7:0] qsfp_txc_2_int; wire qsfp_rx_clk_2_int; wire qsfp_rx_rst_2_int; wire [63:0] qsfp_rxd_2_int; wire [7:0] qsfp_rxc_2_int; wire qsfp_tx_clk_3_int; wire qsfp_tx_rst_3_int; wire [63:0] qsfp_txd_3_int; wire [7:0] qsfp_txc_3_int; wire qsfp_rx_clk_3_int; wire qsfp_rx_rst_3_int; wire [63:0] qsfp_rxd_3_int; wire [7:0] qsfp_rxc_3_int; wire qsfp_tx_clk_4_int; wire qsfp_tx_rst_4_int; wire [63:0] qsfp_txd_4_int; wire [7:0] qsfp_txc_4_int; wire qsfp_rx_clk_4_int; wire qsfp_rx_rst_4_int; wire [63:0] qsfp_rxd_4_int; wire [7:0] qsfp_rxc_4_int; assign clk_156mhz_int = qsfp_tx_clk_1_int; assign rst_156mhz_int = qsfp_tx_rst_1_int; wire qsfp_rx_block_lock_1; wire qsfp_rx_block_lock_2; wire qsfp_rx_block_lock_3; wire qsfp_rx_block_lock_4; wire qsfp_mgt_refclk_0; IBUFDS_GTE3 ibufds_gte3_qsfp_mgt_refclk_0_inst ( .I (qsfp_mgt_refclk_0_p), .IB (qsfp_mgt_refclk_0_n), .CEB (1'b0), .O (qsfp_mgt_refclk_0), .ODIV2 () ); wire qsfp_qpll0lock; wire qsfp_qpll0outclk; wire qsfp_qpll0outrefclk; eth_xcvr_phy_wrapper #( .HAS_COMMON(1) ) qsfp_phy_1_inst ( .xcvr_ctrl_clk(clk_125mhz_int), .xcvr_ctrl_rst(rst_125mhz_int), // Common .xcvr_gtpowergood_out(), // PLL out .xcvr_gtrefclk00_in(qsfp_mgt_refclk_0), .xcvr_qpll0lock_out(qsfp_qpll0lock), .xcvr_qpll0outclk_out(qsfp_qpll0outclk), .xcvr_qpll0outrefclk_out(qsfp_qpll0outrefclk), // PLL in .xcvr_qpll0lock_in(1'b0), .xcvr_qpll0reset_out(), .xcvr_qpll0clk_in(1'b0), .xcvr_qpll0refclk_in(1'b0), // Serial data .xcvr_txp(qsfp_tx1_p), .xcvr_txn(qsfp_tx1_n), .xcvr_rxp(qsfp_rx1_p), .xcvr_rxn(qsfp_rx1_n), // PHY connections .phy_tx_clk(qsfp_tx_clk_1_int), .phy_tx_rst(qsfp_tx_rst_1_int), .phy_xgmii_txd(qsfp_txd_1_int), .phy_xgmii_txc(qsfp_txc_1_int), .phy_rx_clk(qsfp_rx_clk_1_int), .phy_rx_rst(qsfp_rx_rst_1_int), .phy_xgmii_rxd(qsfp_rxd_1_int), .phy_xgmii_rxc(qsfp_rxc_1_int), .phy_tx_bad_block(), .phy_rx_error_count(), .phy_rx_bad_block(), .phy_rx_sequence_error(), .phy_rx_block_lock(qsfp_rx_block_lock_1), .phy_rx_high_ber(), .phy_tx_prbs31_enable(), .phy_rx_prbs31_enable() ); eth_xcvr_phy_wrapper #( .HAS_COMMON(0) ) qsfp_phy_2_inst ( .xcvr_ctrl_clk(clk_125mhz_int), .xcvr_ctrl_rst(rst_125mhz_int), // Common .xcvr_gtpowergood_out(), // PLL out .xcvr_gtrefclk00_in(1'b0), .xcvr_qpll0lock_out(), .xcvr_qpll0outclk_out(), .xcvr_qpll0outrefclk_out(), // PLL in .xcvr_qpll0lock_in(qsfp_qpll0lock), .xcvr_qpll0reset_out(), .xcvr_qpll0clk_in(qsfp_qpll0outclk), .xcvr_qpll0refclk_in(qsfp_qpll0outrefclk), // Serial data .xcvr_txp(qsfp_tx2_p), .xcvr_txn(qsfp_tx2_n), .xcvr_rxp(qsfp_rx2_p), .xcvr_rxn(qsfp_rx2_n), // PHY connections .phy_tx_clk(qsfp_tx_clk_2_int), .phy_tx_rst(qsfp_tx_rst_2_int), .phy_xgmii_txd(qsfp_txd_2_int), .phy_xgmii_txc(qsfp_txc_2_int), .phy_rx_clk(qsfp_rx_clk_2_int), .phy_rx_rst(qsfp_rx_rst_2_int), .phy_xgmii_rxd(qsfp_rxd_2_int), .phy_xgmii_rxc(qsfp_rxc_2_int), .phy_tx_bad_block(), .phy_rx_error_count(), .phy_rx_bad_block(), .phy_rx_sequence_error(), .phy_rx_block_lock(qsfp_rx_block_lock_2), .phy_rx_high_ber(), .phy_tx_prbs31_enable(), .phy_rx_prbs31_enable() ); eth_xcvr_phy_wrapper #( .HAS_COMMON(0) ) qsfp_phy_3_inst ( .xcvr_ctrl_clk(clk_125mhz_int), .xcvr_ctrl_rst(rst_125mhz_int), // Common .xcvr_gtpowergood_out(), // PLL out .xcvr_gtrefclk00_in(1'b0), .xcvr_qpll0lock_out(), .xcvr_qpll0outclk_out(), .xcvr_qpll0outrefclk_out(), // PLL in .xcvr_qpll0lock_in(qsfp_qpll0lock), .xcvr_qpll0reset_out(), .xcvr_qpll0clk_in(qsfp_qpll0outclk), .xcvr_qpll0refclk_in(qsfp_qpll0outrefclk), // Serial data .xcvr_txp(qsfp_tx3_p), .xcvr_txn(qsfp_tx3_n), .xcvr_rxp(qsfp_rx3_p), .xcvr_rxn(qsfp_rx3_n), // PHY connections .phy_tx_clk(qsfp_tx_clk_3_int), .phy_tx_rst(qsfp_tx_rst_3_int), .phy_xgmii_txd(qsfp_txd_3_int), .phy_xgmii_txc(qsfp_txc_3_int), .phy_rx_clk(qsfp_rx_clk_3_int), .phy_rx_rst(qsfp_rx_rst_3_int), .phy_xgmii_rxd(qsfp_rxd_3_int), .phy_xgmii_rxc(qsfp_rxc_3_int), .phy_tx_bad_block(), .phy_rx_error_count(), .phy_rx_bad_block(), .phy_rx_sequence_error(), .phy_rx_block_lock(qsfp_rx_block_lock_3), .phy_rx_high_ber(), .phy_tx_prbs31_enable(), .phy_rx_prbs31_enable() ); eth_xcvr_phy_wrapper #( .HAS_COMMON(0) ) qsfp_phy_4_inst ( .xcvr_ctrl_clk(clk_125mhz_int), .xcvr_ctrl_rst(rst_125mhz_int), // Common .xcvr_gtpowergood_out(), // PLL out .xcvr_gtrefclk00_in(1'b0), .xcvr_qpll0lock_out(), .xcvr_qpll0outclk_out(), .xcvr_qpll0outrefclk_out(), // PLL in .xcvr_qpll0lock_in(qsfp_qpll0lock), .xcvr_qpll0reset_out(), .xcvr_qpll0clk_in(qsfp_qpll0outclk), .xcvr_qpll0refclk_in(qsfp_qpll0outrefclk), // Serial data .xcvr_txp(qsfp_tx4_p), .xcvr_txn(qsfp_tx4_n), .xcvr_rxp(qsfp_rx4_p), .xcvr_rxn(qsfp_rx4_n), // PHY connections .phy_tx_clk(qsfp_tx_clk_4_int), .phy_tx_rst(qsfp_tx_rst_4_int), .phy_xgmii_txd(qsfp_txd_4_int), .phy_xgmii_txc(qsfp_txc_4_int), .phy_rx_clk(qsfp_rx_clk_4_int), .phy_rx_rst(qsfp_rx_rst_4_int), .phy_xgmii_rxd(qsfp_rxd_4_int), .phy_xgmii_rxc(qsfp_rxc_4_int), .phy_tx_bad_block(), .phy_rx_error_count(), .phy_rx_bad_block(), .phy_rx_sequence_error(), .phy_rx_block_lock(qsfp_rx_block_lock_4), .phy_rx_high_ber(), .phy_tx_prbs31_enable(), .phy_rx_prbs31_enable() ); // SGMII interface to PHY wire phy_gmii_clk_int; wire phy_gmii_rst_int; wire phy_gmii_clk_en_int; wire [7:0] phy_gmii_txd_int; wire phy_gmii_tx_en_int; wire phy_gmii_tx_er_int; wire [7:0] phy_gmii_rxd_int; wire phy_gmii_rx_dv_int; wire phy_gmii_rx_er_int; wire [15:0] gig_eth_pcspma_status_vector; wire gig_eth_pcspma_status_link_status = gig_eth_pcspma_status_vector[0]; wire gig_eth_pcspma_status_link_synchronization = gig_eth_pcspma_status_vector[1]; wire gig_eth_pcspma_status_rudi_c = gig_eth_pcspma_status_vector[2]; wire gig_eth_pcspma_status_rudi_i = gig_eth_pcspma_status_vector[3]; wire gig_eth_pcspma_status_rudi_invalid = gig_eth_pcspma_status_vector[4]; wire gig_eth_pcspma_status_rxdisperr = gig_eth_pcspma_status_vector[5]; wire gig_eth_pcspma_status_rxnotintable = gig_eth_pcspma_status_vector[6]; wire gig_eth_pcspma_status_phy_link_status = gig_eth_pcspma_status_vector[7]; wire [1:0] gig_eth_pcspma_status_remote_fault_encdg = gig_eth_pcspma_status_vector[9:8]; wire [1:0] gig_eth_pcspma_status_speed = gig_eth_pcspma_status_vector[11:10]; wire gig_eth_pcspma_status_duplex = gig_eth_pcspma_status_vector[12]; wire gig_eth_pcspma_status_remote_fault = gig_eth_pcspma_status_vector[13]; wire [1:0] gig_eth_pcspma_status_pause = gig_eth_pcspma_status_vector[15:14]; wire [4:0] gig_eth_pcspma_config_vector; assign gig_eth_pcspma_config_vector[4] = 1'b1; // autonegotiation enable assign gig_eth_pcspma_config_vector[3] = 1'b0; // isolate assign gig_eth_pcspma_config_vector[2] = 1'b0; // power down assign gig_eth_pcspma_config_vector[1] = 1'b0; // loopback enable assign gig_eth_pcspma_config_vector[0] = 1'b0; // unidirectional enable wire [15:0] gig_eth_pcspma_an_config_vector; assign gig_eth_pcspma_an_config_vector[15] = 1'b1; // SGMII link status assign gig_eth_pcspma_an_config_vector[14] = 1'b1; // SGMII Acknowledge assign gig_eth_pcspma_an_config_vector[13:12] = 2'b01; // full duplex assign gig_eth_pcspma_an_config_vector[11:10] = 2'b10; // SGMII speed assign gig_eth_pcspma_an_config_vector[9] = 1'b0; // reserved assign gig_eth_pcspma_an_config_vector[8:7] = 2'b00; // pause frames - SGMII reserved assign gig_eth_pcspma_an_config_vector[6] = 1'b0; // reserved assign gig_eth_pcspma_an_config_vector[5] = 1'b0; // full duplex - SGMII reserved assign gig_eth_pcspma_an_config_vector[4:1] = 4'b0000; // reserved assign gig_eth_pcspma_an_config_vector[0] = 1'b1; // SGMII gig_ethernet_pcs_pma_0 gig_eth_pcspma ( // SGMII .txp (phy_sgmii_tx_p), .txn (phy_sgmii_tx_n), .rxp (phy_sgmii_rx_p), .rxn (phy_sgmii_rx_n), // Ref clock from PHY .refclk625_p (phy_sgmii_clk_p), .refclk625_n (phy_sgmii_clk_n), // async reset .reset (rst_125mhz_int), // clock and reset outputs .clk125_out (phy_gmii_clk_int), .clk625_out (), .clk312_out (), .rst_125_out (phy_gmii_rst_int), .idelay_rdy_out (), .mmcm_locked_out (), // MAC clocking .sgmii_clk_r (), .sgmii_clk_f (), .sgmii_clk_en (phy_gmii_clk_en_int), // Speed control .speed_is_10_100 (gig_eth_pcspma_status_speed != 2'b10), .speed_is_100 (gig_eth_pcspma_status_speed == 2'b01), // Internal GMII .gmii_txd (phy_gmii_txd_int), .gmii_tx_en (phy_gmii_tx_en_int), .gmii_tx_er (phy_gmii_tx_er_int), .gmii_rxd (phy_gmii_rxd_int), .gmii_rx_dv (phy_gmii_rx_dv_int), .gmii_rx_er (phy_gmii_rx_er_int), .gmii_isolate (), // Configuration .configuration_vector (gig_eth_pcspma_config_vector), .an_interrupt (), .an_adv_config_vector (gig_eth_pcspma_an_config_vector), .an_restart_config (1'b0), // Status .status_vector (gig_eth_pcspma_status_vector), .signal_detect (1'b1) ); wire [7:0] led_int; assign led[0] = sw[0] ? qsfp_rx_block_lock_1 : led_int[0]; assign led[1] = sw[0] ? qsfp_rx_block_lock_2 : led_int[1]; assign led[2] = sw[0] ? qsfp_rx_block_lock_3 : led_int[2]; assign led[3] = sw[0] ? qsfp_rx_block_lock_4 : led_int[3]; assign led[4] = sw[0] ? 1'b0 : led_int[4]; assign led[5] = sw[0] ? 1'b0 : led_int[5]; assign led[6] = sw[0] ? 1'b0 : led_int[6]; assign led[7] = sw[0] ? 1'b0 : led_int[7]; fpga_core core_inst ( /* * Clock: 156.25 MHz * Synchronous reset */ .clk(clk_156mhz_int), .rst(rst_156mhz_int), /* * GPIO */ .btnu(btnu_int), .btnl(btnl_int), .btnd(btnd_int), .btnr(btnr_int), .btnc(btnc_int), .sw(sw_int), .led(led_int), /* * Ethernet: QSFP28 */ .qsfp_tx_clk_1(qsfp_tx_clk_1_int), .qsfp_tx_rst_1(qsfp_tx_rst_1_int), .qsfp_txd_1(qsfp_txd_1_int), .qsfp_txc_1(qsfp_txc_1_int), .qsfp_rx_clk_1(qsfp_rx_clk_1_int), .qsfp_rx_rst_1(qsfp_rx_rst_1_int), .qsfp_rxd_1(qsfp_rxd_1_int), .qsfp_rxc_1(qsfp_rxc_1_int), .qsfp_tx_clk_2(qsfp_tx_clk_2_int), .qsfp_tx_rst_2(qsfp_tx_rst_2_int), .qsfp_txd_2(qsfp_txd_2_int), .qsfp_txc_2(qsfp_txc_2_int), .qsfp_rx_clk_2(qsfp_rx_clk_2_int), .qsfp_rx_rst_2(qsfp_rx_rst_2_int), .qsfp_rxd_2(qsfp_rxd_2_int), .qsfp_rxc_2(qsfp_rxc_2_int), .qsfp_tx_clk_3(qsfp_tx_clk_3_int), .qsfp_tx_rst_3(qsfp_tx_rst_3_int), .qsfp_txd_3(qsfp_txd_3_int), .qsfp_txc_3(qsfp_txc_3_int), .qsfp_rx_clk_3(qsfp_rx_clk_3_int), .qsfp_rx_rst_3(qsfp_rx_rst_3_int), .qsfp_rxd_3(qsfp_rxd_3_int), .qsfp_rxc_3(qsfp_rxc_3_int), .qsfp_tx_clk_4(qsfp_tx_clk_4_int), .qsfp_tx_rst_4(qsfp_tx_rst_4_int), .qsfp_txd_4(qsfp_txd_4_int), .qsfp_txc_4(qsfp_txc_4_int), .qsfp_rx_clk_4(qsfp_rx_clk_4_int), .qsfp_rx_rst_4(qsfp_rx_rst_4_int), .qsfp_rxd_4(qsfp_rxd_4_int), .qsfp_rxc_4(qsfp_rxc_4_int), /* * Ethernet: 1000BASE-T SGMII */ .phy_gmii_clk(phy_gmii_clk_int), .phy_gmii_rst(phy_gmii_rst_int), .phy_gmii_clk_en(phy_gmii_clk_en_int), .phy_gmii_rxd(phy_gmii_rxd_int), .phy_gmii_rx_dv(phy_gmii_rx_dv_int), .phy_gmii_rx_er(phy_gmii_rx_er_int), .phy_gmii_txd(phy_gmii_txd_int), .phy_gmii_tx_en(phy_gmii_tx_en_int), .phy_gmii_tx_er(phy_gmii_tx_er_int), .phy_reset_n(phy_reset_n), .phy_int_n(phy_int_n), /* * UART: 115200 bps, 8N1 */ .uart_rxd(uart_rxd_int), .uart_txd(uart_txd), .uart_rts(uart_rts), .uart_cts(uart_cts_int) ); endmodule