几个常用的Verilog小程序

几个常用的Verilog小程序
几个常用的Verilog小程序

几个常用的Verilog小程序

(1) 8位串并转换

module haidaoqi(clk,rst,din,dout);

input clk,rst,din;

output [7:0] dout;

reg[7:0] data,dout;

reg[2:0] cnt;

always@(posedge clk or posedge rst)

if(rst) //复位高有效

data <=8'b0;

else

data<= {data[7:0],din};//din是输入串行数据,假设输入数据高位在前

//这是一个移位寄存器

always@(posedge clk or posedge rst)

if(rst)

cnt <= 3'b0;

else

if(cnt == 3'b111)

cnt <= 3'b0;

else

cnt <= cnt +1;//计数器,用来计算移位次数,移位8次在以

后产生一个有效数据

always@(posedge clk or posedge rst)

if(rst)

dout <= 8'b0;

else

if(cnt == 3'b111)

dout <= data;//如果计数器记到7,那么输出一个有效的8位数据

else

dout <= 0;

endmodule

(2) 8 位数据寄存器

module reg8(out_data,in_data,clk,clr);

output[7:0] out_data;

input[7:0] in_data;

input clk,clr;

reg[7:0] out_data;

always @(posedge clk or posedge clr)

begin

if(clr) out_data <=0;

else out_data <=in_data;

end

endmodule

(3) 8位数据锁存器

module haidaoqi(data_out,data_in,clk,rst); output[7:0] data_out;

input[7:0] data_in;

input clk,rst;

reg[7:0] data_out;

always @(rst or clk or data_in)

begin

if (rst) data_out<=8'b0;

else if (clk) data_out<=data_in;

else data_out<=8'b0;

end

endmodule

(4) 8位并串转换

module haidaoqi(rst,clk,tem,D1);

input rst,clk;

input [7:0] tem;

output D1;

reg D1;

wire [7:0] tem;

reg [2:0] counter;

always @(posedge clk or posedge rst) begin

if (rst)

begin

counter<=3'b0;

D1<=0;

end

else if(counter==7)

begin

counter<=3'b0;

D1<=0;

end

else

begin

counter<=counter+1;

D1=tem[counter];

end

end

endmodule

(5) clk一分四/八频

module haidaoqi(clk1,clk2,clk,rst);

output clk1,clk2;

input clk,rst;

reg clk1,clk2;

reg[7:0] state;

parameter S0=8'b00000000,

S1=8'b00000001,

S2=8'b00000010,

S3=8'b00000100,

S4=8'b00001000,

S5=8'b00010000,

S6=8'b00100000,

S7=8'b01000000,

S8=8'b10000000;

always@(posedge clk)

if(rst)

begin

clk1<=0;

clk2<=0;

state<=S0;

end

else

begin

case(state)

S0:state<=S1;

S1:state<=S2;

S2:

begin

clk1<=~clk1;

state<=S3;

end

S3:state<=S4;

S4:

begin

clk1<=~clk1;

clk2=~clk2;

state<=S5;

end

S5:state<=S6;

S6:

begin

clk1<=~clk1;

state<=S7;

end

S7:state<=S8;

S8:

begin

clk1<=~clk1;

clk2=~clk2;

state<=S0;

end

default:state<=S0;

endcase

end

endmodule

(6) 8位比较器

module haidaoqi(a,b,en,y);

input[width-1:0] a,b;

input en;

output y;

reg y;

parameter width=8;

always@(a or b)

if(en)

begin

if(a==b)

y<=1;

else

y<=0;

end

else

y<=0;

endmodule

(7)带使能端的ram

module haidaoqi(dataout,datain,ena,read,write); output[7:0] dataout;

input[7:0] datain;

input ena,read,write;

reg[7:0] ram[1:0];

parameter addr=1'b0;

assign dataout=(read && ena)?ram[addr]:8'hzz;

always@(posedge write)

begin

ram[addr]<=datain;

end

endmodule

(8) 译码器

module haidaoqi(ma,a,b,c,d,e);

input[2:0] ma;

output a,b,c,d,e;

reg a,b,c,d,e;

always@(ma)

case(ma)

3'b001:{a,b,c,d,e}<=5'b10000;

3'b010:{a,b,c,d,e}<=5'b01000;

3'b011:{a,b,c,d,e}<=5'b00100;

3'b100:{a,b,c,d,e}<=5'b00010;

3'b101:{a,b,c,d,e}<=5'b00001;

default:{a,b,c,d,e}<=5'bzzzzz;

endcase

endmodule

(9) 带清0/置1端的T触发器

module T-trigger(clk,T,R,S,Q,Q1);

input clk,T,R,S;

output Q,Q1;

reg Q,Q1;

always @(posedge clk or negedge R or negedge S) begin

if(!R)

begin

Q <= 1'b0;

Q1<=1'b1;

end

else if(!S)

begin

Q <=1'b1;

Q1<=1'b0;

end

else if(T)

begin

Q<=~Q;

Q1<=~Q1;

end

end

endmodule

(10)带起始位识别的串并转换(存8位有效数据)module SIM(din,clk,rst,dout,ok);

input din,clk,rst;

output ok;

output[7:0] dout;

reg[7:0] indata_buf,dout;

reg[3:0] counter;

reg[2:0] state;

reg[1:0] cnt;

reg tag,ok;

integer bitpos=7;

parameter s0=0,s1=1,s2=2,s3=3,s4=4;

always@(posedge clk or posedge rst)

if(rst)

begin

state<=0;

counter<=0;

tag<=0;

indata_buf<=8'bz;

cnt<=0;

bitpos=7;

end

else case(state)

s0:begin

tag=0;

ok<=tag;

if(din)

begin

cnt<=cnt+1;

state<=s0;

if(cnt==3)

begin

state<=s1;

cnt<=0;

end

end

else begin

counter<=0;

state<=s0;

end

end

s1:begin

if(counter==7)

begin

state<=s2;

counter<=0;

end

else

begin

counter<=counter+1;

state<=s0;

end

end

s2:if(!din)

state<=s3;

else

state<=s0;

s3:begin

if(bitpos==-1)

begin

bitpos=7;

state<=s4;

end

else

begin

indata_buf[bitpos]<=din;

bitpos<=bitpos-1;

state<=s3;

end

end

s4:begin

tag=1'b1;

ok<=tag;

dout<=indata_buf;

state<=s0;

end

endcase

endmodul

(11)移位寄存器(9位有效数据输出)module ywjc(din,clk,rst,dout,ok);

input din,clk,rst;

output ok;

output[8:0] dout;

reg[8:0] indata_buf,dout;

reg[3:0] counter;

reg[2:0] state;

reg[1:0] cnt;

reg tag,ok;

integer bitpos=8;

parameter s0=0,s1=1,s2=2,s3=3,s4=4;

always@(posedge clk or posedge rst) if(rst)

begin

state<=0;

counter<=0;

tag<=0;

indata_buf<=9'bz;

cnt<=0;

bitpos=8;

end

else case(state)

s0:begin

tag=0;

ok<=tag;

begin

cnt<=cnt+1;

state<=s0;

if(cnt==3)

begin

state<=s1;

cnt<=0;

end

end

else begin

counter<=0;

state<=s0;

end

end

s1:begin

if(counter==8)

begin

state<=s2;

counter<=0;

end

else

counter<=counter+1;

state<=s0;

end

end

s2:if(!din)

state<=s3;

else

state<=s0;

s3:begin

if(bitpos==-1)

begin

bitpos=8;

state<=s4;

end

else

begin

indata_buf[bitpos]<=din;

bitpos<=bitpos-1;

state<=s3;

end

end

s4:begin

tag=1'b1;

ok<=tag;

dout<=indata_buf;

state<=s0;

end

endcase

endmodule

Director 疑难解答

Director 疑难解答 01. 如何制作一个放映机(projector)可以在不同分辨率下播放? [A] 加入下列语句: on prepareMovie (the stage).rect = (the desktopRectList)[1] (the stage).drawRect = (the desktopRectList)[1] end 注意,这个语句是通过放大或缩小舞台来达到效果的,所以会有变形。 02. 如何导入photoshop的图层? [A] Director7.0以后的版本你可以通过Medialab公司的Photocaster Xtra来实现。 03. 在程序中如何导入图片而不失去图片周围的白色部份? [A] 通过指定图片的trim whitespace属性可以实现: m = new(#bitmap) m.trimWhiteSpace = 0 m.filename = the moviePath & ‘‘file.bmp‘‘ m.media = m.media 04. 如何得到全局变量列表? [A] 在messages的窗口中,你可以输入showGlobals来显示所有的全局变量。以下的代码也可以显示所有的全局变量: repeat with x = 1 to (the globals).count put (the globals).getPropAt(x) & ‘‘= ‘‘& (the globals)[x] end repeat 05. 如何播放mpeg文件? [A] 有一系列的方法,不能说哪一种更好,并且在pc机和mac机上是不一样的,下面是四种常见的方法: 1. 用一个xtra。这种方法用起来简单,且也有好的产品支持,但大多不能跨平台使用。当然,这是需要购买的。 2. 使用ActiveX控件。这只能在pc机上用,相对xtra而言会有更多的限制,但它是免费的,且与标准playback能够很好的集成。

Verilog编码风格

Verilog编码风格 嵌入式开发2010-05-03 15:28:13 阅读14 评论0 字号:大中小订阅 这是以前公司的对fpga代码编写的要求 良好代码编写风格的通则概括如下: (1)对所有的信号名、变量名和端口名都用小写,这样做是为了和业界的习惯保持一致;对常量名和用户定义的类型用大写; (2)使用有意义的信号名、端口名、函数名和参数名; (3)信号名长度不要太长; (4)对于时钟信号使用clk 作为信号名,如果设计中存在多个时钟,使用clk 作为时钟信号的前缀; (5)对来自同一驱动源的信号在不同的子模块中采用相同的名字,这要求在芯片总体设计时就定义好顶层子模块间连线的名字,端口和连接端口的信号尽可能采用相同的名字; (6)对于低电平有效的信号,应该以一个下划线跟一个小写字母b 或n 表示。注意在同一个设计中要使用同一个小写字母表示低电平有效; (7)对于复位信号使用rst 作为信号名,如果复位信号是低电平有效,建议使用rst_n; (8)当描述多比特总线时,使用一致的定义顺序,对于verilog 建议采用bus_signal[x:0]的表示; (9)尽量遵循业界已经习惯的一些约定。如*_r 表示寄存器输出,*_a 表示异步信号,*_pn 表示多周期路径第n 个周期使用的信号,*_nxt 表示锁存前的信号,*_z 表示三态信号等; (10)在源文件、批处理文件的开始应该包含一个文件头、文件头一般包含的内容如下例所示:文件名,作者,模块的实现功能概述和关键特性描述,文件创建和修改的记录,包括修改时间,修改的内容等; (11)使用适当的注释来解释所有的always 进程、函数、端口定义、信号含义、变量含义或信号组、变量组的意义等。注释应该放在它所注释的代码附近,要求简明扼要,只要足够说明设计意图即可,避免过于复杂; (12)每一行语句独立成行。尽管VHDL 和Verilog 都允许一行可以写多个语句,当时每个语句独立成行可以增加可读性和可维护性。同时保持每行小于或等于72 个字符,这样做都是为了提高代码得可读性; (13)建议采用缩进提高续行和嵌套语句得可读性。缩进一般采用两个空格,如西安交通大学SOC 设计中心 2 如果空格太多则在深层嵌套时限制行长。同时缩进避免使用TAB 键,这样可以避免不同机器TAB 键得设置不同限制代码得可移植能力; (14)在RTL 源码的设计中任何元素包括端口、信号、变量、函数、任务、模块等的命名都不能取Verilog 和VHDL 语言的关键字; (15)在进行模块的端口申明时,每行只申明一个端口,并建议采用以下顺序:

AD转换verilog程序

// 16-bit Analogue-Digital Converter // // +-----------------------------+ // | Copyright 1996 DOULOS | // | designer : Tim Pagden | // | opened: 7 Jun 1996 | // +-----------------------------+ `timescale 1 ns / 1 ps module ADC_16bit (analog_in,digital_out); parameter conversion_time = 25.0, // conversion_time in ns // (see `timescale above) charge_limit = 1000000; // = 1 million input[63:0] analog_in; // double-precision representation of a real-valued input port; a fix that enables // analog wires between modules to be coped with in Verilog. // Think of input[63:0] as the equivalent of MAST's electrical. output[15:0] digital_out; reg[15:0] delayed_digitized_signal; reg[15:0] old_analog,current_analog; reg[4:0] changed_bits; reg[19:0] charge; reg charge_ovr; reg reset_charge; /* SIGNALS:- analog_in = 64-bit representation of a real-valued signal analog_signal = real valued signal recovered from analog_in analog_limited = analog_signal, limited to the real-valued input range of the ADC digital_out = digitized 16bit 2's complement quantization of analog_limited */ /* function to convert analog_in to digitized_2s_comp_signal. Takes analog_in values from (+10.0 v - 1LSB) to -10.0 v and converts them to values from +32767 to -32768 respectively */

Director MX 2004使用问答

Director MX 2004使用问答 Q: 为什么用MX2004打包后会显示标题栏? A:把display template中的titlebat options里的选项都取消就可以了。 Q:如何在DR中打开word文件 A:1,在d内打开须使用activex 2,在d外打开调用word程序打开即可 Q:怎样实现让用户选择不同的背景音乐? A:on mouseUp me,7v@ fileobj=new(xtra "fileio")~M+Hhf fileobj.setFilterMask("all file, *.*,mp3,*.mp3,wave, *.wav")i filename=displayOpen(fileobj)^|kHUb if filename="" or filename=void then exitU9 closefile(fileobj) jhI sound playFile 2, string(filename) end Q:请问怎么给mpg视频加遮照? A:1,利用open widndow 做视频遮照 2,用MPEG advance xtra 插件,在属性窗口中把playback opitions 下的DTS取消了,就可以了,然后就在视频之上的通道里放你遮的图片即可 Q:怎么检测本机是否连接到intel网上? A:WinSocket Xtra Ad可以实现,说明: WinSocket Xtra 是一套Sprite Xtra,一共有三个,分别为 TCPServer.X32,TCPClient.X32和UDPSocket.X32。TCPServer.X32是服务器端xtra,TCPClient.X32是客户端xtra,采用Tcp/ip协议。互相配套用于网络信息传递,可以构建类似聊天室,多人连线游戏。UDPSocket.X32采用UDP 协议。独立用于网络信息传递,也可以构建类似聊天室,多人连线游戏。 Q:flash动画导到dr后声音和动画不同步怎么解决? A:使用线索点,最好调好以后把它锁定。 Q:如何检测用户是否安装quicktime,若无就提示安装? A:on exitframe me if quicktimeversion()<5.0 then open the moviepath@"quicktime\fullinstallercn.exe“ halt() else go "start" end if end Q:为什么发布成exe文件后视频不能正常播放? A:1.打包后Xtras文件夹是否在打包文件夹下,是否包含播放视频所需插件 2.视频是否为mpg,如使用DirectMediaXtras,mpg文件是否与exe在同级目录下 Q:如何实现点击打开本地文件夹? A:gotoNetPage("c:\") 不过路径中不要有中文! Q:如何将dr里的flash导出? A:ExportSWF.x32插件。说明: object = xtra("ExportSWF").new()

VerilogHDL经典程序非常适合新手

一、2线-4线译码器 module counter4(q1,q0,ncr,cp); input cp,ncr; output q1,q0; reg q1,q0; always@(posedge cp or negedge ncr) begin if(~ncr){q1,q0}<=2'b00; else{q1,q0}<={q1,q0}+1'b1; end endmodule 二、4选1数据选择器 module selector4_1(i0,i1,i2,i3,a1,a0,y); input i0,i1,i2,i3,a1,a0; output y; reg y; always@(a1or a0) begin case({a1,a0}) 2'b00:y=i0; 2'b01:y=i1; 2'b10:y=i2; 2'b11:y=i3; default:y=0; 一、2线-4线译码器 module counter4(q1,q0,ncr,cp); input cp,ncr; output q1,q0; reg q1,q0; always@(posedge cp or negedge ncr) begin if(~ncr){q1,q0}<=2'b00; else{q1,q0}<={q1,q0}+1'b1; end endmodule 二、4选1数据选择器 module selector4_1(i0,i1,i2,i3,a1,a0,y); input i0,i1,i2,i3,a1,a0; output y; reg y; always@(a1or a0) begin case({a1,a0}) 2'b00:y=i0;

原创:VHDL verilog 互相调用的例子

给两个例子, 一个是VHDL做顶层调用verilog 一个是verilog 做顶层调用VHDL VHDL调用verilog: module sync_block #( parameter INITIALISE = 2'b00 ) ( input clk, // clock to be sync'ed to input data_in, // Data to be 'synced' output data_out // synced data ); //VHD entity dcm_reset is port( ref_reset : in std_logic; -- Synchronous reset in ref_clk domain ref_clk : in std_logic; -- Reliable reference clock of known frequency (125MHz) dcm_locked : in std_logic; -- The DCM locked signal dcm_reset : out std_logic -- The reset signal which should be connected to the DCM ); end dcm_reset; component sync_block port ( clk : in std_logic; -- clock to be sync'ed to data_in : in std_logic; -- Data to be 'synced' data_out : out std_logic -- synced data ); end component; dcm_locked_sync_tx : sync_block port map( clk => ref_clk, data_in => dcm_locked, data_out => dcm_locked_sync ); verilog调用VHDL:(目标还是上述VHDL模块) module gmii_if ( …… ); dcm_reset rx_dcm_reset ( .ref_reset (tx_reset), .ref_clk (tx_clk),

Director实例剖析

Director实例剖析:Director的常用Lingo命令和句柄 常用lingo 利用控制director电影的重要方面就是利用控制各个方面的属性,下面列出常用的精灵属性、字段属性、造型成员属性,以及其他的一些常用的命令和句柄。 1.常用精灵属性 blend 语法:the blend of sprite whichsprite 用途:此属性决定了精灵的混合百分比 举例:set the blend of sprite 3 to 40 bottom 语法:the bottom of sprite whichsprite 用途:此属性决定了精灵矩形边框的下部边缘的坐标值,这个属性可以用来测试但是不能直接修改 举例:set lowest =put the botiom ofsprite (i +l) castlibnum 语法:the castlibnum of sprite whichsprite 用途:此属性决定了精灵所使用的造型成员的cast表的编号,可以被测试和修改。如果更改此属性但是不修改castnum属性,director会使用原来的造型成员编号在新的cast表中为精灵寻找造型成员 举例:set the castlibnum of sprite 3 to the number ofcastlib“newcast” constrainh 语法:constrainh(whichsprite,va1ue) 用途:此函数首先计算表达式va1ue的值,然后和精灵的左右矩形边缘坐标进行比较。如果表达式在精灵左右矩形边缘之间,就返回这个表达式;如果这个表达式小于精灵矩形边缘的左边的坐标值,就返回精灵矩形左边边缘的坐标值;如果表达式大于精灵矩形边缘右边的坐标值,就返回精灵矩形右边边缘的坐标值 举例:put constrainh(1,20) --30 put constrainh(1,60) --60 put constrainh(1,100) constrainv 语法:constrainv(whichsprite,va1ue) 用途:和constrainh类似,但是是和精灵矩形边枢的上下边缘进行比较。 举例:set the locv of sprite l to constrainv(3,the mousev) constraint 语法:the constraint of sprite whichsprite

Verilog HDL编程举例

设计示范和上机习题 练习一.简单的组合逻辑设计 //(方法一): //---------------文件名compare.v ----------------- module compare(equal,a,b); input a,b; output equal; assign equal = (a==b)? 1 : 0; //a等于b时,equal输出为1;a不等于b时,equal输出为0。endmodule //(方法二): module compare(equal,a,b); input a,b; output equal; reg equal; always @(a or b) if(a==b) //a等于b时,equal输出为1; equal =1; else //a不等于b时,equal输出为0。 equal = 0; //思考:如果不写else 部分会产生什么逻辑?

endmodule //------------------------------------------------------------- //----------测试模块源代码(方法之一): `timescale 1ns/1ns // 定义时间单位。 `include "./compare.v" // 包含模块文件。在有的仿真调试环境中并不需要此语句。 //而需要从调试环境的菜单中键入有关模块文件的路径和名称 module t; reg a,b; wire equal; initial // initial常用于仿真时信号的给出。 begin a=0; b=0; #100 a=0; b=1; #100 a=1; b=1; #100 a=1; b=0; #100 a=0; b=0; #100 $stop; //系统任务,暂停仿真以便观察仿真波

verilog程序-60进制计数器

module count60_dongtai_LED ( input clk, input rest_n, output reg [2:0] sel, //位选 output reg [6:0] display ); reg [15:0] count_clk; // 分频计数器,最大2^16=64K分频 reg [5:0] sum_num; //计数缓存器,2^6=64 reg [3:0] g_bit; //个位 reg [3:0] s_bit; //十位 reg [3:0] disp_temp; //分频 always @ (posedge clk or negedge rest_n) begin if(rest_n ==0) begin count_clk=16'b0; end else begin if(count_clk==16'hffff) begin count_clk=16'b0; end else begin count_clk=count_clk+1'b1; end end end // 60进制计数 always @ (negedge count_clk[3] or negedge rest_n) begin // clk_clk[3] 对"clk" 16分频if(rest_n ==0) begin g_bit=4'b0; s_bit=4'b0; sum_num=6'b0; end else begin if (sum_num==6'd59) begin sum_num=6'b0; end else begin sum_num=sum_num+1'b1; end end s_bit=(sum_num/10)%10;

VerilogHDL实例

本文档含有很多Verilog HDL例子://与门 module zxhand2(c,a,b); input a,b; output c; assign c= a & b; endmodule //或门 module zxhor2(c,a,b); input a,b; output c; assign c= a | b; endmodule //非门 module zxhnot2(c,b); input b; output c; assign c=~ b; endmodule ////异或门 module zxhxro2(c,a,b); input b; output c; assign c=a ^ b; endmodule 两选一电路 module data_scan(d0,d1,sel,q); output q; input d0,d1,sel; wire t1,t2,t3; n1 zxhand2(t1,d0,sel); n2 zxhnot2 (t4,sel); n3 zxhand2(t2,d1,t4); n4 zxhor2(t3,t1,t2);

assign q=t1; endmodule verilog HDL实例(一) 练习一.简单的组合逻辑设计 目的: 掌握基本组合逻辑电路的实现方法。 这是一个可综合的数据比较器,很容易看出它的功能是比较数据a与数据b,如果两个数据相同,则给出结果1,否则给出结果0。在Verilog HDL中,描述组合逻辑时常使用assign结构。注意 equal=(a==b)?1:0,这是一种在组合逻辑实现分支判断时常使用的格式。 模块源代码: //--------------- compare.v ----------------- module compare(equal,a,b); input a,b; output equal; assign equal=(a==b)?1:0; //a等于b时,equal输出为1;a不等于b时, //equal输出为0。 endmodule 测试模块用于检测模块设计得正确与否,它给出模块的输入信号,观察模块的内部信号和输出信号,如果发现结果与预期的有所偏差,则要对设计模块进行修改。 测试模块源代码: `timescale 1ns/1ns //定义时间单位。 module comparetest; reg a,b; wire equal; initial //initial常用于仿真时信号的给出。 begin a=0; b=0; #100 a=0; b=1; #100 a=1; b=1; #100 a=1; b=0; #100 $stop; //系统任务,暂停仿真以便观察仿真波形。 end compare compare1(.equal(equal),.a(a),.b(b)); //调用模块。 Endmodule

ChartDirector常见用法(示例代码)

ChartDirector 常见用法(示例代码) 最近在尝试在ChartDirector 里进行坐标的设置,想在这里写写最近最近的学习成果。 下面是我的代码实例,里面就是实现如何在ChartDirector 里进行坐标的设置,代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 public void createChart(ChartViewer viewer, int index) { // 这是两组数据,X 和Y 会一一对应生成;多在多纵轴图中使用,横坐标点会自动调整。 double[] dataY0 = { 4.5, 5}; Date[] dataX0 = { new GregorianCalendar(1999, 1, 1).getTime(), new GregorianCalendar(2000, 8, 6).getTime() }; double[] dataY1 = {7, 6.5, 6, 5, 6.5, 7, 6, 5.5, 5,9,8,7,8}; Date[] dataX1 = {new GregorianCalendar(1999, 1, 1).getTime(), new GregorianCalendar(1999, 6, 1).getTime(), new GregorianCalendar(1999, 11, 1).getTime(), new GregorianCalendar(1999, 11, 15).getTime(), new GregorianCalendar(1999, 12, 9).getTime(), new GregorianCalendar(2000, 2, 3).getTime(), new GregorianCalendar(2000, 7, 13).getTime(), new GregorianCalendar(2001, 4, 5).getTime(), new GregorianCalendar(2001, 8, 16).getTime(), new GregorianCalendar(2001, 10, 16).getTime(),new GregorianCalendar(2001, 12, 16).getTime(),new GregorianCalendar(2002, 2, 16).getTime(),new GregorianCalendar(2002, 4, 16).getTime()}; //这是单独的横坐标数据,横坐标会根据数据进行调整,Y 轴会按照顺利一一对应。 Date[] dataX2 = { new GregorianCalendar(1999, 1, 1).getTime(), new

Verilog的135个经典设计实例

【例3.1】4位全加器 module adder4(cout,sum,ina,inb,cin); output[3:0] sum; output cout; input[3:0] ina,inb; input cin; assign {cout,sum}=ina+inb+cin; endmodule 【例3.2】4位计数器 module count4(out,reset,clk); output[3:0] out; input reset,clk; reg[3:0] out; always @(posedge clk) begin if (reset) out<=0; //同步复位 else out<=out+1; //计数 end endmodule 【例3.3】4位全加器的仿真程序 `timescale 1ns/1ns `include "adder4.v" module adder_tp; //测试模块的名字 reg[3:0] a,b; //测试输入信号定义为reg型 reg cin; wire[3:0] sum; //测试输出信号定义为wire型 wire cout; integer i,j; adder4 adder(sum,cout,a,b,cin); //调用测试对象 always #5 cin=~cin; //设定cin的取值 initial begin a=0;b=0;cin=0; for(i=1;i<16;i=i+1) #10 a=i; //设定a的取值 end - 1 -

initial begin for(j=1;j<16;j=j+1) #10 b=j; //设定b的取值 end initial//定义结果显示格式 begin $monitor($time,,,"%d + %d + %b={%b,%d}",a,b,cin,cout,sum); #160 $finish; end endmodule 【例3.4】4位计数器的仿真程序 `timescale 1ns/1ns `include "count4.v" module coun4_tp; reg clk,reset; //测试输入信号定义为reg型 wire[3:0] out; //测试输出信号定义为wire型 parameter DELY=100; count4 mycount(out,reset,clk); //调用测试对象 always #(DELY/2) clk = ~clk; //产生时钟波形 initial begin//激励信号定义 clk =0; reset=0; #DELY reset=1; #DELY reset=0; #(DELY*20) $finish; end //定义结果显示格式 initial $monitor($time,,,"clk=%d reset=%d out=%d", clk, reset,out); endmodule 【例3.5】“与-或-非”门电路 module AOI(A,B,C,D,F); //模块名为AOI(端口列表A,B,C,D,F) input A,B,C,D; //模块的输入端口为A,B,C,D output F; //模块的输出端口为F - 2 -

Verilog程序(汉字点阵显示

中国石油大学 数电课程设计报告题目: 学院: 班级: 姓名: 学号: 日期: 2012 年 12月

摘要 设计要求: 利用EDA/SOPC 实验开发平台提供的16*16点阵LED以及EPC235核心板,实现循环显示“中国石油大学”这6个汉字(左移或者右移均可)。 (1)手动生成“中国石油大学”这6个汉字在16*16点阵LED 上的6个字模(即控制某些LED亮,某些LED灭)。 (2)实现循环显示“中国石油大学”这6个汉字(左移或者右移均可)。 (3)拓展要求:自主设计(如控制循环速度,方向)。 关键词: 扫描分频,控制速度,点阵,点阵汉字显示,

设计原理及方案: 1、16*16点阵LED内部结构如下图所示。 2、总体设计框图: 3、各子模块的设计: (1)、分频,扫描: module fenpin (clk_50Mhz,clk_4hz,k2,k3); input clk_50Mhz,k2,k3; // 输入端口声明

output clk_4hz; // 输出端口声明reg[24:0] count,ccount; reg clk_4hz; always @(posedge clk_50Mhz) begin if ((k2==0) && (k3==0)) ccount<=500000000; if ((k2==0) && (k3==1)) ccount<=100000000; if ((k2==1) && (k3==0)) ccount<=50000000; if ((k2==1) && (k3==1)) ccount<=10000000; if(count

verilog_FPGA实例

一、组合逻辑实验 (2) 实验13X8译码器程序 (2) 实验2二-十进制译码器 (2) 实验3BCD码—七段数码管显示译码器 (3) 实验48-3编码器 (4) 实验58-3优先编码器 (4) 实验6十—二进制编码器 (5) 实验7三选一数据选择器 (5) 实验8半加器 (6) 实验9全加器 (7) 实验10半减器 (8) 实验11全减器 (8) 实验12多位数值比较器 (9) 实验13奇偶校验 (9) 实验14补码生成 (10) 实验158位硬件加法器的设计 (10) 实验164位并行乘法器 (10) 实验17七人表决器 (10) 实验18格雷码变换 (11) 二、时序逻辑实验 (11) 实验1D触发器 (11) 实验2JK触发器 (12) 实验3四位移位寄存器 (12) 实验4异步计数器 (13) 实验5同步计数器 (14) 实验6可逆计数器 (15) 实验7步长可变的加减计数器 (16) 实验8含异步清0和同步时钟使能的4位加法计数器 (17) 实验9顺序脉冲发生器 (18) 实验10序列信号发生器 (18) 实验11用状态机实现串行数据检测器 (19) 实验12分频器 (20) 实验13Moore状态机 (21) 实验14Mealy状态机 (23) 实验15三层电梯 (24) 实验16性线反馈移位寄存器(LFSR)设计 (32) 实验17正负脉宽数控调制信号发生器 (32) 三、存储器设计 (34) 实验1只读存储器(ROM) (34) 实验2SRAM (34) 实验3FIFO (35) 四、扩展接口实验 (39) 实验1流水灯 (39) 实验2VGA彩色信号显示控制器设计 (40)

director 快捷键

1、F i l e菜单快捷键 命令快捷键 New Movie(新影片)Ctrl+N NewCast(新演员表)Ctrl+Alt+N Open(打开)Ctrl+O Close(关闭)Ctrl+F4 Save(保存)Ctrl+S Import(输入)Ctrl+R Export(输出)Ctrl+Shift+R Preview inBrowser(在浏览器中预览)F12 Page Setup(页面设置)Ctrl+Shift+P Print(打印)Ctrl+P General Preferences(基本参数设置)Ctrl+U Exit/Quit(退出)Alt+F4 2、Edit菜单快捷键 命令快捷键 Undo(撤消)Ctrl+Z Repeat(重复)Ctrl+Y Cut(剪切)Ctrl+X 命令快捷键 Copy(拷贝)Ctrl+C Paste(粘贴)Ctrl+V Clear(清除)Backspace Duplicate(复制)Ctrl+D Select All(全选)Ctrl+A Find Text(查找文本)Ctrl+F Find Handler(查找处理程序)Ctrl+Shift+; Find Cast Member(查找演员)Ctrl+; Find Selection(查找选区)Ctrl+H Find Again(再查找)Ctrl+Alt+F Replace Again(再替换)Ctrl+Alt+E Edit Sprite Frames(编辑角色的帧)Ctrl+Alt+] Edit Entire Sprite(编辑整个角色)Ctrl+Alt+[ Exchange Cast Members(交换演员)Ctrl+E Launch External Editor(运行外部编辑器)Ctrl+,(逗号) 3、View菜单快捷键 命令快捷键 Next Marker(下一个标志)Ctrl+右箭头键 Previous Marker(前一个标志)Ctrl+左箭头键 Zoom In(变焦放大)Ctrl++ Zoom Out(变焦缩小)Ctrl+-(连字符) Show Grid(显示网格)Ctrl+Shift+Alt+G Snap to Grid(吸附于网格)Ctrl+Alt+G Show Rulers(显示标尺)Ctrl+Shift+Alt+R

ADDA等一些芯片的verilog程序

/* AD0809 module v1.0 work up to 5M sample = 25us 40khz for normal clk = 2.5M sample = 30us 33khz */ module ad0809( clkin, adclk, eoc, st, ale, datain, oe, dataout ); input clkin; input eoc; input [7:0]datain; output st; output ale; output oe; output adclk; output [7:0]dataout; reg adclk; reg [7:0]dataout; reg st; reg oe; reg ale; //frequence divider for AD parameter Div_adclk = 8'd9;//(9+1)*2=20 adclk=2.5M parameter Div_clk_state = 4'd4;//(4+1)*2=10 clk_state=5M

reg [8:0]div_cnt_ad;//frequence div cnt reg [3:0]div_cnt_state; reg clk_state; always@(negedge clkin)begin if(div_cnt_ad != Div_adclk) div_cnt_ad <= div_cnt_ad + 1'b1; else begin div_cnt_ad <= 0; adclk <= ~adclk; end if(div_cnt_state != Div_clk_state) div_cnt_state <= div_cnt_state + 1'b1; else begin div_cnt_state <= 0; clk_state <= ~clk_state; end end /*AD convert*/ reg [3:0]state; reg [7:0]delay; initial begin state <= 4'd0; end always@(negedge clk_state)begin case(state) 4'd0:begin //clear all st <= 1'b0; oe <= 1'b0; ale <= 1'b0;

外企常用英文简写

外企日常工作中常用的英语术语和缩写语 办公室职员(Office Clerk)加入公司的整个过程为例,引出在跨国公司(MNC-Multi-National Company) 工作中,日常人们喜欢经常使用的术语(Terminology)和缩写语(Abbreviation)。 [找工作Job Searching]我立志大学毕业后加入一家跨国公司。我制作了精美的个人简历(Resume, cv)。我参加了校园招聘(Campus Recruitment)。我关注报纸招聘广告(Recruiting Ads)。我也经常浏览招聘网站(Recruiting Website)。我还参加人才招聘会(Job Fair)。 [参加面试Be invited for Interview] 我选择了几家中意的公司,投出了简历。终于接到了人力资源部(Human Resources Department)邀请面试的通知。经过几轮面试(Interview)和笔试(Written Test)我终于接到了XXXX公司的聘用书(Offer Letter)。这是一家独资/合资企业(Wholly Foreign-Owned Company/Joint-Venture)。 [录用条件Employment Terms] 我隶属XX部门(Department)。我的职位(Position)是XXXX。我的工作职责(Job Responsibilities)是XXXX。我的直接上司(Direct Supervisor)是XXX。我的起点工资(Starting Salary)是XXXX。我的入职日期(Join-Date)是XXXX。我的试用期(Probation)是3个月。首期劳动合同(Labor Contract/Employment Contract)的期限(Term)是3年。 [第一天上班First day of join] 我乘坐公司班车(Shuttle Bus/Commuting Bus)来到公司。先来到人力资源部报到(Register)。我填了一系列的表格(Forms)。我领到了工卡(Badge Card)、餐卡(Meal Card)、员工手册(Employee Manual)、培训手册(Training Handbook)、保险手册(Insurance Handbook)、安全环境健康(EHS-Environment, Health and Safety)手册。公司培训主管(Training Supervisor)为我做了入职培训(Orientation)。我了解了公司的安全须知(Safety Precautions)和紧急疏散通道(Emergency Evacuation Route)。 [部门Department] 我随后来到我的部门,见到了我的部门经理(Department Manager)和同事(Colleagues)。我来到我的办公桌(Desk)前,看到办公用品(Stationery)和台式计算机(DeskTop)已经摆在桌上。经理说以后还会配备笔记本电脑(Notebook/LapTop)。 [午餐Lunch] 中午在公司餐厅(Cafeteria)吃饭,是免费的午餐(Free Lunch)。饭后跟大家一起外出散步。 [第一次会议First meeting] 下午部门开会(Have a Meeting),讨论目前面临的困难和问题(Difficulty & Issues),经理要求大家通过脑力激荡(Brain-Storming),找出问题的根源(Root Cause),并提出解决方案(Solutions)。 [各种类型会议Various meetings] 公司有多种会议。部门经理的管理层会议(Staff Meeting)。讨论项目进展的项目会议(Project Meeting)。讨论预算的预算会议(Budgeting Meeting)。与美国总部的电话会议(Teleconference Call)。还可以利用视频会议系统(Video Conference)或网络会议(Net-Meeting)系统开会。有各种周会(Weekly Meeting)、月例会(Monthly Meeting)、季度会议(Quarterly Meeting)和年度会议(Annual Meeting)。 [各种计划Various plans] 要制定各种计划(Plans)。有长期计划(Long-term Plan)、中期计

Verilog程序例子

modul e and1(a, b, c); input a; input b; output c; assign c = a & b; endmodul e `timescale 1ns/1ns modul e t; reg a; reg b; wire c; and1 t(a,b,c); initial begin a=0; b=0; #100 a = 1; b = 0; #100 a = 0; b = 1; #100 a = 0; b = 0; #100 a = 1; b = 1; #100 $stop;

end initial $monitor("a = %d, ", a, " b = %d, ", b, "c = %d\n", c); endmodul e modul e add(a, b, in, c, out); input a; input b; input in; output c; output out; assign {out, c} = a + b + in; endmodul e `timescal e 1ns/1ns modul e count_t; reg clk; reg a; reg b; reg in; wire c; wire out; ad d process(a, b, in, c, out);

initial clk = 0; always forever #5 clk = ~clk; initial begin a = 0; b = 0; in = 0; #10 a = 0; b = 0; in = 1; #10 a = 0; b = 1; in = 0; #10 a = 0; b = 1; in = 1; #10 a = 1; b = 0; in = 0; #10 a = 1; b = 0; in = 1; #10 a = 1; b = 1; in = 0; #10 a = 1; b = 1; in = 1; end initial begin #200 $finish; end initial $monitor(" out = %d, c = %d\n", out, c); endmodul e modul e compare (equal, a, b); input a,b; output equal; assign equal= (a==b)?1:0; endmodul e `timescal e 1ns/1ns modul e t; reg a, b; wire equal; initial begin a=0; b=0; #100 a = 1; b = 0;

相关文档
最新文档