在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 5623|回复: 15

[求助] 急急急!!请教大虾怎么把这个Verilog 语言改写成VHDL语言?!程序的作用是什么啊?!

[复制链接]
发表于 2010-4-29 10:39:15 | 显示全部楼层 |阅读模式
20资产
本帖最后由 kscc0202121 于 2010-4-29 10:42 编辑

module counter(clk,clr,out);
input clk;
input clr;
output reg out;
reg[11:0] cnt;
always @(posedge clk or negedge clr)
begin
  if(!clr)
begin
out <= 1'b0;
cnt <= 12'b0;
end
else begin
cnt <= cnt + 1'b1;
if(cnt[11:0]==12'h9db)
begin
cnt <= 12'h0;
out <= 1'b0;
end
else if(cnt[11:0]==12'h9db)
begin
out <= 1'b1;
end
end
end
endmodule

最佳答案

查看完整内容

library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity counter is port( clk,clr : in std_logic; dout : out std_logic ); end counter; architecture arch of counter is signal cnt : unsigned(11 downto 0); begin process(clk,clr) begin if clr = '0' then dout
发表于 2010-4-29 10:39:16 | 显示全部楼层
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity counter is
        port(
                clk,clr : in std_logic;
                dout    : out std_logic
        );
end counter;

architecture arch of counter is
        signal cnt : unsigned(11 downto 0);
       
begin

process(clk,clr)
begin
  if clr = '0' then
        dout <= '0';
        cnt  <= (others=>'0');
  elsif rising_edge(clk) then
        cnt <= cnt + 1;
        if cnt = x"9db" then
                cnt  <= (others=>'0');
                dout <= '0';
        elsif cnt = x"456" then
                dout <= '1';
        end if;
  end if;
end process;
       
end arch;

NOTE: I changed the output port  'out'  in your codes to 'dout' since 'out' is a reserved word in VHDL, I can't assign any port with the name 'out'.
发表于 2010-4-29 10:52:35 | 显示全部楼层
程序有错误。
发表于 2010-4-29 13:21:10 | 显示全部楼层
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
USE ieee.std_logic_unsigned.ALL;

ENTITY counter IS
        PORT
        (
clk:in std_logic;
clr:in std_logic;
data_out std_logic
        );
        END counter;

        ARCHITECTURE arc OF counter IS

                --ref signals
signal cnt:std_logic_vector(11 downto 0):=(others=>'0');
                BEGIN

process(clr,clk)
begin
        if clr='1' then
                data_o<='0';
                cnt<=(others=>'0');
        elsif rising_edge(clk) then
                if cnt/=X"9DB" then
                        cnt<=cnt+1;
                        data_o<='1';
                else
                        cnt<=(others=>'0');
                        data_o<='0';
                end if;
        end if;
end process;


                END arc;
发表于 2010-4-29 13:36:29 | 显示全部楼层
顶楼上的

这应该是一个根据计数结果输出信号状态的程序,其作用要看程序是用在什么样的场合来定
发表于 2010-4-29 13:54:59 | 显示全部楼层
一个简单的循环计数器吧。。
发表于 2010-4-29 15:11:43 | 显示全部楼层
这个程序改改倒是适合求分频那位仁兄。哈哈
 楼主| 发表于 2010-4-29 22:12:06 | 显示全部楼层
为什么?? 2# wycawyc
发表于 2010-4-29 23:07:54 | 显示全部楼层
怎么看都觉得有点别扭呢……好像会产生latch的吧?
发表于 2010-4-30 10:02:08 | 显示全部楼层
编码风格不敢恭维
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /3 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-20 02:08 , Processed in 0.030798 second(s), 6 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表