SlideShare a Scribd company logo
By
Ankur gupta
2511060
Tevatron technologies Pvt. Ltd.
(A registered private limited company under Ministry of
Corporate Affairs, Govt. of India) is a Design and
Product Company focused on VLSI Design, FPGA
Based Design & Embedded Systems and nurturing the
ecosystem for the same. It has branches in Lucknow
,Noida and Bangalore.
What is verilog ?
 Verilog is one of the two major Hardware Description
Languages(HDL) used by hardware designers in industry
and academia.
 VHDL is another one
 Verilog is easier to learn and use than VHDL
 Verilog is C-like . VHDL is very Aad-like.
 Verilog HDL allows a hardware designer to describer
designs at a high level of abstraction such as at the
architectural or behavioral level as well as the lower
implementation levels(i.e., gate and switch levels).
Why use verilog ?
 Digital system are highly complex.
 Verilog language provides the digital designer, a software
platform.
 Verilog allow user to express their design with
BEHAVIORAL CONSTRUCTS.
 A program tool can convert the verilog program to a
description that was used to make exact chip, like VLSI.
Development of verilog
 Verilog was introduced in 1985 by Gateway Design
System Corporation, now a part of Cadence Design
Systems. Until May, 1990, with the formation of Open
Verilog International (OVI),
 Verilog HDL was a proprietary language of Cadence.
Cadence was motivated to open the language to the
Public Domain with the expectation that the market
for Verilog HDL-related software products would grow
more rapidly with broader acceptance of the language
Comparison b/w verilog and VHDL
Different styles of modelling
 Structural - instantiation of primitives and modules
 RTL/Dataflow - continuous assignments
 Behavioral - procedural assignments
MUX in structural style
MUX in RTL/dataflow
MUX in behavioural style
Program structure
 Structure
module <module name> (< port list>);
< declares>
<module items>
endmodule
. Module name
an identifier that uniquely names the module.
. Port list
a list of input, inout and output ports which are used to other
modules.
Program structure
Declares
section specifies data objects as registers,
memories and wires as well as procedural
constructs such as functions and tasks.
. Module items
initial constructs
always constructs
assignment
End module
An example
module Fulladder ( a,b,cin,sum,carry);
input a,b,cin;
output reg sum;
output reg carry;
always@(a,b,cin)
begin
if(a==0 && b==0 && cin==0)
begin
sum=0;
carry=0;
end
else if (a==0 && b==0 && cin==1)
begin
sum=1;
carry=0;
end
else if (a==0 && b==1 && cin==0)
begin
sum=1;
carry=0;
end
else if(a==0 && b==1 && cin==1)
begin
sum=0;
carry=1;
end
else if (a==1 && b==0 && cin==0)
begin
sum=1;
carry=0;
end
else if (a==1 && b==0 && cin==1)
begin
sum=0;
carry=1;
end
else if (a==1 && b==1 && cin==0)
begin
sum=1;
carry=0;
end
else if(a==1 && b==1 && cin==1)
begin
sum=1;
carry=1;
Connections in structural style
 By position association
 module C_2_4_decoder_with_enable (A, E_n, D);
 C_4_16_decoder_with_enable DX (X[3:2], W_n, word);
 A = X[3:2], E_n = W_n, D = word
 By name association
 module C_2_4_decoder_with_enable (A, E_n, D);
 C_2_4_decoder_with_enable DX (.E_n(W_n),
.A(X[3:2]), .D(word));
 A = X[3:2], E_n = W_n, D = word
Language convention
 Case-sensitivity
 Verilog is case-sensitive.
 Some simulators are case-insensitive
 Advice: - Don’t use case-sensitive feature!
 Keywords are lower case
 Different names must be used for different items within the
same scope
 Identifier alphabet:
 Upper and lower case alphabetical
 decimal digits
 underscore
Language convention
 Maximum of 1024 characters in identifier
 First character not a digit
 Statement terminated by ;
 Free format within statement except for within quotes
 Strings enclosed in double quotes and must be on a single line
 Comments:
 All characters after // in a line are treated as a comment
 Multi-line comments begin with /* and end with */
 Compiler directives begin with // synopsys
 Built-in system tasks or functions begin with $
