コード例 #1
0
def gen_bg_hex_files(c_nof_values = 1024, c_nof_streams = 4):
    data = [] 
    for i in range(c_nof_streams): 
        stream_re = []
        stream_im = []
        for j in range(c_nof_values): 
            stream_re.append(j)
            stream_im.append(i)
        data_concat = dsp_test_bg.concatenate_two_lists(stream_re, stream_im, c_in_dat_w)
        data.append(data_concat)
        #filename = "../../src/hex/tb_bg_dat_" + str(i) + ".hex"
        filename = os.environ["UNB"] + "/Firmware/modules/ddr3/src/hex/tb_bg_dat_" + str(i) + ".hex"
        mem_init_file.list_to_hex(list_in=data_concat, filename=filename, mem_width=c_nof_complex*c_in_dat_w, mem_depth=2**(ceil_log2(c_bg_ram_size)))
    return data
コード例 #2
0
def gen_bg_hex_files(c_framesize = 64, c_nof_frames = 32, c_nof_streams = 4):
    data = [] 
    for i in range(c_nof_streams): 
        stream_re = []
        stream_im = []
        for j in range(c_nof_frames): 
            for k in range(c_framesize): 
                stream_re.append(k)
                stream_im.append(j)  
        data_concat = dsp_test_bg.concatenate_two_lists(stream_re, stream_im, c_in_dat_w)
        data.append(data_concat)
        filename = "../../src/hex/tb_bg_dat_" + str(i) + ".hex"
        mem_init_file.list_to_hex(list_in=data_concat, filename=filename, mem_width=c_nof_complex*c_in_dat_w, mem_depth=2**(ceil_log2(c_bg_ram_size)))
    return data
コード例 #3
0
def gen_data_and_hex_files_bf_ss_wide(gen_hex=True):        
    # Apply simple SS wide scheme to select e.g. nof_beams_per_subband=4 sets of equal subbands per bf_unit.
    # . The nof_beams_per_subband must be <= c_nof_subbands=24, because that is the maximum number of different subbands that is available
    # . In this simple scheme the nof_beams_per_subband needs to be a divider of c_nof_weights=256, so a power of 2
    nof_beams_per_subband = 4
    select_buf = []
    for i in range(c_nof_signal_paths_per_stream):  # iterates over the number of single ss units
        select_buf_line = []
        for j in range(nof_beams_per_subband):
            for k in range(c_nof_weights/nof_beams_per_subband): 
                select_buf_line.append(i*c_nof_subbands + j) 
        if (gen_hex == True): 
            filename = "../../src/hex/ss_wide_" + str(i) + ".hex"
            mem_init_file.list_to_hex(list_in=select_buf_line, filename=filename, mem_width=ceil_log2(c_nof_subbands_per_stream), mem_depth=c_nof_weights)
        select_buf.append(select_buf_line)
    return select_buf    
コード例 #4
0
def gen_data_and_hex_files_bf_weights(gen_hex=True, sel='noise', ampl=1.0):    
    weightsBfUnit=[]
    ampl = ampl * 1.0 # Force to float
    for i in range(c_nof_signal_paths):
        singleList_real   = dsp_test_weights.create_waveform(sel, ampl, seed=2*i, noiseLevel=0, length=c_nof_weights)
        singleList_imag   = dsp_test_weights.create_waveform(sel, ampl, seed=2*i+1, noiseLevel=0, length=c_nof_weights)
        singleList_real   = dsp_test_weights.quantize_waveform(singleList_real)
        singleList_imag   = dsp_test_weights.quantize_waveform(singleList_imag)
        if c_debug_print and i==0:
            print "singleList_real = %s" % singleList_real
        weightsSignalPath = dsp_test_weights.concatenate_two_lists(singleList_real, singleList_imag, c_in_weight_w)
        if (gen_hex == True):
            filename = "../../src/hex/weights_" + str(i) + ".hex"
            mem_init_file.list_to_hex(list_in=weightsSignalPath, filename=filename, mem_width=2*c_in_weight_w, mem_depth=c_nof_weights)
        weightsBfUnit.append(weightsSignalPath)
    return weightsBfUnit    
