00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2004 by all Contributors. 00005 All Rights reserved. 00006 00007 The contents of this file are subject to the restrictions and limitations 00008 set forth in the SystemC Open Source License Version 2.4 (the "License"); 00009 You may not use this file except in compliance with such restrictions and 00010 limitations. You may obtain instructions on how to receive a copy of the 00011 License at http://www.systemc.org/. Software distributed by Contributors 00012 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF 00013 ANY KIND, either express or implied. See the License for the specific 00014 language governing rights and limitations under the License. 00015 00016 *****************************************************************************/ 00017 00018 /***************************************************************************** 00019 00020 bios.h -- System Bios Unit. 00021 00022 Original Author: Martin Wang, Synopsys, Inc. 00023 00024 *****************************************************************************/ 00025 00026 /***************************************************************************** 00027 00028 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00029 changes you are making here. 00030 00031 Name, Affiliation, Date: 00032 Description of Modification: 00033 00034 *****************************************************************************/ 00035 00036 00037 00038 #define BOOT_LENGTH 5 00039 00040 struct bios : sc_module { 00041 sc_in<unsigned > datain; // modified instruction 00042 sc_in<bool> cs; // chip select 00043 sc_in<bool> we; // write enable for SMC 00044 sc_in<unsigned > addr; // physical address 00045 00046 sc_out<unsigned > dataout; // ram data out 00047 sc_out<bool> bios_valid; // out valid 00048 sc_out<bool> stall_fetch; // stall fetch if output not valid 00049 sc_in_clk CLK; 00050 00051 // Parameter 00052 unsigned *imemory; // BIOS program data memory 00053 unsigned *itagmemory; // program tag memory (NOT USED) 00054 int wait_cycles; // Cycle # it takes to access memory 00055 00056 void init_param(int given_delay_cycles) { 00057 wait_cycles = given_delay_cycles; 00058 } 00059 00060 //Constructor 00061 SC_CTOR(bios) { 00062 SC_CTHREAD(entry, CLK.pos()); 00063 00064 // initialize instruction imemory from external file 00065 FILE *fp = fopen("bios","r"); 00066 int size=0; 00067 int mem_word; 00068 imemory = new unsigned[4000]; 00069 itagmemory = new unsigned[4000]; 00070 printf("** ALERT ** BIOS: initialize BIOS\n"); 00071 for (size = 0; size < 4000; size++) { // initialize bad data 00072 imemory[size] = 0xffffffff; 00073 itagmemory[size] = 0xffffffff; 00074 } 00075 size = 0; 00076 while (fscanf(fp,"%x\n", &mem_word) != EOF) { 00077 imemory[size] = mem_word; 00078 itagmemory[size] = size; 00079 size++; 00080 } 00081 } 00082 00083 // Process functionality in member function below 00084 void entry(); 00085 }; 00086 00087