ELGIP-51 - Adding generic_sequencer_16 (new ramp instruction)

This commit is contained in:
gianmarcogirau 2020-02-19 16:55:58 +00:00
commit bf83db3d5b
8 changed files with 3236 additions and 0 deletions

View file

@ -0,0 +1,294 @@
[{
"ip_name" : "generic_sequencer_16",
"bus" : "csr",
"addr_width" : "4",
"description" : "Generic Sequencer core",
"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" : "0x10",
"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" : {
"address" : "3",
"width" : "11",
"description" : "Control register",
"fields": {
"seq_enable" : {
"type" : "w",
"bit_len" : "1",
"reset" : "0",
"description" : "Master enable for the sequencer"
},
"reserved_0" : {
"type" : "rsv",
"bit_len" : "1",
"description" : "Reserved bits"
},
"busy" : {
"type" : "r",
"bit_len" : "1",
"reset" : "0",
"description" : "Busy status (writing has no effect---in this register for backwards compatibility)"
},
"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"
},
"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" : "4",
"width" : "32",
"description" : "Configuration values for sequencer",
"fields": {
"ram_rd_addr" : {
"type" : "r",
"bit_len" : "16",
"reset" : "0",
"description" : "Current RAM read address"
},
"return_addr" : {
"type" : "r",
"bit_len" : "16",
"reset" : "0",
"description" : "Current return address"
}
}
},
"trigger" : {
"address" : "5",
"type" : "r",
"width" : "16",
"reset" : "0",
"description" : "Trigger input vector value"
},
"vector" : {
"address" : "6",
"type" : "wp",
"width" : "24",
"reset" : "0",
"description" : "Vector output override from CPU"
},
"r1" : {
"address" : "7",
"type" : "wp",
"width" : "12",
"reset" : "0",
"description" : "R1 register access. Writes only effective when idle."
},
"step" : {
"address" : "8",
"type" : "w0",
"width" : "1",
"reset" : "0",
"description" : "Step request from CPU"
},
"aux_config" : {
"address" : "9",
"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" : "10",
"type" : "r",
"width" : "24",
"reset" : "0",
"subtype" : "signed",
"description" : "value of pos_store"
},
"seq_queue" : {
"address" : "11",
"width" : "32",
"description" : "Sequence Execution Queue",
"fields": {
"queue_add" : {
"type" : "w0",
"bit_len" : "8",
"reset" : "0",
"description" : "Add Sequences to the queue (signed)"
},
"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"
}
}
}
}
},
{
"ip_name" : "generic_sequencer_15",
"bus" : "seq",
"addr_hi_bit" : "8",
"addr_lo_bit" : "0",
"process_regs" : "disabled",
"description" : "This block is the generic sequencer. It is a leaf block for the sequence bus",
"registers" : {
"seq_buff" : {
"address" : "0",
"width" : "32",
"type" : "w",
"reset" : "0",
"description" : "Sequence buffer"
}
}
}]

View file

@ -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)

View file

@ -0,0 +1,60 @@
# 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 ../src/dpram_sclk_16.vhd
vcom -2008 -work $WORKLIB ../src/altera/generic_seq_ram_16.vhd
vcom -2008 -work $WORKLIB ../src/generic_sequencer_16_pkg.vhd
vcom -2008 -work $WORKLIB ../src/generic_sequencer_16.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_16_tb.vhd
vsim -t ps work.generic_sequencer_16_tb
#add wave /generic_sequencer_16_tb/*
#add wave /generic_sequencer_16_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;

View file

