Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Hierachical structural modeling

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Próximo SlideShare
Verilog HDL Verification
Verilog HDL Verification
Cargando en…3
×

Eche un vistazo a continuación

1 de 41 Anuncio

Más Contenido Relacionado

Presentaciones para usted (20)

Similares a Hierachical structural modeling (20)

Anuncio

Más reciente (20)

Anuncio

Hierachical structural modeling

  1. 1. Hanbat Hanbat National National University University Hierarchical StructuralHierarchical Structural ModelingModeling Gookyi Dennis A. N.Gookyi Dennis A. N. SoC Design Lab.SoC Design Lab. June.20.2014
  2. 2. ContentsContents  Module  Generate Statements 2
  3. 3. ModuleModule  The basic units of Verilog HDL are modules  A module has two major parts: The interface The body 3
  4. 4. ModuleModule  A module is defined by using the keyword module and has various forms as below: 4
  5. 5. ParametersParameters  Parameters are constants which can be used throughout the module defining them  They are used to specify delays and width of variables  There are two types of parameters: Module parameter Specify parameter  The module parameters can be defined by using the following keywords within the module: Parameter localparam 5
  6. 6. Parameter DeclarationParameter Declaration  The parameter is used to define module parameters that can be overridden by defparam or module instance parameter value assignment  It has the forms as below: parameter [signed] [range] param_assignment parameter var_types param_assignment  Some examples of the usage of parameter is as below: parameter SIZE =7; parameter WIDTH_BUSA = 24, WIDTH_BUSB = 8; parameter signed [3:0] mux_selector = 4’b0; 6
  7. 7. Localparam DeclarationLocalparam Declaration  It is used to define parameters local to a module  It cannot be overridden by the defparam statement or by module instance parameter value assignment  The following are some examples of the usage of localparam: localparam SIZE =7; localparam WIDTH_BUSA = 24, WIDTH_BUSB = 8; localparam signed [3:0] mux_selector = 4’b0; 7
  8. 8. Parameter PortsParameter Ports  A parameter can be placed between module name and port list or port list declarations  A parameter can have both the type and range specifications as shown below: module module_name #(parameter SIZE =7, parameter WIDTH_BUSA = 24, WIDTH_BUSB = 8, parameter signed [3:0] mux_selector = 4’b0) (port list or port list declaration) … endmodule 8
  9. 9. Module InstantiationModule Instantiation  Modules cannot be nested, however, a module can incorporate a copy (called an instance) of another module into itself through instantiations  The syntax is as below: module_name[#(parameters)]instance_name[range]([ports]); 9
  10. 10. Port Connection RulesPort Connection Rules  Connecting ports to external signals can be done by: Named association: ports are connected by listing their names. The form is as follows: .port_id1(port_expr1),…, .port_idn(port_exprn) Positional association: ports are connected by ordered list of ports, each corresponding to a port. It has the following form: port_expr1, …, port_exprn 10
  11. 11. Module Parameter ValueModule Parameter Value  When a module instantiates other modules, the higher-level module can change the values of parameters defined by the keyword parameter in the lower-level modules  An example is shown below: 11
  12. 12. Module Parameter ValueModule Parameter Value  Waveform and RTL schematic: 12
  13. 13. Module Parameter ValueModule Parameter Value  There are two ways to override parameter values: Defparam statement Module instance parameter value assignment 13
  14. 14. Using TheUsing The defparamdefparam StatementStatement  It is used to redefine the parameter values defined by the keyword parameter  Its syntax is as below: defparam hierarchical_path_name1 = value1, hierarchical_path_name2 = value2, … hierarchical_path_namen = valuen; 14
  15. 15. Using The defparam StatementUsing The defparam Statement  An example is a parameter adder. Here there is the instantiation of two adder modules using the defparam statement 15
  16. 16. Using The defparam StatementUsing The defparam Statement  Waveform 16
  17. 17. Using The defparam StatementUsing The defparam Statement  RTL schematic 17
  18. 18. Module Instance ParameterModule Instance Parameter  The parameters defined by using the keyword parameter within a module are overridden by parameters passed through parameters ports whenever the module is instantiated  There are two approaches: Positional association Named association 18
  19. 19. Module Instance Parameter:Module Instance Parameter: Positional AssociationPositional Association  In this form the order of the assignment must follow the order of declaration of the parameters within the module 19
  20. 20. Module Instance Parameter:Module Instance Parameter: Positional AssociationPositional Association  Waveform 20
  21. 21. Module Instance Parameter:Module Instance Parameter: Positional AssociationPositional Association  RTL schematic 21
  22. 22. Module Instance Parameter: NamedModule Instance Parameter: Named AssociationAssociation  It explicitly links the names specified in the instantiated module and the associated value 22
  23. 23. Module Instance Parameter: NamedModule Instance Parameter: Named AssociationAssociation  Waveform 23
  24. 24. Module Instance Parameter: NamedModule Instance Parameter: Named AssociationAssociation  RTL schematic 24
  25. 25. Generate StatementGenerate Statement  Generate statement allows selection and replication of some statements during elaboration time  Elaboration time is the time after a design has been parsed but before simulation begins  The generate statement has the syntax as below: generate Generate-declaration Generate-loop statements Generate-conditional statements Generate-case statement … endgenerate 25
  26. 26. Generate StatementGenerate Statement  The power of generate statements is that they can conditionally generate declarations and instantiations into a design  There are three kinds of statements that can be used within a generate statement: Generate-loop Generate-conditional Generate-case 26
  27. 27. Generate-loop StatementGenerate-loop Statement  It is formed by using a for statement within a generate statement  The generate loop is of the form: for (init_expr; condition_expr; update_expr) Begin: block_name Generate_statements end  An index variable is always declared when using the for statement within a generate statement  The index variable is declared as follows genvar genvar_id1, … genvar_idn; 27
  28. 28. Generate-loop StatementGenerate-loop Statement  An example is the use of continuous assignment within a generate-loop for converting gray code into binary code  To convert gray code into binary code, we may count the number of 1’s from MSB to the current position  If it is odd, the binary bit is 1  Otherwise, the binary bit is 0 28
  29. 29. Generate-loop StatementGenerate-loop Statement  Code for converting gray code to binary code 29
  30. 30. Generate-loop StatementGenerate-loop Statement  During elaboration time, the generate-loop is expanded  The body of the for statement is replicated once for each value of the iteration as follows: assign bin[0] = ^gray[SIZE-1:0]; assign bin[1] = ^gray[SIZE-1:1]; assign bin[2] = ^gray[SIZE-1:2]; assign bin[3] = ^gray[SIZE-1:3]; assign bin[4] = ^gray[SIZE-1:4]; assign bin[5] = ^gray[SIZE-1:5]; assign bin[6] = ^gray[SIZE-1:6]; assign bin[7] = ^gray[SIZE-1:7]; 30
  31. 31. Generate-loop StatementGenerate-loop Statement  Waveform 31
  32. 32. Generate-loop StatementGenerate-loop Statement  RTL schematic 32
  33. 33. Generate-conditional StatementGenerate-conditional Statement  Allows modules, gate primitives, continuous assignments etc. to be instantiated into another module based on an if-else conditional expression  It has the form as below: if (condition) generate_statements [else generate_statements] if (condition) generate_statements [else if (condition2) generate_statements] [else generate_statements] 33
  34. 34. Generate-conditional StatementGenerate-conditional Statement  An example of generate-conditional statement is given  Here, if-else is employed to set up the boundary cells, the LSB and the MSB of an n-bit adder 34
  35. 35. Generate-conditional StatementGenerate-conditional Statement  Code 35
  36. 36. Generate-conditional StatementGenerate-conditional Statement  Testbench 36
  37. 37. Generate-conditional StatementGenerate-conditional Statement  Technology schematic 37
  38. 38. Generate-Case StatementGenerate-Case Statement  Allows modules, gate primitives, continuous assignments etc. to be instantiated into another module based on the case conditional expression  Its general form is as follows: Case (case_expr) Case_item1: generate_statements … Case_itemn: generate_statements [default: generate_statement] 38
  39. 39. Generate-Case StatementGenerate-Case Statement  An example of is used to model an n-bit adder: 39
  40. 40. Generate-Case StatementGenerate-Case Statement  Waveform 40
  41. 41. Generate-Case StatementGenerate-Case Statement  Technology schematic 41

×