00001 // 00002 // ------------------------------------------------------------- 00003 // Copyright 2004-2008 Synopsys, Inc. 00004 // All Rights Reserved Worldwide 00005 // 00006 // Licensed under the Apache License, Version 2.0 (the 00007 // "License"); you may not use this file except in 00008 // compliance with the License. You may obtain a copy of 00009 // the License at 00010 // 00011 // http://www.apache.org/licenses/LICENSE-2.0 00012 // 00013 // Unless required by applicable law or agreed to in 00014 // writing, software distributed under the License is 00015 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00016 // CONDITIONS OF ANY KIND, either express or implied. See 00017 // the License for the specific language governing 00018 // permissions and limitations under the License. 00019 // ------------------------------------------------------------- 00020 // 00021 00022 00023 `include "ral_env.svh" 00024 00025 `ifndef RAL_TB_ENV 00026 `define RAL_TB_ENV tb_env 00027 `endif 00028 00029 00030 program gen_html; 00031 00032 vmm_log log = new("Documentation Generation", "HTML"); 00033 `RAL_TB_ENV env = new; 00034 00035 integer fp; 00036 00037 initial 00038 begin 00039 vmm_ral_block_or_sys ral_model; 00040 string fname; 00041 00042 ral_model = env.ral.get_model(); 00043 if (ral_model == null) begin 00044 `vmm_fatal(log, "No RAL abstraction model was specified"); 00045 end 00046 00047 // Find out the name of the top-level block or system 00048 // And use it to create the HTML file 00049 fname = ral_model.get_name(); 00050 fp = $fopen({fname, ".html"}, "w"); 00051 if (!fp) begin 00052 int errno; 00053 string reason; 00054 errno = $ferror(fp, reason); 00055 `vmm_fatal(log, {"Cannot open ", fname, ".html for writing: ", reason}); 00056 end 00057 00058 // Generate the HTML header 00059 $fwrite(fp, {"<html><title>", fname, " RAL Model</title>\n"}); 00060 $fwrite(fp, "<body>\n"); 00061 00062 // Is the top construct a block or a system? 00063 begin 00064 vmm_ral_block blk; 00065 vmm_ral_sys sys; 00066 if (!$cast(blk, ral_model)) begin 00067 vmm_ral_sys subsys[]; 00068 string domains[]; 00069 vmm_ral_block blks[]; 00070 00071 // Must be a system! 00072 $cast(sys, ral_model); 00073 document_system(sys); 00074 00075 // Document all subsystems in the top-level systems 00076 sys.get_all_subsys(subsys, domains); 00077 foreach(subsys[i]) begin 00078 document_system(subsys[i], domains[i]); 00079 end 00080 00081 // Document all blocks in the design 00082 sys.get_all_blocks(blks, domains); 00083 foreach(blks[i]) begin 00084 document_block(blks[i], domains[i]); 00085 end 00086 end 00087 else begin 00088 document_block(blk); 00089 end 00090 end 00091 00092 // We are done! 00093 $fwrite(fp, "</body></html>\n"); 00094 $fclose(fp); 00095 00096 `vmm_note(log, {"Documentation can be found in ", fname, ".html"}); 00097 env.report(); 00098 end 00099 00100 00101 function void document_system(vmm_ral_sys sys, 00102 string domain = ""); 00103 string name; 00104 00105 name = sys.get_name(); 00106 if (domain != "") begin 00107 name = {name, ".", domain}; 00108 end 00109 $fwrite(fp, {"<h1>System ", name, "</h1>\n"}); 00110 endfunction: document_system 00111 00112 00113 function void document_block(vmm_ral_block blk, 00114 string domain = ""); 00115 string name; 00116 int n_cols; 00117 00118 name = blk.get_name(); 00119 if (domain != "") begin 00120 name = {name, ".", domain}; 00121 end 00122 $fwrite(fp, {"<h1>Block ", name, "</h1>\n"}); 00123 00124 $fwrite(fp, "<h2>Registers</h2>\n"); 00125 00126 // One column in the table per bit in the physical interface 00127 n_cols = blk.get_n_bytes() * 8; 00128 00129 begin 00130 vmm_ral_reg regs[]; 00131 blk.get_registers(regs, domain); 00132 00133 foreach(regs[i]) begin 00134 vmm_ral_field flds[]; 00135 int last_col; 00136 00137 last_col = n_cols; 00138 00139 // Table header 00140 $fwrite(fp, "<table border=1 rules=all><tr><td colspan=%0d bgcolor=cyan><b>%s</b></td></tr><tr>\n", 00141 n_cols, regs[i].get_name()); 00142 00143 regs[i].get_fields(flds); 00144 00145 // Fields are returned right-to-left. 00146 // Must list them left-to-right 00147 for(int j = flds.size()-1; j >= 0; j--) begin 00148 int lsb, w; 00149 lsb = flds[j].get_lsb_pos_in_register(); 00150 w = flds[j].get_n_bits(); 00151 // Do we have blank bits on the left of the field? 00152 if (lsb+w < last_col) begin 00153 $fwrite(fp, " <td colspan=%0d> </td>\n", last_col - (lsb+w)); 00154 end 00155 00156 $fwrite(fp, " <td colspan=%0d halign=center>%s</td>\n", w, flds[j].get_name()); 00157 00158 last_col = lsb; 00159 end 00160 00161 // Do we have blank LSB bits? 00162 if (last_col > 0) begin 00163 $fwrite(fp, " <td colspan=%0d> </td>\n", last_col); 00164 end 00165 00166 // Close table with index row 00167 $fwrite(fp, "</tr><tr halign=center>"); 00168 for (int j = n_cols-1; j >= 0; j--) begin 00169 $fwrite(fp, "<td>%0d</td>", j); 00170 end 00171 $fwrite(fp, "</tr></table><br> <br>\n"); 00172 end 00173 end 00174 endfunction: document_block 00175 00176 00177 endprogram: gen_html 00178
![]() Intelligent Design Verification Project: VMM, Revision: 1.0.1 |
Copyright (c) 2008 Intelligent Design Verification. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included here: http://www.intelligentdv.com/licenses/fdl.txt |
![]() Doxygen Version: 1.5.6 Sat Oct 18 11:32:18 2008 |