variables
 Nets
 Used for structural connectivity
 Registers
 Abstraction of storage (May or may not be real physical
storage)
 Properties of Both
 Informally called signals
 May be either scalar (one bit) or vector (multiple bits)
Data Types - Nets - Semantics
 wire - connectivity only; no logical
 tri - same as wire, but indicates will be 3-
stated in hardware
 wand - multiple drivers - wired and
 wor - multiple drivers - wired or
 triand - same as wand, but 3-state
 trior - same as wor but 3-state
 supply0 - Global net GND
 supply1 - Global Net VCC (VDD)
 tri0, tri1, trireg
Net Examples
 wire x;
 wire x, y;
 wire [15:0] data, address;
 wire vectored [1:7] control;
 wire address = offset + index;
 wor interrupt_1, interrupt_2;
 tri [31:0] data_bus, operand_bus;
 Value implicitly assigned by connection to primitive or
module output
Data Types - Register Semantics
 reg - stores a logic value
 integer – stores values which are not to be stored in
hardware
 Defaults to simulation computer register length or 32
bits whichever is larger
 No ranges or arrays supported
 May yield excess hardware if value needs to be stored in
hardware; in such a case, use sized reg.
 time - stores time 64-bit unsigned
 real - stores values as real num
 realtime - stores time values as real numbers
Register Assignment
 A register may be assigned value only within:
 a procedural statement
 a user-defined sequential primitive
 a task, or
 a function.
 A reg object may never by assigned value by:
 a primitive gate output or
 a continuous assignment
Register Examples
 reg a, b, c;
 reg [15:0] counter, shift_reg;
 reg [8:4] flops;
 integer sum, difference
Constants (Parameters)
 Declaration of parameters
 parameter A = 2’b00, B = 2’b01, C = 2’b10;
 parameter regsize = 8;
 reg [regsize - 1:0]; /* illustrates use of parameter regsize */
Operators
 Arithmetic (binary: +, -,*,/,%*); (unary: +, -)
 Bitwise (~, &,|,^,~^,^~)
 Reduction (&,~&,|,~|,^,~^,^~)
 Logical (!,&&,||,==,!=,===,!==)
 Relational (<,<=,>,>=)
 Shift (>>,<<)
 Conditional ? :
 Concatenation and Replications {A,B} {4{B}}
* Not supported for variables
Project:UART
 UART: Universal asynchronous Receiver transmitter
 Its a piece of Computer hardware that translates
between parallel and serial forms.
• A UART may be used when:
– High speed is not required
– A cheap communication line between two devices
is required
Use of UART
 PC serial port is a UART!
Serializes data to be sent over serial cable
– De-serializes received data
 Communication between distant computers
– Serializes data to be sent to modem
– De-serializes data received from modem
 Used to be commonly used for internet access
 Used to be used for mainframe access
– A mainframe could have dozens of serial ports
Parts of UART
 Transmitter
 Receiver
 Baud generator( clock generator)
