|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
我将一个简单的分频电路VHDL转成Verilog, 综合出来不 match, 希望大神指点一下。我准备做一下仿真,但是我这个菜鸟未必能debug出来,所以先放问题出来请教各位。还想请问Verilog有没有像C语言或其他编程语言的调试方法?
VHDL:
- entity clk_gen is
- port(
- clk_i : in std_logic;
- clk_o : out std_logic;
- clk_period_i : in unsigned(29 downto 0);
- reset_i : in std_logic
- );
- end clk_gen;
- architecture rtl of clk_gen is
- signal counter : integer:=0;
- begin
- process (clk_i, reset_i)
- begin
- if (reset_i='1') then
- clk_o <= '0';
- counter <= 0;
- elsif (clk_i'event and clk_i='1') then
- counter <= counter + 1;
- if (counter < clk_period_i/2-1) then
- clk_o <= '0';
- elsif (counter >= clk_period_i/2-1 and counter < clk_period_i-1) then
- clk_o <= '1';
- else
- counter <= 0;
- clk_o <= '0';
- end if;
- end if;
- end process;
- end rtl;
复制代码
Verilog:
- module clk_gen (clk_i, clk_o, clk_period_i, reset_i);
- input clk_i;
- output clk_o;
- reg clk_o;
- input[29:0] clk_period_i;
- input reset_i;
- integer counter;
- initial
- begin
- counter <= 0;
- end
- always @(posedge clk_i or posedge reset_i)
- begin
- if (reset_i == 1'b1)
- begin
- clk_o <= 1'b0 ;
- counter <= 0 ;
- //counter = 0 ;
- end
- else begin
- counter <= counter + 1 ;
- //counter = counter + 1 ;
- if (counter < clk_period_i / 2 - 1)
- begin
- clk_o <= 1'b0 ;
- end
- else if (counter >= clk_period_i / 2 - 1 & counter < clk_period_i - 1)
- begin
- clk_o <= 1'b1 ;
- end
- else
- begin
- counter <= 0 ;
- //counter = 0 ;
- clk_o <= 1'b0 ;
- end
- end
- end
- endmodule
复制代码 |
|