@ -0,0 +1,160 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /generic_sequencer_16_tb/clk
add wave -noupdate /generic_sequencer_16_tb/reset_n
add wave -noupdate /generic_sequencer_16_tb/avs_csr_address
add wave -noupdate /generic_sequencer_16_tb/avs_csr_write
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/avs_csr_writedata
add wave -noupdate /generic_sequencer_16_tb/avs_csr_read
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/avs_csr_readdata
add wave -noupdate /generic_sequencer_16_tb/avs_seq_address
add wave -noupdate /generic_sequencer_16_tb/avs_seq_write
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/avs_seq_writedata
add wave -noupdate /generic_sequencer_16_tb/avs_seq_read
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/avs_seq_readdata
add wave -noupdate /generic_sequencer_16_tb/start_req
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/start_addr
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/trigger_in
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/pos_in
add wave -noupdate /generic_sequencer_16_tb/busy
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/vector_out
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/bus_data
add wave -noupdate /generic_sequencer_16_tb/bus_valid
add wave -noupdate /generic_sequencer_16_tb/bus_ack
add wave -noupdate /generic_sequencer_16_tb/setup
add wave -noupdate /generic_sequencer_16_tb/running
add wave -noupdate /generic_sequencer_16_tb/passed
add wave -noupdate /generic_sequencer_16_tb/failed
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/csr_mm_s_rec
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/csr_mm_m_rec
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/seq_mm_s_rec
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/seq_mm_m_rec
add wave -noupdate -divider UUT
add wave -noupdate /generic_sequencer_16_tb/iUUT/clk
add wave -noupdate /generic_sequencer_16_tb/iUUT/reset_n
add wave -noupdate -radix unsigned /generic_sequencer_16_tb/iUUT/avs_csr_address
add wave -noupdate /generic_sequencer_16_tb/iUUT/avs_csr_write
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/avs_csr_writedata
add wave -noupdate /generic_sequencer_16_tb/iUUT/avs_csr_read
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/avs_csr_readdata
add wave -noupdate -radix decimal /generic_sequencer_16_tb/iUUT/avs_seq_address
add wave -noupdate /generic_sequencer_16_tb/iUUT/avs_seq_write
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/avs_seq_writedata
add wave -noupdate /generic_sequencer_16_tb/iUUT/avs_seq_read
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/avs_seq_readdata
add wave -noupdate /generic_sequencer_16_tb/iUUT/start_req
add wave -noupdate -radix hexadecimal -childformat {{/generic_sequencer_16_tb/iUUT/start_addr(8) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/start_addr(7) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/start_addr(6) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/start_addr(5) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/start_addr(4) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/start_addr(3) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/start_addr(2) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/start_addr(1) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/start_addr(0) -radix hexadecimal}} -subitemconfig {/generic_sequencer_16_tb/iUUT/start_addr(8) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/start_addr(7) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/start_addr(6) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/start_addr(5) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/start_addr(4) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/start_addr(3) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/start_addr(2) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/start_addr(1) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/start_addr(0) {-height 15 -radix hexadecimal}} /generic_sequencer_16_tb/iUUT/start_addr
add wave -noupdate -radix hexadecimal -childformat {{/generic_sequencer_16_tb/iUUT/trigger_in(11) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(10) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(9) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(8) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(7) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(6) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(5) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(4) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(3) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(2) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(1) -radix hexadecimal} {/generic_sequencer_16_tb/iUUT/trigger_in(0) -radix hexadecimal}} -subitemconfig {/generic_sequencer_16_tb/iUUT/trigger_in(11) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(10) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(9) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(8) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(7) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(6) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(5) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(4) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(3) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(2) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(1) {-height 15 -radix hexadecimal} /generic_sequencer_16_tb/iUUT/trigger_in(0) {-height 15 -radix hexadecimal}} /generic_sequencer_16_tb/iUUT/trigger_in
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/pos_in
add wave -noupdate /generic_sequencer_16_tb/iUUT/busy
add wave -noupdate /generic_sequencer_16_tb/iUUT/opcode
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/vector_out
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/bus_data
add wave -noupdate /generic_sequencer_16_tb/iUUT/bus_valid
add wave -noupdate /generic_sequencer_16_tb/iUUT/bus_ack
add wave -noupdate /generic_sequencer_16_tb/iUUT/seq_enable
add wave -noupdate /generic_sequencer_16_tb/iUUT/debug_mode
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/return_addr
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/ram_rd_addr
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/ram_rd_data
add wave -noupdate /generic_sequencer_16_tb/iUUT/fsm
add wave -noupdate /generic_sequencer_16_tb/iUUT/fsm_nxt
add wave -noupdate /generic_sequencer_16_tb/iUUT/fetch_enable
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/operand_1
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/operand_2
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/operand_comp
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/subcode
add wave -noupdate /generic_sequencer_16_tb/iUUT/ramp_up
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/ramp_curr
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/ramp_next
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/ramp_final
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/ramp_diff
add wave -noupdate /generic_sequencer_16_tb/iUUT/ramp_diff_top
add wave -noupdate /generic_sequencer_16_tb/iUUT/ramp_to_val
add wave -noupdate /generic_sequencer_16_tb/iUUT/ramp_done
add wave -noupdate /generic_sequencer_16_tb/iUUT/ramp_to_val_last
add wave -noupdate /generic_sequencer_16_tb/iUUT/inc_op_cnt
add wave -noupdate /generic_sequencer_16_tb/iUUT/trig_int
add wave -noupdate /generic_sequencer_16_tb/iUUT/alu_upd
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/r1
add wave -noupdate /generic_sequencer_16_tb/iUUT/inc_ram_addr
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/jump_addr_ext
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/jump_addr
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/pc_value
add wave -noupdate /generic_sequencer_16_tb/iUUT/ld_jmp_addr
add wave -noupdate /generic_sequencer_16_tb/iUUT/jump_abs
add wave -noupdate /generic_sequencer_16_tb/iUUT/jump_rel
add wave -noupdate /generic_sequencer_16_tb/iUUT/clr_seq_queue
add wave -noupdate /generic_sequencer_16_tb/iUUT/clr_seq_queue_i
add wave -noupdate /generic_sequencer_16_tb/iUUT/clr_seq_queue_exe
add wave -noupdate /generic_sequencer_16_tb/iUUT/queue_add_flag
add wave -noupdate /generic_sequencer_16_tb/iUUT/queue_add_flag_d
add wave -noupdate /generic_sequencer_16_tb/iUUT/queue_add_flag_i
add wave -noupdate /generic_sequencer_16_tb/iUUT/queue_inc
add wave -noupdate /generic_sequencer_16_tb/iUUT/queue_dec
add wave -noupdate /generic_sequencer_16_tb/iUUT/seq_completed
add wave -noupdate /generic_sequencer_16_tb/iUUT/seq_queue_empty
add wave -noupdate /generic_sequencer_16_tb/iUUT/set_queue_empty
add wave -noupdate -radix decimal /generic_sequencer_16_tb/iUUT/queue_add
add wave -noupdate -radix decimal /generic_sequencer_16_tb/iUUT/queue_add_i
add wave -noupdate -radix unsigned /generic_sequencer_16_tb/iUUT/queue_left
add wave -noupdate -radix unsigned /generic_sequencer_16_tb/iUUT/queue_exec
add wave -noupdate /generic_sequencer_16_tb/iUUT/jump_r1
add wave -noupdate /generic_sequencer_16_tb/iUUT/loop_active
add wave -noupdate /generic_sequencer_16_tb/iUUT/loop_upd
add wave -noupdate /generic_sequencer_16_tb/iUUT/loop_done
add wave -noupdate -radix unsigned /generic_sequencer_16_tb/iUUT/loop_cnt
add wave -noupdate /generic_sequencer_16_tb/iUUT/ld_trig_mask
add wave -noupdate /generic_sequencer_16_tb/iUUT/ld_trig_sel
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/trig_mask
add wave -noupdate /generic_sequencer_16_tb/iUUT/trig_sel
add wave -noupdate /generic_sequencer_16_tb/iUUT/trig_int
add wave -noupdate /generic_sequencer_16_tb/iUUT/ld_vec
add wave -noupdate /generic_sequencer_16_tb/iUUT/clr_vec_i
add wave -noupdate /generic_sequencer_16_tb/iUUT/clr_vec
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/vector_out_i
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/vector_out
add wave -noupdate /generic_sequencer_16_tb/iUUT/ramp_up
add wave -noupdate /generic_sequencer_16_tb/iUUT/fetch_op
add wave -noupdate /generic_sequencer_16_tb/iUUT/clr_vec_ii
add wave -noupdate /generic_sequencer_16_tb/iUUT/op_cnt
add wave -noupdate /generic_sequencer_16_tb/iUUT/op_cnt_done
add wave -noupdate /generic_sequencer_16_tb/iUUT/inc_op_cnt
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/bus_data
add wave -noupdate /generic_sequencer_16_tb/iUUT/bus_valid
add wave -noupdate /generic_sequencer_16_tb/iUUT/bus_ack
add wave -noupdate /generic_sequencer_16_tb/iUUT/bus_valid_i
add wave -noupdate /generic_sequencer_16_tb/iUUT/bus_pause
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/pos_store
add wave -noupdate /generic_sequencer_16_tb/iUUT/loop_active
add wave -noupdate /generic_sequencer_16_tb/iUUT/vector_val_cpu
add wave -noupdate -radix hexadecimal /generic_sequencer_16_tb/iUUT/vector_cpu
add wave -noupdate /generic_sequencer_16_tb/iUUT/step_req
add wave -noupdate /generic_sequencer_16_tb/iUUT/rst_vector_out
add wave -noupdate /generic_sequencer_16_tb/iUUT/pos_target
add wave -noupdate /generic_sequencer_16_tb/iUUT/ld_ret_addr
add wave -noupdate /generic_sequencer_16_tb/iUUT/save_ret_addr
add wave -noupdate /generic_sequencer_16_tb/iUUT/r1_data
add wave -noupdate /generic_sequencer_16_tb/iUUT/r1_data_valid
add wave -noupdate /generic_sequencer_16_tb/iUUT/decode
add wave -noupdate /generic_sequencer_16_tb/iUUT/busy_i
add wave -noupdate /generic_sequencer_16_tb/iUUT/ld_start_addr
add wave -noupdate /generic_sequencer_16_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}