コード例 #5
0
def gen_data_and_hex_files_bg(gen_hex=True, sel='noise', ampl=1.0):
    multiStream = []
    ampl = ampl * 1.0 # Force to float
    for i in xrange(c_nof_input_streams): 
        singleStream_real = dsp_test_bg.create_waveform(sel, ampl, seed=2*i, noiseLevel=0, length=c_nof_subbands_per_stream)
        singleStream_imag = dsp_test_bg.create_waveform(sel, ampl, seed=2*i+1, noiseLevel=0, length=c_nof_subbands_per_stream)
        singleStream_real = dsp_test_bg.quantize_waveform(singleStream_real)
        singleStream_imag = dsp_test_bg.quantize_waveform(singleStream_imag)
        singleStream      = dsp_test_bg.concatenate_two_lists(singleStream_real, singleStream_imag, c_in_dat_w)
        if c_debug_print and i==0:
            print "singleStream_real = %s" % singleStream_real
        if (gen_hex == True):
            filename = "../../src/hex/tb_bg_dat_" + str(i) + ".hex"
            mem_init_file.list_to_hex(list_in=singleStream, filename=filename, mem_width=2*c_in_dat_w, mem_depth=2**(ceil_log2(c_nof_subbands_per_stream)))
        multiStream.append(singleStream)
    return multiStream
コード例 #6
0
def gen_correlator_snk_in_arr_hex(input_lists):
    """
    bla
    """
    concat_input_lists = concat_complex_2arr(input_lists, NOF_INPUTS, NOF_CHANNELS, COMPLEX_WIDTH)

    # ==========================================================
    # Interleave the lists if user wants folded correlator input
    # . Note: no support for more than 1 fold yet.
    # ==========================================================
    if NOF_INPUT_FOLDS==1:
        input_stream_lists = []
        for input_stream_nr in range(NOF_INPUT_STREAMS):
            input_stream_lists.append( interleave([concat_input_lists[2*input_stream_nr], concat_input_lists[2*input_stream_nr+1]] ) )
    elif NOF_INPUT_FOLDS==0:
        input_stream_lists = concat_input_lists
    
    # ====================
    # Write the HEX files
    # ====================
    for input_stream_nr in range(NOF_INPUT_STREAMS):
        list_to_hex( input_stream_lists[input_stream_nr], PATH+"/"+FILENAME+"_"+str(COMPLEX_WIDTH)+'b_fold_'+str(NOF_INPUT_FOLDS)+'_'+str(input_stream_nr)+".hex", MEM_WIDTH, MEM_DEPTH)
            for j in xrange(0, c_samples_per_packet):
                real = h & (2**c_in_dat_w-1)   # Node number in real part
                imag = i & (2**c_in_dat_w-1)   # Streamnumber in imag part
                data.append((imag << c_in_dat_w) + real)   
            nodeData.append(data)
        dataList.append(nodeData)

    inputData = []
    in_h = 0
    for h in tc.nodeNrs:   
        for i in xrange(g_nof_input_streams):
            if c_write_bg_data == True:      
                bg.write_waveform_ram(dataList[in_h][i], i, [h])
            if c_write_bg_data_to_file == True:                                                                   
                filename = "../../src/hex/node" + str(h) + "/bg_in_data_" + str(i) + ".hex"
                mem_init_file.list_to_hex(list_in=dataList[in_h][i], filename=filename, mem_width=c_nof_complex*c_in_dat_w, mem_depth=2**(ceil_log2(c_bg_ram_size)))
            dataListComplex = bg.convert_concatenated_to_complex(dataList[in_h][i], c_in_dat_w)
            inputData.append(dataListComplex)  
        in_h = in_h+1
    
    # - Enable the block generator
    tc.append_log(3, '>>>')
    tc.append_log(3, '>>> Start the block generator')
    tc.append_log(3, '>>>')
    tc.append_log(3, '')
    
    bg.write_enable_pps()
    
