Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
waveforms_-_rom_logic [2016/11/28 10:57] – [3. ROM logic User Interface in WaveForms 2015] Mircea Dabacanwaveforms_-_rom_logic [2022/10/04 11:38] (current) – external edit 127.0.0.1
Line 13: Line 13:
 For the ROM logic, a Boolean function Truth Table is stored in the Pattern Memory. An n-bit input bus (from DIO pins) builds the address for the Pattern Memory.  Consequently, it generates the output values as Boolean function of DIO arguments. In the figure below, MUX2 selects Pattern Memory, and MUX1 selects the n-bit input bus.  For the ROM logic, a Boolean function Truth Table is stored in the Pattern Memory. An n-bit input bus (from DIO pins) builds the address for the Pattern Memory.  Consequently, it generates the output values as Boolean function of DIO arguments. In the figure below, MUX2 selects Pattern Memory, and MUX1 selects the n-bit input bus. 
  
-Since the size of the Pattern Memory is limited to 2n locations, the input buffer IB is only present for the first n DIO pins (0 to n-1). However, any DIO pin can implement a Boolean function of DIO pins 0 to n-1. +Since the size of the Pattern Memory is limited to 2<sup>n</sup> locations, the input buffer IB is only present for the first n DIO pins (0 to n-1). However, any DIO pin can implement a Boolean function of DIO pins 0 to n-1. 
  
 For Analog Discovery, Analog Discovery 2 and Electronics Explorer default configurations, n = 10, meaning that only DIO0…DIO9 can be used as inputs in ROM logic blocks. Alternate configurations for these devices extend n = 14. For Digital Discovery, n = 15. For Analog Discovery, Analog Discovery 2 and Electronics Explorer default configurations, n = 10, meaning that only DIO0…DIO9 can be used as inputs in ROM logic blocks. Alternate configurations for these devices extend n = 14. For Digital Discovery, n = 15.
Line 49: Line 49:
 //{{anchor:figure_3:Figure 3 ROM Logic implementing a Mealy State Machine.}}// //{{anchor:figure_3:Figure 3 ROM Logic implementing a Mealy State Machine.}}//
  
-===== 3. ROM logic User Interface in WaveForms 2015 =====+===== 3. ROM logic User Interface in WaveForms =====
  
 In the Pattern Generator, click the green “plus” sign and select ROM logic, as shown below. In the Pattern Generator, click the green “plus” sign and select ROM logic, as shown below.
Line 66: Line 66:
   * If a signal is used in both input and output panes, it is a State Variable; the input pane shows its value in the Current State and the output pane indicates its value in the Next State.    * If a signal is used in both input and output panes, it is a State Variable; the input pane shows its value in the Current State and the output pane indicates its value in the Next State. 
   * Use 0, 1 or X (don’t care) in the input pane.   * Use 0, 1 or X (don’t care) in the input pane.
-  * An expanded Truth Table (no X input values) with n input signals has 2n lines. A line including k X values is the collapsed version of 2k lines of the expanded Truth Table. +  * An expanded Truth Table (no X input values) with n input signals has 2<sup>n</sup> lines. A line including k X values is the collapsed version of 2<sup>k</sup> lines of the expanded Truth Table. 
-  * Make sure that all possible input cases are covered, i.e. the logical reunion of all input lines is 2n.+  * Make sure that all possible input cases are covered, i.e. the logical reunion of all input lines is 2<sup>n</sup>.
   * Use 1, 0, “SignalName” or “/SignalName” in the output pane. “SignalName” is the name of one of the signals in the input pane. “/” stands for logical NOT.   * Use 1, 0, “SignalName” or “/SignalName” in the output pane. “SignalName” is the name of one of the signals in the input pane. “/” stands for logical NOT.
   * The table lines are “sequential”, i.e. a line can override lines above it in the table. For example, the first line in the table might be used to describe the default output values, while subsequent lines override particular cases.   * The table lines are “sequential”, i.e. a line can override lines above it in the table. For example, the first line in the table might be used to describe the default output values, while subsequent lines override particular cases.
Line 76: Line 76:
 ===== 4. Example: Three input, synchronous AND gate. ===== ===== 4. Example: Three input, synchronous AND gate. =====
  