View file

@ -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

View file

@ -0,0 +1,839 @@
-------------------------------------------------------------------------------
-- Title : generic_sequencer
-- Project : Generic Components
-------------------------------------------------------------------------------
-- File : generic_sequencer.vhd
-- Author : Robbie Temple (original)
-- Company : Global Inkjet Systems
-- Created : 2016-05-12
-- Last update: 2020-02-19
-- 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_16_pkg.all;
entity generic_sequencer_16 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_RAMP_EN : boolean := false;
BUS_BURST_EN : boolean := false;
POS_BUS_EN : boolean := false;
ALU_EN : boolean := false;
QUEUE_EN : boolean := false);
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_16;
architecture rtl of generic_sequencer_16 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);
begin
-----------------------------------------------------------------------------
-- Control & Status Registers
-----------------------------------------------------------------------------
--
-- The process manages the Control and Status registers
--
AVS_PROC : process(clk, reset_n) is
begin
if reset_n = '0' then
avs_csr_readdata <= (others => '0');
seq_enable <= '0';
rst_vector_out <= '0';
debug_mode <= '0';
vector_val_cpu <= '0';
vector_cpu <= (others => '0');
step_req <= '0';
clr_seq_queue <= '0';
clr_seq_queue_exe <= '0';
seq_queue_empty <= '0';
elsif clk'event and clk = '1' then
--
avs_csr_readdata <= (others => '0');
vector_val_cpu <= '0';
step_req <= '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 avs_csr_write = '1' then
case avs_csr_address is
when CSR_CTRL_ADDR =>
seq_enable <= avs_csr_writedata(0);
rst_vector_out <= avs_csr_writedata(4);
if (QUEUE_EN = true) then
clr_seq_queue <= avs_csr_writedata(8);
clr_seq_queue_exe <= avs_csr_writedata(9);
end if;
if fsm = s_idle then
debug_mode <= avs_csr_writedata(3);
end if;
when CSR_VECTOR_ADDR =>
if fsm = s_idle then
vector_val_cpu <= '1';
vector_cpu <= avs_csr_writedata(VECTOR_WIDTH - 1 downto 0);
end if;
when CSR_STEP_ADDR =>
step_req <= '1';
when CSR_R1_ADDR =>
if (ALU_EN = true) then
r1_data <= avs_csr_writedata(R1_data'range);
r1_data_valid <= '1';
end if;
when CSR_SEQ_QUEUE_ADDR =>
if (QUEUE_EN = true) then
queue_add_flag <= '1';
queue_add <= avs_csr_writedata(7 downto 0);
end if;
when others => null;
end case;
elsif avs_csr_read = '1' then
case avs_csr_address is
when CSR_IP_ID_ADDR =>
avs_csr_readdata <= CSR_IP_ID;
when CSR_IP_VER_ADDR =>
avs_csr_readdata <= CSR_IP_VER;
when CSR_CONFIG_ADDR =>
avs_csr_readdata <= "00" & std_logic_vector(to_unsigned(TRIGGER_WIDTH, 6)) & std_logic_vector(to_unsigned(VECTOR_WIDTH, 6)) & std_logic_vector(to_unsigned(BUS_WIDTH, 6)) & std_logic_vector(to_unsigned(POS_WIDTH, 6)) & std_logic_vector(to_unsigned(log2(SEQ_DEPTH), 6));
when CSR_CTRL_ADDR =>
avs_csr_readdata <= 21x"0" & seq_queue_empty & 5x"0" & rst_vector_out & debug_mode & busy & '0' & seq_enable;
seq_queue_empty <= '0';
when CSR_PC_ADDR =>
avs_csr_readdata(log2(SEQ_DEPTH) - 1 + 16 downto 16) <= return_addr;
avs_csr_readdata(log2(SEQ_DEPTH) - 1 downto 0) <= pc_value;
when CSR_TRIGGER_ADDR =>
avs_csr_readdata(TRIGGER_WIDTH - 1 downto 0) <= trigger_in;
when CSR_VECTOR_ADDR =>
avs_csr_readdata(VECTOR_WIDTH - 1 downto 0) <= vector_out;
when CSR_R1_ADDR =>
if(ALU_EN = true) then
avs_csr_readdata(11 downto 0) <= r1;
end if;
when CSR_AUX_CONFIG_ADDR =>
avs_csr_readdata <= seq_cfg_aux;
when CSR_POS_STORE_ADDR =>
if(POS_BUS_EN = true) then
avs_csr_readdata(POS_WIDTH - 1 downto 0) <= pos_store;
end if;
when CSR_SEQ_QUEUE_ADDR =>
if (QUEUE_EN = true) then
avs_csr_readdata <= queue_exec & queue_left & x"00";
end if;
when others => null;
end case;
end if;
end if;
end process AVS_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.generic_seq_ram_16
generic map(
SEQ_DEPTH => SEQ_DEPTH)
port map(
clock => clk,
address_a => avs_seq_address,
wren_a => avs_seq_write,
data_a => avs_seq_writedata,
q_a => avs_seq_readdata,
address_b => ram_rd_addr,
wren_b => '0',
data_b => (others => '0'),
q_b => ram_rd_data);
-----------------------------------------------------------------------------
-- Sequencer Logic
-----------------------------------------------------------------------------
opcode <= ram_rd_data(31 downto 28);
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;
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) then
if(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;
end if;
elsif (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_next <= (others => '0');
ramp_up <= '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;

View file

@ -0,0 +1,58 @@
-------------------------------------------------------------------------------
-- Title : generic_sequencer_16_pkg
-- Project : Generic IPs
-------------------------------------------------------------------------------
-- File : generic_sequencer_16_pkg.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2018-01-17
-- Last update: 2020-02-18
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Package defining common constants for generic_sequencer_16 core, such as
-- Control & Status registers offset etc.
-------------------------------------------------------------------------------
-- 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_16_pkg is
constant CSR_IP_ID_ADDR : std_logic_vector(3 downto 0) := x"0";
constant CSR_IP_VER_ADDR : std_logic_vector(3 downto 0) := x"1";
constant CSR_CONFIG_ADDR : std_logic_vector(3 downto 0) := x"2";
constant CSR_CTRL_ADDR : std_logic_vector(3 downto 0) := x"3";
constant CSR_PC_ADDR : std_logic_vector(3 downto 0) := x"4";
constant CSR_TRIGGER_ADDR : std_logic_vector(3 downto 0) := x"5";
constant CSR_VECTOR_ADDR : std_logic_vector(3 downto 0) := x"6";
constant CSR_R1_ADDR : std_logic_vector(3 downto 0) := x"7"; -- write only works when sequencer idle
constant CSR_STEP_ADDR : std_logic_vector(3 downto 0) := x"8";
constant CSR_AUX_CONFIG_ADDR : std_logic_vector(3 downto 0) := x"9";
constant CSR_POS_STORE_ADDR : std_logic_vector(3 downto 0) := x"A";
constant CSR_SEQ_QUEUE_ADDR : std_logic_vector(3 downto 0) := x"B";
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_16_pkg;

File diff suppressed because it is too large Load diff