#    bsn.read_bsn_monitor(0)
#    bsn.read_bsn_monitor(1)
   
コード例 #8
0
print 'Creating settings for for 9 SB, 96 SP'
print '====================================='

[result, Rin, Dram, Dsel, Rout, Errout] = ss.create_settings(din, dout)

# =====================================================
# Create the selection buffer values from the settings:
# =====================================================
reorder_in_buf  = ss.ssReorderIn.create_selection_buf(Rin)
select_buf = flatten(Dsel) 
reorder_out_buf = ss.ssReorderOut.create_selection_buf(Rout)

# ================================
# Generate hex file: input reorder
# ================================
list_to_hex(reorder_in_buf, HEX_REORDER_IN_FILE_NAME, HEX_REORDER_IN_MEM_WIDTH, HEX_REORDER_IN_MEM_DEPTH)

# ===========================
# Generate hex files: ss_wide
# ===========================
# First replace the don't cares (-1) with zeroes for list_to_hex (requires integers)
for n,i in enumerate(select_buf):
    if i==-1:
        select_buf[n]=0


# The created select_buf is a flat list meant to MM write to several instances 
# from a certain offset. However, we want to create a HEX file for each
# individual instance, so split the list into 2 (sublist size of 864).
for i, sublist in zip(range(2), split_list(select_buf, 864)):
    list_to_hex(sublist, HEX_SS_WIDE_FILE_PREFIX+str(i)+".hex", HEX_SS_WIDE_MEM_WIDTH, HEX_SS_WIDE_MEM_DEPTH)
コード例 #9
0
g_rd_chunksize     = 16  

c_frame_size        = g_wr_chunksize

c_nof_int_streams   = 1

c_interleave        = 2  

###############################################################################

#

# Create setting for the pre-transpose (subbandselect)

#

###############################################################################

ss_list = []

for h in range(g_wr_chunksize/c_interleave):
    for i in range(g_rd_chunksize):
        for j in range(c_interleave):
            ss_list.append(h*c_interleave + i*g_nof_weights + j)

c_in_dat_w = ceil_log2(g_nof_weights*g_rd_chunksize) # 12
c_mem_depth = g_rd_chunksize * g_wr_chunksize

filename = "../hex/ss_ss_wide_transp.hex"
mem_init_file.list_to_hex(list_in=ss_list, filename=filename, mem_width=c_in_dat_w, mem_depth=c_mem_depth)
      bg.write_block_gen_settings(256, g_blocks_per_sync, 0, 0, 127, c_bsn_init)
  else:
      bg.write_block_gen_settings(c_samples_per_packet, g_blocks_per_sync, c_gapsize, c_mem_low_addr, c_mem_high_addr, c_bsn_init)
  
  # - Create a list with the input data and write it to the RAMs of the block generator
  tc.append_log(3, '>>>')
  tc.append_log(3, '>>> Write data to the waveform RAM of all channels')
  tc.append_log(3, '>>>')
  inputData = []
  for i in xrange(g_nof_input_streams):
      dataList = bg.generate_data_list(c_nof_sp_per_input_stream, g_nof_subbands, 2048*i*4, i, c_bf_in_dat_w)
      if c_write_bg_data == True:                                                                   
          bg.write_waveform_ram(dataList, i)
      if c_write_bg_data_to_file == True:                                                                   
          filename = "../../src/hex/bg_in_data_" + str(i) + ".hex"
          mem_init_file.list_to_hex(list_in=dataList, filename=filename, mem_width=c_nof_complex*c_bf_in_dat_w, mem_depth=2**(ceil_log2(c_bg_ram_size)))
      dataListComplex = bg.convert_concatenated_to_complex(dataList, c_bf_in_dat_w)
      inputData.append(dataListComplex)
  
  ################################################################################
  ##
  ## Create and Write the weight factors 
  ##
  ################################################################################
  tc.append_log(3, '>>>')
  tc.append_log(3, '>>> Create and write weightfactors for all signal paths on all bf_units ')
  tc.append_log(3, '>>>')
 
  weightsNodes = []
  for k in xrange(tc.nofFnNodes):                    
      weightsBf = []
