diff --git a/generic_ip/enc_pd_emul/1/doc/enc_pd_emul_1.json b/generic_ip/enc_pd_emul/1/doc/enc_pd_emul_1.json index 3cd06a1..7d80e09 100644 --- a/generic_ip/enc_pd_emul/1/doc/enc_pd_emul_1.json +++ b/generic_ip/enc_pd_emul/1/doc/enc_pd_emul_1.json @@ -11,9 +11,9 @@ "process": "cpp, txt", "offset": "0x0" }, - "generic_sequencer_15": { - "instance": "seq", - "process": "cpp, txt", + "generic_sequencer_17": { + "instance": "", + "process": "enabled", "offset": "0x20" } }, diff --git a/generic_ip/fire_pulse_manager/7/doc/fpm_ctrl_7.htm b/generic_ip/fire_pulse_manager/7/doc/fpm_ctrl_7.htm deleted file mode 100644 index 40646e8..0000000 --- a/generic_ip/fire_pulse_manager/7/doc/fpm_ctrl_7.htm +++ /dev/null @@ -1,833 +0,0 @@ - - - - - - - - -Datasheet for FPM_CTRL_7 GIS soft IP component - - - - - - -

Datasheet for the FPM_CTRL_7 GIS Soft IP Embedded Logic

-

Register Definitions

-

Offset in core for bus CSR : 0x00020000

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fpm_ctrl_7This block is the fire pulse manager control
Register NameByte Addr OffsetFieldBitsTypesubtypeResetDescription
CSR_FPM_CTRL_7_IP_ID0x0 32 Unique ID for this IP block
IP_NUMBER7:0c0x14IP identifier number
MFR_NUMBER15:8c0xFFManufacturer number
RESERVED31:16rsv0Reserved bits
CSR_FPM_CTRL_7_IP_VER0x4 32 IP Version
MINOR_NUMBER7:0c0x01Minor number
MAJOR_NUMBER15:8c0x07Major number
RESERVED31:16rsv0Reserved bits
CSR_FPM_CTRL_7_FPM_CONFIG0x8 11 Configuration values for the FPM
CH_NUM3:0r0Number of channels
SEB_EPD_LOGIC_PRESENT4r00 => SEB-EPD logic not present, 1 => SEB-EPD logic present
SMB_DIAGNOSTIC_PRESENT5r00 => SMB diagnostic block not present, 1 => SMB diagnostic block present
EVENT_LOGGER_PRESENT6r00 => Event Logger block not present, 1 => Event Logger block present
POF_PROTOCOL_VERSION7r00 => Support POF protocol version 0, 1 => Support POF protocol version 1
DELAY_EQUALIZATION_ENABLE8r00 => No support for delay equalization, 1 => Support for delay equalization
TOF_COMP_ENABLE9r00 => No support for Time-of-Flight compensation, 1 => Support for Time-of-Flight compensation
PIXEL_PITCH_CORR_ENABLE10r00 => No support for pixel-pitch correction, 1 => Support for pixel-pitch correction
CSR_FPM_CTRL_7_FPM_INIT_START0xc 1w 0Start the fpm_init procedure
CSR_FPM_CTRL_7_FPM_INIT_DONE0x10 1r 0fpm_init completed flag
CSR_FPM_CTRL_7_SIGNAL_SELECTION0x14 4 Controls signal selection
FIRE_PULSE_SEL0w0x00 => Use External fire pulses, 1 => Use FPM fire pulses
ENC_PD_EMUL_EN1w0x00 => Use POF RX, 1 => Use internal enc/PD emulator
SEB_EPD_EN2w0x01 => Enable SEB-EPD interface, 0 => Use POF based interface
SEB_EPD_LINKOUT_SEL3w0x00 => SEB_EPD_LINK_OUT is driven by the POF-Tx output, 0 => SEB_EPD_LINK_OUT is driven by the Drop-Watch output
CSR_FPM_CTRL_7_POF_RECEIVER_CONTROL0x18 8 Controls POF receiver
POF_RX_ENABLE0w0x00 => Disable POF RX, 1 => Enable POF RX
UART_REGENERATION_BYPASS1w0x00 => Use UART Regeneration, 1 => Bypass UART Regeneration
CLEAR_MAX2w0x00 => Disabled, 1 => Load the current value of Absolute Position as new maximum
CLEAR_MIN3w0x00 => Disabled, 1 => Load the current value of Absolute Position as new miniumum
UART_RX_DIV7:4w0x4Defines the number of 200 MHz clock cycles per UART data bit
CSR_FPM_CTRL_7_MONITORING_POINT_SELECTION0x1c 16 Selects monitoring points for external header
MP03:0w0x0Selects first monitoring point
MP17:4w0x0Selects second monitoring point
MP211:8w0x0Selects third monitoring point
MP315:12w0x0Selects fourth monitoring point
CSR_FPM_CTRL_7_COARSE_TIME_INIT0x20 32w 0x00000000Defines coarse time counter value
CSR_FPM_CTRL_7_FINE_TIME_INIT0x24 29 Fine time counter value/Load counter enable
FINE_TIME_INIT27:0w0x0000000Defines fine time counter value
TIME_LOAD_EN28w0x0Writting 1 loads the coarse and fine time counters
CSR_FPM_CTRL_7_FINE_TIME_STATUS0x28 28r 0x0000000Current fine time counter value
CSR_FPM_CTRL_7_COARSE_TIME_STATUS0x2c 32r 0x00000000Current coarse time counter value
CSR_FPM_CTRL_7_POF_RX_STATUS0x30 32 Status of POF receiver
PARITY_BIT_ERROR_COUNT15:0r0x0000Counts number of parity errors
SKIPPED_POSITION_ERROR_COUNT31:16r0x0000Counts position skipped type errors
CSR_FPM_CTRL_7_POF_RX_CONTROL_W0x34 10 POF receiver error control
ERROR_RATE_THRES7:0w0x0ADefines RX error rate threshold
RX_WATCHDOG_EN8w0x10 => Disable RX watchdog, 1 => Enable RX Watchdog
RX_WATCHDOG_CLR9w0x00 => RX watchdog counter running, 1 => Clear RX watchdog counter
CSR_FPM_CTRL_7_POF_RX_CONTROL_R0x38 2 POF receiver error status
RX_WATCHDOG0r0x00 => RX watchdog not triggered, 1 => RX watchdog triggered
RX_ERROR_FLAG1r0x00 => Error rate below threshold, 1 => Error rate above threshold
CSR_FPM_CTRL_7_FPM_INTERRUPT0x3c 12 Interrupt control
IRQ_EN0w0x00 => Disable IRQ, 1 => Enable IRQ
RESERVED13:1rsv0Reserved
IRQ_CLR4w0x00 => Don't clear pending IRQ, 1 => Clear pending IRQ
RESERVED27:5rsv0Reserved
IRQ_MASK8w0x00 => IRQ not masked, 1 => IRQ masked
RESERVED311:9rsv0Reserved
CSR_FPM_CTRL_7_IRQ_STATUS0x40 1r 0x00 => IRQ not active, 1 => IRQ active
CSR_FPM_CTRL_7_PD_CNT0x44 16r 0x0PD count, at the Pulse-Generator input
CSR_FPM_CTRL_7_DROP_WATCH_CONFIG0x48 32 Drop-Watch configuration
DW_SRC3:0w0x0Select the source channel for the drop-watch
RESERVED15:4rsv0Reserved
DW_PULSE_WIDTH31:16w0x000ADrop-Watch pulse width, expressed as clock cycles @100MHz
CSR_FPM_CTRL_7_SEB_EPD_LED_STATUS0x4c 12 SEB-EPD LED status
LED_PD_G0r0x0LED PD Green
LED_PD_Y1r0x0LED PD Yellow
LED_PD_R2r0x0LED PD Red
LED_ENC_P1_G3r0x0LED Encoder-Phase-1 Green
LED_ENC_P1_Y4r0x0LED Encoder-Phase-1 Yellow
LED_ENC_P1_R5r0x0LED Encoder-Phase-1 Red
LED_ENC_P2_G6r0x0LED Encoder-Phase-2 Green
LED_ENC_P2_Y7r0x0LED Encoder-Phase-2 Yellow
LED_ENC_P2_R8r0x0LED Encoder-Phase-2 Red
LED_POF_IN_G9r0x0LED POF-In Green
LED_POF_IN_Y10r0x0LED POF-In Yellow
LED_POF_IN_R11r0x0LED POF-In Red
- -

Register/field type key:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeDescription
cConstant, with value defined by "reset" attribute -
rsvSame as constant, except no reset value and always 0. Can be mixed with write types.
wWrite register (and read—no write only type). Register defined in register block and reset to "reset" attribute value. Split into fields (if applicable) for signalling and output, where attribute associated with fields, not register.
wpWrite with pulse. Register is not declared in block, but write bus split into fields as output port signals, and a pulse generated on write to register address. Register reads back 0. The "reset" attribute is for documentation only, as set externally.
w0Same as w, but auto-clears to 0 (and thus always reads as 0). At output port, signal will go high for one cycle when bit is written with a 1 (no effect if written to a 0). No "reset" attribute, as must always be 0.
rRead only value. Input ports generated for each field (where applicable), and concatenated on returned read data bus.
rpSimilar to r, but a pulse generated on a read access to the register address to allow peripheral logic to update value. The "reset" attribute is for documentation only, as set externally.
rwpSimilar to wp, but also generates a (separate) pulse on a read access to the register
  
SubypeDescription
unsignedRegister/field is specified as an unsigned value. -
signedRegister/field is specified as a signed value. -
<blank>Register/field sign status is not explicitly defined and defaults to unsigned. -
-

 


-

Copyright © 2021 Global Inkjet Systems. Generated by gen_htm.py —2021-1-6 13:41

