| 1 | package Text::EP3::Verilog; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Text::EP3::Verilog - Verilog extension for the EP3 preprocessor. | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use Text::EP3; | ||
| 10 | use Text::EP3::Verilog; | ||
| 11 | |||
| 12 | =head1 DESCRIPTION | ||
| 13 | |||
| 14 | This module is an EP3 extension for the Verilog Hardware Description Language. | ||
| 15 | |||
| 16 | =over 4 | ||
| 17 | |||
| 18 | =item The signal directive | ||
| 19 | |||
| 20 | @signal key definition | ||
| 21 | Take a list of signals and generate signal lists in the differing formats | ||
| 22 | that Verilog uses. | ||
| 23 | This is accomplished by formatting a list of new defines and then calling | ||
| 24 | the EP3 define method | ||
| 25 | For example, the following command: | ||
| 26 | |||
| 27 | @signal KEY a[3:0], b, c[width:0], etc. | ||
| 28 | |||
| 29 | will cause the following to be done: | ||
| 30 | |||
| 31 | Define KEY with the list as it appears (can be used in further signal defs) | ||
| 32 | Define KEY{SIG} with the signal list (can be used in port lists) | ||
| 33 | e.g. replace KEY{SIG} with a[3:0], b, c[width:0] | ||
| 34 | Define KEY{EVENT} with the reg list (To be used in event lists) | ||
| 35 | e.g. replace KEY{EVENT} with a or b or c | ||
| 36 | Define KEY{IN} with the input list (you supply the first input and the trailing ';' | ||
| 37 | e.g. replace KEY{INPUT} with [3:0] a;\ninput b;\ninput[width:0] c | ||
| 38 | or ... make the line | ||
| 39 | input KEY{INPUT}; become .. | ||
| 40 | input [3:0] a; | ||
| 41 | input b; | ||
| 42 | input [width:0] c; | ||
| 43 | Define KEY{OUT} with the output list (output [] sig). | ||
| 44 | e.g. like KEY{IN} | ||
| 45 | Define KEY{INOUT} with the inout list (inout [] sig). | ||
| 46 | e.g. like KEY{IN} | ||
| 47 | Define KEY{WIRE} with the wire list (wire [] sig). | ||
| 48 | e.g. like KEY{IN} | ||
| 49 | Define KEY{REG} with the reg list (reg [] sig). | ||
| 50 | e.g. like KEY{IN} | ||
| 51 | Define KEY{DSP} with the printf list (sig=%0[b|x] depending on width). | ||
| 52 | e.g. replace KEY{DSP} with a=%0x, b=%0b, c=%0x | ||
| 53 | This can be used in the $display task | ||
| 54 | $display("KEY{DSP}",KEY{SIG}); | ||
| 55 | |||
| 56 | If the module and the test bench default is set up properly, the user needs | ||
| 57 | only enter the signals in one place in the module file. This section can be | ||
| 58 | included conditionally (e.g. @include "file" PORT) in the test bench and the | ||
| 59 | signals can be automatically generated in the correct format in whichever | ||
| 60 | header they are used. This means that a user can produce a module and its test | ||
| 61 | bench by simply filling in the port list, the behavioral code, and the | ||
| 62 | stimulus (which is of course, the real work). All of the signal header crud | ||
| 63 | can be taken care of automagically. | ||
| 64 | |||
| 65 | =item The step directive | ||
| 66 | |||
| 67 | @step number [command] | ||
| 68 | The step directive is useful to save verbage in test benches. @step 5 command; | ||
| 69 | generates the following code: | ||
| 70 | |||
| 71 | repeat 5 @ (posedge tclk); command; | ||
| 72 | |||
| 73 | The posdege can be changed to '' or negedge (or whatever) using the edgetype | ||
| 74 | directive. The tclk can be changed using the edgename directive. | ||
| 75 | |||
| 76 | =item The edgename directive | ||
| 77 | |||
| 78 | @edgename name | ||
| 79 | The edgename directive allows the user to change the name used in the step | ||
| 80 | directive. The default is 'tclk'. | ||
| 81 | |||
| 82 | =item The edgetype directive | ||
| 83 | |||
| 84 | @edgetype type | ||
| 85 | The edgetype directive allows the user to change the type used in the step | ||
| 86 | directive. The default is 'posedge'. | ||
| 87 | |||
| 88 | =item The denum directive | ||
| 89 | |||
| 90 | @denum key, key, [value], key, ... | ||
| 91 | denum works like the ep3 enum, except that it generates | ||
| 92 | verilog define statements. It also replaces KEY anywhere | ||
| 93 | in the text with `KEY so that the verilog defines will work. | ||
| 94 | (e.g. @denum orange, blue, green will generate: | ||
| 95 | |||
| 96 | `define orange 0 | ||
| 97 | `define blue 0 | ||
| 98 | `define green 0 | ||
| 99 | @define orange `orange | ||
| 100 | @define blue `blue | ||
| 101 | @define green `green | ||
| 102 | |||
| 103 | |||
| 104 | =back | ||
| 105 | |||
| 106 | =head1 AUTHOR | ||
| 107 | |||
| 108 | Gary Spivey, | ||
| 109 | Dept. of Defense, Ft. Meade, MD. | ||
| 110 | spivey@romulus.ncsc.mil | ||
| 111 | |||
| 112 | =head1 SEE ALSO | ||
| 113 | |||
| 114 | perl(1). | ||
| 115 | |||
| 116 | =cut | ||
| 117 | use strict; | ||
| 118 | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); | ||
| 119 | use AutoLoader; | ||
| 120 | use Carp; | ||
| 121 | |||
| 122 | use Exporter; | ||
| 123 | |||
| 124 | @ISA = qw(Exporter AutoLoader); | ||
| 125 | # ************ IMPORTANT FOR ALL EP3 MODULES *********** | ||
| 126 | # Tell EP3 to inherit methods from this module ... | ||
| 127 | # This is necessary to let EP3 know about the methods ... | ||
| 128 | push (@Text::EP3::ISA, qw(Text::EP3::Verilog)); | ||
| 129 | # ******************************************************* | ||
| 130 | # Set up default values | ||
| 131 | |||
| 132 | |||
| 133 | |||
| 134 | @EXPORT = qw( | ||
| 135 | ); | ||
| 136 | $VERSION = '1.00'; | ||
| 137 | |||
| 138 | sub edgename; | ||
| 139 | sub edgetype; | ||
| 140 | sub denum; | ||
| 141 | sub signal; | ||
| 142 | sub step; | ||
| 143 | 1; | ||
| 144 | |||
| 145 | __END__ |