我有以下图论主题的代码,最小生成树的kruskal算法
#include<iostream>
#include<stdlib.h>
using namespace std;
int cost[10][10],i,j,k,n,m,c,visit,visited[10],l,v,count,count1,vst,p;
int main(){
int dup1,dup2;
cout<<" enter number of vertices "<<endl;
cin>>n;
cout<<
我正在研究Dijkstra算法的C++表示/实现,我在网上找到了这个程序,它无法在TurboC++上正确执行。有人知道解决方案吗?我还想知道为什么最小值是31999,代码在移动模拟器上运行,但拒绝在PC TurboC++上运行
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
//using namespace std;
int shortest(int, int);
int cost[10][10], dist[20], i, j, n, k, m, S[20], v, totcost, pa
在VHDL中,我创建了以下包:
--! Custom, 8 bit register map package
package regmap_package is
--! Amount of registers in the array
constant reg_nr : natural := 8;
--! The 8bit register map array type
type regmap_t is array(0 to (reg_nr - 1)) of std_logic_vector(7 downto 0);
end package regmap_
我试图在VHDL中创建一个向量数组,但在modelsim中遇到错误。我有:
type read_data_array is array (0 to 73) of std_logic_vector(7 downto 0);
signal reg_data_stream : read_data_array;
我通过以下方式将数据存储到数组中:
reg_data_stream(counter) <= read_data;
"read_data“是std_logic_vector(7向下到0)的计数器,而" counter”是从0开始递增的
在VHDL语言中,我在给matrix2D的信号类型赋予初始值零时遇到了问题。我把它定义如下:
type matrix2D is array (integer range <> , integer range <> ) of signed(2 downto 0);
在我的VHDL初始值代码中,我写道:
process(matrix1, matrix2, s_out_adder)
variable v_flipflop_adder: matrix2D(0 to 4, 0 to 4) :=((0 to 4),(others =>(others=>'0&
我正在尝试设计一个可综合的VHDL代码,它使用了一些多维数组特性。RTL有一个64字深数组(称为big_array_s__,64×16位),用于存储一些初始的LUT值。还有一个4字深的array(small_array_s__,,4x16位,这是在设计中使用的。需要将大数组的一部分分配到小数组中。下面的代码片段说明了这一点。
type small_array is array (0 to 3) of bit_vector(15 downto 0);
type big_array is array (0 to 64) of bit_vector(15 downto 0);
signal sma
我正在使用vhdl中的多维数组,我有以下vhdl代码:
type mem_array is array(0 to 7) of STD_LOGIC_VECTOR (31 downto 0);
我完全是vhdl的初学者,我的问题是关于我声明的数组的大小,通过实例化这个数组,这是否意味着我有256个(8位大0到7)个32位的位置,或者我只有8个32位的位置?
有人知道这在VHDL中是否合法吗?
type foo is (ONE, TWO, THREE);
signal fooArray is array (foo'left to foo'right) of int;
signal intArray is array (0 to 2) of int;
fooArray <= intArray; -- is this statement legal?
据我所知,读取VHDL LRM时,数组分配是根据位置完成的,而不是通过索引完成的。因此,我知道,分配哪些数组的边界不相等,但其索引长度相等的数组是合法的。但是,没有关于将由整数
我是VHDL的新手。在我的一项任务中,我需要使用VHDL实现状态表方法中的状态机。因此,我为架构实体编写了以下代码:
X,Y是输入位,这是摩尔机器,它接受两个输入,输出一个比特。
architecture Table of SM1_2 is
type StateTable is array(integer range<>,bit range<>,bit range<>) of integer;
type OutTable is array(integer range<>) of bit;
signal State,NextSta
几乎没有使用VHDL和Vivado的经验,所以即使是最简单的东西也要尝试学习。我正在制作一个VHDL数组,如下所示: type reg is array (0 to 15) of STD_LOGIC_VECTOR (15 downto 0);
signal reg_file : reg; 在我的VHDL代码中,我有一个重置,它执行以下操作。(不是整个身体,只是重置部分。 begin
process(Clock,Reset)
begin
if (Reset = '1') then -- Reset register values to d
令人烦恼的是,我知道如何在C++中轻松地做到这一点,但不知道如何使用VHDL。我希望快速、轻松地将数据从受约束的3D数组传输到2D数组,例如:
2d_array[N][M]
3d_array[i][N][M]
2d_array=3d_array[i]
我的VHDL看起来是这样的:
type buff_array is array(2 downto 0, 7 downto 0) of std_logic_vector(31 downto 0);
type ram_array is array(7 downto 0) of std_logic_vector(31 downto 0
关于如何在VHDL和SystemVerilog之间传递2D数组的文档似乎很少。我在VHDL中有以下类型的端口:
package my_package is
type my_array_t is array (natural range <>) of std_logic_vector(N-1 downto 0);
end my_package
entity my_entity is
port(
my_input : in my_array_t(M-1 downto 0);
my_output : out my_array_t(M-
在SystemVerilog中我可以创建一个多维数组,如下所示:
reg [31:0] mem[0:127];
然而,在VHDL中,在VHDL书中在线创建类似的多维数组的所有示例都表明,在创建数组之前必须首先创建一个类型。示例:
type mem_t is array(0 to 127) of std_logic_vector(31 downto 0);
signal mem :mem_t;
有没有可能在VHDL中像在verilog中一样,在不首先为数组创建类型的情况下在一个步骤中完成所有这些操作?示例:
signal mem :array(0 to 127) of std_logic_
考虑以下几点
type foo is (A, B, C);
type foo_vector is array (foo) of std_logic_vector;
如何约束foo_vector?似乎编译器应该能够约束信号,如果我给它默认值。
signal bar : foo_vector : (others => x"0000");
但是编译器只是继续说“信号不能没有约束”。
如果是这样的话,我如何约束这个信号呢?
signal bar : foo_vector(?)(15 downto 0);
我使用的是格子编译器。
或者,如果我做了
type baz_vector
我试图用VHDL编写一个4位计数器,根据我的UD变量的值从"0000“到"1111”或者从"1111“到"0000”(如果UD='1‘它应该向下计数,如果它是’0‘up)。还有一个信号RCO_L,当我的计数器到达计数器(0或15)的一侧时,它得到值=‘0’。最后,当计数器设置为1时,有一个ENP_L信号会抑制它。
我发现很难编写代码,因为我对VHDL有点陌生,而且我遇到了很多错误。如果有人能帮我,我会很感激的。
这就是我到目前为止所做的:
*entity contador is
Port ( A : in STD_LOGIC_VECTOR(3
我试图将数组中的数据输出到我的DE1-SoC板上的7段显示。
以下是我的变量:
display : out std_logic_vector (6 downto 0);
type bigDisplay is array (0 to 4, 0 to 6) of bit;
signal displayArray : bigDisplay;
以下是代码:
display <= displayArray (0, 6-0);
这是我收到的错误:
Error (10381): VHDL Type Mismatch error at Final_Project.vhd(326): indexed na
我在这段简单的代码中遇到了一个我无法理解的问题。我没有在控制台中打印整个数组,而是收到消息"10 undefined“。不过,如果我将"var i“设置为0或更低,那么一切都很好,我会得到一个从该数字到10的完整列表。
当"i“设置为大于0的数字时,为什么这不起作用?用chrome给我的控制台拍了一张照片,展示了它的样子:
var ar = [];
for (var i = 1; i <= 10; i++) {
ar.push(i);
console.log(ar[i]);
}
Data_Int<='0' & Data_Int(7 downto 1); --if shift then shift it right
如何使用连接来移位位置?我以为在VHDL中有一个右移运算符。有人能给我解释一下吗?
假设
Data_Int : std_vector(10 downto 0);
-- and Data_Int has "1010010011"
非常感谢。
首先,我是vhdl的新手,我从项目的主要模块编写了下面的代码,我想实现它作为项目的起点,然后进行模拟:
entity main is
--empty entity
end main;
architecture Behavioral of main is
signal clk : STD_LOGIC := '0';
signal zero : STD_LOGIC_VECTOR(3 downto 0) := "0000";
type Bitonic_Sequence is array (0 to 7) of STD_LOGIC
我正在尝试使用sed和正则表达式删除VHDL文件中的所有注释。
VHDL注释以--开头,后面的行是注释。
我的第一个方法是: sed -i的/--.*//g‘file.vhdl
这将删除所有注释,但该文件还可以包含带有“不关心:符号-”的赋值。因此,像sig1 <= "11--000“这样的任务也会受到影响。此外,赋值可以是像sig1 <= "0--“& "--1”这样的串联。有没有一个好的正则表达式可以涵盖所有这些情况?也许从行尾开始匹配,因为赋值行必须以;?结尾。
一个涵盖所有情况的测试文件:
-- comment start of line
a
我需要一个使用Verilog的VHDL事件的等价物。
这是一个从VHDL到Verilog的转换示例(注意:我需要在同一进程中同时使用posedge和negedge ):
process (CLK, I) begin
if (I'event and I = 1) then //posedge
x <= x + 1;
elsif (I'event and I = 0) //negedge
x <= c + 2;
end if;
if (CLK'event and CLK = 1) // posedge
a <= b + 1;
好吧,伙计们,如果这是一个已经被问过的问题,很抱歉,因为我对VHDL逻辑设计还很陌生,不知道如何准确地表达一个特定的概念。
我要做的是用VHDL实现AES-256算法,以供FPGA使用。
我有一个名为的端口:
entity rijndael is port
(
input : in std_logic_vector(255 downto 0)
subkey: in std_logic_vector(255 downto 0)
output: out std_logic_vector(255 downto 0)
);
end rijndael;
在体系结构中,我如何将input的每个字节指定为用
我对vhdl非常陌生,在我的代码中我似乎找不到错误,我不断地得到这些错误。
alarm.vhdl (line 19, col 5): (E10) Syntax error at/before reserved symbol 'if'.
Error occurred within 'ARCHITECTURE' at line 16, column 28 in alarm.vhdl.
alarm.vhdl (line 31, col 9): (E56) Expected ;, but got IF
alarm.vhdl (line 31, col 9): (E
我不知道怎么准确地描述它,但也许是这样的?
void monitor_thread(void)
{
for(;;){
if (data==10){
data=0;
data2++;
}
}
}
对我来说,在VHDL中,我会意识到这一点:
signal data,data2:std_logic_vector(3 downto 0);
...
process(data)
begin
case data is:
when "0101" => data2<
我对vhdl相当陌生,对于这个看似琐碎的问题,我找不到一个很好的解决方案。我正在寻找一种重新设置整数数组的好方法。
type integer_vector is array (0 to N) of integer;
...
process(...)
variable tab: integer_vector;
...
if reset = '1' then
tab := ??
是否有类似于tab <= (others=>(others=>'0')) (适用于std_logic_vector )的东西?我不想使用反循环,因为合成不支持这一点。
如果我在verilog中显示这条总线,它都是红色的x: // VERILOG: unassigned signal sigx
reg [15:0] sigx; //displays as RED in gtkwaves 如果我用VHDL语言显示这条总线,它全是绿色的u,这很容易漏掉: -- unassigned signal sigu
signal sigu : std_logic_vector(15 downto 0); --displays as GREEN?! in gtkwaves 如何为VHDL正确配置gtkwave,使其具有与verilog相同的行为,将未知值显示为红色而不是绿色