Reading Status of pins/variables of components

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
jbc_2140841
Level 1
Level 1

Hello, everyone!

I had a question for you.  I created a simple state machine that seems to be off by one state when I run it on my development board.  I assume the issue is related to where my clock is being acknowledged with the debouncer so I wanted to output some additional information on the LCD. 

I setup my program and all the components are working nicely, just need to place information on the LCD screen . . . but I just realized I don't actually know how to read variables from the actual component.  For instance, is there a way to read the value on the neg pin of a debouncer without placing an output pin on it and reading the value of the output pin?  In my example, the component is called Debouncer_1, so when I type "Debouncer_1_", autosense isn't pulling anything up.  Not sure if there's a way to do that. 

   

Extending the example (in case library parts aren't setup with variables to be read), I created a State Machine UDB component that is pretty straight forward and I wanted to place the current state (and maybe a clock status) on the LCD.  I would guess that I should be able to read the status of some of my internal variables (like LED0 and LED1), but when I type "StateMachine_", like with the debouncer, nothing comes up.  Maybe I'm missing something?  Or maybe it's not possible at all without tying it to an external pin. 

   

I'm including my library (which includes my state machine), as well as my project file.  If you guys can offer me any insight, that would be greatly appreciated.  Thanks!

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The items LED0 and LED1 of your state machine are not variables but names for signals. Nothing what the debugger is able to "see".

   

As you already discovered an I/O pin connected to a signal could be used to read the state. Another choice is to use a status register component which will read all the signals (up to 8)connected to it.

   

 

   

Bob

View solution in original post

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The items LED0 and LED1 of your state machine are not variables but names for signals. Nothing what the debugger is able to "see".

   

As you already discovered an I/O pin connected to a signal could be used to read the state. Another choice is to use a status register component which will read all the signals (up to 8)connected to it.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
jbc_2140841
Level 1
Level 1

Bob,

   

Thanks for the reply!  I created the status register like you said and placed a variable "statevar" which is set by the variable state, which is set in each individual state (please see pic attached).  I think this will do what I want but it left me with a few additional questions:

   

1)  Is it assumed that these states are binary or am I ok treating it like a non binary variable (I'm only going from 0-3 and I haven't got any flags but I thought I'd ask all the same)?

   

2)  I can call "StateMachine_SMStatusReg_Read();" but I don't know how to read the variables I'm looking for (as the function doesn't take any arguments).  Once it's in a status register, how do I go about getting the values stored?

   

3)  What's the best resource for learning more about this?  I watched a few youtube videos but none of them really had the information I was looking for.  I also looked through a document called the "Component Author Guide", that was pretty helpful but not as complete as I was hoping for as it didn't seem to show how to get information from code and it didn't go over some additional specifics like the difference between sticky and transparent (this might be unnecessary as it describes sticky as being cleared on read so I assume that transparent wouldn't be cleared on read, but it definitely suggests that these variables would need to be binary, to me anyway). 

   

4)  If I wanted to customize an existing UDB provided by Cypress (or at least to break it apart and look how it's put together), is there a way to open it in the UDB editor or is the generated Verilog code all I have to go off of?

   

I'm hoping to make much more complicated UDBs so mastering these basics should be a great step in the right direction!  I'm going to include the updated files, in case it makes it easier to look at.  Thanks again for the help!

0 Likes
jbc_2140841
Level 1
Level 1

For whatever reason, it wouldn't let me upload a picture (I got an error that I don't have permission to access this on the server) so I uploaded the picture here:

   

https://ibb.co/iyxTwa

   

Thanks!

0 Likes
jbc_2140841
Level 1
Level 1

Am I posting in the right area or should I be posting in the Components section when I have questions like this?  I'm not trying to have someone do the work for me, I'm perfectly willing to do things myself but when I get stuck, I'm not really sure where I should be looking or who I should be talking to/where I should be posting in. 

0 Likes