vhdl - VHDL 转 Verilog
问题描述
我有一些 VHDL 代码,我正在尝试转换为 Verilog。
VHDL代码工作正常
library ieee;
use ieee.std_logic_1164.all;
entity find_errors is port(
a: bit_vector(0 to 3);
b: out std_logic_vector(3 downto 0);
c: in bit_vector(5 downto 0));
end find_errors;
architecture not_good of find_errors is
begin
my_label: process (a,c)
begin
if c = "111111" then
b <= To_StdLogicVector(a);
else
b <= "0101";
end if;
end process;
end not_good;
我拥有的 Verilog 代码出现错误“非法引用网络“bw”。” 和 Register 在连续赋值的左侧是非法的
module find_errors(
input [3:0]a,
output [3:0]b,
input [5:0]c
);
wire [0:3]aw;
wire [3:0]bw;
reg [5:0]creg;
assign aw = a;
assign b = bw;
assign creg = c;
always @(a,c)
begin
if (creg == 4'b1111)
bw <= aw;
else
bw <= 4'b0101;
end
endmodule
解决方案
aw
andcreg
是不必要的,bw
需要声明为reg
.
module find_errors(
input [3:0] a,
output [3:0] b,
input [5:0] c
);
reg [3:0] bw;
assign b = bw;
always @(a,c)
begin
if (c == 4'b1111)
bw <= a;
else
bw <= 4'b0101;
end
endmodule
由于没有顺序逻辑,因此您甚至不需要always
块:
module find_errors(
input [3:0] a,
output [3:0] b,
input [5:0] c
);
assign b = (c == 4'b1111) ? a : 4'b0101;
endmodule
推荐阅读
- java - hibernate 在调用 query.list 方法时抛出 NullPointerException
- python - 识别字符串开头的日期
- javascript - 如何从数组中的值组合推送和更新?
- raspberry-pi - 如何扭转意外的 Gzip 压缩?
- php - 有没有办法改变 Laravel 加密算法,所以它针对相同的字符串生成相同的值?
- c - 创建 C 库时如何保存 utils?
- anylogic - “无”的极性如何在 AnyLogic 中起作用?
- javascript - 嵌套循环:最后一个循环总是返回最后一个数组对象
- php - 暂存时出现 WordPress 光滑滑块错误但不是本地错误
- oracle - 我开始在 SQL Developer 上进行 PL/SQL 开发。我在 DEV 环境中的工作将如何被推到 QA 并最终推到 PROD?