CS232 Tips and Tricks

  1. ModelSim
    1. Reusing wave settings in ModelSim: When closing the simulator you say yes to save it (it saves it as wave.so), then next time you open the simulator (i.e. after you have typed vsim) you click file-> load-> macro file... And double click the wave.do file. (Note: It should also be possible to run the wave.do file by typing do wave.do in the Transcript).
    2. ModelSim: If one of the subwindows is missing (e.g. Objects), go to the View menu and select it. That should make it appear.
  2. Quartus
    1. LPM_COUNTER: To use an LPM_COUNTER with just a clock as input and a 4-bit bus as output. Do something like this

      Connect an input pin to the wire labeled clock& and connect a wire (well, it will turn into a bus) to the output bus. Label it q[3..0] Then, when you need to use the most significant bit, make a wire and label it q[3]. If you want to use the least significant bit, then label your wire q[0].

    2. Wiring: If you want to connect one wire to two gates, you can simply draw the wires like this:

      But if this will make your wiring diagram look too messy, then you may want to use names to connect them. So you need a way of giving 1 wire 2 different names. You can do that using a "Wire" symbol (primitives/buffer/wire). Like this:

    3. Generating constant input at 0 (GND) or 1 (VCC): If you need a wire to always be zero, then connect it to the GND (ground) symbol (primitives/other/gnd). If you need a wire to always be one, then connect it to the VCC symbol (primitives/other/vcc).
    4. Board Programmer: If no file shows up when you open Tools/Programmer, then select the button that allows you to open a file (in the programmer window). Open the .sof file in the output_files folder.
  3. Generating input
    1. Driving the LPM_COUNTER with a clock: If you want to simulate a counter going from 0 to 15, then you will need to make sure that 15 full clock cycles fit in your simulation. So when you are making the clock's wave form, make sure you choose a total time that is at least 15 times its period. And when you run the simulation, make sure you run it for a time that is also at least 15 times the clock's period.
    2. Generating input for the prime numbers project: To generate the numbers 0 through 15 in binary, you are using 4 inputs. Let's call them A, B, C, and D. And let's say that we encode the numbers such that A is the most significant bit and D is the least significant bit. To make sure you generate all of the values (0 to 15), you need to make clock signals for each of the bits. The period of the signal of the A bit needs to be the fastest (look at your truth table, and you will see that it changes value on every row). The period of the B bit needs to be twice as long (again, look at your truth table and convince yourself this makes sense). Likewise the period of C needs to be twice as fast as that of B and the period of D needs to be twice as long as the period of C. So, you will want to do something like this (which happens to be for 5 bits):

  4. Doing things on the dwarves
    1. Connecting to the Personal server from a dwarf:
      1. Open the Files Application
      2. On the top bar, click on the Files icon
      3. Click Connect to Server
      4. In the "Server Address" type smb://files.colby.edu/MyFiles
  5. DE1 Board
    1. DE1 Board: If you get the error "Can't access JTAG chain", try plugging the USB cable into the other USB port on the computer. Something has gone wonky where you are.
  6. VHDL
    1. Conditional assignment. In lab 2, you used conditional assignment to set each bit of the output individually. You can also use it to set all the bits at once. For example, suppose the role of our circuit is to reverse the order of bits in a 3-bit array. We could do it like this:
      	result <= "000" when a = "000" else
      	          "100" when a = "001" else
      	          "010" when a = "010" else
      	          "110" when a = "011" else
      	          "001" when a = "100" else
      	          "101" when a = "101" else
      	          "011" when a = "110" else