完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
例子: 带使能信号和复位信号的加法器,由matlab给输入数据addin,en。 错误: VHDL仿真结果貌似是正确的,但是verilog语言仿真的结果addout应该延时输入的addin一个clk,为什么没有延时呢。!! 1. VHDL语言: LIBRARY ieee; USE ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity test is port ( rst_n : in std_logic; clk : in std_logic; en : in std_logic; addin : in std_logic_vector(11 downto 0); addout : out std_logic_vector (11 downto 0) ); END test; architecture rtl of test is signal add1 : std_logic_vector(11 downto 0); begin process(clk,rst_n) begin if rst_n ='0' then add1<=(others=>'0'); elsifclk'event and clk = '1' then if en = '1' then add1<=addin+'1'; else add1<=add1; endif; end if; end process; addout<=add1; end architecture; 2. Verilog语言 module test (clk, rst_n, addin, en, addout ); input clk; input rst_n; input en; input [11:0] addin; output [11:0] addout; reg [11:0] add1; assign addout=add1; always @ (posedge clk) begin if (!rst_n) begin add1=12'h0; end else if(en) begin add1=addin+1; end end endmodule
|
|
相关推荐
1个回答
|
|
这是我给的m文件,即输入的激励:
function [iport,tnext] = test(oport, tnow, portinfo) tnext=[]; iport=struct(); persistent inc; persistent rst; CLK_PERIOD = 1e-8; RST_MUL_TIME = 5; RST_TIME = RST_MUL_TIME * CLK_PERIOD; if isempty(inc) inc=0; iport.addin=dec2bin(0,12); iport.en=dec2bin(0,1); end inc =inc+1; if tnow <= RST_TIME rst = dec2bin(0, 1); inc=[]; else rst = dec2bin(1, 1); end if inc>=10 iport.addin=dec2bin(inc,12); iport.en=dec2bin(1,1); end if 30==mvl2dec(oport.addout) iport.en=dec2bin(0,1); end iport.rst_n=rst; end |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
599 浏览 0 评论
367 浏览 0 评论
563 浏览 0 评论
集创赛(全国大学生集成电路创新创业大赛)和全国大学生FPGA竞赛紫光同创赛道官方定制FPGA开发板|国产FPGA开发板PGL50H
3203 浏览 0 评论
1028 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 粤ICP备14022951号 )
GMT+8, 2024-1-8 23:44 , Processed in 0.338913 second(s), Total 37, Slave 30 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 深圳华秋电子有限公司
电子发烧友 (电路图) 粤公网安备 44030402000349 号 电信与信息服务业务经营许可证:粤 B2-20160233 工商网监 湘ICP备2023018690号