• 0
akeener

Importing a Custom Pattern for a Bus via Script in Waveforms

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?

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Thank you, I realized that I need to convert my waveform from raw binary to decimal in my CSV in order to work properly with the .custom assignment for the bus. It works perfectly now. 

Share this post


Link to post
Share on other sites
  • 0

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)

 

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

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

Edited by akeener

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

That worked perfectly, thanks! I did not realize that customz was just a bit mask, which explains the issues I was having before. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now