Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. Advanced ModelSim commands
  2.  
  3. The wave.do file in Lab 2 contained simple ModelSim commands that forced a signal to logic 0 or logic 1
  4. (e.g., force {SW[0]} 0), followed by run commands that ran the simulation for a predetermined number
  5. of nanoseconds before applying a different test vector. However this approach does not scale well as your
  6. designs become more complex and have more inputs. ModelSim allows you to apply a periodic signal to
  7. your simulation’s inputs which makes creation of test vectors much easier.
  8. The format of a more advanced force command is the following:
  9.  
  10. force {<si gn al n ame >} <i n i t i a l value> <i n i t i a l time>, <new value> <new time>
  11. −repeat <repeat time> −c a n c el <c a n c el time>
  12.  
  13. This will set the signal name to initial value at initial time after the current time and will set it
  14. to new value after new time passed from the current time. This square wave will repeat repeat time
  15. after the current time and you can choose to cancel it at cancel time. In all cases, you can explicitly
  16. specify the time unit in your force command (e.g., by writing ns) after any time value. You can use
  17. shorthands -r and -c instead of -repeat and -cancel.
  18.  
  19. Additionally, you may also force a full bus of signals. For example, you can set a 4-bit wide bus to
  20. decimal 10, by setting its value to 2#1010. The 2 means the constant value is in binary (i.e. base 2)
  21. while the 1010 is the binary constant itself. You could also specify the value in decimal (10#10, or base
  22. 2
  23. 10) or hexadecimal (16#A, or base 16); just ensure that your signal is wide enough to accommodate the
  24. size of your value.
  25.  
  26. Here is an example of test vectors for two 1-bit inputs a and b. Notice that the square wave applied to b
  27. has twice the period of the square wave applied to a, thus modeling all four possible input combinations,
  28. the same way they’d be present in a truth table.
  29.  
  30. force {a} 0 0 , 1 20 −repeat 40
  31. force {b} 0 0 ns , 1 40 ns −r 80
  32.  
  33. Also do not forget to use -timescale 1ns/1ns as an argument to the vlog command, as we did in the
  34. wave.do file provided in Lab 2. The -timescale switch tells ModelSim what the default time unit is when
  35. no unit is specified (first number), and what the smallest unit of time to simulate should be (second
  36. number).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement