Set the include.v file as global included and set its file_type to "Verilog Header".
If file_type is not set to Verilog Header, the include file will be treated as an ordinary Verilog file which can be referred by the other Verilog files and this causes the error above.
set_property file_type "Verilog Header" [get_files ../source_inclu/include.v]
set_property is_global_include true [get_files ../source_inclu/include.v]
Verilog可以从五个层次对电路(系统)进行描述,包括:系统级态腔、算法早闭告级、寄存器传输级(即RTL级)、门级、开关级。我们平时用的最多的为RTL级,故Verilog代码也经常被称为RTL代码。
verilog语言入门教程如下:
1、Verilog语言用于FPGA领域,在quartus ii中进行编辑,点击打开quartus ii,如下图所示。
2、在Verilog中,代码以module为一个模块,在.v文件头部和尾部蔽拦分别输入module+模块名和endmodule即可,如下图所示。
3、在module模块名后虚并中,需要对模块的输入输出端口进行定义,输入相应参数即可,如下图所示。
4、在Verilog中,有三种数据类型,一种是寄存器类型数据差山,一种是线网型,一种是参数型,参数型数据需要在前面加入parameter,点击即可,如下图所示。
5、在使用寄存器类型数据时,需要说明数据位宽,使用[n:0]表示,如下图所示。
6、Verilog中,最常用的语句是always语句,要定义always语句的触发条件,常使用系统时钟,点击即可查看,如下图所示。
你写的代码祥判有问题呗。。。Library ieee
use ieee.std_logic_1164.all
use ieee.std_logic_arith.all
use ieee.std_logic_unsigned.all
entity atel2_bin is
port(
txclk: in std_logic--2400Hz的波特率伏宴亮时钟
reset: in std_logic--复位信号
din: in std_logic_vector(15 downto 0)--发送的数据
start: in std_logic--允许传输信号
sout: out std_logic --串行输出端口
)
end atel2_bin
architecture behav of atel2_bin is
signal thr,len: std_logic_vector(15 downto 0)
signal txcnt_r: std_logic_vector(2 downto 0) --数据位计数
signal sout1: std_logic
signal cou: integer:=0
signal oddb:std_logic
type s is(start1,start2,shift1,shift2,odd1,odd2,stop1,stop2)
signal state:s:=start1
begin
process(txclk)
begin
if rising_edge(txclk) then
if cou<3 then
thr<=0000000001010101--发送的文件头
elsif cou=3 then
thr<=0000000000000010--发送的文件长度
elsif (cou>3 and state=stop2) then
thr<=din--发送的数据
end if
end if
end process
process(reset,txclk)
variable tsr,tsr1,oddb1,oddb2: std_logic_vector(7 downto 0)
begin
if reset=1 then
txcnt_r<=(others=>0)
sout1<=1
state<=start1
cou<=0
elsif txclkevent and txclk=1 then
case state is
when start1=> ----低8位
if start=1 then
if cou=3 then
len<=thr
end if
tsr:=thr(7 downto 0)
oddb1:=thr(7 downto 0)
sout1<=0 --起始位
txcnt_r<=(others=>0)
state<=shift1
else
state<=start1
end if
when shift1=>
oddb<缺宽=oddb1(7) xor oddb1(6) xor oddb1(5) xor oddb1(4) xor oddb1(3) xor oddb1(2) xor oddb1(1) xor oddb1(0)
sout1<=tsr(0) --数据位
tsr(6 downto 0):=tsr(7 downto 1)
tsr(7):=0
txcnt_r<=txcnt_r+1
if (txcnt_r=7) then
state<=odd1cou<=cou+1
end if
when odd1=>--奇校验位
if oddb=1 then
sout1<=0 state<=stop1
else
sout1<=1 state<=stop1
end if
when stop1=>
sout1<=1 --停止位
if cou<4 then
state<=start1
else
state<=start2
end if
when start2=>----高8位
tsr1:=thr(15 downto 8)
oddb2:=thr(15 downto 8)
sout1<=0 --起始位
txcnt_r<=(others=>0)
state<=shift2
when shift2=>
oddb<=oddb2(7) xor oddb2(6) xor oddb2(5) xor oddb2(4) xor oddb2(3) xor oddb2(2) xor oddb2(1) xor oddb2(0)
sout1<=tsr1(0) --数据位
tsr1(6 downto 0):=tsr1(7 downto 1)
tsr1(7):=0
txcnt_r<=txcnt_r+1
if (txcnt_r=7) then
state<=odd2
end if
when odd2=> --奇校验位
if oddb=1 then
sout1<=0state<=stop2
else
sout1<=1state<=stop2
end if
when stop2=>
sout1<=1 --停止位
if len=0000000000000000 then
state<=stop2
else
state<=start1
len<=len-1
end if
end case
end if
end process
sout<=sout1
end behav
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)