Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Whats wrong with my PWM ?

Status
Not open for further replies.

aqcy

Newbie level 3
Joined
Oct 14, 2005
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
Hi guys.. just found out bout this forum. Currently, i am working on a PWM. Using vhdl to generate a pwm to drive a DC motor.. I am using the Xilinx ISE 7.1i software. Below is my code.. i am pretty sure it will work.. but the funny thing is when i simulate using ISE simulator.. the outpwm signal is always 0... the pwm has an 8bit input.. i have tried setting the input to 32,64,128.. but still, pwm output is forever low..

i am getting desperate for a solution and this problem is driving me crazy..can someone please enlighten me?

Code:
library ieee;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

-- Interface definition
entity pwm_module is
       port ( data: in STD_LOGIC_VECTOR (7 downto 0);
              clk: in STD_LOGIC;
              reset: in STD_LOGIC;
              outpwm: out STD_LOGIC
       );
end pwm_module;

architecture Behavioral of pwm_module is

signal int_reg: STD_LOGIC_VECTOR (7 downto 0);
signal counter: STD_LOGIC_VECTOR (7 downto 0);
signal tc: STD_LOGIC;
signal cnt_dir: STD_LOGIC;

begin

	--store data into register
	process(clk, int_reg, reset)
	begin
   if (reset = '1') then
		int_reg <= "00000000";
	elsif (rising_edge(clk)) then
		int_reg <= data;
	end if;
	end process;

	--8 bit up/down counter
	process(clk, counter, tc, cnt_dir)
	begin
		if (tc = '1') then
			counter <= int_reg;
		elsif (rising_edge(clk)) then
			if (tc = '0' and cnt_dir = '1' and counter < "11111111") then --if not end, count up and counter < 255
				counter <= counter + 1;
			elsif (tc = '0' and cnt_dir = '0' and counter > "00000000") then
				counter <= counter - 1;
			end if;
		end if;
	end process;

	process(tc, counter, clk, reset)
	begin
		if (reset = '1') then
			tc <= '1';
		elsif (rising_edge(clk)) then
			if ((counter = "11111111") or (counter = "00000000")) then
				tc <= '1';
			else
				tc <= '0';
			end if;
		end if;
	end process;

	--generate pwm
	process(clk, tc, reset)
	begin
		if (reset = '1') then
			cnt_dir <= '0';
		elsif	(rising_edge(tc)) then
			cnt_dir <= not(cnt_dir);
		else
			cnt_dir <= cnt_dir;
		end if;
	end process;
	
	outpwm <= cnt_dir;

end Behavioral;
[/code]
 

It's working fine here with ModelSim.
A couple months ago I tried ISE simulator. It's so awful I'll never use it.

Here's a crash course in ModelSim (I'm using SE). You will need to add a testbench somewhere.
Code:
vlib work
vcom *.vhd
modelsim pwm_module
  add wave *
  run 10us
  exit
 

    aqcy

    Points: 2
    Helpful Answer Positive Rating
echo47 said:
It's working fine here with ModelSim.
A couple months ago I tried ISE simulator. It's so awful I'll never use it.

Here's a crash course in ModelSim (I'm using SE). You will need to add a testbench somewhere.
Code:
vlib work
vcom *.vhd
modelsim pwm_module
  add wave *
  run 10us
  exit

yeah.. i know ISE sux.. so, does it mean that it can't be simulated ISE, but will work fine on actual implementation? I think later i will pop by the lab and program it onto an fpga and use the oscciloscope...

thanks man.. for the help! =) saved me a lot of time from figuring it our.. been doing it for the whole night and haven't slept a wink! Too bad i never worked with modelsim before..our lecturer reccomended ISE.. :|
 

Most of ISE works fine. The place and route tools usually work great, and there is no alternative. ISE's XST synthesizer is halfway decent once you learn its quirks.

The ISE simulator is something new with version 7.1i. You can probably dig deeper into its simulation results to find what's going wrong, and then adjust your code to make it happy.

It's always nice to have two way to try things. ModelSim may already be installed with your ISE. Even the free ISE WebPACK includes a light version. If you are using Project Navigator, it may provide a link to ModelSim. Or try running it from the command line as shown above.

Be sure to install the latest ISE Service Pack 4. Who knows, that may fix the simulator.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top