Transmitter
module transmitter (clk,ready,datain,dataout);
input clk,ready;
input [7:0] datain;
output reg dataout;
integer count=0;
reg q;
always@(posedge clk)
begin
if(ready==1) begin
q=1;
end
if(q==1)
begin
count=count+1;
if(count==1)
dataout=0;
if (count==2)
dataout=datain[0];
if(count==3)
dataout=datain[1];
if(count==4)
dataout=datain[2];
if(count==5)
dataout=datain[3];
if(count==6)
dataout=datain[4];
if(count==7)
dataout=datain[5];
if(count==8)
dataout=datain[6];
if(count==9)
dataout=datain[7];
if (count==10)
dataout=1;
if (count==11)
begin
q=0;
count=0;
end
if (count==12)
begin
q=0;
count=0;
end
end
end
endmodule
Receiver
module
ps2_keyboard(ps2_clk,ps2_data
,ps2_dataout);
input ps2_clk,ps2_data;
output reg [7:0] ps2_dataout;
integer count=0;
integer q=0;
reg [7:0] store;
reg parity;
always@(negedge ps2_clk)
begin
if (q==0) begin
if(ps2_data==0)
q=1;
end
else if (q==1) begin
if(count<8) begin
store[count]=ps2_data;
end
count=count+1;
if(count==8)
begin
if(ps2_data==(^store))
parity=1;
end
else if (count==9) begin
if(ps2_data==1 &&
parity==1)begin
ps2_dataout[0]=store[0];
ps2_dataout[1]=store[1];
ps2_dataout[2]=store[2];
ps2_dataout[3]=store[3];
ps2_dataout[4]=store[4];
ps2_dataout[5]=store[5];
ps2_dataout[6]=store[6];
ps2_dataout[7]=store[7];
end
q=0;
parity=0;
count=0;
end
end
end
endmodule
Baud generator
module BDG_clk (clk,clk_t);
input clk;
output reg clk_t;
parameter baudrate=9600,b_clk=96000;
integer i=0,divisor;
always@(posedge clk)
begin
i = i + 1;
divisor = (b_clk/baudrate);
if(i== divisor/2)
clk_t=0;
//else if(i>divisor/2)
else if (i == divisor)begin
i = 0;
clk_t=1;
end
end
endmodule
Top UART
module top_uart (clk,datain,dataout,p1);
input clk,datain;
output [7:0] p1;
output dataout;
wire b_clk,ready;
wire [7:0] r_dataout ;
BDG_clk c1( clk,b_clk);
ps2_keyboard r1(b_clk,datain,r_dataout);
transmitter t1(b_clk,ready,r_dataout,dataout);
assign p1=r_dataout;
endmodule
Video of the project
Verilog presentation final
Verilog presentation final
Verilog presentation final

More Related Content

What's hot (20)

PPT
Verilog Tasks and functions
Vinchipsytm Vlsitraining
 
PDF
Verilog Tasks & Functions
anand hd
 
PPTX
Verilog Tutorial - Verilog HDL Tutorial with Examples
E2MATRIX
 
PPTX
Data flow model -Lecture-4
Dr.YNM
 
PDF
Delays in verilog
JITU MISTRY
 
PPT
VHDL-PRESENTATION.ppt
Dr.YNM
 
PDF
Data types in verilog
Nallapati Anindra
 
DOCX
4 bit uni shift reg
E ER Yash nagaria
 
PPTX
Verilog operators
Dr.YNM
 
PPTX
Verilog operators.pptx
VandanaPagar1
 
PPT
Switch level modeling
Devi Pradeep Podugu
 
PPT
UART
Naveen Kumar
 
PDF
Verilog full adder in dataflow & gate level modelling style.
Omkar Rane
 
PPT
Basics of Verilog.ppt
CoEBMSITM
 
PDF
Verilog HDL- 2
Prabhavathi P
 
PDF
VHDL- gate level modelling
VandanaPagar1
 
PDF
vlsi design flow
Anish Gupta
 
PPTX
Line coding
Rina Ahire
 
PDF
Verilog lab manual (ECAD and VLSI Lab)
Dr. Swaminathan Kathirvel
 
PDF
VLSI Fresher Resume
vikas kumar
 
Verilog Tasks and functions
Vinchipsytm Vlsitraining
 
Verilog Tasks & Functions
anand hd
 
Verilog Tutorial - Verilog HDL Tutorial with Examples
E2MATRIX
 
Data flow model -Lecture-4
Dr.YNM
 
Delays in verilog
JITU MISTRY
 
VHDL-PRESENTATION.ppt
Dr.YNM
 
Data types in verilog
Nallapati Anindra
 
4 bit uni shift reg
E ER Yash nagaria
 
Verilog operators
Dr.YNM
 
Verilog operators.pptx
VandanaPagar1
 
Switch level modeling
Devi Pradeep Podugu
 
Verilog full adder in dataflow & gate level modelling style.
Omkar Rane
 
Basics of Verilog.ppt
CoEBMSITM
 
Verilog HDL- 2
Prabhavathi P
 
VHDL- gate level modelling
VandanaPagar1
 
vlsi design flow
Anish Gupta
 
Line coding
Rina Ahire
 
Verilog lab manual (ECAD and VLSI Lab)
Dr. Swaminathan Kathirvel
 
VLSI Fresher Resume
vikas kumar
 

Viewers also liked (6)

PDF
Uart
Ankit Singh
 
DOCX
Uart
cs1090211
 
