07 2013 档案

摘要:简单运算逻辑单元ALU,实现传递,自加1,自减1,相加,相减,与,或,异或,非,左移一位,右移一位.Verilog代码:module ALU(in1,in2,op,out);input[7:0] in1,in2;input[3:0] op;output[15:0] out;wire[7:0] in1,in2;wire[3:0] op;reg[15:0] out;parameter transfer = 4'b0001, increase = 4'b0010, decrease = 4'b0011, addtion = 4'b0100, subtraction = 阅读全文
posted @ 2013-07-27 17:23 ToolsLab 编辑
摘要:四位串行加法器: 被加数a,加数b,低位进位ci,和数s,进位co.Verilog代码:module cxjfq(a,b,ci,s,co);input[3:0] a,b;input ci;output[3:0] s;output co;assign {co,s} = a+b+ci;endmodule仿真结果: 阅读全文
posted @ 2013-07-27 11:38 ToolsLab 编辑
摘要:四选一数据选择器真值表: Verilog代码: module mux4(en,d0,d1,d2,d3,a,y);input en,d0,d1,d2,d3;input[1:0] a;output y;reg y;always@(d0,d1,d2,d3,a,en)begin if(en==1'b0) begin y <= 1'b0; end else case(a) 2'b00: y<=d0; 2'b01: y<=d1; 2'b10: y<=d2; 2'b11: y<=d3; default: y<=1'b 阅读全文
posted @ 2013-07-25 17:41 ToolsLab 编辑
摘要:真值表:clrclkdin[3:0]doutqout1XX000↑din1[3:0]din1[3:0]X0↑Xdin1[2]、din1[1]、din1[0]、Xdin1[3]0↑Xdin1[1]、din1[0]、X、Xdin1[2]0↑Xdin1[0]、X、X、Xdin1[1]0↑din2[3:0]qin2[3:0]din1[0] 0↑Xdin2[2]、din2[1]、din2[0]、Xdin2[3]Verilog代码:module yiweireg4(clr,clk,din,qout);input clk,clr;inp... 阅读全文
posted @ 2013-07-24 17:23 ToolsLab 编辑
摘要:83优先编码器真值表:Verilog代码:module yxbm83(en,d,q);input en;input[7:0] d;output[2:0] q;reg[2:0] q;always@(en,d)begin if(en==1'b1) begin q <= 3'b111; end else begin if(d[7]==1'b0) begin q <= 3'b000; end else if(d[6]==1'b0) begin q <= 3'b001; end else if(d[5]==1'b0) begin 阅读全文
posted @ 2013-07-13 13:41 ToolsLab 编辑
摘要:顶层文件和module模块命名不能以数字开头。 阅读全文
posted @ 2013-07-13 09:45 ToolsLab 编辑
摘要:83编码器的真值表如下: Verilog代码:module bianma83(d,q);input[7:0] d;output[2:0] q;reg[2:0] q;always@(d)begin case(d) 8'b00000001: q=3'b000; 8'b00000010: q=3'b001; 8'b00000100: q=3'b010; 8'b00001000: q=3'b011; 8'b00010000: q=3'b100; 8'b00100000: q=3'b101; 8'b0 阅读全文
posted @ 2013-07-13 09:40 ToolsLab 编辑
摘要:阻塞赋值“=”语句是顺序执行,非阻塞赋值“《=”语句是并行(同时)执行。比如对于下面这段代码: module test(a,b,c,clk);input clk;input a;output b,c;reg b,c;always@(posedge clk)beginb = a; //b <= a;c = b;//c <= b; endendmodule对于阻塞语句,若开始b=0,a=1,clk上升沿后,b=1,c=1; 对于非阻塞语句,若开始b=0,a=1,clk上升沿后,b=1,c=0。仿真结果若下:总结: 1.同一个块程序中:阻塞赋值语句是顺序执行的;非阻塞赋值语句是并行执行的 阅读全文
posted @ 2013-07-12 16:11 ToolsLab 编辑
摘要:数字电路中有逻辑高、逻辑低和高阻三种状态。高阻在Verilog 中用‘z’表示。 三态门真值表: Verilog代码: module santaimen(en,din,dout);input en;input din;output dout;assign dout = en?din:1'bz; endmodule功能仿真: 阅读全文
posted @ 2013-07-12 11:55 ToolsLab 编辑
摘要:D触发器: 真值表:module Dchufaqi(r,s,cp,d,q,qn);input r;input s;input cp;input d;output q;output qn;reg q;reg qn;always@(posedge cp) begin if({r,s}==2'b01) begin q <= 1'b0; qn <= 1'b1; end else if({r,s}==2'b10) begin q <= 1'b1; qn <= ... 阅读全文
posted @ 2013-07-11 15:23 ToolsLab 编辑
摘要:四位二进制计数器和真值表: 代码如下:module jishuqi(clk,rst,en,rset,co,d,q);input clk;input rst;input rset;input en;input[3:0] d;output[3:0] q;output co;reg[3:0] q;reg co;always@(posedge clk) if(rst) begin q <= 4'd0; end else begin if(rset) begin q <= d; end else begin if(en) b... 阅读全文
posted @ 2013-07-09 15:43 ToolsLab 编辑
摘要:参照网上的教程,练习用Verilog写了个分频代码。代码和功能很简单,但新建工程的过程却遇到了点麻烦,输完代码后,“分析和综合”老实不成功,提示“Error:Top-level design entity “fenping” is underfined”,打开“Setting”->"General",看到 Top-level entity 标签后的顶层文件名也是对的,试了几次都提示相同错误。后来打开“...”按键,发现列表里有2个fenping,果断删掉一个,重新"分析和综合",立马好了。 系统时钟10分频代码如下: module fenging( 阅读全文
posted @ 2013-07-08 16:23 ToolsLab 编辑