-In Figure 4, the ROM logic object is named AND3 (optional). DIO0…DIO2 are selected as inputs, DIO3 as output. The signal names are changed to i0…i2, respectively o3 (optional). The synchronizing frequency is set to 5MHz, meaning the output signal will be synchronized to a 5MHz clock with 0o phase, relative to the moment of running the Pattern Generator; this way, the output signal is synchronized to other signals generated by the Pattern generator.  +In Figure 5, the ROM logic object is named AND3 (optional). DIO0…DIO2 are selected as inputs, DIO3 as output. The signal names are changed to i0…i2, respectively o3 (optional). The synchronizing frequency is set to 5MHz, meaning the output signal will be synchronized to a 5MHz clock with 0° phase, relative to the moment of running the Pattern Generator; this way, the output signal is synchronized to other signals generated by the Pattern generator.  
-In the Truth Table tab, the first line describes the default case, with the output signal value of 0. With three X-es in the input pane, this line is equivalent to 23=8 expanded lines. However, the second line overrides one line out of the eight, forcing the output signal to 1 when all inputs are 1.+ 
 +In the Truth Table tab, the first line describes the default case, with the output signal value of 0. With three X-es in the input pane, this line is equivalent to 2<sup>3</sup>=8 expanded lines. However, the second line overrides one line out of the eight, forcing the output signal to 1 when all inputs are 1.
 The equivalent VHDL code is: The equivalent VHDL code is:
        
Line 103: Line 104:
  
 To observe the dynamic behavior of the synchronized 3-input AND gate, define a binary counter on DIO2…DIO0 in the Pattern Generator. Set the clock frequency to 3MHz. (However, the closest frequency WaveForms can generate is 2.941MHz.) This frequency is chosen not to be integer multiple or submultiple of the ROM logic frequency (5MHz). Also define a 5MHz clock on DIO4 (same as for the ROM logic). This clock is not used by the ROM logic, but will serve as reference for observation in the Logic Analyzer. To observe the dynamic behavior of the synchronized 3-input AND gate, define a binary counter on DIO2…DIO0 in the Pattern Generator. Set the clock frequency to 3MHz. (However, the closest frequency WaveForms can generate is 2.941MHz.) This frequency is chosen not to be integer multiple or submultiple of the ROM logic frequency (5MHz). Also define a 5MHz clock on DIO4 (same as for the ROM logic). This clock is not used by the ROM logic, but will serve as reference for observation in the Logic Analyzer.
 +
 Open a Logic Analyzer. Add/Bus with DIO2…DIO0, and Add/Signals DIO3 and DIO4. Set the trigger on the falling edge of DIO2. Set convenient time base and position. Run Pattern generator and Logic analyzer. Observe instable image for DIO3 and DIO4, as their frequency is not correlated with Bus1. Open a Logic Analyzer. Add/Bus with DIO2…DIO0, and Add/Signals DIO3 and DIO4. Set the trigger on the falling edge of DIO2. Set convenient time base and position. Run Pattern generator and Logic analyzer. Observe instable image for DIO3 and DIO4, as their frequency is not correlated with Bus1.
 +
 Run a Single step in the Logic analyzer. Observe that DIO3 (the AND gate output) does not synchronize with the edges of Bus1 inputs, but with DIO4: DIO4 is not the actual ROM Logic clock, but it has the same frequency and phase, so it can be used as an image of the actual ROM Logic clock. Since the ROM Logic is synchronized to the completion of each clock period, and DIO4 starts with a 0 and continues with a 1, the DIO3 seems to be synchronized on the falling edge of DIO4. Run a Single step in the Logic analyzer. Observe that DIO3 (the AND gate output) does not synchronize with the edges of Bus1 inputs, but with DIO4: DIO4 is not the actual ROM Logic clock, but it has the same frequency and phase, so it can be used as an image of the actual ROM Logic clock. Since the ROM Logic is synchronized to the completion of each clock period, and DIO4 starts with a 0 and continues with a 1, the DIO3 seems to be synchronized on the falling edge of DIO4.
  
Line 113: Line 116:
 ===== 5. Example: Binary counter with Count Enable input. ===== ===== 5. Example: Binary counter with Count Enable input. =====
  