PPT
Verilog hdl design examples
dennis gookyi
 
PDF
Verilog HDL Training Course
Paul Laskowski
 
PPTX
Verilog
Mr SMAK
 
PPT
Behavioral modeling
dennis gookyi
 
Uart
cs1090211
 
Verilog hdl design examples
dennis gookyi
 
Verilog HDL Training Course
Paul Laskowski
 
Verilog
Mr SMAK
 
Behavioral modeling
dennis gookyi
 
Ad

Similar to Verilog presentation final (20)

PPTX
Verilog Final Probe'22.pptx
SyedAzim6
 
PPTX
System Verilog Tutorial - VHDL
E2MATRIX
 
PDF
Verilog
abkvlsi
 
PPTX
verilog_tutorial1.pptx
SuyashMishra465104
 
PDF
DLD5.pdf
Shashi738182
 
PPT
Crash course in verilog
Pantech ProLabs India Pvt Ltd
 
PPTX
systemverilog and veriog presentation
KhushiV8
 
PDF
VHDL- data types
VandanaPagar1
 
PDF
Verilog_Overview.pdf
QuangHuyDo3
 
PPT
Verilogforlab
Shankar Bhukya
 
PPTX
a verilog presentation for deep concept understa
SRAJALDWIVEDI1
 
PPTX
Verilog data types -For beginners
Dr.YNM
 
PPTX
HDL_verilog_unit_1 for engagement subjects and technology
praveenbudihal
 
PDF
Short Notes on Verilog and SystemVerilog
Jason J Pulikkottil
 
PDF
Verilog_Cheat_sheet_1672542963.pdf
sagar414433
 
PDF
Verilog_Cheat_sheet_1672542963.pdf
sagar414433
 
PDF
Verilog Cheat sheet-2 (1).pdf
DrViswanathKalannaga1
 
PDF
verilog ppt .pdf
RavinaBishnoi8
 
PDF
dokumen.tips_verilog-basic-ppt.pdf
Velmathi Saravanan
 
PPTX
systemverilog and veriog presentation
KhushiV8
 
Verilog Final Probe'22.pptx
SyedAzim6
 
System Verilog Tutorial - VHDL
E2MATRIX
 
Verilog
abkvlsi
 
verilog_tutorial1.pptx
SuyashMishra465104
 
DLD5.pdf
Shashi738182
 
Crash course in verilog
Pantech ProLabs India Pvt Ltd
 
systemverilog and veriog presentation
KhushiV8
 
VHDL- data types
VandanaPagar1
 
Verilog_Overview.pdf
QuangHuyDo3
 
Verilogforlab
Shankar Bhukya
 
a verilog presentation for deep concept understa
SRAJALDWIVEDI1
 
Verilog data types -For beginners
Dr.YNM
 
HDL_verilog_unit_1 for engagement subjects and technology
praveenbudihal
 
Short Notes on Verilog and SystemVerilog
Jason J Pulikkottil
 
Verilog_Cheat_sheet_1672542963.pdf
sagar414433
 
Verilog_Cheat_sheet_1672542963.pdf
sagar414433
 
Verilog Cheat sheet-2 (1).pdf
DrViswanathKalannaga1
 
verilog ppt .pdf
RavinaBishnoi8
 
dokumen.tips_verilog-basic-ppt.pdf
Velmathi Saravanan
 
systemverilog and veriog presentation
KhushiV8
 
Ad

Recently uploaded (20)

PPTX
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
PDF
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PDF
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PPTX
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
SERVERLESS PERSONAL TO-DO LIST APPLICATION
anushaashraf20
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 