- - - diff --git a/generic_ip/generic_sequencer/17/build/generic_sequencer_17.qip b/generic_ip/generic_sequencer/17/build/generic_sequencer_17.qip new file mode 100644 index 0000000..424975e --- /dev/null +++ b/generic_ip/generic_sequencer/17/build/generic_sequencer_17.qip @@ -0,0 +1,16 @@ +set_global_assignment -name IP_TOOL_NAME "generic_sequencer_16" +set_global_assignment -name IP_TOOL_VERSION "18.0" +set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone V}" + +set COMMON_PATH ../../../common/0/src +set SEQUENCER_PATH ../../../generic_sequencer/17/src + +# common +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$COMMON_PATH/common_pkg.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$COMMON_PATH/alt_rw_dp_ram.vhd"] + +# Generic Sequencer +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SEQUENCER_PATH/generic_sequencer_17_cmd_pkg.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SEQUENCER_PATH/generic_sequencer_17_pkg_auto.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SEQUENCER_PATH/generic_sequencer_17_csr_regs_auto.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SEQUENCER_PATH/generic_sequencer_17.vhd"] diff --git a/generic_ip/generic_sequencer/17/build/generic_sequencer_17.tcl b/generic_ip/generic_sequencer/17/build/generic_sequencer_17.tcl new file mode 100644 index 0000000..0902227 --- /dev/null +++ b/generic_ip/generic_sequencer/17/build/generic_sequencer_17.tcl @@ -0,0 +1,71 @@ +# TCL File Generated by Component Editor 16.0 +# Wed Oct 25 15:26:07 BST 2017 +# DO NOT MODIFY + + +# +# generic_sequencer_17 "generic_sequencer_17" v1.0 +# GMG 2017.10.25.15:26:07 +# Generic Sequencer +# + +# +# request TCL package from ACDS 16.0 +# +package require -exact qsys 18.1 + + +# +# module generic_sequencer_17 +# +set_module_property DESCRIPTION "Generic Sequencer" +set_module_property NAME generic_sequencer_17 +set_module_property VERSION 1.0 +set_module_property INTERNAL false +set_module_property OPAQUE_ADDRESS_MAP true +set_module_property GROUP "GIS Components" +set_module_property AUTHOR GMG +set_module_property DISPLAY_NAME generic_sequencer_17 +set_module_property INSTANTIATE_IN_SYSTEM_MODULE true +set_module_property EDITABLE true +set_module_property REPORT_TO_TALKBACK false +set_module_property ALLOW_GREYBOX_GENERATION false +set_module_property REPORT_HIERARCHY false + + +# +# file sets +# +add_fileset QUARTUS_SYNTH QUARTUS_SYNTH "" "" +set_fileset_property QUARTUS_SYNTH TOP_LEVEL generic_sequencer_17 +set_fileset_property QUARTUS_SYNTH ENABLE_RELATIVE_INCLUDE_PATHS false +set_fileset_property QUARTUS_SYNTH ENABLE_FILE_OVERWRITE_MODE false +add_fileset_file common_pkg.vhd VHDL PATH ../../../common/0/src/common_pkg.vhd +add_fileset_file alt_rw_dp_ram.vhd VHDL PATH ../../../common/0/src/altera/alt_rw_dp_ram.vhd +add_fileset_file generic_sequencer_17_cmd_pkg.vhd VHDL PATH ../../../generic_sequencer/17/src/generic_sequencer_17_cmd_pkg.vhd +add_fileset_file generic_sequencer_17_pkg_auto.vhd VHDL PATH ../../../generic_sequencer/17/src/generic_sequencer_17_pkg_auto.vhd +add_fileset_file generic_sequencer_17_csr_regs_auto.vhd VHDL PATH ../../../generic_sequencer/17/src/generic_sequencer_17_csr_regs_auto.vhd +add_fileset_file generic_sequencer_17.vhd VHDL PATH ../../../generic_sequencer/17/src/generic_sequencer_17.vhd + +# +# parameters +# + + +# +# display items +# + + +# +# connection point clock +# +add_interface clock clock end +set_interface_property clock clockRate 0 +set_interface_property clock ENABLED true +set_interface_property clock EXPORT_OF "" +set_interface_property clock PORT_NAME_MAP "" +set_interface_property clock CMSIS_SVD_VARIABLES "" +set_interface_property clock SVD_ADDRESS_GROUP "" + +add_interface_port clock clk clk Input 1 \ No newline at end of file diff --git a/generic_ip/generic_sequencer/17/doc/generic_sequencer_17.json b/generic_ip/generic_sequencer/17/doc/generic_sequencer_17.json new file mode 100644 index 0000000..b99c656 --- /dev/null +++ b/generic_ip/generic_sequencer/17/doc/generic_sequencer_17.json @@ -0,0 +1,316 @@ +[{ + "ip_name" : "generic_sequencer_17", + "bus" : "csr", + "addr_width" : "4", + "description" : "Generic Sequencer core", + "notes" : "This is the generic sequencer processing element core used in various products for a variety of purposes, such as pulse generation control, waveform generation for analogue heads and print data control. More details of this component can be found at https://confluence.gisapps.co.uk/display/EL/Generic+Sequencer.", + "registers" : { + "ip_id" : { + "address" : "0", + "width" : "32", + "description" : "Unique ID for this IP block", + "fields": { + "ip_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x01", + "description" : "IP identifier number" + }, + "mfr_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0xFF", + "description" : "Manufacturer number" + + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "16", + "description" : "Reserved bits" + } + } + }, + "ip_ver" : { + "address" : "1", + "width" : "32", + "description" : "Bits[7:0] = Minor version number, Bits[15:8] = Major version number, etc.", + "fields": { + "minor_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x00", + "description" : "Minor number" + }, + "major_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x11", + "description" : "Major number" + + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "16", + "description" : "Reserved bits" + } + } + }, + "config" : { + "address" : "2", + "width" : "30", + "description" : "Configuration values for sequencer", + "fields": { + "seq_depth" : { + "type" : "r", + "bit_len" : "6", + "reset" : "0", + "description" : "LOG2 (+1?) of SEQ_DEPTH generic" + }, + "pos_width" : { + "type" : "r", + "bit_len" : "6", + "reset" : "0", + "description" : "POS_WIDTH generic value" + }, + "bus_width" : { + "type" : "r", + "bit_len" : "6", + "reset" : "0", + "description" : "BUS_WIDTH generic value" + }, + "vector_width" : { + "type" : "r", + "bit_len" : "6", + "reset" : "0", + "description" : "VECTOR_WIDTH generic value" + }, + "trigger_width" : { + "type" : "r", + "bit_len" : "6", + "reset" : "0", + "description" : "TRIGGER_WIDTH generic value" + } + } + }, + "ctrl_w" : { + "address" : "3", + "width" : "11", + "description" : "Control register write fields", + "fields": { + "seq_enable" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0", + "description" : "Master enable for the sequencer" + }, + "reserved_0" : { + "type" : "rsv", + "bit_len" : "2", + "description" : "Reserved bits" + }, + "debug_mode" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0", + "description" : "Enter debug mode (only has effect if not busy)" + }, + "rst_vector_out" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0", + "description" : "Reset vector_out when start_req is asserted" + }, + "reserved_1" : { + "type" : "rsv", + "bit_len" : "3", + "description" : "Reserved bits" + }, + "clr_seq_queue" : { + "type" : "w0", + "bit_len" : "1", + "reset" : "0", + "description" : "Clear the sequencer queue" + }, + "clr_seq_queue_exe": { + "type" : "w0", + "bit_len" : "1", + "reset" : "0", + "description" : "Clear the executed sequences counter" + }, + "reserved_2" : { + "type" : "rsv", + "bit_len" : "1", + "description" : "Reserved bits" + } + } + }, + "ctrl_r" : { + "address" : "4", + "width" : "11", + "description" : "Control register read fields", + "fields": { + "reserved_0" : { + "type" : "rsv", + "bit_len" : "2", + "description" : "Reserved bits" + }, + "busy" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "Busy status (writing has no effect---in this register for backwards compatibility)" + }, + "reserved_1" : { + "type" : "rsv", + "bit_len" : "7", + "description" : "Reserved bits" + }, + "seq_queue_empty" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "asserted when End-and-Queue is executed with queue_left = 0. Cleared upon reading" + } + } + }, + "pc" : { + "address" : "5", + "width" : "32", + "description" : "RAM addresses of sequencer", + "fields": { + "ram_rd_addr" : { + "type" : "r", + "bit_len" : "9", + "reset" : "0", + "description" : "Current RAM read address" + }, + "reserved_0" : { + "type" : "rsv", + "bit_len" : "7", + "description" : "Reserved bits" + }, + "return_addr" : { + "type" : "r", + "bit_len" : "9", + "reset" : "0", + "description" : "Current return address" + }, + "reserved_1" : { + "type" : "rsv", + "bit_len" : "7", + "description" : "Reserved bits" + } + } + }, + "trigger" : { + "address" : "6", + "type" : "r", + "width" : "12", + "reset" : "0", + "description" : "Trigger input vector value" + }, + "vector" : { + "address" : "7", + "type" : "wp", + "width" : "24", + "reset" : "0", + "description" : "Vector output override from CPU" + }, + "r1" : { + "address" : "8", + "type" : "wp", + "width" : "12", + "reset" : "0", + "description" : "R1 register access. Writes only effective when idle." + }, + "step" : { + "address" : "9", + "type" : "w0", + "width" : "1", + "reset" : "0", + "description" : "Step request from CPU" + }, + "aux_config" : { + "address" : "10", + "width" : "6", + "description" : "Aux Configuration values for sequencer", + "fields": { + "ADD_VEC_PIPE" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "Add 1 level of pipeline on vector_out" + }, + "VECT_RAMP_EN" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "Enable support for VEC_RAMP_UP/DN instructions" + }, + "BUS_BURST_EN" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "Enable support for BUS_BURST instructions" + }, + "POS_BUS_EN" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "Enable support for POS input bus" + }, + "ALU_EN" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "Enable support for ALU instruction" + }, + "QUEUE_EN" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "Enable support for End-and-Queue instruction" + } + } + }, + "pos_store" : { + "address" : "11", + "type" : "r", + "width" : "24", + "reset" : "0", + "subtype" : "signed", + "description" : "value of pos_store" + }, + "seq_queue_w" : { + "address" : "12", + "width" : "8", + "type" : "wp", + "reset" : "0", + "description" : "Sequence Execution Queue write" + }, + "seq_queue_r" : { + "address" : "13", + "width" : "32", + "description" : "Sequence Execution Queue read bits", + "fields": { + "reserved_0" : { + "type" : "rsv", + "bit_len" : "8", + "description" : "Reserved bits" + }, + "queue_left" : { + "type" : "r", + "bit_len" : "8", + "reset" : "0", + "description" : "Number of sequences currently in the queue" + }, + "queue_exec" : { + "type" : "r", + "bit_len" : "16", + "reset" : "0", + "description" : "Number of sequences executed" + } + } + } + } +}] \ No newline at end of file diff --git a/generic_ip/generic_sequencer/17/sim/run_sim.py b/generic_ip/generic_sequencer/17/sim/run_sim.py new file mode 100644 index 0000000..20abf03 --- /dev/null +++ b/generic_ip/generic_sequencer/17/sim/run_sim.py @@ -0,0 +1,120 @@ +##///////////////////////////////////////////////////////////////////////////// +## Title : Run Simulation script +##///////////////////////////////////////////////////////////////////////////// +## File : run_sim.py +## Author : Gianmarco Girau +## Company : GIS +## Target : Re-usable across multiple projects with minor customizations +## Dependency : none +##///////////////////////////////////////////////////////////////////////////// +## Description: Script for running in Jenkins custom ModelSim testbenches +##///////////////////////////////////////////////////////////////////////////// +## Last update: 2017-09-26 +##///////////////////////////////////////////////////////////////////////////// +## Revisions : +## Date Version Author Description +## 2017-09-26 01.00.0a gmg Created +##///////////////////////////////////////////////////////////////////////////// + +import os, sys, subprocess + +##///////////////////////////////////////////////////////////////////////////// +## Check Simulation Results +##///////////////////////////////////////////////////////////////////////////// + +def check_result(logfile): + searchfile = open(logfile, "r") + ok = 0 + for line in searchfile: + if "SUCCESS" in line: + print("/////////////////////////////////////////////////////////////////////////////") + print('TEST SUCCESSFUL') + print("/////////////////////////////////////////////////////////////////////////////") + ok = 1 + break + if "FAILURE" in line: + print("/////////////////////////////////////////////////////////////////////////////") + print('TEST FAILED') + print("/////////////////////////////////////////////////////////////////////////////") + break + + searchfile.close() + if ok == 0: + sys.exit(1) + +##///////////////////////////////////////////////////////////////////////////// +## Run Modelsim Simulation script +##///////////////////////////////////////////////////////////////////////////// + +def run_msim_script(sim_job, cmd_line_mode = 1): + + # create a copy of the do file, edit the copy as necessary + orig_do_file = "./{0}.do".format(sim_job) + + print("/////////////////////////////////////////////////////////////////////////////") + print("Running {0} ...".format(orig_do_file)) + print("/////////////////////////////////////////////////////////////////////////////") + + + + + if os.path.isfile(orig_do_file) == False: + print("ERROR: Cannot find do file " + orig_do_file) + sys.exit(1) + + do_file = "./{0}_tmp.do".format(sim_job) + orig_do_file_cnt = open(orig_do_file , "r") + do_file_cnt = open(do_file, "w") + + # Remove command ".main clear" in cmd line mode + for line in orig_do_file_cnt: + if cmd_line_mode == 1 and line.strip() == ".main clear": + do_file_cnt.write("#.main clear\n") + elif cmd_line_mode == 1 and line.find("do wave_") != -1: + do_file_cnt.write("#" + line) + else: + do_file_cnt.write(line) + + # manually add commands to exit from modelsim at the end of simulation + if cmd_line_mode == 1: + do_file_cnt.write("\n") + do_file_cnt.write("quit -sim; quit -f\n") + + orig_do_file_cnt.close() + do_file_cnt.close() + + log_file = "./{0}.log".format(sim_job) + + vsim_cmd = os.environ['QUARTUS_ROOTDIR']+"\\..\\modelsim_ase\\win32aloem\\vsim" + + if cmd_line_mode == 1: + cmd_opt = "-c" + else: + cmd_opt = "" + sub_call = "{0} {1} -l {2} -do {3}".format(vsim_cmd, cmd_opt, log_file, do_file) + subprocess.call(sub_call) + + ''' + if cmd_line_mode == 1: + # Run in command line mode + subprocess.call([vsim_cmd, "-c", "-l", log_file, "-do", do_file]) + else: + # Run in GUI mode + subprocess.call([os.environ['QUARTUS_ROOTDIR']+"\\..\\modelsim_ase\\win32aloem\\vsim", + "-do", do_file, "-l", log_file]) + ''' + + # remove the local copy of the do file + os.remove(do_file) + + check_result(log_file) + +##///////////////////////////////////////////////////////////////////////////// +## Execute Simulation Scripts +##///////////////////////////////////////////////////////////////////////////// + +if __name__ == "__main__": + + print("Running Generic-Sequencer testbench ...") + run_msim_script("sim_gen_seq", cmd_line_mode=1) + diff --git a/generic_ip/generic_sequencer/17/sim/sim_gen_seq.do b/generic_ip/generic_sequencer/17/sim/sim_gen_seq.do new file mode 100644 index 0000000..35ec34e --- /dev/null +++ b/generic_ip/generic_sequencer/17/sim/sim_gen_seq.do @@ -0,0 +1,63 @@ +# Simulation macro for print_ctrl + +.main clear + +# Cleanup libraries +foreach lib [list work OSVVM] { + file delete -force -- $lib + vlib $lib +} + +set GEN_IP_PATH ../../../ +set COMMON_PATH $GEN_IP_PATH/common/0 +set OSVVM_PATH $COMMON_PATH/src/test/OSVVM + +set WORKLIB work + +vlib ./work +vmap work ./work + +# Compile the UUT +vcom -2008 -work $WORKLIB $COMMON_PATH/src/common_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/src/altera/alt_rw_dp_ram.vhd +#vcom -2008 -work $WORKLIB ../src/dpram_sclk_16.vhd +#vcom -2008 -work $WORKLIB ../src/altera/generic_seq_ram_16.vhd +vcom -2008 -work $WORKLIB ../src/generic_sequencer_17_cmd_pkg.vhd +vcom -2008 -work $WORKLIB ../src/generic_sequencer_17_pkg_auto.vhd +vcom -2008 -work $WORKLIB ../src/generic_sequencer_17_csr_regs_auto.vhd +vcom -2008 -work $WORKLIB ../src/generic_sequencer_17.vhd + +# Compile the constrained random related packages +vlib OSVVM +vcom -2008 -work OSVVM \ + $OSVVM_PATH/RandomBasePkg.vhd \ + $OSVVM_PATH/SortListPkg_int.vhd \ + $OSVVM_PATH/RandomPkg.vhd \ + $OSVVM_PATH/NamePkg.vhd \ + $OSVVM_PATH/MessagePkg.vhd \ + $OSVVM_PATH/CoveragePkg.vhd + +# Compile support files +vcom -2008 -work $WORKLIB $COMMON_PATH/src/test/common_test_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/src/test/log_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/src/test/avalon_verify_pkg.vhd + +# Compile the testbench +vcom -2008 -work $WORKLIB ./../src/test/generic_sequencer_17_tb.vhd + +vsim -t ps work.generic_sequencer_17_tb + + +#add wave /generic_sequencer_17_tb/* +#add wave /generic_sequencer_17_tb/iUUT/* + +# remove warnings from standard numeric/arithmetic packages (speed-up simulation) +set StdArithNoWarnings 1 +set NumericStdNoWarnings 1 + +do wave_gen_seq.do + +when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} +run -all + +#run 100 us; \ No newline at end of file diff --git a/generic_ip/generic_sequencer/17/sim/wave_gen_seq.do b/generic_ip/generic_sequencer/17/sim/wave_gen_seq.do new file mode 100644 index 0000000..9221d9c --- /dev/null +++ b/generic_ip/generic_sequencer/17/sim/wave_gen_seq.do @@ -0,0 +1,160 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate /generic_sequencer_17_tb/clk +add wave -noupdate /generic_sequencer_17_tb/reset_n +add wave -noupdate /generic_sequencer_17_tb/avs_csr_address +add wave -noupdate /generic_sequencer_17_tb/avs_csr_write +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/avs_csr_writedata +add wave -noupdate /generic_sequencer_17_tb/avs_csr_read +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/avs_csr_readdata +add wave -noupdate /generic_sequencer_17_tb/avs_seq_address +add wave -noupdate /generic_sequencer_17_tb/avs_seq_write +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/avs_seq_writedata +add wave -noupdate /generic_sequencer_17_tb/avs_seq_read +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/avs_seq_readdata +add wave -noupdate /generic_sequencer_17_tb/start_req +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/start_addr +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/trigger_in +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/pos_in +add wave -noupdate /generic_sequencer_17_tb/busy +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/vector_out +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/bus_data +add wave -noupdate /generic_sequencer_17_tb/bus_valid +add wave -noupdate /generic_sequencer_17_tb/bus_ack +add wave -noupdate /generic_sequencer_17_tb/setup +add wave -noupdate /generic_sequencer_17_tb/running +add wave -noupdate /generic_sequencer_17_tb/passed +add wave -noupdate /generic_sequencer_17_tb/failed +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/csr_mm_s_rec +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/csr_mm_m_rec +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/seq_mm_s_rec +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/seq_mm_m_rec +add wave -noupdate -divider UUT +add wave -noupdate /generic_sequencer_17_tb/iUUT/clk +add wave -noupdate /generic_sequencer_17_tb/iUUT/reset_n +add wave -noupdate -radix unsigned /generic_sequencer_17_tb/iUUT/avs_csr_address +add wave -noupdate /generic_sequencer_17_tb/iUUT/avs_csr_write +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/avs_csr_writedata +add wave -noupdate /generic_sequencer_17_tb/iUUT/avs_csr_read +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/avs_csr_readdata +add wave -noupdate -radix decimal /generic_sequencer_17_tb/iUUT/avs_seq_address +add wave -noupdate /generic_sequencer_17_tb/iUUT/avs_seq_write +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/avs_seq_writedata +add wave -noupdate /generic_sequencer_17_tb/iUUT/avs_seq_read +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/avs_seq_readdata +add wave -noupdate /generic_sequencer_17_tb/iUUT/start_req +add wave -noupdate -radix hexadecimal -childformat {{/generic_sequencer_17_tb/iUUT/start_addr(8) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/start_addr(7) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/start_addr(6) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/start_addr(5) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/start_addr(4) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/start_addr(3) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/start_addr(2) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/start_addr(1) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/start_addr(0) -radix hexadecimal}} -subitemconfig {/generic_sequencer_17_tb/iUUT/start_addr(8) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/start_addr(7) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/start_addr(6) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/start_addr(5) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/start_addr(4) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/start_addr(3) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/start_addr(2) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/start_addr(1) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/start_addr(0) {-height 15 -radix hexadecimal}} /generic_sequencer_17_tb/iUUT/start_addr +add wave -noupdate -radix hexadecimal -childformat {{/generic_sequencer_17_tb/iUUT/trigger_in(11) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(10) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(9) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(8) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(7) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(6) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(5) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(4) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(3) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(2) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(1) -radix hexadecimal} {/generic_sequencer_17_tb/iUUT/trigger_in(0) -radix hexadecimal}} -subitemconfig {/generic_sequencer_17_tb/iUUT/trigger_in(11) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(10) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(9) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(8) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(7) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(6) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(5) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(4) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(3) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(2) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(1) {-height 15 -radix hexadecimal} /generic_sequencer_17_tb/iUUT/trigger_in(0) {-height 15 -radix hexadecimal}} /generic_sequencer_17_tb/iUUT/trigger_in +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/pos_in +add wave -noupdate /generic_sequencer_17_tb/iUUT/busy +add wave -noupdate /generic_sequencer_17_tb/iUUT/opcode +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/vector_out +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/bus_data +add wave -noupdate /generic_sequencer_17_tb/iUUT/bus_valid +add wave -noupdate /generic_sequencer_17_tb/iUUT/bus_ack +add wave -noupdate /generic_sequencer_17_tb/iUUT/seq_enable +add wave -noupdate /generic_sequencer_17_tb/iUUT/debug_mode +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/return_addr +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/ram_rd_addr +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/ram_rd_data +add wave -noupdate /generic_sequencer_17_tb/iUUT/fsm +add wave -noupdate /generic_sequencer_17_tb/iUUT/fsm_nxt +add wave -noupdate /generic_sequencer_17_tb/iUUT/fetch_enable +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/operand_1 +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/operand_2 +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/operand_comp +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/subcode +add wave -noupdate /generic_sequencer_17_tb/iUUT/ramp_up +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/ramp_curr +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/ramp_next +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/ramp_final +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/ramp_diff +add wave -noupdate /generic_sequencer_17_tb/iUUT/ramp_diff_top +add wave -noupdate /generic_sequencer_17_tb/iUUT/ramp_to_val +add wave -noupdate /generic_sequencer_17_tb/iUUT/ramp_done +add wave -noupdate /generic_sequencer_17_tb/iUUT/ramp_to_val_last +add wave -noupdate /generic_sequencer_17_tb/iUUT/inc_op_cnt +add wave -noupdate /generic_sequencer_17_tb/iUUT/trig_int +add wave -noupdate /generic_sequencer_17_tb/iUUT/alu_upd +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/r1 +add wave -noupdate /generic_sequencer_17_tb/iUUT/inc_ram_addr +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/jump_addr_ext +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/jump_addr +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/pc_value +add wave -noupdate /generic_sequencer_17_tb/iUUT/ld_jmp_addr +add wave -noupdate /generic_sequencer_17_tb/iUUT/jump_abs +add wave -noupdate /generic_sequencer_17_tb/iUUT/jump_rel +add wave -noupdate /generic_sequencer_17_tb/iUUT/clr_seq_queue +add wave -noupdate /generic_sequencer_17_tb/iUUT/clr_seq_queue_i +add wave -noupdate /generic_sequencer_17_tb/iUUT/clr_seq_queue_exe +add wave -noupdate /generic_sequencer_17_tb/iUUT/queue_add_flag +add wave -noupdate /generic_sequencer_17_tb/iUUT/queue_add_flag_d +add wave -noupdate /generic_sequencer_17_tb/iUUT/queue_add_flag_i +add wave -noupdate /generic_sequencer_17_tb/iUUT/queue_inc +add wave -noupdate /generic_sequencer_17_tb/iUUT/queue_dec +add wave -noupdate /generic_sequencer_17_tb/iUUT/seq_completed +add wave -noupdate /generic_sequencer_17_tb/iUUT/seq_queue_empty +add wave -noupdate /generic_sequencer_17_tb/iUUT/set_queue_empty +add wave -noupdate -radix decimal /generic_sequencer_17_tb/iUUT/queue_add +add wave -noupdate -radix decimal /generic_sequencer_17_tb/iUUT/queue_add_i +add wave -noupdate -radix unsigned /generic_sequencer_17_tb/iUUT/queue_left +add wave -noupdate -radix unsigned /generic_sequencer_17_tb/iUUT/queue_exec +add wave -noupdate /generic_sequencer_17_tb/iUUT/jump_r1 +add wave -noupdate /generic_sequencer_17_tb/iUUT/loop_active +add wave -noupdate /generic_sequencer_17_tb/iUUT/loop_upd +add wave -noupdate /generic_sequencer_17_tb/iUUT/loop_done +add wave -noupdate -radix unsigned /generic_sequencer_17_tb/iUUT/loop_cnt +add wave -noupdate /generic_sequencer_17_tb/iUUT/ld_trig_mask +add wave -noupdate /generic_sequencer_17_tb/iUUT/ld_trig_sel +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/trig_mask +add wave -noupdate /generic_sequencer_17_tb/iUUT/trig_sel +add wave -noupdate /generic_sequencer_17_tb/iUUT/trig_int +add wave -noupdate /generic_sequencer_17_tb/iUUT/ld_vec +add wave -noupdate /generic_sequencer_17_tb/iUUT/clr_vec_i +add wave -noupdate /generic_sequencer_17_tb/iUUT/clr_vec +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/vector_out_i +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/vector_out +add wave -noupdate /generic_sequencer_17_tb/iUUT/ramp_up +add wave -noupdate /generic_sequencer_17_tb/iUUT/fetch_op +add wave -noupdate /generic_sequencer_17_tb/iUUT/clr_vec_ii +add wave -noupdate /generic_sequencer_17_tb/iUUT/op_cnt +add wave -noupdate /generic_sequencer_17_tb/iUUT/op_cnt_done +add wave -noupdate /generic_sequencer_17_tb/iUUT/inc_op_cnt +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/bus_data +add wave -noupdate /generic_sequencer_17_tb/iUUT/bus_valid +add wave -noupdate /generic_sequencer_17_tb/iUUT/bus_ack +add wave -noupdate /generic_sequencer_17_tb/iUUT/bus_valid_i +add wave -noupdate /generic_sequencer_17_tb/iUUT/bus_pause +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/pos_store +add wave -noupdate /generic_sequencer_17_tb/iUUT/loop_active +add wave -noupdate /generic_sequencer_17_tb/iUUT/vector_val_cpu +add wave -noupdate -radix hexadecimal /generic_sequencer_17_tb/iUUT/vector_cpu +add wave -noupdate /generic_sequencer_17_tb/iUUT/step_req +add wave -noupdate /generic_sequencer_17_tb/iUUT/rst_vector_out +add wave -noupdate /generic_sequencer_17_tb/iUUT/pos_target +add wave -noupdate /generic_sequencer_17_tb/iUUT/ld_ret_addr +add wave -noupdate /generic_sequencer_17_tb/iUUT/save_ret_addr +add wave -noupdate /generic_sequencer_17_tb/iUUT/r1_data +add wave -noupdate /generic_sequencer_17_tb/iUUT/r1_data_valid +add wave -noupdate /generic_sequencer_17_tb/iUUT/decode +add wave -noupdate /generic_sequencer_17_tb/iUUT/busy_i +add wave -noupdate /generic_sequencer_17_tb/iUUT/ld_start_addr +add wave -noupdate /generic_sequencer_17_tb/iUUT/ld_pos +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {24927383 ps} 0} +quietly wave cursor active 1 +configure wave -namecolwidth 283 +configure wave -valuecolwidth 194 +configure wave -justifyvalue left +configure wave -signalnamewidth 0 +configure wave -snapdistance 10 +configure wave -datasetprefix 0 +configure wave -rowmargin 4 +configure wave -childrowmargin 2 +configure wave -gridoffset 0 +configure wave -gridperiod 1 +configure wave -griddelta 40 +configure wave -timeline 0 +configure wave -timelineunits ps +update +WaveRestoreZoom {23944887 ps} {27786423 ps} diff --git a/generic_ip/generic_sequencer/17/src/altera/generic_seq_ram_16.vhd b/generic_ip/generic_sequencer/17/src/altera/generic_seq_ram_16.vhd new file mode 100644 index 0000000..e92a03a --- /dev/null +++ b/generic_ip/generic_sequencer/17/src/altera/generic_seq_ram_16.vhd @@ -0,0 +1,229 @@ +-- megafunction wizard: %RAM: 2-PORT% +-- GENERATION: STANDARD +-- VERSION: WM1.0 +-- MODULE: altsyncram + +-- ============================================================ +-- File Name: generic_seq_ram.vhd +-- Megafunction Name(s): +-- altsyncram +-- +-- Simulation Library Files(s): +-- altera_mf +-- ============================================================ +-- ************************************************************ +-- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE! +-- +-- 14.1.1 Build 190 01/19/2015 SJ Web Edition +-- ************************************************************ + + +--Copyright (C) 1991-2015 Altera Corporation. All rights reserved. +--Your use of Altera Corporation's design tools, logic functions +--and other software and tools, and its AMPP partner logic +--functions, and any output files from any of the foregoing +--(including device programming or simulation files), and any +--associated documentation or information are expressly subject +--to the terms and conditions of the Altera Program License +--Subscription Agreement, the Altera Quartus II License Agreement, +--the Altera MegaCore Function License Agreement, or other +--applicable license agreement, including, without limitation, +--that your use is for the sole purpose of programming logic +--devices manufactured by Altera and sold by Altera or its +--authorized distributors. Please refer to the applicable +--agreement for further details. + + +LIBRARY ieee; +USE ieee.std_logic_1164.all; + +LIBRARY altera_mf; +USE altera_mf.altera_mf_components.all; +use work.common_pkg.all; + +ENTITY generic_seq_ram_16 IS + generic ( + SEQ_DEPTH : natural range 1 to 1024 + ); + PORT + ( + address_a : IN STD_LOGIC_VECTOR (log2(SEQ_DEPTH)-1 DOWNTO 0); + address_b : IN STD_LOGIC_VECTOR (log2(SEQ_DEPTH)-1 DOWNTO 0); + clock : IN STD_LOGIC := '1'; + data_a : IN STD_LOGIC_VECTOR (31 DOWNTO 0); + data_b : IN STD_LOGIC_VECTOR (31 DOWNTO 0); + wren_a : IN STD_LOGIC := '0'; + wren_b : IN STD_LOGIC := '0'; + q_a : OUT STD_LOGIC_VECTOR (31 DOWNTO 0); + q_b : OUT STD_LOGIC_VECTOR (31 DOWNTO 0) + ); +END generic_seq_ram_16; + + +ARCHITECTURE SYN OF generic_seq_ram_16 IS + + SIGNAL sub_wire0 : STD_LOGIC_VECTOR (31 DOWNTO 0); + SIGNAL sub_wire1 : STD_LOGIC_VECTOR (31 DOWNTO 0); + +BEGIN + q_a <= sub_wire0(31 DOWNTO 0); + q_b <= sub_wire1(31 DOWNTO 0); + + altsyncram_component : altsyncram + GENERIC MAP ( + address_reg_b => "CLOCK0", + clock_enable_input_a => "BYPASS", + clock_enable_input_b => "BYPASS", + clock_enable_output_a => "BYPASS", + clock_enable_output_b => "BYPASS", + indata_reg_b => "CLOCK0", + intended_device_family => "Cyclone V", + lpm_type => "altsyncram", + numwords_a => SEQ_DEPTH, + numwords_b => SEQ_DEPTH, + operation_mode => "BIDIR_DUAL_PORT", + outdata_aclr_a => "NONE", + outdata_aclr_b => "NONE", + outdata_reg_a => "UNREGISTERED", + outdata_reg_b => "UNREGISTERED", + power_up_uninitialized => "FALSE", + read_during_write_mode_mixed_ports => "OLD_DATA", + read_during_write_mode_port_a => "NEW_DATA_NO_NBE_READ", + read_during_write_mode_port_b => "NEW_DATA_NO_NBE_READ", + widthad_a => log2(SEQ_DEPTH), + widthad_b => log2(SEQ_DEPTH), + width_a => 32, + width_b => 32, + width_byteena_a => 1, + width_byteena_b => 1, + wrcontrol_wraddress_reg_b => "CLOCK0" + ) + PORT MAP ( + address_a => address_a, + address_b => address_b, + clock0 => clock, + data_a => data_a, + data_b => data_b, + wren_a => wren_a, + wren_b => wren_b, + q_a => sub_wire0, + q_b => sub_wire1 + ); + + + +END SYN; + +-- ============================================================ +-- CNX file retrieval info +-- ============================================================ +-- Retrieval info: PRIVATE: ADDRESSSTALL_A NUMERIC "0" +-- Retrieval info: PRIVATE: ADDRESSSTALL_B NUMERIC "0" +-- Retrieval info: PRIVATE: BYTEENA_ACLR_A NUMERIC "0" +-- Retrieval info: PRIVATE: BYTEENA_ACLR_B NUMERIC "0" +-- Retrieval info: PRIVATE: BYTE_ENABLE_A NUMERIC "0" +-- Retrieval info: PRIVATE: BYTE_ENABLE_B NUMERIC "0" +-- Retrieval info: PRIVATE: BYTE_SIZE NUMERIC "8" +-- Retrieval info: PRIVATE: BlankMemory NUMERIC "1" +-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_A NUMERIC "0" +-- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_B NUMERIC "0" +-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_A NUMERIC "0" +-- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_B NUMERIC "0" +-- Retrieval info: PRIVATE: CLRdata NUMERIC "0" +-- Retrieval info: PRIVATE: CLRq NUMERIC "0" +-- Retrieval info: PRIVATE: CLRrdaddress NUMERIC "0" +-- Retrieval info: PRIVATE: CLRrren NUMERIC "0" +-- Retrieval info: PRIVATE: CLRwraddress NUMERIC "0" +-- Retrieval info: PRIVATE: CLRwren NUMERIC "0" +-- Retrieval info: PRIVATE: Clock NUMERIC "0" +-- Retrieval info: PRIVATE: Clock_A NUMERIC "0" +-- Retrieval info: PRIVATE: Clock_B NUMERIC "0" +-- Retrieval info: PRIVATE: IMPLEMENT_IN_LES NUMERIC "0" +-- Retrieval info: PRIVATE: INDATA_ACLR_B NUMERIC "0" +-- Retrieval info: PRIVATE: INDATA_REG_B NUMERIC "1" +-- Retrieval info: PRIVATE: INIT_FILE_LAYOUT STRING "PORT_A" +-- Retrieval info: PRIVATE: INIT_TO_SIM_X NUMERIC "0" +-- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone V" +-- Retrieval info: PRIVATE: JTAG_ENABLED NUMERIC "0" +-- Retrieval info: PRIVATE: JTAG_ID STRING "NONE" +-- Retrieval info: PRIVATE: MAXIMUM_DEPTH NUMERIC "0" +-- Retrieval info: PRIVATE: MEMSIZE NUMERIC "8192" +-- Retrieval info: PRIVATE: MEM_IN_BITS NUMERIC "0" +-- Retrieval info: PRIVATE: MIFfilename STRING "" +-- Retrieval info: PRIVATE: OPERATION_MODE NUMERIC "3" +-- Retrieval info: PRIVATE: OUTDATA_ACLR_B NUMERIC "0" +-- Retrieval info: PRIVATE: OUTDATA_REG_B NUMERIC "0" +-- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0" +-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_MIXED_PORTS NUMERIC "2" +-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_A NUMERIC "3" +-- Retrieval info: PRIVATE: READ_DURING_WRITE_MODE_PORT_B NUMERIC "3" +-- Retrieval info: PRIVATE: REGdata NUMERIC "1" +-- Retrieval info: PRIVATE: REGq NUMERIC "0" +-- Retrieval info: PRIVATE: REGrdaddress NUMERIC "0" +-- Retrieval info: PRIVATE: REGrren NUMERIC "0" +-- Retrieval info: PRIVATE: REGwraddress NUMERIC "1" +-- Retrieval info: PRIVATE: REGwren NUMERIC "1" +-- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0" +-- Retrieval info: PRIVATE: USE_DIFF_CLKEN NUMERIC "0" +-- Retrieval info: PRIVATE: UseDPRAM NUMERIC "1" +-- Retrieval info: PRIVATE: VarWidth NUMERIC "0" +-- Retrieval info: PRIVATE: WIDTH_READ_A NUMERIC "32" +-- Retrieval info: PRIVATE: WIDTH_READ_B NUMERIC "32" +-- Retrieval info: PRIVATE: WIDTH_WRITE_A NUMERIC "32" +-- Retrieval info: PRIVATE: WIDTH_WRITE_B NUMERIC "32" +-- Retrieval info: PRIVATE: WRADDR_ACLR_B NUMERIC "0" +-- Retrieval info: PRIVATE: WRADDR_REG_B NUMERIC "1" +-- Retrieval info: PRIVATE: WRCTRL_ACLR_B NUMERIC "0" +-- Retrieval info: PRIVATE: enable NUMERIC "0" +-- Retrieval info: PRIVATE: rden NUMERIC "0" +-- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all +-- Retrieval info: CONSTANT: ADDRESS_REG_B STRING "CLOCK0" +-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_A STRING "BYPASS" +-- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_B STRING "BYPASS" +-- Retrieval info: CONSTANT: CLOCK_ENABLE_OUTPUT_A STRING "BYPASS" +-- Retrieval info: CONSTANT: CLOCK_ENABLE_OUTPUT_B STRING "BYPASS" +-- Retrieval info: CONSTANT: INDATA_REG_B STRING "CLOCK0" +-- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone V" +-- Retrieval info: CONSTANT: LPM_TYPE STRING "altsyncram" +-- Retrieval info: CONSTANT: NUMWORDS_A NUMERIC "256" +-- Retrieval info: CONSTANT: NUMWORDS_B NUMERIC "256" +-- Retrieval info: CONSTANT: OPERATION_MODE STRING "BIDIR_DUAL_PORT" +-- Retrieval info: CONSTANT: OUTDATA_ACLR_A STRING "NONE" +-- Retrieval info: CONSTANT: OUTDATA_ACLR_B STRING "NONE" +-- Retrieval info: CONSTANT: OUTDATA_REG_A STRING "UNREGISTERED" +-- Retrieval info: CONSTANT: OUTDATA_REG_B STRING "UNREGISTERED" +-- Retrieval info: CONSTANT: POWER_UP_UNINITIALIZED STRING "FALSE" +-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_MIXED_PORTS STRING "DONT_CARE" +-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_PORT_A STRING "NEW_DATA_NO_NBE_READ" +-- Retrieval info: CONSTANT: READ_DURING_WRITE_MODE_PORT_B STRING "NEW_DATA_NO_NBE_READ" +-- Retrieval info: CONSTANT: WIDTHAD_A NUMERIC "8" +-- Retrieval info: CONSTANT: WIDTHAD_B NUMERIC "8" +-- Retrieval info: CONSTANT: WIDTH_A NUMERIC "32" +-- Retrieval info: CONSTANT: WIDTH_B NUMERIC "32" +-- Retrieval info: CONSTANT: WIDTH_BYTEENA_A NUMERIC "1" +-- Retrieval info: CONSTANT: WIDTH_BYTEENA_B NUMERIC "1" +-- Retrieval info: CONSTANT: WRCONTROL_WRADDRESS_REG_B STRING "CLOCK0" +-- Retrieval info: USED_PORT: address_a 0 0 8 0 INPUT NODEFVAL "address_a[7..0]" +-- Retrieval info: USED_PORT: address_b 0 0 8 0 INPUT NODEFVAL "address_b[7..0]" +-- Retrieval info: USED_PORT: clock 0 0 0 0 INPUT VCC "clock" +-- Retrieval info: USED_PORT: data_a 0 0 32 0 INPUT NODEFVAL "data_a[31..0]" +-- Retrieval info: USED_PORT: data_b 0 0 32 0 INPUT NODEFVAL "data_b[31..0]" +-- Retrieval info: USED_PORT: q_a 0 0 32 0 OUTPUT NODEFVAL "q_a[31..0]" +-- Retrieval info: USED_PORT: q_b 0 0 32 0 OUTPUT NODEFVAL "q_b[31..0]" +-- Retrieval info: USED_PORT: wren_a 0 0 0 0 INPUT GND "wren_a" +-- Retrieval info: USED_PORT: wren_b 0 0 0 0 INPUT GND "wren_b" +-- Retrieval info: CONNECT: @address_a 0 0 8 0 address_a 0 0 8 0 +-- Retrieval info: CONNECT: @address_b 0 0 8 0 address_b 0 0 8 0 +-- Retrieval info: CONNECT: @clock0 0 0 0 0 clock 0 0 0 0 +-- Retrieval info: CONNECT: @data_a 0 0 32 0 data_a 0 0 32 0 +-- Retrieval info: CONNECT: @data_b 0 0 32 0 data_b 0 0 32 0 +-- Retrieval info: CONNECT: @wren_a 0 0 0 0 wren_a 0 0 0 0 +-- Retrieval info: CONNECT: @wren_b 0 0 0 0 wren_b 0 0 0 0 +-- Retrieval info: CONNECT: q_a 0 0 32 0 @q_a 0 0 32 0 +-- Retrieval info: CONNECT: q_b 0 0 32 0 @q_b 0 0 32 0 +-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.vhd TRUE +-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.inc FALSE +-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.cmp TRUE +-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram.bsf FALSE +-- Retrieval info: GEN_FILE: TYPE_NORMAL generic_seq_ram_inst.vhd FALSE +-- Retrieval info: LIB_FILE: altera_mf diff --git a/generic_ip/generic_sequencer/17/src/generic_sequencer_17.vhd b/generic_ip/generic_sequencer/17/src/generic_sequencer_17.vhd new file mode 100644 index 0000000..2fd9e0d --- /dev/null +++ b/generic_ip/generic_sequencer/17/src/generic_sequencer_17.vhd @@ -0,0 +1,870 @@ +------------------------------------------------------------------------------- +-- Title : generic_sequencer +-- Project : Generic Components +------------------------------------------------------------------------------- +-- File : generic_sequencer.vhd +-- Author : Robbie Temple (original) +-- Company : Global Inkjet Systems +-- Created : 2016-05-12 +-- Last update: 2021-01-14 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Generic Sequencer core +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.common_pkg.all; +use work.generic_sequencer_17_cmd_pkg.all; + +entity generic_sequencer_17 is + generic( + TRIGGER_WIDTH : natural range 1 to 16 := 16; + VECTOR_WIDTH : natural range 1 to 24 := 14; + RAMP_WIDTH : natural range 1 to 16 := 14; -- Must be less than or equal to VECTOR_WIDTH + BUS_WIDTH : natural range 1 to 32 := 12; + POS_WIDTH : natural range 1 to 24 := 12; + SEQ_DEPTH : natural range 256 to 4096 := 256; + ADD_VEC_PIPE : boolean := false; -- Add a pipeline register on vector_out + VECT_CPU_EN : boolean := false; + VECT_RAMP_EN : boolean := false; + BUS_BURST_EN : boolean := false; + POS_BUS_EN : boolean := false; + ALU_EN : boolean := false; + QUEUE_EN : boolean := false; + DEVICE_FAMILY : string := "Cyclone V" -- "Cyclone 10 LP" + ); + port( + -- + clk : in std_logic; + reset_n : in std_logic; + -- + avs_csr_address : in std_logic_vector(3 downto 0); + avs_csr_write : in std_logic; + avs_csr_writedata : in std_logic_vector(31 downto 0); + avs_csr_read : in std_logic; + avs_csr_readdata : out std_logic_vector(31 downto 0) := (others => '0'); + -- + avs_seq_address : in std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + avs_seq_write : in std_logic; + avs_seq_writedata : in std_logic_vector(31 downto 0); + avs_seq_read : in std_logic; + avs_seq_readdata : out std_logic_vector(31 downto 0) := (others => '0'); + -- + start_req : in std_logic; + start_addr : in std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + -- + trigger_in : in std_logic_vector(TRIGGER_WIDTH - 1 downto 0); + pos_in : in std_logic_vector(POS_WIDTH - 1 downto 0); + -- + busy : out std_logic; + -- + vector_out : out std_logic_vector(VECTOR_WIDTH - 1 downto 0); + -- + bus_data : out std_logic_vector(BUS_WIDTH - 1 downto 0); + bus_valid : out std_logic; + bus_ack : in std_logic); +end entity generic_sequencer_17; + +architecture rtl of generic_sequencer_17 is + + ----------------------------------------------------------------------------- + -- Constant and types + ----------------------------------------------------------------------------- + + constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF01"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00001000"; + + type fsm_t is (s_idle, s_init, s_fetch, s_decode, + -- + s_trig_mask, s_trig_wait, + s_vec_set, s_vec_ramp, + s_bus_burst, s_bus_data, + s_pos_store, s_pos_wait, + -- + s_alu, + -- + s_loop, s_jump, s_branch, s_return, + -- + s_end); + + ----------------------------------------------------------------------------- + -- Signals + ----------------------------------------------------------------------------- + + signal fsm, fsm_nxt : fsm_t; + + signal seq_cfg_aux : std_logic_vector(31 downto 0) := 32x"0"; + + signal seq_enable : std_logic; + signal rst_vector_out : std_logic; + signal debug_mode : std_logic; + + signal ram_rd_addr : std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + signal ram_rd_data : std_logic_vector(31 downto 0); + + signal operand_1 : std_logic_vector(11 downto 0); + signal operand_2 : std_logic_vector(11 downto 0); + signal operand_comp : std_logic_vector(23 downto 0); + signal opcode : std_logic_vector(3 downto 0); + signal subcode : std_logic_vector(3 downto 0); + signal jump_addr_ext : std_logic_vector(11 downto 0); + signal jump_addr : std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + signal pc_value : std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + + signal pos_store : std_logic_vector(POS_WIDTH - 1 downto 0); + signal pos_target : std_logic_vector(POS_WIDTH - 1 downto 0); + + signal trig_mask : std_logic_vector(TRIGGER_WIDTH - 1 downto 0); + signal trig_sel : std_logic_vector(3 downto 0); + signal trig_int : std_logic; + + signal vector_out_i : std_logic_vector(VECTOR_WIDTH - 1 downto 0); + signal ramp_curr : std_logic_vector(RAMP_WIDTH - 1 downto 0); + signal ramp_next : std_logic_vector(RAMP_WIDTH - 1 downto 0); + signal ramp_final : std_logic_vector(RAMP_WIDTH - 1 downto 0); + signal ramp_diff : std_logic_vector(RAMP_WIDTH downto 0); + + + signal op_cnt : std_logic_vector(11 downto 0); + signal loop_cnt : std_logic_vector(11 downto 0); + + signal return_addr : std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + + signal r1, r1_data : std_logic_vector(11 downto 0); + signal r1_data_valid : std_logic; -- strobe to cause R1 to be updated with R1_data value + + signal decode, clr_vec, ld_vec : std_logic; + signal bus_valid_i, busy_i : std_logic; + signal ld_start_addr, inc_ram_addr : std_logic; + signal ld_trig_mask, ld_trig_sel : std_logic; + signal ld_pos, ld_ramp : std_logic; + signal zero_flag, alu_upd : std_logic; + signal clr_vec_i, clr_vec_ii : std_logic; + signal fetch_op, ramp_up : std_logic; + signal op_cnt_done, inc_op_cnt : std_logic; + signal bus_pause, ld_jmp_addr : std_logic; + signal jump_abs, jump_rel, jump_r1 : std_logic; + signal ld_ret_addr, save_ret_addr : std_logic; + signal loop_active, loop_upd : std_logic; + signal loop_done, ramp_diff_top : std_logic; + signal start_req_d, start_req_i : std_logic; + signal ramp_to_val, ramp_done : std_logic; + signal ramp_to_val_last : std_logic; + + signal vector_val_cpu : std_logic; + signal vector_cpu : std_logic_vector(VECTOR_WIDTH - 1 downto 0); + + signal step_req : std_logic; + signal fetch_enable : std_logic; + + signal clr_seq_queue : std_logic; + signal clr_seq_queue_i : std_logic; + signal clr_seq_queue_exe : std_logic; + signal queue_add_flag : std_logic; + signal queue_add_flag_d : std_logic; + signal queue_add_flag_i : std_logic; + signal queue_inc : std_logic; + signal queue_dec : std_logic; + signal seq_completed : std_logic; + signal seq_queue_empty : std_logic; + signal set_queue_empty : std_logic; + signal queue_add : std_logic_vector(7 downto 0); + signal queue_add_i : std_logic_vector(7 downto 0); + signal queue_left : std_logic_vector(7 downto 0); + signal queue_exec : std_logic_vector(15 downto 0); + + signal debug_mode_r : std_logic; + signal clr_seq_queue_r : std_logic; + signal clr_seq_queue_exe_r: std_logic; + signal vector_val_cpu_p : std_logic; + signal vector_cpu_r : std_logic_vector(VECTOR_WIDTH - 1 downto 0); + signal r1_data_valid_p : std_logic; + signal r1_data_r : std_logic_vector(11 downto 0); + signal seq_queue_w_p : std_logic; + signal seq_queue_w_r : std_logic_vector(7 downto 0); + +begin + + ----------------------------------------------------------------------------- + -- Control & Status Registers + ----------------------------------------------------------------------------- + + generic_sequencer_17_csr_regs_i : entity work.generic_sequencer_17_csr_regs + generic map ( + ADDR_DECODE_WIDTH => 4 + ) + port map ( + -- Clock and reset + clk => clk, + rst_n => reset_n, + + -- auto-generated + + -- Internal signal ports + ctrl_w_seq_enable => seq_enable, + ctrl_w_debug_mode => debug_mode_r, + ctrl_w_rst_vector_out => rst_vector_out, + ctrl_w_clr_seq_queue => clr_seq_queue_r, + ctrl_w_clr_seq_queue_exe => clr_seq_queue_exe_r, + step => step_req, + vector_pulse => vector_val_cpu_p, + vector => vector_cpu_r, + vector_in => vector_out, + r1_pulse => r1_data_valid_p, + r1 => r1_data_r, + r1_in => r1_data, + seq_queue_w_pulse => seq_queue_w_p, + seq_queue_w => seq_queue_w_r, + seq_queue_w_in => (others => '0'), + config_seq_depth => std_logic_vector(to_unsigned(log2(SEQ_DEPTH), 6)), + config_pos_width => std_logic_vector(to_unsigned(POS_WIDTH, 6)), + config_bus_width => std_logic_vector(to_unsigned(BUS_WIDTH, 6)), + config_vector_width => std_logic_vector(to_unsigned(VECTOR_WIDTH, 6)), + config_trigger_width => std_logic_vector(to_unsigned(TRIGGER_WIDTH, 6)), + ctrl_r_busy => busy, + ctrl_r_seq_queue_empty => seq_queue_empty, + pc_ram_rd_addr => pc_value, + pc_return_addr => return_addr, + trigger => trigger_in, + aux_config_ADD_VEC_PIPE => seq_cfg_aux(0), + aux_config_VECT_RAMP_EN => seq_cfg_aux(1), + aux_config_BUS_BURST_EN => seq_cfg_aux(2), + aux_config_POS_BUS_EN => seq_cfg_aux(3), + aux_config_ALU_EN => seq_cfg_aux(4), + aux_config_QUEUE_EN => seq_cfg_aux(5), + pos_store => pos_store, + seq_queue_r_queue_left => queue_left, + seq_queue_r_queue_exec => queue_exec, + + -- end auto-generated + + -- Slave bus port + avs_address => avs_csr_address(3 downto 0), + avs_write => avs_csr_write, + avs_writedata => avs_csr_writedata, + avs_read => avs_csr_read, + avs_readdata => avs_csr_readdata + + ); + + -- + -- The process manages the registers + -- + REG_PROC : process(clk, reset_n) is + begin + if reset_n = '0' then + debug_mode <= '0'; + clr_seq_queue <= '0'; + clr_seq_queue_exe <= '0'; + seq_queue_empty <= '0'; + elsif clk'event and clk = '1' then + -- + vector_val_cpu <= '0'; + clr_seq_queue <= '0'; + clr_seq_queue_exe <= '0'; + queue_add_flag <= '0'; + + if (ALU_EN = true) then + if (busy_i = '0') then + r1_data_valid <= '0'; + end if; + end if; + + if (QUEUE_EN = true and set_queue_empty = '1') then + seq_queue_empty <= '1'; + end if; + + if fsm = s_idle then + debug_mode <= debug_mode_r; + end if; + + if (QUEUE_EN = true) then + clr_seq_queue <= clr_seq_queue_r; + clr_seq_queue_exe <= clr_seq_queue_exe_r; + end if; + + if(VECT_CPU_EN = true) then + if(fsm = s_idle) and (vector_val_cpu_p = '1') then + vector_val_cpu <= '1'; + vector_cpu <= vector_cpu_r; + end if; + end if; + + if (ALU_EN = true) and (r1_data_valid_p = '1') then + r1_data <= r1_data_r; + r1_data_valid <= '1'; + end if; + + if (QUEUE_EN = true) and (seq_queue_w_p = '1') then + queue_add_flag <= '1'; + queue_add <= seq_queue_w_r; + end if; + end if; + end process REG_PROC; + + seq_cfg_aux(0) <= '1' when ADD_VEC_PIPE = true else '0'; + seq_cfg_aux(1) <= '1' when VECT_RAMP_EN = true else '0'; + seq_cfg_aux(2) <= '1' when BUS_BURST_EN = true else '0'; + seq_cfg_aux(3) <= '1' when POS_BUS_EN = true else '0'; + seq_cfg_aux(4) <= '1' when ALU_EN = true else '0'; + seq_cfg_aux(5) <= '1' when QUEUE_EN = true else '0'; + + trig_int <= trigger_in(to_integer(unsigned(trig_sel))) and trig_mask(to_integer(unsigned(trig_sel))); + + --pragma translate_off + assert (to_integer(unsigned(trig_sel)) < TRIGGER_WIDTH) report "ERROR: trig_sel out of selectable trigger mask" severity failure; + --pragma translate_on + + ----------------------------------------------------------------------------- + -- Dual-Port Memory buffer + ----------------------------------------------------------------------------- + + iRAM : entity work.alt_rw_dp_ram + generic map( + DATA_WIDTH => 32, + DEPTH => SEQ_DEPTH, + REGISTER_OUTPUT => "UNREGISTERED", + READ_WRITE_MODE => "OLD_DATA", + DEVICE_FAMILY => DEVICE_FAMILY + + ) + port map( + clk => clk, + addr_a => avs_seq_address, + wren_a => avs_seq_write, + wrdata_a => avs_seq_writedata, + rddata_a => avs_seq_readdata, + addr_b => ram_rd_addr, + wren_b => '0', + wrdata_b => (others => '0'), + rddata_b => ram_rd_data + ); + + ----------------------------------------------------------------------------- + -- Sequencer Logic + ----------------------------------------------------------------------------- + + start_req_i <= start_req and not start_req_d; + + -- FSM Status Register + pFSM_SR : process(reset_n, clk) + begin + if (reset_n = '0') then + fsm <= s_idle; + elsif (clk = '1' and clk'event) then + fsm <= fsm_nxt; + opcode <= ram_rd_data(31 downto 28); + end if; + end process pFSM_SR; + + -- FSM combinational logic + pFSM_CL : process(all) + begin + -- Default assignments + fsm_nxt <= fsm; + -- + decode <= '0'; + clr_vec_i <= '0'; + ld_vec <= '0'; + ld_ramp <= '0'; + busy_i <= '1'; + ld_start_addr <= '0'; + inc_ram_addr <= '0'; + fetch_op <= '0'; + ld_trig_mask <= '0'; + inc_op_cnt <= '0'; + loop_upd <= '0'; + seq_completed <= '0'; + set_queue_empty <= '0'; + if (BUS_BURST_EN = true) then + bus_valid_i <= '0'; + end if; + if (ALU_EN = true) then + alu_upd <= '0'; + end if; + if (POS_BUS_EN = true) then + ld_pos <= '0'; + end if; + + -- Determine next state + if (seq_enable = '0') then + busy_i <= '0'; + if (rst_vector_out = '1') then + clr_vec_i <= '1'; + end if; + fsm_nxt <= s_idle; + elsif (start_req_i = '1') then + busy_i <= '0'; + ld_start_addr <= '1'; + fsm_nxt <= s_init; + else + case fsm is + + when s_idle => + busy_i <= '0'; + if seq_enable = '1' and start_req_i = '1' then + ld_start_addr <= '1'; + fsm_nxt <= s_init; + end if; + + when s_init => + if (rst_vector_out = '1') then + clr_vec_i <= '1'; + end if; + fsm_nxt <= s_fetch; + + when s_fetch => + if (fetch_enable = '1') then + inc_ram_addr <= '1'; + fetch_op <= '1'; + fsm_nxt <= s_decode; + end if; + + when s_return => + fsm_nxt <= s_fetch; + + when s_decode => + decode <= '1'; + case opcode is + -- + when CMD_NOP => fsm_nxt <= s_fetch; + -- + when CMD_TRIG_MASK => fsm_nxt <= s_trig_mask; + when CMD_TRIG_WAIT => fsm_nxt <= s_trig_wait; + when CMD_VEC_SET => fsm_nxt <= s_vec_set; + when CMD_VEC_RAMP_UP => fsm_nxt <= s_vec_ramp; + when CMD_VEC_RAMP_DN => fsm_nxt <= s_vec_ramp; + when CMD_VEC_RAMP => fsm_nxt <= s_vec_ramp; + when CMD_BUS_BURST => fsm_nxt <= s_bus_burst; + when CMD_POS_STORE => fsm_nxt <= s_pos_store; + when CMD_POS_WAIT => fsm_nxt <= s_pos_wait; + when CMD_ALU => fsm_nxt <= s_alu; + when CMD_LOOP => fsm_nxt <= s_loop; + when CMD_JUMP => fsm_nxt <= s_jump; + when CMD_BRANCH => fsm_nxt <= s_branch; + when CMD_RETURN => fsm_nxt <= s_return; + when CMD_END => fsm_nxt <= s_end; + when others => null; + end case; + + when s_trig_mask => + ld_trig_mask <= '1'; + fsm_nxt <= s_fetch; + + when s_trig_wait => + if (trig_int = '1') then + inc_op_cnt <= '1'; + end if; + if (op_cnt_done = '1') then + fsm_nxt <= s_fetch; + end if; + + when s_vec_set => + ld_vec <= '1'; + fsm_nxt <= s_fetch; + + when s_vec_ramp => + if (VECT_RAMP_EN = false) then + fsm_nxt <= s_fetch; + else + if (trig_int = '1') then + inc_op_cnt <= '1'; + ld_ramp <= '1'; + end if; + if (ramp_done = '1' and ((ramp_to_val = '0' and trig_int = '1') or ramp_to_val = '1')) then + ld_ramp <= '1'; + fsm_nxt <= s_fetch; + end if; + end if; + + when s_bus_burst => + if (BUS_BURST_EN = true) then + bus_valid_i <= '1'; + if (op_cnt_done = '1' and bus_ack = '1') then + bus_valid_i <= '0'; + fsm_nxt <= s_fetch; + elsif (bus_pause = '0') then + inc_ram_addr <= '1'; + inc_op_cnt <= '1'; + end if; + else + fsm_nxt <= s_fetch; + end if; + + when s_pos_store => + if (POS_BUS_EN = true) then + ld_pos <= '1'; + end if; + fsm_nxt <= s_fetch; + + when s_pos_wait => + if (pos_in = pos_target) then + fsm_nxt <= s_fetch; + end if; + + when s_alu => + if (ALU_EN = true) then + alu_upd <= '1'; + end if; + fsm_nxt <= s_fetch; + + when s_jump | s_branch => + fsm_nxt <= s_fetch; + + when s_loop => + loop_upd <= '1'; + fsm_nxt <= s_fetch; + + when s_end => + if (subcode = x"0") then + fsm_nxt <= s_idle; + elsif (QUEUE_EN = true and (subcode = x"1" or subcode = x"2")) then + if (unsigned(queue_left) > 0) then + seq_completed <= '1'; + fsm_nxt <= s_fetch; + else + set_queue_empty <= '1'; + fsm_nxt <= s_end; + end if; + else + fsm_nxt <= s_idle; + end if; + + when others => null; + end case; + end if; + end process pFSM_CL; + + ld_trig_sel <= '1' when decode = '1' and (opcode = CMD_TRIG_WAIT or opcode = CMD_VEC_RAMP_UP or opcode = CMD_VEC_RAMP_DN or opcode = CMD_VEC_RAMP) else '0'; + + -- + pSEQ_REGs : process(reset_n, clk) + begin + if (reset_n = '0') then + vector_out_i <= (others => '0'); + elsif (clk = '1' and clk'event) then + start_req_d <= start_req; + fetch_enable <= (not debug_mode) or (debug_mode and step_req); + if (fetch_op = '1') then + pc_value <= ram_rd_addr; + end if; + if (fetch_op = '1') then + operand_comp <= ram_rd_data(23 downto 0); + subcode <= ram_rd_data(27 downto 24); + end if; + busy <= busy_i; + if (ld_start_addr = '1') then + ram_rd_addr <= start_addr; + elsif (ld_jmp_addr = '1') then + ram_rd_addr <= jump_addr; + elsif (ld_ret_addr = '1') then + ram_rd_addr <= return_addr; + elsif (inc_ram_addr = '1') then + ram_rd_addr <= std_logic_vector(unsigned(ram_rd_addr) + 1); + end if; + if (ld_trig_mask = '1') then + trig_mask <= operand_comp(TRIGGER_WIDTH - 1 downto 0); + end if; + if (ld_trig_sel = '1') then + trig_sel <= subcode; + end if; + if (ld_vec = '1' and subcode = "0001") then + clr_vec_ii <= '1'; + else + clr_vec_ii <= '0'; + end if; + if (clr_vec = '1') then + vector_out_i <= (others => '0'); + elsif (ld_vec = '1') then + vector_out_i <= operand_comp(VECTOR_WIDTH - 1 downto 0); + elsif(VECT_RAMP_EN = true and ld_ramp = '1') then + if(ramp_up = '1' and ramp_next(ramp_next'high) = '0' and vector_out_i(ramp_next'high) = '1') then + vector_out_i(RAMP_WIDTH-1 downto 0) <= (others => '1'); + elsif(ramp_up = '0' and ramp_next(ramp_next'high) = '1' and vector_out_i(ramp_next'high) = '0') then + vector_out_i(RAMP_WIDTH-1 downto 0) <= (others => '0'); + elsif(ramp_to_val = '1' and ramp_done = '1') then + vector_out_i(RAMP_WIDTH-1 downto 0) <= ramp_final; + else + vector_out_i(RAMP_WIDTH-1 downto 0) <= ramp_next; + end if; + elsif (VECT_CPU_EN = true and vector_val_cpu = '1') then + vector_out_i <= vector_cpu; + end if; + if(VECT_RAMP_EN = true and decode = '1') then + if(opcode = CMD_VEC_RAMP) then + ramp_to_val <= '1'; + else + ramp_to_val <= '0'; + end if; + end if; + if (save_ret_addr = '1') then + return_addr <= ram_rd_addr; + end if; + if (decode = '1') then + op_cnt <= (others => '0'); + elsif (inc_op_cnt = '1') then + op_cnt <= std_logic_vector(unsigned(op_cnt) + 1); + end if; + if (start_req_i = '1' or (loop_done = '1' and loop_upd = '1')) then + loop_active <= '0'; + elsif (decode = '1' and opcode = CMD_LOOP) then + loop_active <= '1'; + end if; + if (loop_active = '0' and opcode = CMD_LOOP) then + loop_cnt <= (others => '0'); + elsif (loop_upd = '1') then + loop_cnt <= std_logic_vector(unsigned(loop_cnt) + 1); + end if; + end if; +end process pSEQ_REGs; + + loop_done <= '1' when unsigned(loop_cnt) = unsigned(operand_2) else '0'; + + operand_1 <= operand_comp(11 downto 0); + operand_2 <= operand_comp(23 downto 12); + + clr_vec <= clr_vec_i or clr_vec_ii; + + op_cnt_done <= '1' when op_cnt = operand_1 else '0'; + + jump_addr_ext <= operand_1 when jump_abs = '1' else + std_logic_vector(signed('0' & ram_rd_addr) + signed(operand_1) - 1) when jump_rel = '1' else + r1; + + jump_addr <= jump_addr_ext(jump_addr'range); + + ld_jmp_addr <= '1' when decode = '1' and (jump_abs = '1' or jump_rel = '1' or jump_r1 = '1') else '0'; + + jump_abs <= '1' when (opcode = CMD_JUMP and (subcode = X"0" or (subcode = X"1" and zero_flag = '1') or (subcode = X"2" and zero_flag = '0'))) or (opcode = CMD_END and subcode = X"1") else '0'; + jump_rel <= '1' when (opcode = CMD_BRANCH and (subcode = X"0" or (subcode = X"1" and zero_flag = '1') or (subcode = X"2" and zero_flag = '0'))) or (opcode = CMD_LOOP and loop_done = '0') or (opcode = CMD_END and subcode = X"2") else '0'; + jump_r1 <= '1' when opcode = CMD_JUMP and subcode = X"F" else '0'; + + save_ret_addr <= ld_jmp_addr; + ld_ret_addr <= '1' when decode = '1' and (opcode = CMD_RETURN) else '0'; + + ----------------------------------------------------------------------------- + -- Others - Generics dependent + ----------------------------------------------------------------------------- + + gVECT_NO_PIPE : if ADD_VEC_PIPE = false generate + vector_out <= vector_out_i; + end generate gVECT_NO_PIPE; + + gVECT_PIPE : if ADD_VEC_PIPE = true generate + pVECT_PIPE : process(clk) + begin + if (clk = '1' and clk'event) then + vector_out <= vector_out_i; + end if; + end process pVECT_PIPE; + end generate gVECT_PIPE; + + gRAMP_GEN : if VECT_RAMP_EN = true generate + + gRAMP_FINAL: if RAMP_WIDTH > 12 generate + ramp_final <= operand_1 & std_logic_vector(to_unsigned(0, RAMP_WIDTH-12)); + else generate + ramp_final <= operand_1(RAMP_WIDTH-1 downto 0); + end generate gRAMP_FINAL; + + ramp_done <= '1' when (ramp_to_val = '0' and op_cnt_done = '1') or ramp_to_val_last = '1' else '0'; + + ramp_curr <= vector_out_i(ramp_curr'range); + + ramp_next <= std_logic_vector(unsigned(ramp_curr) + unsigned(operand_2)) when ramp_up = '1' else + std_logic_vector(unsigned(ramp_curr) - unsigned(operand_2)); + + ramp_diff <= std_logic_vector(signed('0' & ramp_final) - signed('0' & ramp_curr)); + + ramp_to_val_last <= '1' when ramp_to_val = '1' and ((ramp_diff(ramp_diff'left) xor ramp_diff_top) = '1' or signed(ramp_diff) = 0) else '0'; + + pRAMP_REGs : process(clk) + begin + if (clk = '1' and clk'event) then + if (decode = '1') then + if (opcode = CMD_VEC_RAMP_UP) then + ramp_up <= '1'; + else + ramp_up <= '0'; + end if; + elsif(ramp_to_val = '1') then + ramp_up <= not ramp_diff(ramp_diff'left); + end if; + if(decode = '1' or inc_op_cnt = '1') then + ramp_diff_top <= ramp_diff(ramp_diff'left); + end if; + end if; + end process pRAMP_REGs; + + end generate gRAMP_GEN; + + gRAMP_NOGEN : if VECT_RAMP_EN = false generate + ramp_up <= '0'; + ramp_done <= '0'; + ramp_curr <= (others => '0'); + ramp_next <= (others => '0'); + ramp_diff <= (others => '0'); + ramp_final <= (others => '0'); + + end generate gRAMP_NOGEN; + + gBUS_BURST_GEN : if BUS_BURST_EN = true generate + + pBURST_REGs : process(clk) + begin + if (clk = '1' and clk'event) then + bus_valid <= bus_valid_i and not (bus_ack and bus_pause); + bus_pause <= bus_valid_i and (not bus_ack or inc_ram_addr); + if (seq_enable = '0') then + bus_data <= (others => '0'); + elsif (bus_valid_i = '1' and (bus_pause = '0' or bus_ack = '1')) then + bus_data <= ram_rd_data(BUS_WIDTH - 1 downto 0); + end if; + end if; + end process pBURST_REGs; + + end generate gBUS_BURST_GEN; + + gBUS_BURST_NOGEN : if BUS_BURST_EN = false generate + + bus_valid <= '0'; + bus_pause <= '0'; + bus_data <= (others => '0'); + + end generate gBUS_BURST_NOGEN; + + gPOS_GEN : if POS_BUS_EN = true generate + + pPOS_REGs : process(clk) + begin + if (clk = '1' and clk'event) then + if (ld_pos = '1') then + pos_store <= pos_in; + end if; + if (decode = '1') then + case subcode is + when X"0" => + pos_target <= operand_comp(pos_in'range); + when X"1" => + pos_target <= std_logic_vector(signed(pos_in) + signed(operand_comp(pos_in'range))); + when X"2" => + pos_target <= pos_store; + when X"3" => + pos_target <= std_logic_vector(signed(pos_store) + signed(operand_comp(pos_in'range))); + when others => null; + end case; + end if; + end if; + end process pPOS_REGs; + + end generate gPOS_GEN; + + gALU_GEN : if ALU_EN = true generate + + pALU_REGs : process(clk) + variable r1_next : std_logic_vector(11 downto 0); + begin + if (clk = '1' and clk'event) then + -- Update ALU register R1 + if (busy_i = '0' and r1_data_valid = '1') then + r1 <= R1_data; + elsif (alu_upd = '1') then + case subcode is + when x"2" => + r1_next := operand_1; + when x"3" => + r1_next := std_logic_vector(signed(r1) + signed(operand_1)); + when x"4" => + r1_next := std_logic_vector(signed(r1) - signed(operand_1)); + when others => null; + end case; + r1 <= r1_next; + end if; + -- Update ALU flag + if (alu_upd = '1') then + case subcode is + when x"0" => + if ((trigger_in(TRIGGER_WIDTH - 1 downto 0) and trig_mask(TRIGGER_WIDTH - 1 downto 0)) = (operand_comp(TRIGGER_WIDTH - 1 downto 0) and trig_mask(TRIGGER_WIDTH - 1 downto 0))) then + zero_flag <= '1'; + else + zero_flag <= '0'; + end if; + when x"1" => + if (r1 = operand_1) then + zero_flag <= '1'; + else + zero_flag <= '0'; + end if; + when x"2" | x"3" | x"4" => + if (signed(r1_next) = 0) then + zero_flag <= '1'; + else + zero_flag <= '0'; + end if; + when others => null; + end case; + end if; + end if; + end process pALU_REGs; + + end generate gALU_GEN; + + gALU_NOGEN : if ALU_EN = false generate + + r1 <= (others => '0'); + zero_flag <= '0'; + + end generate gALU_NOGEN; + + gQUEUE_GEN : if QUEUE_EN = true generate + + pQUEUE_REGs : process(clk) + begin + if (clk = '1' and clk'event) then + queue_add_flag_d <= queue_add_flag and seq_completed; + queue_inc <= queue_add_flag_i and (not queue_add(queue_add'left)); + queue_dec <= queue_add_flag_i and queue_add(queue_add'left); + if (queue_add_flag = '1' and queue_add(queue_add'left) = '1') then + queue_add_i <= std_logic_vector(unsigned(not (queue_add)) + 1); + else + queue_add_i <= queue_add; + end if; + if (seq_enable = '0' or clr_seq_queue_i = '1') then + queue_left <= (others => '0'); + elsif (seq_completed = '1') then + queue_left <= std_logic_vector(unsigned(queue_left) - 1); + elsif (queue_inc = '1') then + queue_left <= std_logic_vector(unsigned(queue_left) + unsigned(queue_add_i)); + elsif (queue_dec = '1') then + queue_left <= std_logic_vector(unsigned(queue_left) - unsigned(queue_add_i)); + end if; + if (seq_enable = '0' or clr_seq_queue_exe = '1') then + queue_exec <= (others => '0'); + elsif (seq_completed = '1') then + queue_exec <= std_logic_vector(unsigned(queue_exec) + 1); + end if; + end if; + end process pQUEUE_REGs; + + clr_seq_queue_i <= '1' when clr_seq_queue = '1' or (queue_dec = '1' and unsigned(queue_left) < unsigned(queue_add_i)) else '0'; + + -- if seq_completed is asserted together with queue_add_flag, delay + -- queue_add_flag of 1 clock cycle + queue_add_flag_i <= queue_add_flag or queue_add_flag_d; + + end generate gQUEUE_GEN; + + gQUEUE_NOGEN : if QUEUE_EN = false generate + + queue_left <= (others => '0'); + queue_exec <= (others => '0'); + + end generate gQUEUE_NOGEN; + +end rtl; diff --git a/generic_ip/generic_sequencer/17/src/generic_sequencer_17_cmd_pkg.vhd b/generic_ip/generic_sequencer/17/src/generic_sequencer_17_cmd_pkg.vhd new file mode 100644 index 0000000..056c92b --- /dev/null +++ b/generic_ip/generic_sequencer/17/src/generic_sequencer_17_cmd_pkg.vhd @@ -0,0 +1,44 @@ +------------------------------------------------------------------------------- +-- Title : generic_sequencer_17_cmd_pkg +-- Project : Generic IPs +------------------------------------------------------------------------------- +-- File : generic_sequencer_17_cmd_pkg.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2018-01-17 +-- Last update: 2021-01-14 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Package defining commmands for generic_sequencer_17 core +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.common_pkg.all; + + +package generic_sequencer_17_cmd_pkg is + + constant CMD_NOP : std_logic_vector(3 downto 0) := x"0"; + constant CMD_TRIG_MASK : std_logic_vector(3 downto 0) := x"1"; + constant CMD_TRIG_WAIT : std_logic_vector(3 downto 0) := x"2"; + constant CMD_VEC_SET : std_logic_vector(3 downto 0) := x"3"; + constant CMD_VEC_RAMP_UP : std_logic_vector(3 downto 0) := x"4"; + constant CMD_VEC_RAMP_DN : std_logic_vector(3 downto 0) := x"5"; + constant CMD_BUS_BURST : std_logic_vector(3 downto 0) := x"6"; + constant CMD_POS_STORE : std_logic_vector(3 downto 0) := x"7"; + constant CMD_POS_WAIT : std_logic_vector(3 downto 0) := x"8"; + constant CMD_VEC_RAMP : std_logic_vector(3 downto 0) := x"9"; + constant CMD_ALU : std_logic_vector(3 downto 0) := x"A"; + constant CMD_LOOP : std_logic_vector(3 downto 0) := x"B"; + constant CMD_JUMP : std_logic_vector(3 downto 0) := x"C"; + constant CMD_BRANCH : std_logic_vector(3 downto 0) := x"D"; + constant CMD_RETURN : std_logic_vector(3 downto 0) := x"E"; + constant CMD_END : std_logic_vector(3 downto 0) := x"F"; + +end package generic_sequencer_17_cmd_pkg; diff --git a/generic_ip/generic_sequencer/17/src/test/generic_sequencer_17_tb.vhd b/generic_ip/generic_sequencer/17/src/test/generic_sequencer_17_tb.vhd new file mode 100644 index 0000000..e1ee34c --- /dev/null +++ b/generic_ip/generic_sequencer/17/src/test/generic_sequencer_17_tb.vhd @@ -0,0 +1,1476 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.common_pkg.all; +use work.generic_sequencer_17_pkg.all; + +use work.log_pkg.all; +use work.avalon_verify_pkg.all; + +entity generic_sequencer_17_tb is + -- .. +end entity generic_sequencer_17_tb; + +architecture behav of generic_sequencer_17_tb is + + constant TRIGGER_WIDTH : natural range 1 to 12 := 12; + constant VECTOR_WIDTH : natural range 1 to 24 := 24; + constant RAMP_WIDTH : natural range 1 to 16 := 14; + constant BUS_WIDTH : natural range 1 to 32 := 32; + constant POS_WIDTH : natural range 1 to 24 := 24; + constant SEQ_DEPTH : natural range 256 to 4096 := 512; + constant ADD_VEC_PIPE : boolean := true; + constant VECT_RAMP_EN : boolean := true; + constant BUS_BURST_EN : boolean := true; + constant POS_BUS_EN : boolean := true; + constant ALU_EN : boolean := true; + constant QUEUE_EN : boolean := true; + + constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF01"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00001100"; + + constant CLK_PERIOD : time := 10 ns; + + -- Logging Verbosity Level + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + + constant MAX_SIM_TIME : time := 100 us; -- Maximum simulation time + + -- + signal clk : std_logic := '0'; + signal reset_n : std_logic := '0'; + -- + signal avs_csr_address : std_logic_vector(3 downto 0); + signal avs_csr_write : std_logic; + signal avs_csr_writedata : std_logic_vector(31 downto 0); + signal avs_csr_read : std_logic; + signal avs_csr_readdata : std_logic_vector(31 downto 0) := (others => '0'); + -- + signal avs_seq_address : std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + signal avs_seq_write : std_logic; + signal avs_seq_writedata : std_logic_vector(31 downto 0); + signal avs_seq_read : std_logic; + signal avs_seq_readdata : std_logic_vector(31 downto 0) := (others => '0'); + -- + signal start_req : std_logic; + signal start_addr : std_logic_vector(log2(SEQ_DEPTH) - 1 downto 0); + -- + signal trigger_in : std_logic_vector(TRIGGER_WIDTH - 1 downto 0); + signal pos_in : std_logic_vector(POS_WIDTH - 1 downto 0); + -- + signal busy : std_logic; + -- + signal vector_out : std_logic_vector(VECTOR_WIDTH - 1 downto 0); + -- + signal bus_data : std_logic_vector(BUS_WIDTH - 1 downto 0); + signal bus_valid : std_logic; + signal bus_ack : std_logic; + + -- TB specific signals + signal setup : boolean; + signal running : boolean; + signal passed : boolean := false; + signal failed : boolean := false; + signal test_timeout : boolean := false; + signal test_completed : boolean := false; + + signal error_flag : boolean; + + signal csr_mm_s_rec : mm_s_rec_t; + signal csr_mm_m_rec : mm_m_rec_t; + + signal seq_mm_s_rec : mm_s_rec_t; + signal seq_mm_m_rec : mm_m_rec_t; + + signal update_cfg : boolean; + +begin + + clk <= not clk after 0.5*CLK_PERIOD; + + clk_clk <= clk; + + reset_reset_n <= '1' after 100 ns; + + ----------------------------------------------------------------------------- + -- UUT + ----------------------------------------------------------------------------- + + iUUT : entity work.generic_sequencer_17 + generic map( + TRIGGER_WIDTH => TRIGGER_WIDTH, + VECTOR_WIDTH => VECTOR_WIDTH, + RAMP_WIDTH => RAMP_WIDTH, + BUS_WIDTH => BUS_WIDTH, + POS_WIDTH => POS_WIDTH, + SEQ_DEPTH => SEQ_DEPTH, + ADD_VEC_PIPE => ADD_VEC_PIPE, + VECT_RAMP_EN => VECT_RAMP_EN, + BUS_BURST_EN => BUS_BURST_EN, + POS_BUS_EN => POS_BUS_EN, + ALU_EN => ALU_EN, + QUEUE_EN => QUEUE_EN) + port map( + -- + clk => clk, + reset_n => reset_reset_n, + -- + avs_csr_address => avs_csr_address, + avs_csr_write => avs_csr_write, + avs_csr_writedata => avs_csr_writedata, + avs_csr_read => avs_csr_read, + avs_csr_readdata => avs_csr_readdata, + -- + avs_seq_address => avs_seq_address, + avs_seq_write => avs_seq_write, + avs_seq_writedata => avs_seq_writedata, + avs_seq_read => avs_seq_read, + avs_seq_readdata => avs_seq_readdata, + -- + start_req => start_req, + start_addr => start_addr, + -- + trigger_in => trigger_in, + pos_in => pos_in, + -- + busy => busy, + -- + vector_out => vector_out, + -- + bus_data => bus_data, + bus_valid => bus_valid, + bus_ack => bus_ack); + + ----------------------------------------------------------------------------- + -- AVS Sequencer signal mapping + ----------------------------------------------------------------------------- + + seq_mm_s_rec.mm_readdata <= avs_seq_readdata; + + avs_seq_write <= seq_mm_m_rec.mm_write; + avs_seq_writedata <= seq_mm_m_rec.mm_writedata; + avs_seq_address <= seq_mm_m_rec.mm_address(avs_seq_address'range); + avs_seq_read <= seq_mm_m_rec.mm_read; + + ----------------------------------------------------------------------------- + + csr_mm_s_rec.mm_readdata <= avs_csr_readdata; + + avs_csr_write <= csr_mm_m_rec.mm_write; + avs_csr_writedata <= csr_mm_m_rec.mm_writedata; + avs_csr_address <= csr_mm_m_rec.mm_address(avs_csr_address'range); + avs_csr_read <= csr_mm_m_rec.mm_read; + + pCFG_SEQ : process + procedure init is + begin + mm_m_init(seq_mm_m_rec); + end init; + + procedure send_seq_table is + begin + -- TRIG_MASK, TRIG_WAIT, VEC_SET + mm_32b_write(x"00000000", x"10000003", seq_mm_s_rec, seq_mm_m_rec); -- Trigger mask + mm_32b_write(x"00000001", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000002", x"30000001", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"00000003", x"20000002", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000004", x"30000002", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"00000005", x"21000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000006", x"30000003", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"00000007", x"21000002", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000008", x"30000004", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"00000009", x"10000800", seq_mm_s_rec, seq_mm_m_rec); -- Trigger mask + mm_32b_write(x"0000000A", x"2B000004", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"0000000B", x"31000800", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"0000000C", x"31000400", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"0000000D", x"31000200", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"0000000E", x"30FFFFFF", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"0000000F", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- End + + -- RAMP-UP/DOWN, VEC_SET + mm_32b_write(x"00000020", x"100000F0", seq_mm_s_rec, seq_mm_m_rec); -- Trigger mask + mm_32b_write(x"00000021", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"00000022", x"4400103F", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Up + mm_32b_write(x"00000023", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000024", x"5400103F", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Down + mm_32b_write(x"00000025", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000026", x"30000100", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"00000027", x"54008021", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Down + mm_32b_write(x"00000028", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000029", x"30FFFF00", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"0000002A", x"4401003F", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Up + mm_32b_write(x"0000002B", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"0000002C", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"0000002D", x"44001000", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Up + mm_32b_write(x"0000002E", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"0000002F", x"54001000", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-down + mm_32b_write(x"00000030", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000031", x"44001004", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Up + mm_32b_write(x"00000032", x"54001003", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Down + mm_32b_write(x"00000033", x"44001004", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Up + mm_32b_write(x"00000034", x"54001003", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Down + mm_32b_write(x"00000035", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- End + mm_32b_write(x"00000036", x"30003FF0", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"00000037", x"4400103F", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Up + mm_32b_write(x"00000038", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000039", x"3000000F", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"0000003A", x"5400103F", seq_mm_s_rec, seq_mm_m_rec); -- Ramp-Down + mm_32b_write(x"0000003B", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- End + + -- BUS_BURST + mm_32b_write(x"00000040", x"1000000F", seq_mm_s_rec, seq_mm_m_rec); -- Trigger mask + mm_32b_write(x"00000041", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000042", x"60000004", seq_mm_s_rec, seq_mm_m_rec); -- Bus-Burst + mm_32b_write(x"00000043", x"DEADBEEF", seq_mm_s_rec, seq_mm_m_rec); -- Burst-Data + mm_32b_write(x"00000044", x"BADA5555", seq_mm_s_rec, seq_mm_m_rec); -- Burst-Data + mm_32b_write(x"00000045", x"CAFEF00D", seq_mm_s_rec, seq_mm_m_rec); -- Burst-Data + mm_32b_write(x"00000046", x"DEADBEEF", seq_mm_s_rec, seq_mm_m_rec); -- Burst-Data + mm_32b_write(x"00000047", x"60000001", seq_mm_s_rec, seq_mm_m_rec); -- Bus-Burst + mm_32b_write(x"00000048", x"FFFF0000", seq_mm_s_rec, seq_mm_m_rec); -- Burst-Data + mm_32b_write(x"00000049", x"60000001", seq_mm_s_rec, seq_mm_m_rec); -- Bus-Burst + mm_32b_write(x"0000004A", x"0000FFFF", seq_mm_s_rec, seq_mm_m_rec); -- Burst-Data + mm_32b_write(x"0000004B", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- End + + -- POS_STORE, POS_WAIT + mm_32b_write(x"00000060", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000061", x"80000064", seq_mm_s_rec, seq_mm_m_rec); -- POS_WAIT + mm_32b_write(x"00000062", x"70000000", seq_mm_s_rec, seq_mm_m_rec); -- POS_STORE + mm_32b_write(x"00000063", x"30000001", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000064", x"81000032", seq_mm_s_rec, seq_mm_m_rec); -- POS_WAIT + mm_32b_write(x"00000065", x"30000002", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000066", x"82000000", seq_mm_s_rec, seq_mm_m_rec); -- POS_WAIT + mm_32b_write(x"00000067", x"30000003", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000068", x"83000014", seq_mm_s_rec, seq_mm_m_rec); -- POS_WAIT + mm_32b_write(x"00000069", x"30000004", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"0000006A", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- END + + -- JUMP, RETURN + mm_32b_write(x"00000080", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000081", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"00000082", x"C00000F0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"00000083", x"30000001", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000084", x"C00000F3", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"00000085", x"30000002", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000086", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- END + mm_32b_write(x"000000F0", x"300000F0", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000F1", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"000000F2", x"C0000083", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000F3", x"300000F1", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000F4", x"E0000000", seq_mm_s_rec, seq_mm_m_rec); -- RETURN + + -- JUMP, ALU + mm_32b_write(x"00000090", x"1000000F", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_MASK + mm_32b_write(x"00000091", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000092", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"00000093", x"A000000C", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"00000094", x"C1000090", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (meant to fail) + mm_32b_write(x"00000095", x"30000001", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000096", x"A000000F", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"00000097", x"C10000E0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"00000098", x"30000002", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000099", x"A20000A5", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"0000009A", x"A100005A", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"0000009B", x"C1000090", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (meant to fail) + mm_32b_write(x"0000009C", x"30000003", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"0000009D", x"A10000A5", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"0000009E", x"C10000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"0000009F", x"30000004", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000A0", x"A3000001", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"000000A1", x"A10000A5", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"000000A2", x"C20000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000A3", x"30000005", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000A4", x"A10000A6", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"000000A5", x"C10000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000A6", x"30000006", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000A7", x"A4000002", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"000000A8", x"A10000A5", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"000000A9", x"C20000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000AA", x"30000007", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000AB", x"A10000A4", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"000000AC", x"C10000E2", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000AD", x"30000008", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000AE", x"A20000E2", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"000000AF", x"CF000000", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000B0", x"30000009", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000B1", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- END + mm_32b_write(x"000000E0", x"300000E0", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000E1", x"C0000098", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"000000E2", x"300000E1", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000E3", x"E0000000", seq_mm_s_rec, seq_mm_m_rec); -- RETURN + + -- BRANCH, ALU + mm_32b_write(x"000000C0", x"10000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_MASK + mm_32b_write(x"000000C1", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000C2", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"000000C3", x"D0000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH + mm_32b_write(x"000000C4", x"C00000C0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) + mm_32b_write(x"000000C5", x"30000001", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000C6", x"A2000055", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"000000C7", x"A10000AA", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"000000C8", x"D2000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH + mm_32b_write(x"000000C9", x"C00000C0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) + mm_32b_write(x"000000CA", x"30000002", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000CB", x"A1000055", seq_mm_s_rec, seq_mm_m_rec); -- ALU + mm_32b_write(x"000000CC", x"D2000FF4", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH (to not be executed) + mm_32b_write(x"000000CD", x"30000003", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"000000CE", x"D1000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH + mm_32b_write(x"000000CF", x"C00000C0", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) + mm_32b_write(x"000000D0", x"30000004", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH + mm_32b_write(x"000000D1", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- END + + -- LOOP + mm_32b_write(x"00000100", x"10000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_MASK + mm_32b_write(x"00000101", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000102", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"00000103", x"30000AAA", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000104", x"30000555", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000105", x"B0004FFE", seq_mm_s_rec, seq_mm_m_rec); -- LOOP + mm_32b_write(x"00000106", x"30000BBB", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000107", x"30000CCC", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000108", x"B0001FFE", seq_mm_s_rec, seq_mm_m_rec); -- LOOP + mm_32b_write(x"00000109", x"30000DDD", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"0000010A", x"B0000FFF", seq_mm_s_rec, seq_mm_m_rec); -- LOOP + mm_32b_write(x"0000010B", x"30000EEE", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"0000010C", x"B0000FFF", seq_mm_s_rec, seq_mm_m_rec); -- LOOP + mm_32b_write(x"0000010D", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- END + + -- DEBUG mode + mm_32b_write(x"00000110", x"300000FF", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000111", x"300000EE", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000112", x"300000DD", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000113", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- END + + -- Quick test + mm_32b_write(x"00000120", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000121", x"1000000F", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_MASK + mm_32b_write(x"00000122", x"C0000122", seq_mm_s_rec, seq_mm_m_rec); -- JUMP + mm_32b_write(x"00000123", x"00000000", seq_mm_s_rec, seq_mm_m_rec); -- NOP + + -- END_AND_QUEUE instruction + mm_32b_write(x"00000130", x"10000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_MASK + mm_32b_write(x"00000131", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"00000132", x"30000A11", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000133", x"F2000001", seq_mm_s_rec, seq_mm_m_rec); -- END_AND_QUEUE (JUMP +1) + mm_32b_write(x"00000134", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"00000135", x"30000A22", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000136", x"F2000004", seq_mm_s_rec, seq_mm_m_rec); -- END_AND_QUEUE (JUMP +4) + mm_32b_write(x"00000137", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"00000138", x"30000A44", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000139", x"F2000004", seq_mm_s_rec, seq_mm_m_rec); -- END_AND_QUEUE (JUMP +4) + mm_32b_write(x"0000013A", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"0000013B", x"30000A33", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"0000013C", x"F2000FFB", seq_mm_s_rec, seq_mm_m_rec); -- END_AND_QUEUE (JUMP -5) + mm_32b_write(x"0000013D", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"0000013E", x"30000A55", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"0000013F", x"F1000140", seq_mm_s_rec, seq_mm_m_rec); -- END_AND_QUEUE-(JUMP to ox140) + mm_32b_write(x"00000140", x"20000001", seq_mm_s_rec, seq_mm_m_rec); -- TRIG_WAIT + mm_32b_write(x"00000141", x"30000B00", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000142", x"F1000131", seq_mm_s_rec, seq_mm_m_rec); -- END_AND_QUEUE-(JUMP to ox131) + + -- BRANCH, ALU (2): Check Zero Flag update on ALU ADD/SUB + mm_32b_write(x"00000150", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000151", x"A2000000", seq_mm_s_rec, seq_mm_m_rec); -- MOV R1, Op1 + mm_32b_write(x"00000152", x"A3000001", seq_mm_s_rec, seq_mm_m_rec); -- ADD R1,R1, OP1 + mm_32b_write(x"00000153", x"D2000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH PC+2 IF FLAG/=0 + mm_32b_write(x"00000154", x"C0000000", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) + mm_32b_write(x"00000155", x"30000003", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"00000156", x"A4000001", seq_mm_s_rec, seq_mm_m_rec); -- SUB R1,R1, OP1 + mm_32b_write(x"00000157", x"D1000002", seq_mm_s_rec, seq_mm_m_rec); -- BRANCH PC+2 IF FLAG=0 + mm_32b_write(x"00000158", x"C0000000", seq_mm_s_rec, seq_mm_m_rec); -- JUMP (to not be executed) + mm_32b_write(x"00000159", x"30000007", seq_mm_s_rec, seq_mm_m_rec); -- VEC_SET + mm_32b_write(x"0000015A", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- END + + -- RAMP-to-VALUE + mm_32b_write(x"00000160", x"100000F0", seq_mm_s_rec, seq_mm_m_rec); -- Trigger mask + mm_32b_write(x"00000161", x"30000000", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"00000162", x"94004020", seq_mm_s_rec, seq_mm_m_rec); -- Vec-Ramp + mm_32b_write(x"00000163", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000164", x"94004000", seq_mm_s_rec, seq_mm_m_rec); -- Vec-Ramp + mm_32b_write(x"00000165", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"00000166", x"30003FFF", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"00000167", x"94001FFE", seq_mm_s_rec, seq_mm_m_rec); -- Vec-Ramp + mm_32b_write(x"00000168", x"94001FFF", seq_mm_s_rec, seq_mm_m_rec); -- Vec-Ramp + mm_32b_write(x"00000169", x"94001FFD", seq_mm_s_rec, seq_mm_m_rec); -- Vec-Ramp + mm_32b_write(x"0000016A", x"30003FFF", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"0000016B", x"94003FF8", seq_mm_s_rec, seq_mm_m_rec); -- Vec-Ramp + mm_32b_write(x"0000016C", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"0000016D", x"94007FFF", seq_mm_s_rec, seq_mm_m_rec); -- Vec-Ramp + mm_32b_write(x"0000016E", x"25000001", seq_mm_s_rec, seq_mm_m_rec); -- Trigger wait + mm_32b_write(x"0000016F", x"30000014", seq_mm_s_rec, seq_mm_m_rec); -- Vector set + mm_32b_write(x"00000170", x"94007000", seq_mm_s_rec, seq_mm_m_rec); -- Vec-Ramp + mm_32b_write(x"00000171", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- End + + -- + + end procedure send_seq_table; + + begin + mm_m_init(seq_mm_m_rec); + setup <= false; + -- + wait for 300 ns; + send_seq_table; + setup <= true; + -- + wait until update_cfg = true; + mm_32b_write(x"00000142", x"F0000000", seq_mm_s_rec, seq_mm_m_rec); -- END -- + wait; + end process pCFG_SEQ; + + pTEST_PROC : process + variable data : std_logic_vector(31 downto 0); + variable vect_out_lat : natural; + variable vect_out_pipe : natural; + + procedure csr_read(addr : in std_logic_vector; data : out std_logic_vector(31 downto 0)) is + begin + mm_32b_read(std_logic_vector(resize(unsigned(addr),32)), data, csr_mm_s_rec, csr_mm_m_rec); + end procedure csr_read; + + procedure csr_write(addr : in std_logic_vector; data : in std_logic_vector(31 downto 0)) is + begin + mm_32b_write(std_logic_vector(resize(unsigned(addr),32)), data, csr_mm_s_rec, csr_mm_m_rec); + end procedure csr_write; + + procedure wait_clk_cycles(cycles : in natural) is + begin + for n in 0 to cycles-1 loop + wait until clk = '1' and clk'event; + end loop; -- n + end procedure wait_clk_cycles; + + procedure check_vector(latency : in natural; exp_val : in std_logic_vector) is + begin + wait_clk_cycles(latency); + wait until clk = '0' and clk'event; + if(vector_out /= exp_val) then + log("ERROR: detected vector_out = 0x" & to_hstring(vector_out) & ", expected = 0x" & to_hstring(exp_val) & ".", VLOW); + error_flag <= true; + wait; + end if; + end procedure check_vector; + + procedure check_burst_data(exp_val : in std_logic_vector; timeout : in natural) is + variable valid : boolean; + begin + valid := false; + for n in 0 to timeout-1 loop + wait until clk = '0' and clk'event; + if(bus_valid = '1') then + valid := true; + exit; + end if; + end loop; -- n + if(valid = false) then + log("ERROR: cannot detect bus_valid before timeout (Expected value = " & to_hstring(exp_val) & ").", VLOW); + error_flag <= true; + wait; + else + if(bus_data /= exp_val) then + log("ERROR: detected bus_data = 0x" & to_hstring(bus_data) & ", expected = 0x" & to_hstring(exp_val) & ".", VLOW); + error_flag <= true; + wait; + end if; + end if; + end procedure check_burst_data; + + begin + + --------------------------------------------------------------------------- + -- Init + --------------------------------------------------------------------------- + + mm_m_init(csr_mm_m_rec); + -- + update_cfg <= false; + -- + start_req <= '0'; + start_addr <= (others => '0'); + -- + trigger_in <= (others => '0'); + pos_in <= (others => '0'); + -- + bus_ack <= '0'; + -- + running <= false; + error_flag <= false; + + --Set the verbosity level for logging + set_log_verbosity(VERBOSITY_LEVEL); + + if(ADD_VEC_PIPE = true) then + vect_out_lat := 4; + vect_out_pipe := 1; + else + vect_out_lat := 3; + vect_out_pipe := 0; + end if; + + log_header("Generic-Sequencer verification:", VLOW); + + wait until rising_edge(reset_reset_n); + wait for 100 ns; + wait until rising_edge(clk); + + -- Check IP ID reg + csr_read(CSR_IP_ID_ADDR, data); + if(data /= CSR_IP_ID) then + log("ERROR: detected IP ID: read = 0x" & to_hstring(data) & ", expected = 0x" & to_hstring(CSR_IP_ID) & ".", VLOW); + error_flag <= true; + wait; + end if; + + -- Check IP Version reg + csr_read(CSR_IP_VER_ADDR, data); + if(data /= CSR_IP_VER) then + log("ERROR: detected IP Version: read = 0x" & to_hstring(data) & ", expected = 0x" & to_hstring(CSR_IP_VER) & ".", VLOW); + error_flag <= true; + wait; + end if; + log("Detected Generic-Core version 0x" & to_hstring(data(15 downto 0)) & ".", VMEDIUM); + + -- Report Generic-core config + csr_read(CSR_CONFIG_ADDR, data); + log("Sequencer Configuration:", VMEDIUM); + log("Trigger width = " & to_string(to_integer(unsigned(data(29 downto 24)))), VMEDIUM); + log("Vector width = " & to_string(to_integer(unsigned(data(23 downto 18)))), VMEDIUM); + log("Bus width = " & to_string(to_integer(unsigned(data(17 downto 12)))), VMEDIUM); + log("Position width = " & to_string(to_integer(unsigned(data(11 downto 6)))), VMEDIUM); + log("Seq Depth [log2] = " & to_string(to_integer(unsigned(data( 5 downto 0)))), VMEDIUM); + csr_read(CSR_AUX_CONFIG_ADDR, data); + log("Aux Config = " & to_string(data(4 downto 0)), VMEDIUM); + -- + if(setup /= true) then + wait until setup = true; + end if; + running <= true; + + csr_write(CSR_CTRL_W_ADDR, x"00000001"); + log("Sequencer Enabled.", VMEDIUM); + + --------------------------------------------------------------------------- + -- Verify TRIG_MASK, TRIG_WAIT, VEC_SET + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("Verifying TRIG_MASK, TRIG_WAIT, VEC_SET instructions ...", VLOW); + -- Issue a start request + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(0, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Generate the required stimuli, check the results + wait_clk_cycles(10); + trigger_in <= (0 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + check_vector(vect_out_lat+1, 24x"1"); + wait_clk_cycles(3); + -- check whether trigger wait works with continuous clock cycles + trigger_in <= (0 => '1', others => '0'); + wait_clk_cycles(2); + trigger_in <= (others => '0'); + check_vector(vect_out_lat+1, 24x"2"); + -- + wait_clk_cycles(10); + trigger_in <= (1 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + check_vector(vect_out_lat+1, 24x"3"); + wait_clk_cycles(vect_out_lat); + -- check whether trigger wait works with continuous clock cycles + trigger_in <= (1 => '1', others => '0'); + wait_clk_cycles(2); + trigger_in <= (others => '0'); + check_vector(vect_out_lat+1, 24x"4"); + wait_clk_cycles(10); + -- Last iteration with trigger #12 + trigger_in <= (11 => '1', others => '0'); + wait_clk_cycles(2); + trigger_in <= (others => '0'); + trigger_in <= (11 => '1', others => '0'); + wait_clk_cycles(2); + trigger_in <= (others => '0'); + -- check self-clearing vector-out + check_vector(vect_out_lat+1, 24x"800"); + check_vector(1, 24x"0"); + check_vector(vect_out_lat-1-vect_out_pipe, 24x"400"); + check_vector(1, 24x"0"); + check_vector(vect_out_lat-1-vect_out_pipe, 24x"200"); + check_vector(1, 24x"0"); + check_vector(vect_out_lat, 24x"FFFFFF"); + + wait_clk_cycles(4); + if(busy /= '0') then + log("ERROR: busy flag is still asserted.", VLOW); + error_flag <= true; + wait; + end if; + + log("Completed.", VLOW); + + --------------------------------------------------------------------------- + -- Verify RAMP-UP/DOWN, VEC_SET + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("Verifying RAMP-UP/DOWN instructions ...", VLOW); + + -- Issue a start request + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(32, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + wait_clk_cycles(10); + for n in 0 to 63 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + end loop; -- n + check_vector(1, 24x"40"); + wait_clk_cycles(1); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(4); + trigger_in <= (others => '0'); + for n in 0 to 63 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + end loop; -- n + check_vector(1, 24x"0"); + wait_clk_cycles(10); + + -- Now restart the sequence from the beginning, issue contiguous trigger + -- events during ramp up and down + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(32, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Generate the required stimuli, check the results + wait_clk_cycles(10); + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(64+3); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + check_vector(1, 24x"40"); + wait_clk_cycles(1); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(5); + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(64+3); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + check_vector(1, 24x"0"); + wait_clk_cycles(1); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(5); + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(64+3); + trigger_in <= (others => '0'); + check_vector(1, 24x"000000"); -- (256 -1024 = -768) + wait_clk_cycles(5); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(5); + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(64+3); + trigger_in <= (others => '0'); + check_vector(1, 24x"FFFFFF"); -- (256) + -- single step ramp-up and ramp down + wait_clk_cycles(5); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(5); + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(4); + check_vector(1, 24x"000001"); + trigger_in <= (others => '0'); + wait_clk_cycles(1); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(5); + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(4); + check_vector(1, 24x"000000"); + trigger_in <= (others => '0'); + wait_clk_cycles(5); + trigger_in <= (4 => '1', 5 => '1', others => '0'); + wait until busy = '0'; + check_vector(1, 24x"000002"); + + -- Now restart check the saturation mechanism of the ramp-vector + trigger_in <= (others => '0'); + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(54, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + wait_clk_cycles(10); + for n in 0 to 63 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + end loop; -- n + check_vector(1, 24x"3FFF"); + wait_clk_cycles(1); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(4); + trigger_in <= (others => '0'); + for n in 0 to 63 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + end loop; -- n + check_vector(1, 24x"0000"); + wait_clk_cycles(10); + + -- Now check the VEC-RAMP instruction (Ramp-to-value) + trigger_in <= (others => '0'); + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(352, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + wait_clk_cycles(10); + for n in 0 to 31 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + --wait_clk_cycles(1); + end loop; -- n + check_vector(1, 24x"0080"); + wait_clk_cycles(1); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(4); + trigger_in <= (others => '0'); + for n in 0 to 63 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + --wait_clk_cycles(1); + end loop; -- n + check_vector(1, 24x"0000"); + wait_clk_cycles(10); + + wait_clk_cycles(1); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(4); + trigger_in <= (others => '0'); + for n in 0 to 7 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + end loop; -- n + check_vector(1, 24x"3FF8"); + + for n in 0 to 3 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + end loop; -- n + check_vector(1, 24x"3FFC"); + + for n in 0 to 7 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + end loop; -- n + check_vector(1, 24x"3FF4"); + + wait_clk_cycles(10); + for n in 0 to 16 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + end loop; -- n + check_vector(1, 24x"3FE0"); + + wait_clk_cycles(1); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(4); + trigger_in <= (others => '0'); + + wait_clk_cycles(10); + for n in 0 to 16 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + end loop; -- n + -- Here you get "3FFF" instead of "3FFC" because the saturation mechanism + -- kicks in + check_vector(1, 24x"3FFF"); + + wait_clk_cycles(1); + trigger_in <= (5 => '1', others => '0'); + wait_clk_cycles(4); + trigger_in <= (others => '0'); + + wait_clk_cycles(10); + for n in 0 to 16 loop + trigger_in <= (4 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(3); + end loop; -- n + check_vector(1, 24x"0000"); + + + + log("Completed.", VLOW); + + wait_clk_cycles(50); + + --------------------------------------------------------------------------- + -- Verify BUS_BURST + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("Verifying BUS-BURST instruction ...", VLOW); + + -- Issue a start request + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(4*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + wait_clk_cycles(10); + trigger_in <= (0 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(2); + if(bus_valid /='1') then + wait until bus_valid = '1'; + end if; + bus_ack <= '1'; + check_burst_data(X"DEADBEEF", 1); + wait_clk_cycles(2); + check_burst_data(X"BADA5555", 1); + wait_clk_cycles(2); + check_burst_data(X"CAFEF00D", 1); + wait_clk_cycles(2); + check_burst_data(X"DEADBEEF", 1); + wait_clk_cycles(4); + check_burst_data(X"FFFF0000", 1); + wait_clk_cycles(4); + check_burst_data(X"0000FFFF", 1); + + wait until bus_valid = '0'; + bus_ack <= '0'; + wait_clk_cycles(10); + + -- Repeat the procedure, but this time assert bus_ack one cycle at the time + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(4*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + wait_clk_cycles(10); + trigger_in <= (0 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(5); + bus_ack <= '1'; + --wait_clk_cycles(1); + --bus_ack <= '0'; + check_burst_data(X"DEADBEEF", 1); + wait_clk_cycles(1); + bus_ack <= '0'; + wait_clk_cycles(3); + bus_ack <= '1'; + check_burst_data(X"BADA5555", 1); + wait_clk_cycles(1); + bus_ack <= '0'; + wait_clk_cycles(1); + bus_ack <= '1'; + check_burst_data(X"CAFEF00D", 1); + wait_clk_cycles(1); + bus_ack <= '0'; + wait_clk_cycles(3); + bus_ack <= '1'; + check_burst_data(X"DEADBEEF", 1); + wait_clk_cycles(1); + bus_ack <= '0'; + wait_clk_cycles(3); + bus_ack <= '1'; + check_burst_data(X"FFFF0000", 1); + wait_clk_cycles(1); + bus_ack <= '0'; + wait_clk_cycles(3); + bus_ack <= '1'; + check_burst_data(X"0000FFFF", 1); + wait_clk_cycles(1); + bus_ack <= '0'; + + wait until busy = '0'; + wait_clk_cycles(10); + + log("Completed.", VLOW); + + -------------------------------------------------------------------------- + -- Verify POS_STORE, POS_WAIT + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("Verifying POS_STORE, POS_WAIT instructions ...", VLOW); + + -- Issue a start request + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(6*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + wait_clk_cycles(10); + pos_in <= std_logic_vector(to_unsigned(100, POS_WIDTH)); + check_vector(10, 24x"1"); + wait_clk_cycles(1); + pos_in <= std_logic_vector(to_unsigned(150, POS_WIDTH)); + check_vector(10, 24x"2"); + wait_clk_cycles(1); + pos_in <= std_logic_vector(to_unsigned(100, POS_WIDTH)); + check_vector(10, 24x"3"); + wait_clk_cycles(1); + pos_in <= std_logic_vector(to_unsigned(120, POS_WIDTH)); + check_vector(10, 24x"4"); + wait_clk_cycles(1); + + pos_in <= (others => '0'); + if(busy /= '0') then + wait until busy = '0'; + end if; + wait_clk_cycles(10); + + -- check the value of pos_store + csr_read(CSR_POS_STORE_ADDR, data); + if(data(23 downto 0) /= std_logic_vector(to_unsigned(100, POS_WIDTH))) then + log("ERROR: Read pos_stored = 0x" & to_hstring(data(23 downto 0)) & ", expected = 0x" & to_hstring(std_logic_vector(to_unsigned(100, POS_WIDTH))) & ".", VLOW); + error_flag <= true; + wait; + end if; + + log("Completed.", VLOW); + + -------------------------------------------------------------------------- + -- Verify JUMP, RETURN + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("Verifying JUMP, RETURN, instructions ...", VLOW); + + -- Issue a start request + trigger_in <= (others => '0'); + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(8*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + + wait_clk_cycles(10); + check_vector(10, 24x"0"); + wait_clk_cycles(1); + trigger_in <= (0 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + check_vector(10, 24x"F0"); + wait_clk_cycles(1); + trigger_in <= (0 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + check_vector(vect_out_lat+4, 24x"1"); + check_vector(6, 24x"F1"); + check_vector(6, 24x"2"); + + if(busy /= '0') then + wait until busy = '0'; + end if; + + log("Completed.", VLOW); + + -------------------------------------------------------------------------- + -- Verify JUMP, ALU + --------------------------------------------------------------------------- + + wait_clk_cycles(20); + + log_separator_line(VLOW); + log("Verifying JUMP, ALU instructions ...", VLOW); + + -- Issue a start request + trigger_in <= (others => '0'); + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(9*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + + wait_clk_cycles(10); + check_vector(10, 24x"0"); + wait_clk_cycles(1); + trigger_in <= (0 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + check_vector(vect_out_lat+7, 24x"1"); + wait_clk_cycles(1); + trigger_in <= (0 => '1', 1 => '1', 2 => '1', 3 => '1', others => '0'); + wait_clk_cycles(1); + check_vector(vect_out_lat+4, 24x"E0"); + check_vector(6, 24x"2"); + check_vector(12, 24x"3"); + check_vector(9, 24x"E1"); + check_vector(6, 24x"4"); + check_vector(12, 24x"E1"); + check_vector(6, 24x"5"); + check_vector(9, 24x"E1"); + check_vector(6, 24x"6"); + check_vector(12, 24x"E1"); + check_vector(6, 24x"7"); + check_vector(12, 24x"E1"); + check_vector(6, 24x"8"); + check_vector(6, 24x"E1"); + check_vector(6, 24x"9"); + + if(busy /= '0') then + wait until busy = '0'; + end if; + + log("Completed.", VLOW); + + wait_clk_cycles(10); + + -------------------------------------------------------------------------- + -- Verify BRANCH, ALU + --------------------------------------------------------------------------- + + wait_clk_cycles(20); + + log_separator_line(VLOW); + log("Verifying BRANCH, ALU instructions ...", VLOW); + + -- Issue a start request + trigger_in <= (others => '0'); + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(12*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + + wait_clk_cycles(10); + check_vector(10, 24x"0"); + wait_clk_cycles(1); + trigger_in <= (0 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + check_vector(vect_out_lat+7, 24x"1"); + check_vector(9, 24x"2"); + check_vector(9, 24x"3"); + check_vector(6, 24x"4"); + + if(busy /= '0') then + wait until busy = '0'; + end if; + + log("Completed.", VLOW); + + wait_clk_cycles(10); + + -------------------------------------------------------------------------- + -- Verify LOOP + --------------------------------------------------------------------------- + + wait_clk_cycles(20); + + log_separator_line(VLOW); + log("Verifying LOOP instruction ...", VLOW); + + -- Issue a start request + trigger_in <= (others => '0'); + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(16*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + + wait_clk_cycles(10); + check_vector(10, 24x"0"); + wait_clk_cycles(1); + trigger_in <= (0 => '1', others => '0'); + wait_clk_cycles(1); + trigger_in <= (others => '0'); + wait_clk_cycles(2); + for n in 0 to 4 loop + check_vector(3, 24x"AAA"); + check_vector(3, 24x"555"); + wait_clk_cycles(3); + end loop; -- n + for n in 0 to 1 loop + check_vector(3, 24x"BBB"); + check_vector(3, 24x"CCC"); + wait_clk_cycles(3); + end loop; -- n + check_vector(3, 24x"DDD"); + wait_clk_cycles(3); + check_vector(3, 24x"EEE"); + + if(busy /= '0') then + wait until busy = '0'; + end if; + + log("Completed.", VLOW); + + wait_clk_cycles(10); + + --------------------------------------------------------------------------- + -- Check the Sequencer in DEBUG mode + --------------------------------------------------------------------------- + + wait_clk_cycles(20); + + log_separator_line(VLOW); + log("Verifying Debug mode ...", VLOW); + + -- Enable Debug mode + csr_write(CSR_CTRL_W_ADDR, 32x"9"); + wait_clk_cycles(5); + + -- set the vector value + csr_write(CSR_VECTOR_ADDR, 32x"AA"); + + -- set R1 value + csr_write(CSR_R1_ADDR, 32x"ABC"); + + -- Issue a start request + trigger_in <= 12x"123"; + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(17*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + wait_clk_cycles(20); + + for n in 0 to 63 loop + csr_write(CSR_STEP_ADDR, 32x"1"); + wait_clk_cycles(3); + + if(busy = '0') then + exit; + end if; + + end loop; -- n + + csr_read(CSR_PC_ADDR, data); + if(data(15 downto 0) /= X"0113") then + log("ERROR: PC counter value is = 0x" & to_hstring(data) & ", expected = 0x0113.", VLOW); + error_flag <= true; + wait; + end if; + + csr_read(CSR_VECTOR_ADDR, data); + if(data /= X"000000DD") then + log("ERROR: vector-out value is = 0x" & to_hstring(data) & ", expected = 0x000000DD.", VLOW); + error_flag <= true; + wait; + end if; + + csr_read(CSR_R1_ADDR, data); + if(data /= X"00000ABC") then + log("ERROR: R1 value is = 0x" & to_hstring(data) & ", expected = 0x00000ABC.", VLOW); + error_flag <= true; + wait; + end if; + + csr_read(CSR_TRIGGER_ADDR, data); + if(data /= X"00000123") then + log("ERROR: trigger value is = 0x" & to_hstring(data) & ", expected = 0x00000123.", VLOW); + error_flag <= true; + wait; + end if; + + -- Disable Debug mode + if(busy /= '0') then + wait until busy = '0'; + end if; + csr_write(CSR_CTRL_W_ADDR, 32x"1"); + wait_clk_cycles(5); + + log("Completed.", VLOW); + + wait_clk_cycles(10); + + --------------------------------------------------------------------------- + -- Quick Test + --------------------------------------------------------------------------- + + wait_clk_cycles(20); + + log_separator_line(VLOW); + log("Verifying Quick Test ...", VLOW); + + -- Issue a start request + trigger_in <= 12x"0"; + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(18*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + wait_clk_cycles(20); + + for n in 0 to 63 loop + csr_read(CSR_PC_ADDR, data); + wait_clk_cycles(5); + end loop; + + log("Completed.", VLOW); + + wait_clk_cycles(10); + + --------------------------------------------------------------------------- + -- End-and-Queue Test + --------------------------------------------------------------------------- + + wait_clk_cycles(20); + + log_separator_line(VLOW); + log("Verifying End-and-Queue ...", VLOW); + + -- Queue up 11 sequences (5 + 1 + 5) + csr_write(CSR_SEQ_QUEUE_W_ADDR, 32x"B"); + -- Verify QUEUE_LEFT is equal to 11 + wait_clk_cycles(2); + csr_read(CSR_SEQ_QUEUE_R_ADDR, data); + if(unsigned(data(15 downto 8)) /= 11) then + log("ERROR: detected " & to_string(to_integer(unsigned(data(15 downto 8)))) & " sequences in the queue, expecting 11.", VLOW); + error_flag <= true; + wait; + end if; + + -- Issue a start request + trigger_in <= 12x"0"; + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned(19*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + wait_clk_cycles(5); + trigger_in <= 12x"1"; + + wait_clk_cycles(1); + check_vector(6, 24x"A11"); + check_vector(10, 24x"A22"); + check_vector(10, 24x"A33"); + check_vector(10, 24x"A44"); + check_vector(10, 24x"A55"); + check_vector(10, 24x"B00"); + + -- block the execution by de-asserting the trigger + trigger_in <= 12x"0"; + -- check that seq_queue_empty is de-asserted + csr_read(CSR_CTRL_R_ADDR, data); + if(data(10) = '1') then + log("ERROR: detected SEQ_QUEUE_EMPTY", VLOW); + error_flag <= true; + wait; + end if; + -- restart the execution + trigger_in <= 12x"1"; + wait_clk_cycles(5); + check_vector(10, 24x"A11"); + check_vector(10, 24x"A22"); + check_vector(10, 24x"A33"); + check_vector(10, 24x"A44"); + check_vector(10, 24x"A55"); + check_vector(10, 24x"B00"); + -- check that seq_queue_empty is now asserted + wait_clk_cycles(10); + csr_read(CSR_CTRL_R_ADDR, data); + if(data(10) /= '1') then + log("ERROR: SEQ_QUEUE_EMPTY is not asserted: CSR_CTRL = 0x" & to_hstring(data) & ".", VLOW); + error_flag <= true; + wait; + end if; + -- check the number of executed sequences + csr_read(CSR_SEQ_QUEUE_R_ADDR, data); + if(unsigned(data(31 downto 16)) /= 11) then + log("ERROR: detected " & to_string(to_integer(unsigned(data(31 downto 16)))) & " executed sequences, expecting 11.", VLOW); + error_flag <= true; + wait; + end if; + + -- Add and remove, add again some sequences to the queue + trigger_in <= 12x"0"; + -- Queue up 5 sequences + csr_write(CSR_SEQ_QUEUE_W_ADDR, 32x"5"); + -- Verify QUEUE_LEFT is equal to 5 + wait_clk_cycles(2); + csr_read(CSR_SEQ_QUEUE_R_ADDR, data); + if(unsigned(data(15 downto 8)) /= 5) then + log("ERROR: detected " & to_string(to_integer(unsigned(data(15 downto 8)))) & " sequences in the queue, expecting 5.", VLOW); + error_flag <= true; + wait; + end if; + -- remove 2 sequences from the queue + csr_write(CSR_SEQ_QUEUE_W_ADDR, 24x"0" & X"FE"); + -- Verify QUEUE_LEFT is equal to 2 + wait_clk_cycles(2); + csr_read(CSR_SEQ_QUEUE_R_ADDR, data); + -- Note: only 2 sequences left in the queue because the first one starts the + -- execution as soon as you add to the queue + if(unsigned(data(15 downto 8)) /= 2) then + log("ERROR: detected " & to_string(to_integer(unsigned(data(15 downto 8)))) & " sequences in the queue, expecting 2.", VLOW); + error_flag <= true; + wait; + end if; + + -- try to remove 4 sequences from the queue, and see that the queue goes to + -- zero + csr_write(CSR_SEQ_QUEUE_W_ADDR, 24x"0" & X"FC"); + -- Verify QUEUE_LEFT is equal to 0 + wait_clk_cycles(2); + csr_read(CSR_SEQ_QUEUE_R_ADDR, data); + -- Note: only 2 sequences left in the queue because the first one starts the + -- execution as soon as you add to the queue + if(unsigned(data(15 downto 8)) /= 0) then + log("ERROR: detected " & to_string(to_integer(unsigned(data(15 downto 8)))) & " sequences in the queue, expecting 0.", VLOW); + error_flag <= true; + wait; + end if; + + -- update the sequencer RAM: change the last End-and-Queue instruction with + -- a normal End instruction : this is done by process pCFG_SEQ when + -- update_cfg is asserted + update_cfg <= true; + -- Queue up 5 sequences + csr_write(CSR_SEQ_QUEUE_W_ADDR, 32x"5"); + -- restart the execution + trigger_in <= 12x"1"; + wait_clk_cycles(5); + check_vector(10, 24x"A11"); + check_vector(10, 24x"A22"); + check_vector(10, 24x"A33"); + check_vector(10, 24x"A44"); + check_vector(10, 24x"A55"); + check_vector(10, 24x"B00"); + + wait_clk_cycles(5); + if(busy /= '0') then + log("ERROR: busy flag is still asserted.", VLOW); + error_flag <= true; + wait; + end if; + + log("Completed.", VLOW); + + wait_clk_cycles(10); + + --------------------------------------------------------------------------- + -- BRANCH/ALU Test (2) + --------------------------------------------------------------------------- + + wait_clk_cycles(20); + + log_separator_line(VLOW); + log("Verifying BRANCH, ALU instructions (2) ...", VLOW); + + -- Issue a start request + trigger_in <= (others => '0'); + wait until clk = '1' and clk'event; + start_addr <= std_logic_vector(to_unsigned((16+5)*16, log2(SEQ_DEPTH))); + start_req <= '1'; + wait until clk = '1' and clk'event; + start_req <= '0'; + + -- Issue a trigger event at the time + + check_vector(7, 24x"0"); + check_vector(vect_out_lat+6, 24x"3"); + check_vector(vect_out_lat+6, 24x"7"); + + if(busy /= '0') then + wait until busy = '0'; + end if; + + log("Completed.", VLOW); + + wait_clk_cycles(10); + + --------------------------------------------------------------------------- + -- End + --------------------------------------------------------------------------- + + passed <= true after 100 ns; + wait; + + end process pTEST_PROC; + + failed <= error_flag after 100 ns; + + CHECK_SIM_TIMEOUT: process + begin -- process CHECK_SIM_TIMEOUT + while now < MAX_SIM_TIME loop + wait for 100 us; + end loop; + test_timeout <= true; + wait; + end process CHECK_SIM_TIMEOUT; + + pREPORT_RESULT : process + begin + wait until failed = true or passed = true or test_timeout = true; + wait for 1 us; + log_separator_line(VLOW); + if(failed = true) then + log("FAILURE: test completed with errors.", VLOW); + elsif(passed = true) then + log("SUCCESS: test successfully completed.", VLOW); + elsif(test_timeout = true) then + log("FAILURE: test achieved max-sim-time without reaching ", VLOW); + log(" failed/passed condition.", VLOW); + end if; + log_separator_line(VLOW); + test_completed <= true; + end process pREPORT_RESULT; + +end behav;