当前位置: 首页 > news >正文

便宜点的网站空间需要做网站建设和推广

便宜点的网站空间,需要做网站建设和推广,有自己的网站做淘宝联盟号做吗,企业管理咨询是一种文章目录 使用function名称作为“常量”numeric_std包集中使用乘法的注意项variable的使用对于entity设置属性的方法在entity声明中嵌入function的定义VHDL仿真读写文件File declaration/File handingFile readingFile writing小例子 使用函数 模块中打印出调试信息 使用functi… 文章目录 使用function名称作为“常量”numeric_std包集中使用乘法的注意项variable的使用对于entity设置属性的方法在entity声明中嵌入function的定义VHDL仿真读写文件File declaration/File handingFile readingFile writing小例子 使用函数 模块中打印出调试信息 使用function名称作为“常量” 测试代码如下function仅有名称没有输入在function内部使用全局constant进行参数处理后续代码中可以直接使用function名称作为常量 numeric_std包集中使用乘法的注意项 近日看到一个VHDL Coding Style中提示说使用numeric_std包集时不要直接将unsigned/signed数据与natural/integer类型的数据相乘。 今天看了一下numeric_std的源码发现如果直接直接将无符号数/有符号数与整数相乘的话乘积很有可能会溢出。主要原因是由于包集在实现整数与符号数相乘的时候是先将整数转成了无符号数/有符号数之后再进行的乘法运算而整数转换后的位宽是与输入的符号数的位宽相一致的这就可能导致在整数进行类型转换的过程中出现数据溢出的情况。 这其实算不上bug因为源码中对此进行了明确说明主要是在使用的时候需要注意规避这一点不要让符号数与整数直接相乘可以手动进行位宽转换后再做运算。相应的源码如下图所示 variable的使用 在网上流传的介绍VHDL Coding Style的文章中一般是不建议在可综合的代码中使用变量的这大概是由于variable具有局部作用域、赋值立即生效、仿真工具支持的不够等几个原因。但最近看到几段VHDL代码大量使用variable且使用方式非常规范。在一个prcoess中进行组合逻辑的设计在另一个prcoess中使用寄存器进行时序逻辑的设计。在使用变量的process中一般是如下的处理流程 Latch the current value各类组合逻辑Combinatorial outputs before the resetResetRegister the variable for next clock cycleRegistered Outputs comb : process (localMac, r, rst, rxMaster, txSlave) isvariable v : RegType;variable i : natural; begin-- Latch the current valuev : r;-- Reset the flagsv.rxSlave : AXI_STREAM_SLAVE_INIT_C;if txSlave.tReady 1 thenv.txMaster.tValid : 0;v.txMaster.tLast : 0;v.txMaster.tUser : (others 0);v.txMaster.tKeep : (others 1);end if;-- State Machinecase r.state is-- end case;-- Combinatorial outputs before the resetrxSlave v.rxSlave;-- Resetif (rst 1) thenv : REG_INIT_C;end if;-- Register the variable for next clock cyclerin v;-- Registered Outputs txMaster r.txMaster;end process comb;seq : process (clk) is beginif rising_edge(clk) thenr rin after TPD_G;end if; end process seq;free_range_vhdl.pdf 11.4 Signals vs. Variables 对于entity设置属性的方法 类似的对于verilog的module设置attribute的方法如下 在entity声明中嵌入function的定义 VHDL仿真 有时写vhdl时使用了record、array等数据类型此时使用verilog进行仿真时略有不便用vhdl仿真倒是方便不少。 读写文件 File declaration/File handing File reading File writing 小例子 使用函数 library ieee;use ieee.std_logic_1164.all;use ieee.numeric_std.all;entity test is end test;architecture Behavioral of test is-- convert a hex string to a std_logic_vectorfunction hex_string_to_std_logic_vector(inp: string; width : integer)return std_logic_vector isconstant strlen : integer : inpLENGTH;variable result : std_logic_vector(width-1 downto 0);variable bitval : std_logic_vector((strlen*4)-1 downto 0);variable posn : integer;variable ch : character;variable vec : string(1 to strlen);beginvec : inp;-- default value is zeroresult : (others 0);posn : (strlen*4)-1;for i in 1 to strlen loopch : vec(i);case ch iswhen 0 bitval(posn downto posn-3) : 0000;when 1 bitval(posn downto posn-3) : 0001;when 2 bitval(posn downto posn-3) : 0010;when 3 bitval(posn downto posn-3) : 0011;when 4 bitval(posn downto posn-3) : 0100;when 5 bitval(posn downto posn-3) : 0101;when 6 bitval(posn downto posn-3) : 0110;when 7 bitval(posn downto posn-3) : 0111;when 8 bitval(posn downto posn-3) : 1000;when 9 bitval(posn downto posn-3) : 1001;when A | a bitval(posn downto posn-3) : 1010;when B | b bitval(posn downto posn-3) : 1011;when C | c bitval(posn downto posn-3) : 1100;when D | d bitval(posn downto posn-3) : 1101;when E | e bitval(posn downto posn-3) : 1110;when F | f bitval(posn downto posn-3) : 1111;when others bitval(posn downto posn-3) : XXXX;-- synthesis translate_offASSERT falseREPORT Invalid hex value SEVERITY ERROR;-- synthesis translate_onend case;posn : posn - 4;end loop;if (width strlen*4) then-- bitval larger than desired widthresult : bitval(width-1 downto 0);else-- bitval smaller than desired width-- MSB is padded with zeros since default value for result is all 0sresult((strlen*4)-1 downto 0) : bitval;end if;return result;end;-- convert a binary string into a std_logic_vector (e.g., 0b10.1 101)function bin_string_to_std_logic_vector (inp : string)return std_logic_vectorisvariable pos : integer;variable vec : string(1 to inplength);variable result : std_logic_vector(inplength-1 downto 0);beginvec : inp;pos : inplength-1;-- Set default valueresult : (others 0);for i in 1 to veclength loop-- synthesis translate_offif (pos 0) and (vec(i) 0 or vec(i) 1 or vec(i) X or vec(i) U) thenassert falsereport Input string is larger than output std_logic_vector. Truncating output.;return result;end if;-- synthesis translate_onif vec(i) 0 thenresult(pos) : 0;pos : pos - 1;end if;if vec(i) 1 thenresult(pos) : 1;pos : pos - 1;end if;-- synthesis translate_offif (vec(i) X or vec(i) U) thenresult(pos) : U;pos : pos - 1;end if;-- synthesis translate_onend loop;return result;end;signal data_1 : std_logic_vector(5 downto 0);signal data_2 : std_logic_vector(7 downto 0);begindata_1 bin_string_to_std_logic_vector(101001);data_2 hex_string_to_std_logic_vector(45,8);end Behavioral; 模块中打印出调试信息 VHDL的仿真不如verilog方便因此一般我都是用verilog对整个模块做仿真。但有的时候想在某个可综合的VHDL模块内部嵌入仿真调试信息这样在仿真时可以更直观的观测到运行结果。这在verilog中可以直接使用display和monitor函数在VHDL中则需要借用report函数或者自己编写函数实现。 library ieee;use ieee.std_logic_1164.all;use ieee.numeric_std.all; library work; -- use work.stdio_h.all;entity counter is generic(SIM_VERBOSE : natural : 1 ); port ( clk : in std_logic;cnt : out std_logic_vector(15 downto 0) ); end counter;architecture Behavioral of counter issignal cnt_i : unsigned(15 downto 0) : (others0);begincnt std_logic_vector(cnt_i);process(clk)beginif rising_edge(clk) thencnt_i cnt_i 1;-- if(SIM_VERBOSE1) then -- if(cnt_i 20) then -- printf(The time is %d ns\n,now); -- printf(The cnt_i value is %u\n,std_logic_vector(cnt_i)); -- printf(-------------------------\n); -- end if; -- end if;end if;end process;-- synthesis translate_offgen_sim_info : if SIM_VERBOSE1 generatebeginprocess(cnt_i)use work.stdio_h.all;beginif(cnt_i 20) thenprintf(The time is %d ns\n,now);printf(The cnt_i value is %u\n,std_logic_vector(cnt_i)); printf(-------------------------------------------------------\n);printf(The cnt_i value is %s,the cnt_i part value is %u \n,std_logic_vector(cnt_i),std_logic_vector(cnt_i(3 downto 0)));printf(-------------------------------------------------------\n);end if;end process;end generate;-- synthesis translate_onend Behavioral; Modelsim运行结果如下所示
http://www.sadfv.cn/news/207665/