Verilog presentation final

  • 2. Tevatron technologies Pvt. Ltd. (A registered private limited company under Ministry of Corporate Affairs, Govt. of India) is a Design and Product Company focused on VLSI Design, FPGA Based Design & Embedded Systems and nurturing the ecosystem for the same. It has branches in Lucknow ,Noida and Bangalore.
  • 3. What is verilog ?  Verilog is one of the two major Hardware Description Languages(HDL) used by hardware designers in industry and academia.  VHDL is another one  Verilog is easier to learn and use than VHDL  Verilog is C-like . VHDL is very Aad-like.  Verilog HDL allows a hardware designer to describer designs at a high level of abstraction such as at the architectural or behavioral level as well as the lower implementation levels(i.e., gate and switch levels).
  • 4. Why use verilog ?  Digital system are highly complex.  Verilog language provides the digital designer, a software platform.  Verilog allow user to express their design with BEHAVIORAL CONSTRUCTS.  A program tool can convert the verilog program to a description that was used to make exact chip, like VLSI.
  • 5. Development of verilog  Verilog was introduced in 1985 by Gateway Design System Corporation, now a part of Cadence Design Systems. Until May, 1990, with the formation of Open Verilog International (OVI),  Verilog HDL was a proprietary language of Cadence. Cadence was motivated to open the language to the Public Domain with the expectation that the market for Verilog HDL-related software products would grow more rapidly with broader acceptance of the language
  • 7. Different styles of modelling  Structural - instantiation of primitives and modules  RTL/Dataflow - continuous assignments  Behavioral - procedural assignments
  • 11. Program structure  Structure module <module name> (< port list>); < declares> <module items> endmodule . Module name an identifier that uniquely names the module. . Port list a list of input, inout and output ports which are used to other modules.
  • 12. Program structure Declares section specifies data objects as registers, memories and wires as well as procedural constructs such as functions and tasks. . Module items initial constructs always constructs assignment End module
  • 13. An example module Fulladder ( a,b,cin,sum,carry); input a,b,cin; output reg sum; output reg carry; always@(a,b,cin) begin if(a==0 && b==0 && cin==0) begin sum=0; carry=0; end else if (a==0 && b==0 && cin==1) begin sum=1; carry=0; end else if (a==0 && b==1 && cin==0) begin sum=1; carry=0; end
  • 14. else if(a==0 && b==1 && cin==1) begin sum=0; carry=1; end else if (a==1 && b==0 && cin==0) begin sum=1; carry=0; end else if (a==1 && b==0 && cin==1) begin sum=0; carry=1; end else if (a==1 && b==1 && cin==0) begin sum=1; carry=0; end else if(a==1 && b==1 && cin==1) begin sum=1; carry=1;
  • 15. Connections in structural style  By position association  module C_2_4_decoder_with_enable (A, E_n, D);  C_4_16_decoder_with_enable DX (X[3:2], W_n, word);  A = X[3:2], E_n = W_n, D = word  By name association  module C_2_4_decoder_with_enable (A, E_n, D);  C_2_4_decoder_with_enable DX (.E_n(W_n), .A(X[3:2]), .D(word));  A = X[3:2], E_n = W_n, D = word
  • 16. Language convention  Case-sensitivity  Verilog is case-sensitive.  Some simulators are case-insensitive  Advice: - Don’t use case-sensitive feature!  Keywords are lower case  Different names must be used for different items within the same scope  Identifier alphabet:  Upper and lower case alphabetical  decimal digits  underscore
  • 17. Language convention  Maximum of 1024 characters in identifier  First character not a digit  Statement terminated by ;  Free format within statement except for within quotes  Strings enclosed in double quotes and must be on a single line  Comments:  All characters after // in a line are treated as a comment  Multi-line comments begin with /* and end with */  Compiler directives begin with // synopsys  Built-in system tasks or functions begin with $
  • 18. variables  Nets  Used for structural connectivity  Registers  Abstraction of storage (May or may not be real physical storage)  Properties of Both  Informally called signals  May be either scalar (one bit) or vector (multiple bits)
  • 19. Data Types - Nets - Semantics  wire - connectivity only; no logical  tri - same as wire, but indicates will be 3- stated in hardware  wand - multiple drivers - wired and  wor - multiple drivers - wired or  triand - same as wand, but 3-state  trior - same as wor but 3-state  supply0 - Global net GND  supply1 - Global Net VCC (VDD)  tri0, tri1, trireg
  • 20. Net Examples  wire x;  wire x, y;  wire [15:0] data, address;  wire vectored [1:7] control;  wire address = offset + index;  wor interrupt_1, interrupt_2;  tri [31:0] data_bus, operand_bus;  Value implicitly assigned by connection to primitive or module output
  • 21. Data Types - Register Semantics  reg - stores a logic value  integer – stores values which are not to be stored in hardware  Defaults to simulation computer register length or 32 bits whichever is larger  No ranges or arrays supported  May yield excess hardware if value needs to be stored in hardware; in such a case, use sized reg.  time - stores time 64-bit unsigned  real - stores values as real num  realtime - stores time values as real numbers
  • 22. Register Assignment  A register may be assigned value only within:  a procedural statement  a user-defined sequential primitive  a task, or  a function.  A reg object may never by assigned value by:  a primitive gate output or  a continuous assignment
  • 23. Register Examples  reg a, b, c;  reg [15:0] counter, shift_reg;  reg [8:4] flops;  integer sum, difference
  • 24. Constants (Parameters)  Declaration of parameters  parameter A = 2’b00, B = 2’b01, C = 2’b10;  parameter regsize = 8;  reg [regsize - 1:0]; /* illustrates use of parameter regsize */
  • 25. Operators  Arithmetic (binary: +, -,*,/,%*); (unary: +, -)  Bitwise (~, &,|,^,~^,^~)  Reduction (&,~&,|,~|,^,~^,^~)  Logical (!,&&,||,==,!=,===,!==)  Relational (<,<=,>,>=)  Shift (>>,<<)  Conditional ? :  Concatenation and Replications {A,B} {4{B}} * Not supported for variables
  • 26. Project:UART  UART: Universal asynchronous Receiver transmitter  Its a piece of Computer hardware that translates between parallel and serial forms. • A UART may be used when: – High speed is not required – A cheap communication line between two devices is required
  • 27. Use of UART  PC serial port is a UART! Serializes data to be sent over serial cable – De-serializes received data  Communication between distant computers – Serializes data to be sent to modem – De-serializes data received from modem  Used to be commonly used for internet access  Used to be used for mainframe access – A mainframe could have dozens of serial ports
  • 28. Parts of UART  Transmitter  Receiver  Baud generator( clock generator)
  • 29. Transmitter module transmitter (clk,ready,datain,dataout); input clk,ready; input [7:0] datain; output reg dataout; integer count=0; reg q; always@(posedge clk) begin if(ready==1) begin q=1; end if(q==1) begin count=count+1; if(count==1) dataout=0; if (count==2) dataout=datain[0]; if(count==3) dataout=datain[1]; if(count==4) dataout=datain[2]; if(count==5) dataout=datain[3]; if(count==6) dataout=datain[4]; if(count==7) dataout=datain[5]; if(count==8) dataout=datain[6]; if(count==9) dataout=datain[7]; if (count==10) dataout=1; if (count==11) begin q=0; count=0; end
  • 31. Receiver module ps2_keyboard(ps2_clk,ps2_data ,ps2_dataout); input ps2_clk,ps2_data; output reg [7:0] ps2_dataout; integer count=0; integer q=0; reg [7:0] store; reg parity; always@(negedge ps2_clk) begin if (q==0) begin if(ps2_data==0) q=1; end else if (q==1) begin if(count<8) begin store[count]=ps2_data; end count=count+1; if(count==8) begin if(ps2_data==(^store)) parity=1; end else if (count==9) begin if(ps2_data==1 && parity==1)begin ps2_dataout[0]=store[0]; ps2_dataout[1]=store[1]; ps2_dataout[2]=store[2]; ps2_dataout[3]=store[3]; ps2_dataout[4]=store[4];
  • 33. Baud generator module BDG_clk (clk,clk_t); input clk; output reg clk_t; parameter baudrate=9600,b_clk=96000; integer i=0,divisor; always@(posedge clk) begin i = i + 1; divisor = (b_clk/baudrate); if(i== divisor/2) clk_t=0; //else if(i>divisor/2) else if (i == divisor)begin i = 0; clk_t=1; end end endmodule
  • 34. Top UART module top_uart (clk,datain,dataout,p1); input clk,datain; output [7:0] p1; output dataout; wire b_clk,ready; wire [7:0] r_dataout ; BDG_clk c1( clk,b_clk); ps2_keyboard r1(b_clk,datain,r_dataout); transmitter t1(b_clk,ready,r_dataout,dataout); assign p1=r_dataout; endmodule
  • 35. Video of the project