-In the figure below, DIO8 is renamed CE and is used as Count Enable. DIO7…DIO0 are renamed c7…c0 and are the state/output bits of the 8-bit binary counter. Notice how X-es, signal names, and negated signal names are used in the Truth Table. The clock for the counter is 100kHz. The Truth Table was written in Excel (colored background area in sheet CounterWithCe8Bit of RomLogicTruthTables.xls) and copied in the appropriate tab. +In the figure below, DIO8 is renamed CE and is used as Count Enable. DIO7…DIO0 are renamed c7…c0 and are the state/output bits of the 8-bit binary counter. Notice how X-es, signal names, and negated signal names are used in the Truth Table. The clock for the counter is 100kHz. The Truth Table was written in Excel (colored background area in sheet CounterWithCe8Bit of {{:waveformsromlogic:RomLogicTruthTables.xlsx|RomLogicTruthTables.xlsx}}) and copied in the appropriate tab. 
-Line 1 in the Truth Table (equivalent to 28=256 expanded lines) means: when LSB c0=’0’: all bits c7…c1 keep value; c0 changes to ‘1’ only if CE=’1’. All other lines cover the cases when c0=’1’. + 
-Line 2 (equivalent to 27=128 expanded lines): means when c1=’0’ and c0=’1’: both will swap if CE=’1’ or keep their value if CE=’0’; all other bits keep their value. +Line 1 in the Truth Table (equivalent to 2<sup>8</sup>=256 expanded lines) means: when LSB c0=’0’: all bits c7…c1 keep value; c0 changes to ‘1’ only if CE=’1’. All other lines cover the cases when c0=’1’. 
-All nine lines are equivalent to 29=512 expanded lines and define all possible cases (8 bit+1 Count Enable).+ 
 +Line 2 (equivalent to 2<sup>7</sup>=128 expanded lines): means when c1=’0’ and c0=’1’: both will swap if CE=’1’ or keep their value if CE=’0’; all other bits keep their value. 
 + 
 +All nine lines are equivalent to 2<sup>9</sup>=512 expanded lines and define all possible cases (8 bit+1 Count Enable). 
 To verify the behavior, add a clock signal on DIO8 (Frequency=1kHz, Duty Factor=80%). As defined above, DIO8 is Count Enable for the binary counter.  To verify the behavior, add a clock signal on DIO8 (Frequency=1kHz, Duty Factor=80%). As defined above, DIO8 is Count Enable for the binary counter. 
 +
 In the Logic Analyzer, Add/Bus DIO7…DIO0 and Add/Signal DIO8. Run Pattern Generator and Single step Logic Analyzer. Observe the behavior of the binary counter. In the Logic Analyzer, Add/Bus DIO7…DIO0 and Add/Signal DIO8. Run Pattern Generator and Single step Logic Analyzer. Observe the behavior of the binary counter.
  
Line 150: Line 158:
 //{{anchor:figure_10:Figure 10.Pattern Generator prepared for PWM with static input.}}// //{{anchor:figure_10:Figure 10.Pattern Generator prepared for PWM with static input.}}//
  
-A 5-bit counter is implemented in a ROM logic object, as below, on DIO9…DIO5, renamed c4…c0. The Truth Table was written in Excel (sheet PWM in RomLogicTrouthTables.xls) and copied in the Truth Table tab. The clock frequency is set to 1MHz.+A 5-bit counter is implemented in a ROM logic object, as below, on DIO9…DIO5, renamed c4…c0. The Truth Table was written in Excel (sheet PWM in {{:waveformsromlogic:RomLogicTruthTables.xlsx|RomLogicTruthTables.xlsx}}) and copied in the Truth Table tab. The clock frequency is set to 1MHz.
  
 {{:waveformsromlogic:RL_11_5BitCounterRomLogic.png|Figure 11. 5 bit counter ROM logic.}} {{:waveformsromlogic:RL_11_5BitCounterRomLogic.png|Figure 11. 5 bit counter ROM logic.}}
Line 156: Line 164:
 //{{anchor:figure_11:Figure 11. 5 bit counter ROM logic.}}// //{{anchor:figure_11:Figure 11. 5 bit counter ROM logic.}}//
  
