ShellAlbert / Summary2019

record the reading books in 2019
1 stars 0 forks source link

verilog syntax #1

Open ShellAlbert opened 5 years ago

ShellAlbert commented 5 years ago

output reg [2WIDTH-1:0] dataout //问题就在这里... 以前没见过 output reg 这种连用的表示,我对此的臆测是,它等价于下面的代码: output [2WIDTH-1:0] dataout //先声明 output 变量 reg [2*WIDTH-1:0] dataout;//再声明 reg 同名变量 //...

这是verilog2001的语法。 你不觉得你写的第二段代码很冗长吗?一个端口为什么要分两行来写呢?在verilog95里甚至要用3行写。 所以verilog2001引入了这种类似C的定义方法,一句话就把端口所有的属性全交代清楚了。

ShellAlbert commented 5 years ago

module test(out);

output out;

`define wow

`ifdef wow

initial $display("wom is defined.");

`else

initial $display("wom is not defined.");

`endif endmodule 预编译指令

ShellAlbert commented 5 years ago

input echo;

reg [1:0] echo_r;

always@(posedge clk or negedge rst_n)

if(!rst_n)

   echo_r<=2'b00;

else

   echo_r<={echo_r[0],echo};

对输入信号echo缓存2拍

ShellAlbert commented 5 years ago

quartus tcl管脚分配

FPGA芯片的引脚很多,如果手工分配,工作量很大,且容易出错。应该采用自动分配引脚的方法。 具体做法如下: 1 打开一个已经分配好引脚的工程,应该选择使用引脚比较多的工程。 2 点击Assignments 菜单下的Pins 菜单项, 打开引脚分配界面, 点击File菜单下的Export菜单项,打开引脚导出对话框, 选择导出文件类型为Tcl 3 在一个新的工程, 若要分配引脚, 点击View菜单下Utility Windows 的Tcl Console, 在Quartus 主界面的右下方,出现Tcl Console 4 将第二步生成的Tcl文件用记事本打开,选择全部内容复制, 在Quartus的Tcl Console窗口粘贴, 并按回车键结束Tcl 命令。 5 点击Assignments 菜单下的Pins 菜单项, 打开引脚分配界面,可以见到已经分配了引脚。

ShellAlbert commented 5 years ago

quartus 中自动分配管脚的三种方法

1.编写tcl文件 (1)在Quartus中新建一个Tcl Scripe File,文件内容的格式如下:

setup.tcl

setup pin setting

set_global_assignment -name RESERVE_ALL_UNUSED_PINS "AS INPUT TRI-STATED" set_global_assignment -name ENABLE_INIT_DONE_OUTPUT OFF set_location_assignment PIN_D13 -to iCLK set_location_assignment PIN_G26 -to iRST_N set_location_assignment PIN_H3 -to LCD_DATA[7] ....... 其中#setup.tcl和#setup pin setting为说明语句,#setup.tcl中的setup为该文件名字,可以更改。 注意:LCD_DATA[7]中的\一定要加上。 (2)保存 (3)Project->Add/Remove Files.....->找到该文件,点击Add (4)Tools->Tcl Scripe .....->选中该文件,点击run 设置完毕。

2.添加.cvs文件 (1)新建一个excel文件,内容格式如下: To Location

SW[0] PIN_N25 SW[1] PIN_N26 SW[2] PIN_P25 SW[3] PIN_AE14 SW[4] PIN_AF14

保存时将文件类型设为.cvs格式。 注意:该文件中的引脚名一定要和quartus顶层文件的输入输出引脚名一样。 (2)Assignments->Import Assignments.....->导入该文件,点击OK。 设置完毕。

3.txt文件 格式: to,location SW0,PIN_N25 SW1,PIN_N26 ... 导入方法与CSV文件相同