Содержание
- 2. Areas of using System level Verilog is not ideally suited for abstract system-level simulation Digital Verilog
- 3. Simulation and Synthesis with Verilog Use Verilog for simulation Describe modular-hierarchical design Develop a testbench Analyze
- 4. Verilog provides mechanism for testbench description and description of hardware Resulting waveform or ASCII output is
- 5. Top-down Design Methodology
- 6. Bottom-up design methodology
- 7. Module declaration Hardware is described in a module Module description is bracketed by module and endmodule
- 8. Module example module T_FF (q, clock, reset); . . . . endmodule
- 9. Levels of description using verilog HDL Behavioral or algorithmic level Dataflow level Gate level Switch level
- 10. Design has a hierarchy of modules A module can completely specify hardware or consist of instantiation
- 11. Illegal module nesting module ripple_carry_counter(q, clk, reset); output [3:0] q; input clk, reset; module T_FF(q, clock,
- 12. Instances Design has a hierarchy of modules A module can completely specify hardware or consist of
- 13. Example of instances module ripple_carry_counter(q, clk, reset); output [3:0] q; input clk, reset; T_FF tff0 (q[0],clk,
- 14. Example of instances module T_FF(q, clk, reset); output q; input clk, reset; wire d; D_FF dff0(q,
- 15. Components of simulation
- 16. Components of simulation
- 17. Summary Two kinds of design methodologies are used for digital design: top-down and bottom-up Modules are
- 18. Lexical Conventions Comments A one-line comment - // A multiple-line comment or block comment "/*" and
- 19. OPERATORS Operators are of three types: unary binary ternary a = &b; a = b ||
- 20. Number Specification There are two types of number specification in Verilog sized unsized
- 21. Lexical Conventions Sized numbers ' only in decimal and specifies the number of bits in the
- 22. Lexical Conventions Legal base formats are decimal ('d or 'D), hexadecimal ('h or 'H), binary ('b
- 23. Lexical Conventions The number is specified 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 24. Lexical Conventions Examples of sized numbers 5'b01010 // This is a 5-bit binary number 16'hAbC //
- 25. Unsized numbers Examples 431215 // This is a 32-bit decimal number by default 'hd8 // This
- 26. Lexical Conventions 16'hx13x // This is a 16-bit hex number; 4 least and 4 most significant
- 27. Lexical Conventions Underscore characters and question marks 12'b1111_0000_1010 // Use of underline characters for readability 4'b10??
- 28. Identifiers and Keywords Keywords are special identifiers reserved to define the language constructs Keywords are in
- 29. Keywords
- 30. Identifiers made up of alphanumeric characters, the underscore ( _ ), or the dollar sign (
- 31. Identifiers and Keywords examples wire temp; // wire is a keyword; temp is an identifier output
- 32. Data Types
- 33. Nets represent connections between hardware elements. Nets are declared primarily with the keyword wire. The default
- 34. Nets Examples wire a; // Declare net a for the above circuit wire b,c; // Declare
- 35. Registers Registers represent data storage elements. Keyword is reg Default value for a reg data type
- 36. Example of Register reg reset; initial begin reset = 1'b1; #100 reset = 1'b0; end
- 37. Vectors Nets or reg data types can be declared as vectors vectors can be declared at
- 38. Vectors examples wire a; // scalar net variable wire [7:0] bus; // 8-bit bus wire [31:0]
- 39. Arrays Arrays are allowed in Verilog for reg, integer, time, and vector register data types Arrays
- 40. Arrays examples integer count[0:7]; reg bool[31:0]; time chk_point[1:100]; reg [4:0] port_id[0:7]; integer matrix[4:0][0:255]; // Illegal
- 41. Examples of assignments to elements of arrays Examples count[5] = 0; chk_point[100] = 0; port_id[3] =
- 42. Memories Memories are modeled in Verilog as array of registers reg mem1bit[0:1023]; reg [7:0] membyte[0:1023]; reg
- 43. Parameters Verilog allows constants to be defined in a module by the keyword parameter parameter port_id
- 44. Displaying information $display("Hello Verilog World"); $display($time); reg [0:40] virtual_addr; $display("At time %d virtual address is %h",
- 45. Monitoring information Usage: $monitor(p1,p2,p3,....,pn); Unlike $display, $monitor needs to be invoked only once .
- 46. Stopping and finishing in a simulation The task $stop is provided to stop during a simulation.
- 47. Stopping and finishing in a simulation initial begin clock = 0; reset = 1; #100 $stop;
- 48. Components of a Verilog Module
- 49. Modules, ports, declarations Scalar and vector ports All ports are wires Initially all values are Z
- 50. Port Connection Rules
- 51. Connecting Ports to External Signals Connecting by ordered list Connecting ports by name fulladd4 fa_byname(.c_out(C_OUT), .sum(SUM),
- 52. Hierarchical Names stimulus stimulus.q stimulus.qbar stimulus.set stimulus.reset stimulus.m1 stimulus.m1.Q stimulus.m1.Qbar stimulus.m1.S stimulus.m1.R stimulus.n1 stimulus.n2
- 53. Gate level combinational parts, using primitives, timing Verilog allows the use of gate built-in primitives An
- 54. Gate Instantiation of And/Or Gates wire OUT, IN1, IN2; and a1(OUT, IN1, IN2); nand na1(OUT, IN1,
- 55. Gate Delays Rise, Fall, and Turn-off Delays There are three types of delays from the inputs
- 56. Rise Delay The rise delay is associated with a gate output transition to a 1 from
- 57. Fall Delay The fall delay is associated with a gate output transition to a 0 from
- 58. Turn-off delay The turn-off delay is associated with a gate output transition to the high impedance
- 59. Types of Delay Specification // Delay of delay_time for all transitions and #(delay_time) a1(out, i1, i2);
- 60. Examples of delay specification and #(5) a1(out, i1, i2); and #(4,6) a2(out, i1, i2); bufif0 #(3,4,5)
- 61. Example Min, Max, and Typical Delay Values // One delay // if +mindelays, delay= 4 //
- 62. Example Min, Max, and Typical Delay Values // Two delays // if +mindelays, rise= 3, fall=
- 63. Example Min, Max, and Typical Delay Values // Three delays // if +mindelays, rise= 2 fall=
- 64. Delay Example
- 65. Delay Example module D (out, a, b, c); output out; input a,b,c; wire e; and #(5)
- 66. Continuous Assignments The left hand side of an assignment must always be a scalar or vector
- 67. Continuous Assignments The operands on the right-hand side can be registers or nets or function calls.
- 68. Examples of Continuous Assignment assign c = a & b; assign data [31:0] = dataA[31:0] ^
- 69. Implicit Continuous Assignment /Regular continuous assignment wire out; assign out = in1 & in2; //Same effect
- 70. Implicit Net Declaration Implicit net declaration is NOT allowed in Verilog 1995. wire i1, i2; assign
- 71. Delays regular assignment delay implicit continuous assignment delay net declaration delay
- 72. Regular Assignment Delay The delay value is specified after the keyword assign assign #10 out =
- 73. Implicit Continuous Assignment Delay An equivalent method is to use an implicit continuous assignment to specify
- 74. Net Declaration Delay //Net Delays wire # 10 out; assign out = in1 & in2; //The
- 75. Expressions Expressions are constructs that combine operators and operands to produce a result. a ^ b
- 76. Operands Operands can be constants, integers, real numbers, nets, registers, times, bit-select (one bit of vector
- 77. Operands : examples real a, b, c; c = a - b; //a and b are
- 78. Operator Types
- 79. Operator Types
- 80. Operator Types
- 81. Operator Types
- 82. Arithmetic Operators There are two types of arithmetic operators: binary unary
- 83. Binary operators Binary arithmetic operators are multiply (*) divide (/) add (+) subtract (-) power (**)
- 84. Examples If any operand bit has a value x, then the result of the entire expression
- 85. Logical Operators Logical operators are logical-and (&&), logical-or (||) logical-not (!). Operators && and || are
- 86. Logical Operators Logical operators always evaluate to a 1-bit value, 0 (false), 1 (true), or x
- 87. Logical Operators Examples // Logical operations A = 3; B = 0; A && B //
- 88. // Unknowns A = 2'b0x; B = 2'b10; A && B // Evaluates to x. Equivalent
- 89. Relational Operators Relational operators are greater-than (>) less-than ( greater-than-or-equal-to (>=) less-than-or-equal-to (
- 90. Equality Operators Equality operators are logical equality (==) logical inequality (!=) case equality (===) case inequality
- 91. Equality Operators
- 92. Equality Operators Examples // A = 4, B = 3 // X = 4'b1010, Y =
- 93. Bitwise Operators Bitwise operators are negation (~) and(&) or (|) xor (^) xnor (^~, ~^)
- 94. Bitwise Operators Examples // X = 4'b1010, Y = 4'b1101 // Z = 4'b10x1 ~X //
- 95. Difference between Logical and Bitwise operators // X = 4'b1010, Y = 4'b0000 X | Y
- 96. Reduction Operators Reduction operators are and (&) nand (~&) or (|) nor (~|) xor (^) xnor
- 97. Reduction Operators Examples // X = 4'b1010 &X //Equivalent to 1 & 0 & 1 &
- 98. Shift Operators Shift operators are right shift ( >>) left shift (
- 99. Shift Operators // X = 4'b1100 Y = X >> 1; //Y is 4'b0110. Shift right
- 100. Concatenation Operator The concatenation operator is {, } // A = 1'b1, B = 2'b00, C
- 101. Replication Operator A replication constant specifies how many times to replicate the number inside the brackets
- 102. Conditional Operator The conditional operator is (?:) and takes three operands. Usage: condition_expr ? true_expr :
- 103. Conditional Operator Examples //model functionality of a tristate buffer assign addr_bus = drive_enable ? addr_out :36'bz;
- 104. Behavioral Modeling
- 105. Levels of description using verilog HDL Behavioral or algorithmic level Dataflow level Gate level Switch level
- 106. Structured Procedures There are two structured procedure statements in Verilog: always initial
- 107. initial Statement An initial block starts at time 0, executes exactly once during a simulation, and
- 108. Examples of initial statement module stimulus; reg x,y, a,b, m; initial m = 1'b0; initial begin
- 109. always Statement The always statement starts at time 0 and executes the statements in the always
- 110. Example of always statement module clock_gen ( clock); output clock; reg clock; initial clock = 1'b0;
- 111. Procedural Assignments Procedural assignments update values of reg, integer, real, or time variables. The value placed
- 112. Procedural Assignments The left-hand side of a procedural assignment can be one of the following: A
- 113. Procedural Assignments There are two types of procedural assignment statements: blocking nonblocking
- 114. Blocking Assignments Blocking assignment statements are executed in the order they are specified in a sequential
- 115. Example of blocking statement reg x, y, z; reg [15:0] reg_a, reg_b; integer count; initial begin
- 116. Nonblocking Assignments A
- 117. Nonblocking Assignments Example reg x, y, z; reg [15:0] reg_a, reg_b; integer count; initial begin x
- 118. Recomendation Do not mix blocking and nonblocking assignments in the same always block.
- 119. Race Conditions always @(posedge clock) a = b; always @(posedge clock) b = a;
- 120. Eliminate Race Conditions always @(posedge clock) a always @(posedge clock) b
- 121. Timing Controls Delay-based timing control can be specified by a number, identifier, or a mintypmax_expression. There
- 122. Regular delay control x = 0; #10 y = 1; #latency z = 0; // Delay
- 123. Intra-assignment delay control reg x, y, z; initial begin x = 0; z = 0; y
- 124. Equivalent method with temporary variables and regular delay control initial begin x = 0; z =
- 125. Zero delay control initial begin x = 0; y = 0; end initial begin #0 x
- 126. Event-Based Timing Control An event is the change in the value on a register or a
- 127. Regular event control The @ symbol is used to specify an event control. @(clock) q =
- 128. Regular event control @(negedge clock) q = d; //q = d is executed whenever signal clock
- 129. Named event control event received_data; always @(posedge clock) begin if(last_data_packet) ->received_data; end always @(received_data) data_buf =
- 130. Event OR Control always @ ( reset or clock or d) begin if (reset) q =
- 131. Not Supported In Verilog 1995 always @ ( reset, clock, d) begin if (reset) q =
- 132. Not Supported In Verilog 1995 always @(posedge clk, negedge reset) if(!reset) q else q
- 133. Suppored by Verilog 1995 always @(a or b or c or d or e or f
- 134. Level-Sensitive Timing Control The keyword wait is used for level-sensitive constructs. always wait (count_enable) #20 count
- 135. Conditional Statements Example //Type 1 statements if(!lock) buffer = data; if(enable) out = in; //Type 2
- 136. Conditional Statements Example //Type 3 statements //Execute statements based on ALU control signal. if (alu_control ==
- 137. Multiway Branching The keywords case, endcase, and default are used in the case statement. case (expression)
- 138. Multiway Branching example //Execute statements based on the ALU control signal reg [1:0] alu_control; ... ...
- 139. Multiway Branching example module mux4_to_1 (out, i0, i1, i2, i3, s1, s0); output out; input i0,
- 140. Loops There are four types of looping statements in Verilog: while for repeat forever All looping
- 141. while Loop The while loop executes until the while- expression is not true. If multiple statements
- 142. while Loop example integer count; initial begin count = 0; while (count //exit at count 128
- 143. for Loop An initial condition A check to see if the terminating condition is true A
- 144. for Loop Example integer count; initial for ( count=0; count $display ("Count = %d", count);
- 145. repeat Loop The keyword repeat is used for this loop. integer count; initial begin count =
- 146. forever loop The keyword forever is used to express this Loop. The loop does not contain
- 147. forever loop example reg clock; initial begin clock = 1'b0; forever #10 clock = ~clock; end
- 148. Sequential and Parallel Blocks The keywords begin and end are used to group statements into sequential
- 149. Sequential Blocks Example reg x, y; reg [1:0] z, w; initial begin x = 1'b0; y
- 150. Parallel Block Example reg x, y; reg [1:0] z, w; initial fork x = 1'b0; #5
- 151. Special Features of Blocks There are three special features available with block statements: nested blocks named
- 152. Nested blocks Example Blocks can be nested initial begin x = 1'b0; fork #5 y =
- 153. Named blocks Blocks can be given names. Local variables can be declared for the named block.
- 154. Named Blocks Example module top; initial begin: block1 integer i; // can be accessed as top.block1.i
- 155. Disabling named blocks The keyword disable provides a way to terminate the execution of a named
- 156. Timing and Delays
- 157. Types of Delay Models There are three types of delay models used in Verilog: Distributed Lumped
- 158. Distributed Delay
- 159. Example Distributed Delays //Distributed delays in gate-level modules module M (out, a, b, c, d); output
- 160. //Distributed delays in data flow definition of a module module M (out, a, b, c, d);
- 161. Lumped Delay
- 162. Example Lumped Delay //Lumped Delay Model module M (out, a, b, c, d); output out; input
- 163. Pin-to-Pin Delays Path a-e-out delay = 9 Path c-f-out delay = 11 Path b-e-out delay =
- 164. Path Delay Modeling path delay - a delay between a source (input or inout) pin and
- 165. Specify Blocks Assign pin-to-pin timing delays across module paths Set up timing checks in the circuits
- 166. Specify Blocks //Pin-to-pin delays module M (out, a, b, c, d); output out; input a, b,
- 167. Parallel connection A parallel connection is specified by the symbol => Usage: ( => ) =
- 168. Parallel connection
- 169. Parallel connection //bit-to-bit connection. both a and out are single-bit (a => out) = 9; //vector
- 170. Illegal parallel connection //illegal connection. a[4:0] is a 5-bit //vector, out[3:0] is 4-bit. //Mismatch between bit
- 171. Full Conection A full connection is specified by the symbol *>. Usage: ( *> ) =
- 172. Full connection
- 173. Full Connection example //Full Connection module M (out, a, b, c, d); output out; input a,
- 174. Full Connection //a[31:0] is a 32-bit vector and out[15:0] is a 16- // bit vector. Delay
- 175. Edge-Sensitive Paths if ( RSCEN ) ( posedge CLK => ( RSCOUT : 1'bx )) =
- 176. specparam statements //Specify parameters using specparam statement specify //define parameters inside the specify block specparam d_to_q
- 177. Conditional path delays specify if (a) (a => out) = 9; if (~a) (a => out)
- 178. Rise, fall, and turn-off delays One, two, three, six, or twelve delay values can be specified
- 179. Rise, fall, and turn-off delays Example //Specify one delay only. Used for all //transitions. specparam t_delay
- 180. Rise, fall, and turn-off delays Example //Specify three delays, rise, fall, and turn-off //Rise used for
- 181. Rise, fall, and turn-off delays Example //specify six delays. //Delays are specified in order //for transitions
- 182. Rise, fall, and turn-off delays Example //specify twelve delays. //Delays are specified in order //for transitions
- 183. Min, max, and typical delays //Specify three delays, rise, fall, and turn-off //Each delay has a
- 184. Handling x transitions Transitions from x to a known state should take the maximum possible time
- 185. Handling x transitions //Six delays specified . //for transitions 0->1, 1->0, 0->z, z->1, 1->z, z>0 specparam
- 186. Handling x transitions 0->x min(t_01, t_0z) = 9 1->x min(t_10, t_1z) = 11 z->x min(t_z0, t_z1)
- 187. Timing Checks $setup and $hold checks the setup time is the minimum time the data must
- 188. $setup and $hold checks
- 189. $setup task Usage: $setup(data_event, reference_event, limit); data_event : Signal that is monitored for violations reference_event :
- 190. $setup task example specify $setup(data, posedge clock, 3); $setup ( RSCEN, posedge CLK, Tsc); endspecify
- 191. $hold task Usage: $hold (reference_event, data_event, limit); reference_event Signal that establishes a reference for monitoring the
- 192. $hold task example specify $hold(posedge clear, data, 5); $hold ( posedge CLK &&& CHKEN8A, RSCIN, Trscx,
- 193. $width Check
- 194. $width Check Usage: $width(reference_event, limit); reference_event Edge-triggered event (edge transition of a signal) limit Minimum width
- 195. $width Check example //width check is set. //posedge of clear is the reference_event //the next negedge
- 196. Delay Back-Annotation The designer writes the RTL description and then performs functional simulation. The RTL description
- 197. Delay Back-Annotation The gate-level netlist is then converted to layout by a place and route tool.
- 198. Delay Back-Annotation
- 199. Summary There are three types of delay models: lumped, distributed, and path delays. Distributed delays are
- 200. Summary Specify blocks are the basic blocks for expressing path delay information. In modules, specify blocks
- 201. Summary Path delays can be conditional or dependent on the values of signals in the circuit.
- 202. Summary Setup, hold, and width are timing checks that check timing integrity of the digital circuit.
- 203. Timing and Delays
- 204. Learning Objectives Identify types of delay models, distributed, lumped, and pin-to-pin (path) delays used in Verilog
- 205. Learning Objectives Describe state-dependent path delays. Explain rise, fall, and turn-off delays. Understand how to set
- 206. Types of Delay Models There are three types of delay models used in Verilog: Distributed Lumped
- 207. Distributed Delay
- 208. Example Distributed Delays //Distributed delays in gate-level modules module M (out, a, b, c, d); output
- 209. //Distributed delays in data flow definition of a module module M (out, a, b, c, d);
- 210. Lumped Delay
- 211. Example Lumped Delay //Lumped Delay Model module M (out, a, b, c, d); output out; input
- 212. Pin-to-Pin Delays Path a-e-out delay = 9 Path c-f-out delay = 11 Path b-e-out delay =
- 213. Path Delay Modeling path delay - a delay between a source (input or inout) pin and
- 214. Specify Blocks Assign pin-to-pin timing delays across module paths Set up timing checks in the circuits
- 215. Specify Blocks //Pin-to-pin delays module M (out, a, b, c, d); output out; input a, b,
- 216. Parallel connection A parallel connection is specified by the symbol => Usage: ( => ) =
- 217. Parallel connection
- 218. Parallel connection //bit-to-bit connection. both a and out are single-bit (a => out) = 9; //vector
- 219. Illegal parallel connection //illegal connection. a[4:0] is a 5-bit //vector, out[3:0] is 4-bit. //Mismatch between bit
- 220. Full Conection A full connection is specified by the symbol *>. Usage: ( *> ) =
- 221. Full connection
- 222. Full Connection example //Full Connection module M (out, a, b, c, d); output out; input a,
- 223. Full Connection //a[31:0] is a 32-bit vector and out[15:0] is a 16- // bit vector. Delay
- 224. Edge-Sensitive Paths if ( RSCEN ) ( posedge CLK => ( RSCOUT : 1'bx )) =
- 225. specparam statements //Specify parameters using specparam statement specify //define parameters inside the specify block specparam d_to_q
- 226. Conditional path delays specify if (a) (a => out) = 9; if (~a) (a => out)
- 227. Rise, fall, and turn-off delays One, two, three, six, or twelve delay values can be specified
- 228. Rise, fall, and turn-off delays Example //Specify one delay only. Used for all //transitions. specparam t_delay
- 229. Rise, fall, and turn-off delays Example //Specify three delays, rise, fall, and turn-off //Rise used for
- 230. Rise, fall, and turn-off delays Example //specify six delays. //Delays are specified in order //for transitions
- 231. Rise, fall, and turn-off delays Example //specify twelve delays. //Delays are specified in order //for transitions
- 232. Min, max, and typical delays //Specify three delays, rise, fall, and turn-off //Each delay has a
- 233. Handling x transitions Transitions from x to a known state should take the maximum possible time
- 234. Handling x transitions //Six delays specified . //for transitions 0->1, 1->0, 0->z, z->1, 1->z, z>0 specparam
- 235. Handling x transitions 0->x min(t_01, t_0z) = 9 1->x min(t_10, t_1z) = 11 z->x min(t_z0, t_z1)
- 236. Timing Checks $setup and $hold checks the setup time is the minimum time the data must
- 237. $setup and $hold checks
- 238. $setup task Usage: $setup(data_event, reference_event, limit); data_event : Signal that is monitored for violations reference_event :
- 239. $setup task example specify $setup(data, posedge clock, 3); $setup ( RSCEN, posedge CLK, Tsc); endspecify
- 240. $hold task Usage: $hold (reference_event, data_event, limit); reference_event Signal that establishes a reference for monitoring the
- 241. $hold task example specify $hold(posedge clear, data, 5); $hold ( posedge CLK &&& CHKEN8A, RSCIN, Trscx,
- 242. $width Check
- 243. $width Check Usage: $width(reference_event, limit); reference_event Edge-triggered event (edge transition of a signal) limit Minimum width
- 244. $width Check example //width check is set. //posedge of clear is the reference_event //the next negedge
- 245. Delay Back-Annotation The designer writes the RTL description and then performs functional simulation. The RTL description
- 246. Delay Back-Annotation The gate-level netlist is then converted to layout by a place and route tool.
- 247. Delay Back-Annotation
- 248. Summary There are three types of delay models: lumped, distributed, and path delays. Distributed delays are
- 249. Summary Specify blocks are the basic blocks for expressing path delay information. In modules, specify blocks
- 250. Summary Path delays can be conditional or dependent on the values of signals in the circuit.
- 252. Скачать презентацию