易截截图软件、单文件、免安装、纯绿色、仅160KB

基本运算单元的高层次综合:C/C++ to RTL

本文以加法为例:[code]
//----------------------------------------------------
//adder.c
//---------------------------------------------------
void adder(int a, int b, int *sum)
{
        *sum = a + b;
}
[/code][size=3]
[/size]
HLS工具(AutoPilot)综合之后的结果:[code]
//---------------------------------------------------
//adder.v
//--------------------------------------------------
`timescale 1 ns / 1 ps
module adder (
        a,
        b,
        sum
);
input  [31:0] a;
input  [31:0] b;
output  [31:0] sum;
assign sum = (b + a);
endmodule //adder
[/code][size=3]
[/size][code]
//---------------------------------------------------
//adder.vhd
//---------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
library work;
use work.AESL_components.all;
entity adder is
port (
    a : IN STD_LOGIC_VECTOR (31 downto 0);
    b : IN STD_LOGIC_VECTOR (31 downto 0);
    sum : OUT STD_LOGIC_VECTOR (31 downto 0) );
end;
architecture behav of adder is
begin
    sum <= esl_add(b, a);
end behav;
[/code][size=3]
[/size]
备注:加减乘除、位运算、逻辑运算等等基本的C/C++运算都可以很方便的用AutoPilot综合成对应的RTL代码(verilog/vhdl)[/size]


相关文档:

C+C C×C

1.C语言中,long被存储为四个字节的补码。写一个程序,分别将这四个字节的内容取出,以16进制的方式显示在屏幕上。程序所需的long由用户从键盘输入,0表示输入结束。
程序运行效果如下:
input n: 12345678<回车>
hex: 00 BC 61 4E
input
n: -12345678<回车>
hex: FF 43 9E B2
input n: 0<回车& ......

快速求a的b次幂对c取余

快速幂取模理论基础:  计算 a^b mod c ?
  由(a x b) mod c=((a mod c) x b) mod c.
 我们可以将 b先表示成就:
   b=at2^t+at-1 2^t-1+……a02^0. (ai=[0,1]).
 这样我们由 a^b mod c=(a^(at2^t+at-12^t-1+…a02^0)mod c.
 然而我们求  a^(2^(i+1)) ......

浅议C /CLI的gcnew关键字

http://west263.com/info/html/chengxusheji/C-C--/20080224/9240.html
1. gcnew返回的是个句柄(Handle),而new返回的是实际的内存地址.
  2. gcnew创建的对象由虚拟机托管,而new创建的对象必须自己来管理和释放.
  当然,从程式员的角度来说,管他是句柄还是什么其他的东西,总跑不掉是对某块内存地址的引用,实际 ......

关于 extern "C"

当这个世界还只有C的时候,是不需要extern "C"的。
但是,当C++出现之后,有时候,我们就需要extern "C"了。
那究竟是在什么样的情况下,我们需要用extern "C"呢?
有人说,是为了C能够调用C++,有人说是为了在C++中能调用C的库函数。是不是把你弄糊涂了?
先说说extern "C"是啥作用吧。
extern "C" 是告诉C++编译器, ......

Can C beat RTL?


http://www.edn.com/article/457428-Can_C_beat_RTL_.php 
With the appearance of higher speeds and more DSP macrocells in low-cost FPGAs, more and more design teams are seeing the configurable chips not as glue but as a way to accelerate the inner loops of numerical algorithms, either in conjun ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号