Jump to content
  • 0

Importing a Custom Pattern for a Bus via Script in Waveforms


akeener

Question

Hello, 

In my waveforms script I am trying to import and run a saved custom 7-bit bus pattern in csv format that I generated from the custom pattern generator. I am able to read the data from the csv, but when I do:

Patterns1.Channels.Bus._custom = data

all of the data is just written into the first channel of the bus. Is there another format or syntax that should be used when specifying patterns for custom busses?

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

Hi @akeener

You could parse the text binary represented numbers like this:

var rgsz = String(FileRead("~/Desktop/default.csv")).split("\n") // split by separator
var rg = [] // integer array
rgsz.forEach(function(el){ 
    el = el.substring(1)  // to remove prefix like: B0101
    var v = parseInt(el,2) // binary text number to integer
    if(!isNaN(v)){
        rg.push(v) 
    }
})
print(rg)

 

Link to comment
Share on other sites

@attila

I have a very closely related question where I am reading in a custom file and then generating a custom waveform array based on the imported waveform. In my case, I am reading in a csv of data bits. I am interjecting high Z on the bus between each data cycle. The issue I am having is that the .customz parameter does not read the 'Z' value properly and gives undefined behavior during that cycle. Additionally, it seems to read '1's as 'Z's. I need to be able to write '1', '0', and 'Z' in my pattern. I have the output type set to tristate. 

For example, I would like to be able to do a data stream on the bus like this:

b11111, bZZZZZ, b00000, bZZZZZ

Here is an example of my code:

rgsz.forEach(function(el){ 
	var v = parseInt(el,2) // binary text number to integer
           
	if(!isNaN(v)){
		
    	rg.push(v)
		rg.push("Z")
	}
     
})

Patterns1.Channels.BUS.customz = rg

How would I set up the script to properly set the appropriate '1', 'Z', and '0' states on a bus? Thanks for the help!

Link to comment
Share on other sites

Hi @akeener

The .customz is used as a mask. Bits of ones make the output high impedance Z, where it is zero the bit of .custom is used to drive low/high, 0/1

Here for instance the last .customz sample is 2 which makes bus[1] Z and the last .custom is 1 makes bus[0] 1, and the other bus[3-2] will be 0.

image.thumb.png.7cdcbaa3727de4abd139caf7bf1e310b.png

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...