コード例 #11
0
###############################################################################
# USR header
###############################################################################
usr_hdr = 0
usr_hdr_bytes = CommonBytes(usr_hdr, USR_HDR_LENGTH)

###############################################################################
# Total header
###############################################################################
tot_hdr_bytes = eth_hdr_bytes & ip_hdr_bytes & udp_hdr_bytes & usr_hdr_bytes

###############################################################################
# Convert header bytes to 64b word list
# . The LS word of the RAM is released first. We want the MS part of the header
#   to be released into the MAC first, so we must fill the 64b word list in
#   reverse.
###############################################################################
tot_hdr_words = CommonWords64(tot_hdr_bytes.data, NOF_HDR_WORDS)

word_list = []
for w in reversed(range(NOF_HDR_WORDS)):
    word_list.append(tot_hdr_words[w])
    print "w=", w, " data=", hex(tot_hdr_words[w])

###############################################################################
# Generate the HEX file
###############################################################################
print "Generating hex file:", FILENAME
list_to_hex(word_list, FILENAME, MEM_WIDTH, MEM_DEPTH)
print "Done."
input_signals_concat_reordered[2] = input_signals_concat[6]
input_signals_concat_reordered[17] = input_signals_concat[5]
input_signals_concat_reordered[9] = input_signals_concat[4]
input_signals_concat_reordered[1] = input_signals_concat[3]
input_signals_concat_reordered[16] = input_signals_concat[2]
input_signals_concat_reordered[8] = input_signals_concat[1]
input_signals_concat_reordered[0] = input_signals_concat[0]

###############################################################################
# Interleave 2 lists into one
###############################################################################
input_signals_concat_inter = []
for i in range(NOF_INPUTS):
    input_signals_concat_inter.append(
        interleave([input_signals_concat_reordered[2 * i], input_signals_concat_reordered[2 * i + 1]])
    )

###############################################################################
# Use this list for each block generator
###############################################################################
bg_lists = input_signals_concat_inter

###############################################################################
# Write the HEX files
###############################################################################
MEM_WIDTH = COMPLEX_WIDTH * 2
MEM_DEPTH = 2 * NOF_WORDS_PER_BLOCK  # We're interleaving, hence twice the depth

for input_nr in range(NOF_INPUTS):
    list_to_hex(bg_lists[input_nr], PATH + "/" + FILENAME + "_" + str(input_nr) + ".hex", MEM_WIDTH, MEM_DEPTH)
FILENAME = "diag_bg_subband_dat_8b"

MEM_WIDTH = 16
MEM_DEPTH = 256 

NOF_LANES = 12
NOF_SP_PER_LANE = 8
NOF_SB_PER_LANE = 9

# ============================
# Create a list of 12 sublists
# ============================
subband_streams = [] # array of 12 streams (lists)
for lane in range(NOF_LANES):
    lane_stream_re = [] # one stream with 9 subbands
    lane_stream_im = []
    for subband in range(NOF_SB_PER_LANE):
        # Append a block of 8 signal paths to real stream
        lane_stream_re.append( range(lane*NOF_SP_PER_LANE, (lane+1)*NOF_SP_PER_LANE, 1) )
        # Append a block of 8 subband IDs to imag stream       
        lane_stream_im.append( NOF_SP_PER_LANE*[subband] )
    # Now interleave the real stream with the imag stream and append it to our subband stream array 0..11
    subband_streams.append( interleave([flatten(lane_stream_re), flatten(lane_stream_im)]))

# ===================================
# Write the 12 subband data HEX files
# ===================================
for lane in range(NOF_LANES):
    list_to_hex(subband_streams[lane], PATH+"/"+FILENAME+"_"+str(lane)+".hex", MEM_WIDTH, MEM_DEPTH)

