From f82462f98e92f9584ddfaa3978e041be2cbd3238 Mon Sep 17 00:00:00 2001 From: Johann Faerber Date: Sun, 13 Mar 2022 16:35:52 +0100 Subject: added documentation examples in markdown --- doc/images/Duty_Cycle_Examples.png | Bin 0 -> 15246 bytes doc/images/de1_pwm_schematic.svg | 984 ++++++++++++++++++++++++++++++ doc/images/pwm_conceptional_rtl.svg | 301 +++++++++ doc/pulse_width_modulator_datasheet.md | 136 ++--- doc/pulse_width_modulator_presentation.md | 70 +-- doc/pulse_width_modulator_report.md | 189 ++---- 6 files changed, 1440 insertions(+), 240 deletions(-) create mode 100644 doc/images/Duty_Cycle_Examples.png create mode 100644 doc/images/de1_pwm_schematic.svg create mode 100644 doc/images/pwm_conceptional_rtl.svg (limited to 'doc') diff --git a/doc/images/Duty_Cycle_Examples.png b/doc/images/Duty_Cycle_Examples.png new file mode 100644 index 0000000..5c516e1 Binary files /dev/null and b/doc/images/Duty_Cycle_Examples.png differ diff --git a/doc/images/de1_pwm_schematic.svg b/doc/images/de1_pwm_schematic.svg new file mode 100644 index 0000000..db5d876 --- /dev/null +++ b/doc/images/de1_pwm_schematic.svg @@ -0,0 +1,984 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pwm_width_i + + + + + + + + + + + + + + CLOCK_50 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rst_ni + + + + + + + + + + + + + + KEY0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + clk_i + + + + + + en_pwm_pi + + + + + + rst_ni + + + + + + pwm_o + + + + + + + MUV + + + + + + + + pwm + + + + + + en_pi + + + + + + + + + + + + pwm_width_i + + + + + + + + + + + + + + + + + + 8 + + + + + + pwm_o + + + + + + + + + + + + rst_ni + + + + + + + + + + + + + + + + + + + clk_i + + + + + + + + + + + + + + + + + + + + + + + + + clk_i + + + + + + + + + + + + + + + + + + + + LEDR[0] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LEDR[1] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LEDR[7] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + clk_i + + + + + + + + + + + + + + n + + + + + + m + + + + + + + + prescaler + + + + + + + + cntdnmodm + + + + + + en_pi + + + + + + + + + + + + count_o + + + + + + + + + + + + + + + + + + n + + + + + + tc_o + + + + + + + + + + + + rst_ni + + + + + + + + + + + + + + + + + + + clk_i + + + + + + + + + + + + + + + + + + + + + + + + + 1‘ + + + + + + OPEN + + + + + + + + + + + + rst_ni + + + + + + + + + + + + + + + SW[7..0] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + L + + + + + + H + + + + + + + + pwm_width_i + + + + + + + + + + + + + + GPO_1[1] + + + + + + + + + + + + + + + + + + + + + GPO_1[2] + + + + + + + + + + + + + + + + + + + + + GPO_1[0] + + + + + + + + + + + + + clk_i + + + + + + en_pwm_pi + + + + + + + + + + + + pwm_o + + + + \ No newline at end of file diff --git a/doc/images/pwm_conceptional_rtl.svg b/doc/images/pwm_conceptional_rtl.svg new file mode 100644 index 0000000..3b652ed --- /dev/null +++ b/doc/images/pwm_conceptional_rtl.svg @@ -0,0 +1,301 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Incrementer+1 + + + + + + + statereg + + + + + + + + + + + + + + + + + + C1 + + + + + + + outputlogic + + + + + + + outputbuffer + + + + + + + + + + + + + + + + + + C1 + + + + + + R + + + + + + R + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EN1 + + + + + + EN1 + + + + + + + + + + + + + + + + + + + + + + + + en_pi + + + + + + clk_i + + + + + + rst_ni + + + + + + pwm_width_i + + + + + + pwm_o + + + + + + current_state + + + + + + next_state + + + + + + buf_next + + + + + + + + + + + \ No newline at end of file diff --git a/doc/pulse_width_modulator_datasheet.md b/doc/pulse_width_modulator_datasheet.md index 2f1caa4..5aa4784 100644 --- a/doc/pulse_width_modulator_datasheet.md +++ b/doc/pulse_width_modulator_datasheet.md @@ -1,45 +1,38 @@ Introduction ============ -A heartbeat generator can be used in a digital system to ... +Pulse width modulation (PWM) is a technique to generate periodic waveforms with adjustable duty cycles. PWM is used in many application areas like communications, power control, measurement, AD/DA-conversion, etc. [[1]](https://en.wikipedia.org/wiki/Pulse-width_modulation) + Features ======== -Normal rhythm produces four entities – a P wave, a QRS complex, a T wave, and a U wave – that each -have a fairly unique pattern. [[1]](https://en.wikipedia.org/wiki/Electrocardiography) - -For simplicity the existing heartbeat module generates the QRS complex and T wave only. - - * Models QRS-Complex and T-Wave - * Average time values based on 72 bpm - * Enable input for external prescaler + * default 8-bit resolution + * 8-bit control word input + * Enable input for external prescaler to control PWM period General Description =================== -![Heartbeat Generator - Schematic Symbol](images/heartbeat_gen.png){width=40%} +![Pulse Width Modulator - Schematic Symbol](images/pwm.svg){width=40%} -| **Name** | **Type** | **Direction** | **Polarity** | **Description** | -|-------------|-------------------|:-------------:|:------------:|-----------------| -| clk_i | std_ulogic | IN | HIGH | clock | +| **Name** | **Type** | **Direction** | **Polarity** | **Description** | +|-------------|----------------------|:-------------:|:------------:|-----------------| +| clk_i | std_ulogic | IN | HIGH | | +| rst_ni | std_ulogic | IN | LOW | | +| en_pi | std_ulogic | IN | HIGH | | +| pwm_width_i | std_ulogic_vector[8] | IN | HIGH | 8-bit control input word | +| pwm_o | std_ulogic | OUT | HIGH | | -: Heartbeat Generator - Description of I/O Signals +: Pulse Width Modulator - Description of I/O Signals Functional Description ====================== -The shape of an [electrogardiogramm](https://en.wikipedia.org/wiki/Electrocardiography) as a voltage graph over time - - -![Electrocardiogram](images/ECG-SinusRhythmLabel.png){width=20%} - -The important QRS complex and T wave are modelled as digital pulses. - -![QRS Complex and T Wave Pulses](images/qrs-complex-t-wave-pulses.pdf){width=80%} +A mod-256 counter ... Design Description @@ -47,27 +40,27 @@ Design Description A conceptional RTL diagram is shown below. -![Heartbeat Generator - Conceptional RTL](images/heartbeat_gen_conceptional_rtl.pdf){width=60%} +![Pulse Width Modulator - Conceptional RTL](images/pwm_conceptional_rtl.svg){width=60%} -The simulation result shows two full periods based on a clock period of 1 ms +The simulation result shows the corner cases minimum, maximum, switched off, and a cuty cycle of 50 %. -![Two Periods - Simulation Result](images/heartbeat_gen_two_periods_simwave.png){width=80%} +![Pulse Width Modulator - Simulation Result](images/pwm_simwave.png){width=80%} -In more detail using cursors to display correct parameters of the QRS complex and T wave. +In more detail using cursors to display a PWM frequency of f~PWM~=21.7kHz -![QRS-Complex and T-Wave - Simulation Result](images/qrs-complex-t-wave_simwave.png){width=80%} +![Pulse Width Modulator - 21.7 kHz - Simulation Result](images/pwm_21.7kHz_simwave.png){width=80%} Device Utilization and Performance ================================== -The following table shows the utilisation of both modules heartbeat_gen and cntdnmodm. +The following table shows the utilisation of both modules pwm and cntdnmodm. The following results are extracted from ```pure - pnr/de1_heartbeat_gen/de1_heartbeat_gen.fit.rpt + pnr/de1_pwm/de1_pwm.fit.rpt ``` @@ -80,7 +73,7 @@ The following results are extracted from The following results are extracted from ```pure -de1_heartbeat_gen.sta.rpt +de1_pwm.sta.rpt ``` ```pure @@ -103,9 +96,9 @@ Application Note ================ The following test environment on a DE1 prototype board uses a system clock frequency of 50 MHz. -A prescaler is parameterised to generate an output signal with a period of 1 ms. +A prescaler is parameterised to generate an output signal with a period of 46.08 us. -![Test Environment on DE1 Prototype Board](images/de1_heartbeat_gen_schematic.pdf){width=70%} +![Test Environment on DE1 Prototype Board](images/de1_pwm_schematic.svg){width=70%} @@ -115,7 +108,7 @@ Appendix References ---------- -* [Wiki: Electrocardiography](https://en.wikipedia.org/wiki/Electrocardiography) +* [Wiki: Pulse Width Modulation](https://en.wikipedia.org/wiki/Pulse-width_modulation) Project Hierarchy ----------------- @@ -123,15 +116,15 @@ Project Hierarchy ### Module Hierarchy for Verification ```pure -t_heartbeat_gen(tbench) - heartbeat_gen(rtl) +t_pwm(tbench) + pwm(rtl) ``` ### Prototype Environment ```pure -de1_heartbeat_gen(structure) - heartbeat_gen(rtl) +de1_pwm(structure) + pwm(rtl) cntdnmodm(rtl) ``` @@ -139,60 +132,39 @@ VHDL Sources ------------ ```vhdl -LIBRARY IEEE; -USE IEEE.std_logic_1164.ALL; - -ENTITY heartbeat_gen IS - PORT (clk_i : IN std_ulogic; - rst_ni : IN std_ulogic; - en_pi : IN std_ulogic; - count_o : OUT std_ulogic_vector; - heartbeat_o : OUT std_ulogic - ); -END heartbeat_gen; -``` - -```vhdl -LIBRARY IEEE; +LIBRARY ieee; USE IEEE.std_logic_1164.ALL; USE IEEE.numeric_std.ALL; -ARCHITECTURE rtl OF heartbeat_gen IS +ENTITY pwm IS - CONSTANT n : natural := 10; - CONSTANT zero : unsigned(n-1 DOWNTO 0) := (OTHERS => '0'); + PORT( + clk_i : IN std_ulogic; -- clock input + rst_ni : IN std_ulogic; -- reset L-active + en_pi : IN std_ulogic; -- enable H-active + pwm_width_i : IN std_ulogic_vector(7 DOWNTO 0); -- width of pulse + pwm_o : OUT std_ulogic); -- pwm output - CONSTANT heartbeat_period : unsigned(n-1 DOWNTO 0) := to_unsigned(833, n); - CONSTANT qrs_width : unsigned(n-1 DOWNTO 0) := to_unsigned(100, n); - CONSTANT st_width - CONSTANT t_width - CONSTANT qt_width +END pwm; - SIGNAL next_state, current_state : unsigned(n-1 DOWNTO 0); +ARCHITECTURE rtl OF pwm IS - SIGNAL tc_qrs : std_ulogic; -- qrs interval - SIGNAL tc_t : std_ulogic; -- T wave - -BEGIN + SIGNAL next_state, current_state : unsigned(7 DOWNTO 0); -- states - next_state_logic : - + SIGNAL buf_next : std_ulogic; -- output buffer +BEGIN - state_register : - - - -- output_logic - t_wave : tc_t <= - - - - qrs_complex : tc_qrs <= - - - output_value : heartbeat_o <= - + next_state_logic : next_state <= + + state_register : current_state <= (OTHERS => '0') WHEN rst_ni = '0' ELSE + next_state WHEN rising_edge(clk_i) AND (en_pi = '1'); + counter_output : buf_next <= + + -- output buffer + output_register : pwm_o <= + END rtl; ``` @@ -201,6 +173,6 @@ Revision History | **Date** | **Version** | **Change Summary** | |:----------|:-------------|:--------------------| -| May 2020 | 0.1 | Initial Release | -| April 2021 | 0.2 | Added parameterisation | +| May 2022 | 0.1 | Initial Release | +| April 2022 | 0.2 | Added VHDL code | diff --git a/doc/pulse_width_modulator_presentation.md b/doc/pulse_width_modulator_presentation.md index d742c03..83cbaf7 100644 --- a/doc/pulse_width_modulator_presentation.md +++ b/doc/pulse_width_modulator_presentation.md @@ -1,8 +1,8 @@ --- -title: Heartbeat Generator +title: Pulse Width Modulator subtitle: VLSI-Design Module - Presentation author: J Färber -date: SS2021 +date: SS2022 --- Overview @@ -20,26 +20,25 @@ Overview Features ======== - * Models QRS-Complex and T-Wave - * Average time values based on 72 bpm - * Enable input for external prescaler - + * Default 8-bit resolution + * 8-bit control word input + * Enable input for external prescaler to control PWM period + Interface Signals ================= -![Heartbeat Generator - Schematic Symbol](images/heartbeat_gen_symbol.pdf){width=40%} +![Pulse Width Modulator - Schematic Symbol](images/pwm.svg){width=40%} Functional Description ====================== -Simplification to Digital Pulses +Duty Cycle --------- -![Electrocardiogram](images/ECG-SinusRhythmLabel.png){width=20%} - +![Duty Cycle Examples](images/Duty_Cycle_Examples.png){width=60%} -![QRS Complex and T Wave Pulses](images/qrs-complex-t-wave-pulses.pdf){width=80%} +[Reference: Wikipedia - Pulse Width Modulation](https://en.wikipedia.org/wiki/Pulse-width_modulation) Functional Description @@ -48,37 +47,37 @@ Functional Description Conceptional RTL Diagram --------------- -![Heartbeat Generator - Conceptional RTL](images/heartbeat_gen_conceptional_rtl.pdf){width=60%} +![Pulse Width Modulator - Conceptional RTL](images/pwm_conceptional_rtl.svg){width=60%} Simulation Result - Top Level ============================= -![Two Periods - Simulation Result](images/heartbeat_gen_two_periods_simwave.png){width=80%} +![Pulse Width Modulator - Simulation Result](images/pwm_simwave.png){width=80%} Device Utilization and Performance ================================== ```pure -+------------------------------------------------------------------------------+ -; Fitter Summary ; -+------------------------------------+-----------------------------------------+ -; Fitter Status ; Successful - Wed Mar 31 11:50:15 2021 ; -; Quartus II 32-bit Version ; 13.0.1 Build 232 06/12/2013 SP 1 SJ Web ; -; Revision Name ; de1_heartbeat_gen ; -; Top-level Entity Name ; de1_heartbeat_gen ; -; Family ; Cyclone II ; -; Device ; EP2C20F484C7 ; -; Timing Models ; Final ; -; Total logic elements ; 50 / 18,752 ( < 1 % ) ; -; Total combinational functions ; 50 / 18,752 ( < 1 % ) ; -; Dedicated logic registers ; 26 / 18,752 ( < 1 % ) ; -; Total registers ; 26 ; -; Total pins ; 15 / 315 ( 5 % ) ; -; Total virtual pins ; 0 ; -; Total memory bits ; 0 / 239,616 ( 0 % ) ; -; Embedded Multiplier 9-bit elements ; 0 / 52 ( 0 % ) ; -; Total PLLs ; 0 / 4 ( 0 % ) ; -+------------------------------------+-----------------------------------------+ ++-----------------------------------------------------------------------------+ +; Fitter Summary ; ++------------------------------------+----------------------------------------+ +; Fitter Status ; Successful - Fri Mar 11 10:39:29 2022 ; +; Quartus II 32-bit Version ; 13.0.1 Build 232 06/12/2013 SP 1 SJ Web; +; Revision Name ; de1_pwm ; +; Top-level Entity Name ; de1_pwm ; +; Family ; Cyclone II ; +; Device ; EP2C20F484C7 ; +; Timing Models ; Final ; +; Total logic elements ; 38 / 18,752 ( < 1 % ) ; +; Total combinational functions ; 38 / 18,752 ( < 1 % ) ; +; Dedicated logic registers ; 21 / 18,752 ( < 1 % ) ; +; Total registers ; 21 ; +; Total pins ; 22 / 315 ( 7 % ) ; +; Total virtual pins ; 0 ; +; Total memory bits ; 0 / 239,616 ( 0 % ) ; +; Embedded Multiplier 9-bit elements ; 0 / 52 ( 0 % ) ; +; Total PLLs ; 0 / 4 ( 0 % ) ; ++------------------------------------+----------------------------------------+ ``` Demonstration @@ -87,7 +86,7 @@ Demonstration Prototype Setup --------------- -![Test Environment on DE1 Prototype Board](images/de1_heartbeat_gen_schematic.pdf){width=70%} +![Test Environment on DE1 Prototype Board](images/de1_pwm_schematic.svg){width=70%} Demonstration ============= @@ -95,7 +94,8 @@ Demonstration Test Environment ---------------- - +Measurement Result +----------- diff --git a/doc/pulse_width_modulator_report.md b/doc/pulse_width_modulator_report.md index 67cb4c2..5aa4784 100644 --- a/doc/pulse_width_modulator_report.md +++ b/doc/pulse_width_modulator_report.md @@ -1,51 +1,38 @@ Introduction ============ -A heartbeat generator can be used in a digital system to display activity of a system. -Based on population studies, a heartrate between 60 and 100 beats per minute (bpm) -is considered as normal for a human adult. +Pulse width modulation (PWM) is a technique to generate periodic waveforms with adjustable duty cycles. PWM is used in many application areas like communications, power control, measurement, AD/DA-conversion, etc. [[1]](https://en.wikipedia.org/wiki/Pulse-width_modulation) + Features ======== -Normal rhythm produces four entities – a P wave, a QRS complex, a T wave, and a U wave – that each -have a fairly unique pattern. [[1]](https://en.wikipedia.org/wiki/Electrocardiography) - -For simplicity the existing heartbeat modules generates the QRS complex and T wave only. - - * Models QRS-Complex and T-Wave - * Average time values based on 72 bpm - * Enable input for external prescaler + * default 8-bit resolution + * 8-bit control word input + * Enable input for external prescaler to control PWM period General Description =================== -![Heartbeat Generator - Schematic Symbol](images/heartbeat_gen_symbol.pdf){width=40%} +![Pulse Width Modulator - Schematic Symbol](images/pwm.svg){width=40%} -| **Name** | **Type** | **Direction** | **Polarity** | **Description** | -|-------------|-------------------|:-------------:|:------------:|-----------------| -| clk_i | std_ulogic | IN | HIGH | clock | -| rst_ni | std_ulogic | IN | LOW | reset | -| en_pi | std_ulogic | IN | HIGH | enable | -| count_o | std_ulogic_vector | OUT | HIGH | count value | -| heartbeat_o | std_ulogic | OUT | HIGH | hearbeat pulse output | +| **Name** | **Type** | **Direction** | **Polarity** | **Description** | +|-------------|----------------------|:-------------:|:------------:|-----------------| +| clk_i | std_ulogic | IN | HIGH | | +| rst_ni | std_ulogic | IN | LOW | | +| en_pi | std_ulogic | IN | HIGH | | +| pwm_width_i | std_ulogic_vector[8] | IN | HIGH | 8-bit control input word | +| pwm_o | std_ulogic | OUT | HIGH | | -: Heartbeat Generator - Description of I/O Signals +: Pulse Width Modulator - Description of I/O Signals Functional Description ====================== -The shape of an [electrogardiogramm](https://en.wikipedia.org/wiki/Electrocardiography) as a voltage graph over time - - -![Electrocardiogram](images/ECG-SinusRhythmLabel.png){width=20%} - -The important QRS complex and T wave are modelled as digital pulses. - -![QRS Complex and T Wave Pulses](images/qrs-complex-t-wave-pulses.pdf){width=80%} +A mod-256 counter ... Design Description @@ -53,88 +40,65 @@ Design Description A conceptional RTL diagram is shown below. -![Heartbeat Generator - Conceptional RTL](images/heartbeat_gen_conceptional_rtl.pdf){width=60%} +![Pulse Width Modulator - Conceptional RTL](images/pwm_conceptional_rtl.svg){width=60%} -The simulation result shows two full periods based on a clock period of 1 ms +The simulation result shows the corner cases minimum, maximum, switched off, and a cuty cycle of 50 %. -![Two Periods - Simulation Result](images/heartbeat_gen_two_periods_simwave.png){width=80%} +![Pulse Width Modulator - Simulation Result](images/pwm_simwave.png){width=80%} -In more detail using cursors to display correct parameters of the QRS complex and T wave. +In more detail using cursors to display a PWM frequency of f~PWM~=21.7kHz -![QRS-Complex and T-Wave - Simulation Result](images/qrs-complex-t-wave_simwave.png){width=80%} +![Pulse Width Modulator - 21.7 kHz - Simulation Result](images/pwm_21.7kHz_simwave.png){width=80%} Device Utilization and Performance ================================== -The following table shows the utilisation of both modules heartbeat_gen and cntdnmodm. +The following table shows the utilisation of both modules pwm and cntdnmodm. + +The following results are extracted from + + ```pure + pnr/de1_pwm/de1_pwm.fit.rpt + ``` + ```pure +--------------------------------------------------------------------------------------+ ; Fitter Summary ; +------------------------------------+-------------------------------------------------+ -; Fitter Status ; Successful - Wed Mar 31 11:50:15 2021 ; -; Quartus II 32-bit Version ; 13.0.1 Build 232 06/12/2013 SP 1 SJ Web Edition ; -; Revision Name ; de1_heartbeat_gen ; -; Top-level Entity Name ; de1_heartbeat_gen ; -; Family ; Cyclone II ; -; Device ; EP2C20F484C7 ; -; Timing Models ; Final ; -; Total logic elements ; 50 / 18,752 ( < 1 % ) ; -; Total combinational functions ; 50 / 18,752 ( < 1 % ) ; -; Dedicated logic registers ; 26 / 18,752 ( < 1 % ) ; -; Total registers ; 26 ; -; Total pins ; 15 / 315 ( 5 % ) ; -; Total virtual pins ; 0 ; -; Total memory bits ; 0 / 239,616 ( 0 % ) ; -; Embedded Multiplier 9-bit elements ; 0 / 52 ( 0 % ) ; -; Total PLLs ; 0 / 4 ( 0 % ) ; -+------------------------------------+-------------------------------------------------+ ``` -```pure +The following results are extracted from + ```pure +de1_pwm.sta.rpt +``` + +```pure +----------------------------------------------------------------------------------------+ ; TimeQuest Timing Analyzer Summary ; +--------------------+-------------------------------------------------------------------+ -; Quartus II Version ; Version 13.0.1 Build 232 06/12/2013 Service Pack 1 SJ Web Edition ; -; Revision Name ; de1_heartbeat_gen ; -; Device Family ; Cyclone II ; -; Device Name ; EP2C20F484C7 ; -; Timing Models ; Final ; -; Delay Model ; Combined ; -; Rise/Fall Delays ; Unavailable ; -+--------------------+-------------------------------------------------------------------+ -----------------------------------------+ ; Clocks ; +------------+------+--------+-----------+ -; Clock Name ; Type ; Period ; Frequency ; -+------------+------+--------+-----------+ -; CLOCK_50 ; Base ; 20.000 ; 50.0 MHz ; -+------------+------+--------+-----------+ +-----------------------------------------------------------------------------+ ; Multicorner Timing Analysis Summary ; +------------------+-------+-------+----------+---------+---------------------+ -; Clock ; Setup ; Hold ; Recovery ; Removal ; Minimum Pulse Width ; -+------------------+-------+-------+----------+---------+---------------------+ -; Worst-case Slack ; 3.390 ; 0.241 ; 13.381 ; 3.796 ; 8.889 ; -; CLOCK_50 ; 3.390 ; 0.241 ; 13.381 ; 3.796 ; 8.889 ; -; Design-wide TNS ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; -; CLOCK_50 ; 0.000 ; 0.000 ; 0.000 ; 0.000 ; 0.000 ; -+------------------+-------+-------+----------+---------+---------------------+ + ``` Application Note ================ The following test environment on a DE1 prototype board uses a system clock frequency of 50 MHz. -A prescaler is parameterised to generate an output signal with a period of 1 ms. +A prescaler is parameterised to generate an output signal with a period of 46.08 us. -![Test Environment on DE1 Prototype Board](images/de1_heartbeat_gen_schematic.pdf){width=70%} +![Test Environment on DE1 Prototype Board](images/de1_pwm_schematic.svg){width=70%} @@ -144,7 +108,7 @@ Appendix References ---------- -* [Wiki: Electrocardiography](https://en.wikipedia.org/wiki/Electrocardiography) +* [Wiki: Pulse Width Modulation](https://en.wikipedia.org/wiki/Pulse-width_modulation) Project Hierarchy ----------------- @@ -152,15 +116,15 @@ Project Hierarchy ### Module Hierarchy for Verification ```pure -t_heartbeat_gen(tbench) - heartbeat_gen(rtl) +t_pwm(tbench) + pwm(rtl) ``` ### Prototype Environment ```pure -de1_heartbeat_gen(structure) - heartbeat_gen(rtl) +de1_pwm(structure) + pwm(rtl) cntdnmodm(rtl) ``` @@ -168,60 +132,39 @@ VHDL Sources ------------ ```vhdl -LIBRARY IEEE; -USE IEEE.std_logic_1164.ALL; - -ENTITY heartbeat_gen IS - PORT (clk_i : IN std_ulogic; - rst_ni : IN std_ulogic; - en_pi : IN std_ulogic; - count_o : OUT std_ulogic_vector; - heartbeat_o : OUT std_ulogic - ); -END heartbeat_gen; -``` - -```vhdl -LIBRARY IEEE; +LIBRARY ieee; USE IEEE.std_logic_1164.ALL; USE IEEE.numeric_std.ALL; -ARCHITECTURE rtl OF heartbeat_gen IS - - CONSTANT n : natural := 10; - CONSTANT zero : unsigned(n-1 DOWNTO 0) := (OTHERS => '0'); - - CONSTANT heartbeat_period : unsigned(n-1 DOWNTO 0) := to_unsigned(833, n); - CONSTANT qrs_width : unsigned(n-1 DOWNTO 0) := to_unsigned(100, n); - CONSTANT st_width - CONSTANT t_width - CONSTANT qt_width +ENTITY pwm IS - SIGNAL next_state, current_state : unsigned(n-1 DOWNTO 0); + PORT( + clk_i : IN std_ulogic; -- clock input + rst_ni : IN std_ulogic; -- reset L-active + en_pi : IN std_ulogic; -- enable H-active + pwm_width_i : IN std_ulogic_vector(7 DOWNTO 0); -- width of pulse + pwm_o : OUT std_ulogic); -- pwm output - SIGNAL tc_qrs : std_ulogic; -- qrs interval - SIGNAL tc_t : std_ulogic; -- T wave +END pwm; -BEGIN - - next_state_logic : - +ARCHITECTURE rtl OF pwm IS + SIGNAL next_state, current_state : unsigned(7 DOWNTO 0); -- states - state_register : - + SIGNAL buf_next : std_ulogic; -- output buffer - -- output_logic - t_wave : tc_t <= - - - - qrs_complex : tc_qrs <= - - - output_value : heartbeat_o <= +BEGIN + next_state_logic : next_state <= + + state_register : current_state <= (OTHERS => '0') WHEN rst_ni = '0' ELSE + next_state WHEN rising_edge(clk_i) AND (en_pi = '1'); + counter_output : buf_next <= + + -- output buffer + output_register : pwm_o <= + END rtl; ``` @@ -230,6 +173,6 @@ Revision History | **Date** | **Version** | **Change Summary** | |:----------|:-------------|:--------------------| -| May 2020 | 0.1 | Initial Release | -| April 2021 | 0.2 | Added parameterisation | +| May 2022 | 0.1 | Initial Release | +| April 2022 | 0.2 | Added VHDL code | -- cgit v1.2.3