-A second ROM logic (sheet PWM in RomLogicTrouthTables.xls) compares DIO9…DIO5 = c4…c0 = “5BitCounter” with DIO4…DIO0 = s4…s0 = ”Sample”. DIO10 = CY = ”CarryOut” is High when “Sample” is higher. Notice again how higher order bits (later lines in the Truth Table) override the lower order bits (earlier lines in the Truth Table).+A second ROM logic (sheet PWM in {{:waveformsromlogic:RomLogicTruthTables.xlsx|RomLogicTruthTables.xlsx}}) compares DIO9…DIO5 = c4…c0 = “5BitCounter” with DIO4…DIO0 = s4…s0 = ”Sample”. DIO10 = CY = ”CarryOut” is High when “Sample” is higher. Notice again how higher order bits (later lines in the Truth Table) override the lower order bits (earlier lines in the Truth Table).
  
 {{:waveformsromlogic:RL_12_5By5BitComparatorRomLogic.png|Figure 12. 5-by-5 bit Comparator ROM logic.}} {{:waveformsromlogic:RL_12_5By5BitComparatorRomLogic.png|Figure 12. 5-by-5 bit Comparator ROM logic.}}
Line 162: Line 170:
 //{{anchor:figure_12:Figure 12. 5-by-5 bit Comparator ROM logic.}}// //{{anchor:figure_12:Figure 12. 5-by-5 bit Comparator ROM logic.}}//
  
-An external RC Low Pass Filter (100kΩ, 1nF) is used to build the analog signal, removing the carrier from the PWM signal. The WaveForms scope shows the PWM signal (C1) and the filtered signal (C 2). +An external RC Low Pass Filter (100kΩ, 1nF) is used to build the analog signal, removing the carrier from the PWM signal. The WaveForms scope shows the PWM signal (C1) and the filtered signal (C2). 
  
 {{:waveformsromlogic:RL_13_RcLowPassFilter.png|Figure 13. RC Low Pass Filter.}} {{:waveformsromlogic:RL_13_RcLowPassFilter.png|Figure 13. RC Low Pass Filter.}}
Line 179: Line 187:
 //{{anchor:figure_14:Figure 14. Static PWM Scope capture.}}// //{{anchor:figure_14:Figure 14. Static PWM Scope capture.}}//
  
-Variable n-bit sample can be used as a modulator signal. For the second experiment, set a custom 5-bit Bus 1 in the Pattern Generator, to drive a sinus signal with 100 samples per period. Generate a .csv file, with 100 values of form (sheet SinusSamples in RomLogicTrouthTables.xls):+Variable n-bit sample can be used as a modulator signal. For the second experiment, set a custom 5-bit Bus 1 in the Pattern Generator, to drive a sinus signal with 100 samples per period. Generate a .csv file, with 100 values of form (sheet SinusSamples in {{:waveformsromlogic:RomLogicTruthTables.xlsx|RomLogicTruthTables.xlsx}}):
  
 $$sample_i=16+int(15*sin((2∙π∙i)/100))∈[1…31]$$ $$sample_i=16+int(15*sin((2∙π∙i)/100))∈[1…31]$$
Line 204: Line 212:
 ===== 7. Example: PDM modulator. ===== ===== 7. Example: PDM modulator. =====
  
-In the figure below, an n-bit accumulator is used to add the sample value over and over. The Carry Out bit is the Pulse Density Modulated (PDM) signal. The accumulator is refreshed with fcnt frequency, while samples succeed with fsample rate. Same frequencies and names are used as for PWM, for comparison.+In the figure below, an n-bit accumulator is used to add the sample value over and over. The Carry Out bit is the Pulse Density Modulated (PDM) signal. The accumulator is refreshed with f<sub>cnt</sub> frequency, while samples succeed with f<sub>sample</sub> rate. Same frequencies and names are used as for PWM, for comparison.
  
 {{:waveformsromlogic:RL_17_PdmModulatorBlockDiagram.png|Figure 17. PDM modulator block diagram.}} {{:waveformsromlogic:RL_17_PdmModulatorBlockDiagram.png|Figure 17. PDM modulator block diagram.}}
Line 216: Line 224:
 //{{anchor:figure_18:Figure 18. Open a second pattern generator.}}// //{{anchor:figure_18:Figure 18. Open a second pattern generator.}}//
  