コード例 #14
0
# =============================================
# Convert complex type to concatenated unsigned
# =============================================
for input_nr in range(NOF_INPUTS):
    for word in range(NOF_CHANNELS):
        re = int(round(input_lists[input_nr][word].real))
        im = int(round(input_lists[input_nr][word].imag))
        print 'Input', input_nr, 'Channel', word, 're,im', re, im
        re_bits = CommonBits(re, COMPLEX_WIDTH)
        im_bits = CommonBits(im, COMPLEX_WIDTH)
        concat_bits = re_bits & im_bits
        input_lists[input_nr][word] = concat_bits.data

# ==========================================================
# Interleave the lists if user wants folded correlator input
# . Note: no support for more than 1 fold yet.
# ==========================================================
if NOF_FOLDS==1:
    input_stream_lists = []
    for input_stream_nr in range(NOF_INPUT_STREAMS):
        input_stream_lists.append( interleave([input_lists[2*input_stream_nr], input_lists[2*input_stream_nr+1]] ) )
elif NOF_FOLDS==0:
    input_stream_lists = input_lists

# ====================
# Write the HEX files
# ====================
for input_stream_nr in range(NOF_INPUT_STREAMS):
    list_to_hex( input_stream_lists[input_stream_nr], PATH+"/"+FILENAME+"_"+str(COMPLEX_WIDTH)+'b_fold_'+str(NOF_FOLDS)+'_'+str(input_stream_nr)+".hex", MEM_WIDTH, MEM_DEPTH)

コード例 #15
0
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################

from common import *
from mem_init_file import list_to_hex

# Purpose:
# . Generate the 3 counter data HEX data files that are used by the 3 
#   block generators per interface.
# Description:
# . The count ranges from 0..899
# . This range is written to 32, 64 and 128 bit HEX files matching the data
#   width of 1GbE, 10GbE and the internal loopback respectively.

PATH = "../hex"
FILENAME = "counter_data"

NOF_STREAMS = 3
MEM_WIDTHS  = [32, 64, 128]
MEM_DEPTH   = 1024

# ====================
# Write the HEX files
# ====================
for mem_width in MEM_WIDTHS:
    for stream in range(NOF_STREAMS):
        list_to_hex( range(900), PATH+"/"+FILENAME+"_"+str(mem_width)+'_'+str(stream)+".hex", mem_width, MEM_DEPTH)

コード例 #16
0
interleaved = []
for stream_pair in split_list(ids_per_beamlet_concat, 2):
    interleaved.append(interleave(stream_pair))

# Concatenate the beamlet pairs in time to yield 1 list for each of the 4 streams
interleaved_concat_0 = []
interleaved_concat_1 = []
interleaved_concat_2 = []
interleaved_concat_3 = []
for i in range(NOF_BEAMLET_BLOCKS):
    interleaved_concat_0+=interleaved[4*i+0] # combine interleaved beamlet pair lists 0,4,8,12,16,20,24,28,32,36,40
    interleaved_concat_1+=interleaved[4*i+1] # combine interleaved beamlet pair lists 1,5, ..
    interleaved_concat_2+=interleaved[4*i+2] # etc.
    interleaved_concat_3+=interleaved[4*i+3]

bg_lists = []
bg_lists.append(interleaved_concat_0)
bg_lists.append(interleaved_concat_1)
bg_lists.append(interleaved_concat_2)
bg_lists.append(interleaved_concat_3)

###############################################################################
# Write the HEX files
###############################################################################
MEM_WIDTH  = COMPLEX_WIDTH*2
MEM_DEPTH  = NOF_BEAMLETS_PER_SYNC*NOF_TIMESAMPLES_PER_BEAMLET/NOF_STREAMS

for stream_index in range(NOF_STREAMS):
    list_to_hex( bg_lists[stream_index], PATH+"/"+FILENAME+'_'+str(stream_index)+".hex", MEM_WIDTH, MEM_DEPTH)