![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
||||
|
||||
Displaying signals internal to the architecture part of an entityHello,
I am trying to write a code to scan the code generated by the keyboard through an FPGA board. The project is now in an early development stage. Heres the most basic process in which I try to synchronise the inputs to the system viz. kb_clk and data to the on board 'sys_clk', the system clk. heres the code ive written, Code:
Code:
What I don't understand now is how do I display the contents of the signals 'current_kbclk' and 'current_data' which are internal to the entity code_test_process1(within the architecture part and hence hidden in some way i guess) so that I may check if the inputs are sampled only at sys_clk or not. How do I display those signals as well on the wave? Best Regards, Aijaz Baig. __________________
Hope to hear from you guys! -------------------------------------------------- Best Regards, Aijaz Baig. |
|
#2
|
|||
|
|||
Re: Displaying signals internal to the architecture part of an entityQuote:
Here's where your Modelsim gui interface is a little different than the one to which I have access right now, so I can't tell you exactly how which menu items to click to display the waveforms that you want. I assume that you have already invoked the simulator within modelsim and you have opened the "wave" window to see some waveforms. The Modelsim command window should contain a prompt, something like Code:
or some such thing. In the Modelsim command window, you can try the following: Code:
(test_bench is your top-level entity and p1 is the name of the component instantiated therein. This adds all signals in that entity to the "wave" window.) If this doesn't work, get back to me, and I will try to get some more specific instructions for your interface. My Modelsim on-line help documentation includes a "tutorial". If yours has one, I strongly recommend that you go through it first. It should have a section on "Adding items to a Wave Window" or some such thing. Poke around your GUI "help" documentation (Probably the User Manual). Look for a section on "Graphic Interface" and look for "Signals Window", "Struct Window" or similar-sounding items. It should show you how to display the structure of your design (a hierarchical tree of your entities) and how to display the signals within a given entity and them add the signals to the "wave" window. Regards, Dave |
|
#3
|
||||
|
||||
Re: Displaying signals internal to the architecture part of an entityHello.
I was able to add those two signals to the wave window by using the command line version command add wave/test_bench/p1/* which adds all the signals within the component instantiation P1. Now I seem to have a different problem. In my test_bench entity(i.e. in the architecture part) I have made sys_clk work like a clock for a specified period of time. It isn't showing up on the wave window when I simulate for about 600 ns. Only the signals data and kb_clk seem to get updated with some values. Not even sys_clk gets updated with the values I supplied. Would you let me know where am I going wrong here. (I've included a zipped version of the wave image as before so that you may have a look). And by the way its kinda sad not to be online so often like during the summer vacations but I know these courses on VHDL based design are gonna keep me a lil too busy now Hope to hear from you soon, __________________
Hope to hear from you guys! -------------------------------------------------- Best Regards, Aijaz Baig. |
|
#4
|
|||
|
|||
Re: Displaying signals internal to the architecture part of an entityQuote:
The only connections between the different entities and components of a design are through their ports. In VHDL there are no global variables or signals. (And that's a Really, Really Good Thing, in my opinion. Not that it matters what my opinion is. There simply aren't any. Period.) Here's your port declaration for the code_test_process entity: Code:
There is only one signal into that entity: kb_clk The local signal sys_clk inside code_test_process doesn't have a driver. Therefore, it has a std_logic_value of 'U' (uninitialized). Since the process inside that architecture, any signals driven by that process remain 'U'. To get some action, you could try the following: Code:
Or, just forget about sys_clk inside that architecture and: Code:
Regards, Dave |
|
#5
|
||||
|
||||
Re: Displaying signals internal to the architecture part of an entityHello.
Thanks for the idea. However what I want is to read the keystrokes and display them on the display output of an FPGA board. Now as per documentation, the signal kb_clk is not a real clock. It is just a signal generated by the keyboard to enable us to read the actual data corresponding to a keystroke at the 'correct time'. To be more specific, we can be sure of getting the actual data if we read in the data signal only on the falling edge of this kb_clk. So both these signals kb_clk and kb_data are like normal inputs to the board and the first thing in this little school project is that we need to synchronise both these 'external' inputs to the on board clock viz. the sys_clk. I've tried to accomplish this using a process as you can see. So one cannot assign the value of the signal kb_clk to the signal sys_clk as you suggested. I hope you now have an idea of what im trying to do.. And if u can suggest a simpler and/or a better way and/or something that just works __________________
Hope to hear from you guys! -------------------------------------------------- Best Regards, Aijaz Baig. |
|
#6
|
|||
|
|||
Re: Displaying signals internal to the architecture part of an entityQuote:
This is a very practical problem. The easiest and most robust designs are where there is one system clock and all processes are synchronous with this clock. Capturing outside events (that are not synchronous with respect to system clock) is almost always an issue. In order to solve this problem you need some system specification. In all designs, before you actually start designing, you should have a design specification that describes: inputs(s) ==> processing ==> output(s) The rest of this post is mostly a lesson in logic design considerations, with VHDL examples of the design and its simulation testbench. Suppose your kb_clk has a minimum pulse width of one millisecond. That is, it goes high when a key is struck and stays high for (at least) one millisecond before going low. The new data are guaranteed to be valid when the kb_clk goes low and to stay valid until the next new kb_clk event. Suppose your system_clock is running at 10 MHz. That means that its period is 100 ns, so it can be used to sample the kb_clk and will never "miss a beat". There are a couple of common, easy-to-use and easy-to-synthesize techniques for synchronizing external signals. The kb_clk signal is just treated as a "normal" signal, and does not itself go to a "clock" input of a flip-flop. Now, suppose your kb_clk has a minimum pulse width of one microsecond and your system clock is running at 100 kHz (clock period = 10 microseconds). It should be clear that you can't use the system clock to sample the kb_clk signal in an effort to detect its falling edge. Since the system clock is so much slower, it is possible (likely) that a kb_clk pulse will be missed. In this case you capture the kb_data with a process that is triggered by the falling edge of kb_clk, and you must also create a process that uses kb_clk to set a flip-flop (or something) that stays set until a system clock comes along and resets it. In other words you still have the issue of creating a synchronous "data ready" signal from every asynchronous external keyboard event. In both cases you have to be familiar with some practical hardware issues concerning problems that arise in the "real world" whenever the data input and clock input to a flip-flop (or whatever) change at the exact same time (or they both change within some very small time interval). The issue is covered in hardware design classes as "metastability" of sequential elements. In the second case you have an additional issue that may affect simulation and real hardware testing: A gate array or fpga with more than one clock domain (some flip-flops affected by one clock and some affected by another) must be handled very carefully. Another consideration for simulation (but not necessarily absolutely necessary for fpga designs) is that all sequential processes should have a reset signal so that counters and other state machines can always start in a known state before the system clock starts doing its thing. In most of my design, every single process in the whole design has an asynchronous reset signal. For historical purposes, I usually use an active-low asynchronous reset, and the processes usually look something like this: Code:
This is an idiom. This is guaranteed to be synthesizable, and the use of an asynchronous reset is almost always in my designs for test purposes as well as for ease of simulation. Here is a possible component to capture the keyboard data in the case where the system clock is much faster than external events: Code:
Here is a generator for the kb_clk and kb_data signals consistent with your example. I gave it a 10 MHz system clock. Even the cheapest FPGA components nowadays support 100 MHz (or faster) system clocks, so the use of a 10 MHz system clock is kind of "loafing along". Usually Keyboard strobes are somewhat longer (tens of milliseconds or more), but this is only an example. Code:
Finally, the testbench with a simple structural architecture that ties the device under development to the signal generator: Code:
Run for 1 us. Regards, Dave Last edited by davekw7x : 03-Sep-2006 at 10:39.
|
|
#7
|
||||
|
||||
Re: Displaying signals internal to the architecture part of an entityHello.
That was one good thing to read about in the post. Now I have come up with a program which does gets compiled. However the result isn't what is expected. To enable you to read the documentation which my school superviser provided as an 'aid' to get the job done, I've included this link where u can read what we are supposed to be doing. Additionally, you can have a look at my post and see what can be done to fix the logical errors in the code. Code:
Hoping to hear from you soon, __________________
Hope to hear from you guys! -------------------------------------------------- Best Regards, Aijaz Baig. |
|
#8
|
|||
|
|||
Re: Displaying signals internal to the architecture part of an entityQuote:
What a great assignment! You will learn a lot by implementing it correctly. I won't address anything other than your sticking point: Here's your process. (I reformatted it to my taste; there is nothing wrong with your way; I just like working with things that look familiar to me.)" Code:
You have defined a signal driver, which will be synthesized into a flip-flop that will be set to '1' when the temp_kb_clk changes from '1' to '0', and the flip-flop value stays there forever (or until power-failure or cosmic rays or some other non-simulated event causes the FPGA to lose its mind). That explains the simulation results: it is doing exactly that. Furthermore, since it depends on an edge of kb_clk, and you are explicitly told not to use multiple clocks for a given flip-flop, there is no synchronous way ever to get it back to a '0' state again. Big problem. Quote:
It seems to me that one of the points here is that all signals should be synchronized to the system clock. That is, no flip-flops (or other state machines) should change values except on the rising edge of the system clock. In other words, the only signal with 'EVENT or 'LAST_VALUE attached (or with the rising_edge() stuff I showed last time) in the entire design should be your system clock. That is the essence of elementary synchronous design: one clock domain. Period. By the way, I'm thinking that the ModelSim tcl stuff for the testbench that is in the assignment has a little flaw according to your post. I think the first line should be something like Code:
The instruction in the assignment (without the "us" on the period and repetition values to indicate "microseconds") uses simulation default time steps, which is, apparently, 1 ps. (So the resulting clock has a frequency of something like 12 GHz --- somewhat beyond the range of the target technology.) Anyhow, if you are going to use the tcl stuff for your testbench, make the change I suggested, and the simulation will look more reasonable, I think (with the system clock something like 12 MHz). Of course you can simulate this behavioral stuff with any clock speed that you want, but later on, if you want to check the simulation results with synthesized logic (including calculated delays from the actual device), you will need a more realistic clock. (You can check with your instructor to see if you are really supposed to be using a 12 GHz simulation clock.) Now, back to the problem you specifically asked about: I showed a general way of creating a signal you can use to detect a new key event last time, but your instructor tells you pretty much the same thing here: Quote:
So: use system clock to capture the old value in a flip-flop. Then at the next system clock see if the old value was '1' and the current value is '0'. (My way had a flip-flop for current value and shifted "current" value to "old" value each time for the comparison.) Regards, Dave Last edited by davekw7x : 04-Sep-2006 at 08:51.
|
Recent GIDBlog
Halfway done! by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The