相关文章:

  • pc网站如何做移动网站成都软件外包公司
  • 淘宝客的wordpress模板下载地址seo发布网站
  • 信息发布网站设计免费做苗木网站
  • 外贸网站模板免费下载网站访问速度优化
  • 做兼职哪个网站好住建局哪个科室最吃香
  • 织梦网站被做跳转临漳专业做网站
  • 建网站怎么分类网站建设销售前景
  • wordpress qiniu-uploader 使用南宁seo多少钱报价
  • 哪家网站做推广好优化方案系列丛书
  • 中国建设银行网站的机构wordpress文章循环不带置顶文章
  • 家庭网络如何做网站服务器百度seo流量
  • 北京京水建设集团有限公司网站上海工程建设交易信息网站
  • 淮安做网站酷站网站
  • 网站带app建设南阳建设工程信息网站
  • 温州自适应网站建设深圳做英文网站的公司
  • 网站备案时间多久网站建设客户需求调查表
  • 网站分析流程郑州餐饮网站建设哪家好
  • 河北省建设安全监督站的网站濮阳家电网站建设
  • 微擎 网站开发工具网网站制作开发
  • 营销型网站建设信融网站制作西安
  • 网站改版换域名wordpress ajax 登陆
  • php网站开发实例教程百度网站备案查询
  • 重庆渝兴建设有限公司网站自己的网站怎么和百度做友链
  • 免费 网站 模板产品宣传方式有哪些
  • 番禺学校网站建设建议电子商务网站建设的重要行
  • 贞丰县建设局网站那个网站是做房产中介的
  • 专业网站建设加盟合作搜索引擎seo
  • 网站ome系统怎么做重庆搜索引擎优化seo
  • 美心西饼在哪个网站做问卷调查河北搜索引擎推广方法
  • 佛山网站建设网络公司音乐网站建设的意义