diff options
author | saurabhb17 | 2020-03-17 20:42:57 +0530 |
---|---|---|
committer | GitHub | 2020-03-17 20:42:57 +0530 |
commit | c967b3b3b27dc4e76ee2bb7a1820a97c5306b8d2 (patch) | |
tree | 2c80091a39cceebca01eb5cf3de102de8cdae3df /Examples/NGHDL_Examples/custom_mixed_mode/customblock.vhdl | |
parent | 2ea4bdb9b08b2a5da5a0b6ad0a5fe6a82510b9ec (diff) | |
parent | 0771d3b179c16dc4bd486f71a7d7576cbcc59bec (diff) | |
download | eSim-c967b3b3b27dc4e76ee2bb7a1820a97c5306b8d2.tar.gz eSim-c967b3b3b27dc4e76ee2bb7a1820a97c5306b8d2.tar.bz2 eSim-c967b3b3b27dc4e76ee2bb7a1820a97c5306b8d2.zip |
Merge pull request #137 from saurabhb17/master
fp-lib-table modifications
Diffstat (limited to 'Examples/NGHDL_Examples/custom_mixed_mode/customblock.vhdl')
-rw-r--r-- | Examples/NGHDL_Examples/custom_mixed_mode/customblock.vhdl | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Examples/NGHDL_Examples/custom_mixed_mode/customblock.vhdl b/Examples/NGHDL_Examples/custom_mixed_mode/customblock.vhdl new file mode 100644 index 00000000..afe2c4dd --- /dev/null +++ b/Examples/NGHDL_Examples/custom_mixed_mode/customblock.vhdl @@ -0,0 +1,43 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity customblock is +port(C : in std_logic; + D : in std_logic; + Q : out std_logic); +end customblock; + + +architecture bhv of customblock is + signal count: integer:=1; --counts number of CLOCK cycles + signal period: integer:=10; --PWM signal period is 10 times of clock period + signal boost : integer:=9; --number of clock pulses during T_ON + signal buck : integer:=1; --number of clock pulses during T_OFF +begin + process (C,D) + + begin + + if(C='1' and C'event) then + count<=count+1; + if(count=period)then -- resets count for period + count<=1; + end if; + if(D='1') then --boost duty cycle when compartor output is high-- + if(count<=boost)then + Q<='1'; + elsif(count>boost) then + Q<='0'; + end if; + end if; + if(D='0')then --buck duty cycle when compartor output is low-- + if(count<=buck)then -- + Q<='1'; + elsif(count>buck)then + Q<='0'; + end if; + end if; + end if; + end process; +end bhv; |