- A 5-bit PDM modulator is implemented in the PDM Accumulator ROM logic object, with DIO 9…DIO5 = a4…a0 as “Accumulator”, DIO4…DIO0 = s4…s0 as “Sample” and DIO10 as “CY” which is the PDM signal (copy colored background area in sheet PDM of RomLogicTrouthTables.xls and paste into the Truth Table).+ A 5-bit PDM modulator is implemented in the PDM Accumulator ROM logic object, with DIO 9…DIO5 = a4…a0 as “Accumulator”, DIO4…DIO0 = s4…s0 as “Sample” and DIO10 as “CY” which is the PDM signal (copy colored background area in sheet PDM of {{:waveformsromlogic:RomLogicTruthTables.xlsx|RomLogicTruthTables.xlsx}} and paste into the Truth Table).
  
 {{:waveformsromlogic:RL_19_OpenASecondPatternGenerator.png|Figure 19. Implementing a PDM in ROM logic.}} {{:waveformsromlogic:RL_19_OpenASecondPatternGenerator.png|Figure 19. Implementing a PDM in ROM logic.}}
Line 226: Line 234:
 $$(CY,a4…a0) <= (a4…a0) + (s4…s0)$$ $$(CY,a4…a0) <= (a4…a0) + (s4…s0)$$
  
-To compare with PWM, similar examples are used. The same external RC filter, the clock frequency of the modulator, the sinus sample LUT and sample frequency are all the same as in the corresponding PWM experiments.  +To compare with PWM, similar examples are used. The same external RC filter, the clock frequency of the modulator, the sinus Sample Memory and sample frequency are all the same as in the corresponding PWM experiments.  
- In the static experiment, the same duty factor is generated, with a much higher frequency, resulting in a much smaller ripple of the analog signal. + 
 +In the static experiment, the same duty factor is generated, with a much higher frequency, resulting in a much smaller ripple of the analog signal. 
  
 {{:waveformsromlogic:RL_20_StaticPdmScopeCapture.png|Figure 20. Static PDM scope capture.}} {{:waveformsromlogic:RL_20_StaticPdmScopeCapture.png|Figure 20. Static PDM scope capture.}}
Line 234: Line 243:
  
 In the dynamic experiment, the same sinus custom Bus1 was used, as for the PWM. The average Duty Factor is again around 50%, the frequency is variable and the average frequency is much higher compared to PWM, for the same clock frequency. The ripple of the analog signal is also much smaller. In the dynamic experiment, the same sinus custom Bus1 was used, as for the PWM. The average Duty Factor is again around 50%, the frequency is variable and the average frequency is much higher compared to PWM, for the same clock frequency. The ripple of the analog signal is also much smaller.
-The lowest instantaneous frequency of the PDM signal happens when the sample value is either 1LSB or 2n-1LSB, and is the same as the constant frequency of the PWM signal. For all other values of the samples, the resulting instantaneous frequency is higher, up to half of the clock frequency, when the sample value is at half of the range.  + 
 +The lowest instantaneous frequency of the PDM signal happens when the sample value is either 1LSB or 2<sup>n</sup>-1LSB, and is the same as the constant frequency of the PWM signal. For all other values of the samples, the resulting instantaneous frequency is higher, up to half of the clock frequency, when the sample value is at half of the range.   
 Having both instances of the Pattern generator open, is very easy to run them alternatively for easy comparison on the scope instrument. Hitting Run on one instance automatically turns the other instance in Busy state. Having both instances of the Pattern generator open, is very easy to run them alternatively for easy comparison on the scope instrument. Hitting Run on one instance automatically turns the other instance in Busy state.
  
Line 242: Line 253:
  
 The spectrum analyzer instrument is used to analyze data in the frequency domain. The two traces correspond to the two scope channels in the experiments above. In the spectral view, a cursor is set at fcarrier. Some parameters of the modulated and analog signals are shown in the measurements window. The spectrum analyzer instrument is used to analyze data in the frequency domain. The two traces correspond to the two scope channels in the experiments above. In the spectral view, a cursor is set at fcarrier. Some parameters of the modulated and analog signals are shown in the measurements window.
 +
 The carrier fundamental and harmonics are significant for PWM, while PDM spread those components more uniformly in the spectrum.  The carrier fundamental and harmonics are significant for PWM, while PDM spread those components more uniformly in the spectrum. 
 +
 The measurements have much better values for SFDR, SNR, SINAD and ENOB in the case of PDM. The measurements have much better values for SFDR, SNR, SINAD and ENOB in the case of PDM.